/*
 **************************************************************************
 *
 * Boot-ROM-Code to load an operating system across a TCP/IP network.
 *
 * Module:  memory.h
 * Purpose: Definitions for boot rom memory layout
 * Entries: None
 *
 **************************************************************************
 *
 * Copyright (C) 1995-2003 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: memory.h,v 1.6 2003/03/09 00:24:27 gkminix Exp $
 */

#ifndef _MEMORY_H
#define _MEMORY_H


/*
 **************************************************************************
 *
 * The memory layout of the bootrom looks like this:
 *
 *      +------------------+                     (00000:0)
 *      | Int & BIOS data  |    2kB
 *      +------------------+            LOWMEM   (01000:0)
 *      | OS loading area  |  variable
 *      +------------------+
 *      | Bootrom code     |  variable
 *      +------------------+            MEMEND   (0A000:0)
 *      | Video memory     |
 *      | Compressed ROM   |  384kB
 *      | BIOS             |
 *      +------------------+            EXTMEM   (10000:0)
 *      | OS loading area  |
 *      +------------------+            physical end of memory
 *
 *
 * During initialization and decompression of the bootrom code (either
 * out of the real rom or a floppy image), the lower OS loading area
 * looks like this:
 *
 *      +------------------+            DECOMPMEM (02000:0)
 *      | Decompressed ROM |  256kB
 *      +------------------+            FLOPMEM   (05000:0)
 *      | Floppy image     |  128kB
 *      +------------------+            FLOPEND   (07000:0)
 *
 * Note that FLOPEND should not exceed 07000:0, as the decompression code
 * puts itself right behind that address, and it requires 64kB of free
 * memory.
 */
#ifndef _USE_ASSEMBLER

#define LOWMEM		0x007C0L /* beginning of OS loading area	*/
#define DOSEXTMEM	0x01000L /* beginning of DOS extended area	*/
#define DECOMPMEM	0x02000L /* beginning of decompressed image	*/
#define DECOMPEND	0x05000L /* end of decompressed image area	*/
#define FLOPMEM		0x05000L /* beginning of floppy loading area	*/
#define FLOPEND		0x07000L /* end of floppy loading area		*/
#define OSENDMEM	0x08000L /* end of guaranteed OS loading area	*/
#define MEMEND		0x0A000L /* end of ram on typical PC system	*/
#define ROMSIZE		0x08000L /* max. size of rom area in bytes	*/
#define EXTMEM		0x10000L /* beginning of extended memory area	*/

#else				/* _USE_ASSEMBLER */

LOWMEM		equ	$07C0		! beginning of OS loading area
DECOMPMEM	equ	$2000		! beginning of decompressed image
DECOMPEND	equ	$5000		! end of decompressed image area
FLOPMEM		equ	$5000		! beginning of floppy loading area
FLOPEND		equ	$7000		! end of floppy loading area
OSENDMEM	equ	$8000		! end of guaranteed OS loading area
MEMEND		equ	$A000		! end of ram on typical PC system
ROMSIZE		equ	$8000		! size of rom area in bytes

#endif				/* _USE_ASSEMBLER */


/*
 **************************************************************************
 *
 * The ROM startup code, the kernel image and the network driver startup
 * code all need some values inserted at their beginning by the binary
 * patch program. Define the offsets to those values from the beginning
 * of each file.
 *
 * Note that these values have to correspond to the actual offsets
 * in the corresponding assembler files (rom.S, kernel.S and netdrv.S)!
 *
 * The version number values in each file will be checked by the binary
 * patch program. They should be at different offsets, so that an error
 * will be generated when an invalid file is fed into the patch program.
 */
#ifdef _USE_ASSEMBLER

DATAOFS		equ	$0008		! offset to special data values

/* Offsets into the ROM startup code */
ROMMAJOROFS	equ	DATAOFS +  0	! offset to major version num
ROMMINOROFS	equ	DATAOFS +  1	! offset to minor version num
ROMSEROFS	equ	DATAOFS +  2	! offset to rom serial num
ROMVECTOFS	equ	DATAOFS +  6	! offset to bootrom vector
ROMCOMPSIZEOFS	equ	DATAOFS +  8	! offset to compressed size in bytes
ROMTOTSIZEOFS	equ	DATAOFS + 12	! offset to total size in paragraphs
ROMPCIPTROFS	equ	DATAOFS + 16	! offset to ptr to PCI struct
ROMPNPPTROFS	equ	DATAOFS + 18	! offset to ptr to PnP header
ROMIDOFS	equ	DATAOFS + 20	! offset to ID string
ROMBOOTFLGOFS	equ	DATAOFS + 28	! offset to boot flags

/* Offsets into the kernel code */
KRNLOADER	equ	$0003		! offset to kernel loader code
KRNTEXTOFS	equ	DATAOFS +  0	! offset to kernel text size
KRNDATAOFS	equ	DATAOFS +  2	! offset to kernel data size
KRNROMIDOFS	equ	DATAOFS +  4	! offset to kernel ROM ID offset
KRNSIZEOFS	equ	DATAOFS +  6	! offset to total kernel size
KRNMAJOROFS	equ	DATAOFS +  8	! offset to major version num
KRNMINOROFS	equ	DATAOFS +  9	! offset to minor version num

/* Offsets into the network driver code */
NETLOADER	equ	$0003		! offset to driver loader code
NETTEXTOFS	equ	DATAOFS +  0	! offset to driver text size
NETDATAOFS	equ	DATAOFS +  2	! offset to driver data size
NETROMIDOFS	equ	DATAOFS +  4	! offset to driver ROM ID offset
NETSIZEOFS	equ	DATAOFS +  6	! offset to total driver size
NETMAJOROFS	equ	DATAOFS +  8	! offset to major version num
NETMINOROFS	equ	DATAOFS +  9	! offset to minor version num
NETBUSTYPEOFS	equ	DATAOFS + 10	! offset to bus type

