/* vim: set filetype=c:
 *
 * romcheck.h86  -  General definitions for romcheck
 *
 * Copyright (C) 1998-2007 Gero Kuhlmann <gero@gkminix.han.de>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: romcheck.h86,v 1.6 2007/01/06 18:31:21 gkminix Exp $
 */


/*
 * We need some common definitions for C source code
 */
#ifndef _ASSEMBLY_
# include <common.h86>
#endif



/*
 * Memory layout
 */
#define STARTSEG	0xC000		/* First segment in memory scan */
#define ENDSEG		0xF000		/* Last segment in memory scan */
#define VIDEOSEG	0xC000		/* Usual place for video BIOS */



/*
 * Structure holding the result of the memory scan.
 */
#ifndef _ASSEMBLY_

struct scaninfo {
	__u16   signum;		/* Number of signatures found */
	__u16  *sigsegs;	/* Segments of rom signatures */
	__u16  *sigsize;	/* Size of roms according to sigs */
	__u16  *sigvalid;	/* Buffer indicating valid checksums */
	__u16  *sigcpyrt;	/* Offset to rom copyright text */

	__u16   nbindex;	/* Index to netboot signature area */
	__u8    nbmajor;	/* Netboot rom major version */
	__u8    nbminor;	/* Netboot rom minor version */

	__u16   romsize;	/* Size of rom buffer */
	__u8   *rombuf;		/* Buffer holding id for each rom seg */
};

#else

		.struct	0
si_signum:	.struct	.+2		# Number of signatures found
si_sigsegs:	.struct	.+4		# Segments of rom signatures
si_sigsize:	.struct	.+4		# Size of roms according to sigs
si_sigvalid:	.struct	.+4		# Buffer indicating valid checksums
si_sigcpyrt:	.struct	.+4		# Pointer to rom copyright text
si_nbindex:	.struct	.+2		# Index to netboot signature area
si_nbmajor:	.struct	.+1		# netboot rom major version
si_nbminor:	.struct	.+1		# netboot rom minor version
si_romsize:	.struct	.+2		# size of rom buffer
si_rombuf:	.struct	.+4		# buffer holding id for each rom seg

#endif



/*
 * Type IDs for rom segments
 */
#define TYPE_RAM	0		/* Memory RAM */
#define TYPE_ROM	1		/* Memory is ROM or write-protected */
#define TYPE_UNKNOWN	2		/* Cant determine whether ROM or RAM */
#define TYPE_EMPTY	3		/* Probably empty ROM */



/*
 * Characters used to display the scan result
 */
#define CHAR_DASH	'-'		/* Memory area not used by rom */
#define CHAR_VALID	0xB2		/* Memory area used by rom */
#define CHAR_INVALID	0xB0		/* Memory area has invalid checksum */

#define CHAR_RAM	0x04		/* Segment is RAM */
#define CHAR_ROM	0xB1		/* Segment is ROM or write-protected */
#define CHAR_EMPTY	0xF9		/* Segment is probably empty ROM */
#define CHAR_UNKNOWN	0xFA		/* Cant determine segment type */



/*
 * External routines
 */
#ifndef _ASSEMBLY_

/* Routines in module doscan.S86 */
extern void doscan(struct scaninfo *sip);

/* Routines in module printscan.c86 */
extern void printscan(const struct scaninfo *sip);

/* Routines in module printhex.c86 */
extern void printhex(const struct scaninfo *sip);

/* Routines in module printinfo.c86 */
extern void printinfo(const struct scaninfo *sip);
extern void printnb(const struct scaninfo *sip);

/* Routines in module io.c86 */
extern char waitchar(void);
extern int readint(const char *prompt, int minval, int maxval, int defval);
extern unsigned short readhex(const char *prompt,
	unsigned short minval, unsigned short maxval, unsigned short defval);

#endif