#else				/* _USE_ASSEMBLER */

#define DATAOFS		0x00008L	/* offset to special data	*/

/* Offsets into the ROM startup code */
#define ROMLENOFS	0x00002L	/* offset to rom length byte	*/
#define ROMMAJOROFS	(DATAOFS +  0L)	/* offset to major version num	*/
#define ROMMINOROFS	(DATAOFS +  1L)	/* offset to minor version num	*/
#define ROMSEROFS	(DATAOFS +  2L)	/* offset to rom serial num	*/
#define ROMVECTOFS	(DATAOFS +  6L)	/* offset to bootrom vector	*/
#define ROMCOMPSIZEOFS	(DATAOFS +  8L)	/* offset to compressed size	*/
#define ROMTOTSIZEOFS	(DATAOFS + 12L)	/* offset to total size in para	*/
#define ROMPCIPTROFS	(DATAOFS + 16L)	/* offset to ptr to PCI struct	*/
#define ROMPNPPTROFS	(DATAOFS + 18L)	/* offset to ptr to PnP header	*/
#define ROMIDOFS	(DATAOFS + 20L)	/* offset to ID string		*/
#define ROMBOOTFLGOFS	(DATAOFS + 28L)	/* offset to boot flags		*/
#define ROMFLASHOFS	(DATAOFS + 29L)	/* offset to flash EPROM loader	*/

/* Offsets into the kernel code */
#define KRNTEXTOFS	(DATAOFS +  0L)	/* offset to kernel text size	*/
#define KRNDATAOFS	(DATAOFS +  2L)	/* offset to kernel data size	*/
#define KRNROMIDOFS	(DATAOFS +  4L)	/* offset to kernel ROM ID ofs	*/
#define KRNSIZEOFS	(DATAOFS +  6L)	/* offset to total kernel size	*/
#define KRNMAJOROFS	(DATAOFS +  8L)	/* offset to major version num	*/
#define KRNMINOROFS	(DATAOFS +  9L)	/* offset to minor version num	*/

/* Offsets into the network driver code */
#define NETTEXTOFS	(DATAOFS +  0L)	/* offset to driver text size	*/
#define NETDATAOFS	(DATAOFS +  2L)	/* offset to driver data size	*/
#define NETROMIDOFS	(DATAOFS +  4L)	/* offset to driver ROM ID ofs	*/
#define NETSIZEOFS	(DATAOFS +  6L)	/* offset to total driver size	*/
#define NETMAJOROFS	(DATAOFS +  8L)	/* offset to major version num	*/
#define NETMINOROFS	(DATAOFS +  9L)	/* offset to minor version num	*/
#define NETBUSTYPEOFS	(DATAOFS + 10L)	/* offset to bus type		*/

#endif				/* _USE_ASSEMBLER */


/*
 **************************************************************************
 *
 * The bootrom kernel and network driver interface files have a ROM ID
 * structure at their beginning. It's almost the same with both files:
 */
#ifdef _USE_ASSEMBLER

ROMID_SIG	equ	$0000		! offset to ROM ID signature
ROMID_LENGTH	equ	$0004		! offset to structure length
ROMID_CHKSUM	equ	$0005		! offset to structure checksum
ROMID_REV	equ	$0006		! offset to structure revision
ROMID_APIREV	equ	$0007		! offset to API revision
ROMID_LOADER	equ	$000A		! offset to ROM loader offset
ROMID_STKSIZE	equ	$000C		! offset to stack size
ROMID_DATASIZE	equ	$000E		! offset to data segment size
ROMID_CODESIZE	equ	$0010		! offset to code segment size
ROMID_BUSTYPE	equ	$0012		! offset to bus type string

#else				/* _USE_ASSEMBLER */

#define ROMID_SIG	0x0000		/* offset to ROM ID signature	*/
#define ROMID_LENGTH	0x0004		/* offset to structure length	*/
#define ROMID_CHKSUM	0x0005		/* offset to structure checksum	*/
#define ROMID_REV	0x0006		/* offset to structure revision	*/
#define ROMID_APIREV	0x0007		/* offset to API revision	*/
#define ROMID_LOADER	0x000A		/* offset to ROM loader offset	*/
#define ROMID_STKSIZE	0x000C		/* offset to stack size		*/
#define ROMID_DATASIZE	0x000E		/* offset to data segment size	*/
#define ROMID_CODESIZE	0x0010		/* offset to code segment size	*/
#define ROMID_BUSTYPE	0x0012		/* offset to bus type string	*/
#define ROMID_MIN_SIZE	0x0012		/* min size of ROM ID structure	*/

#define BUSTYPE_SIZE	4		/* length of bus type string	*/

#endif				/* _USE_ASSEMBLER */


/*
 **************************************************************************
 *
 * Boot flags:
 */
#ifdef _USE_ASSEMBLER

ROMFLG_ASKNET	equ	%00000001	! ask for network boot
ROMFLG_ASKTIME	equ	%00011110	! timeout for keystroke
ROMFLG_FLOADER	equ	%00100000	! flash loader installed

#else

#define ROMFLG_ASKNET	0x01		/* ask for network boot		*/
#define ROMFLG_ASKTIME	0x1E		/* timeout for keystroke	*/
#define ROMFLG_FLOADER	0x20		/* flash loader installed	*/

#endif				/* _USE_ASSEMBLER */
#endif				/* _MEMORY_H */



syntax highlighted by Code2HTML, v. 0.9.1