////////////////////////////////////////////////////////////////////////
////	Definitions of the Digi-MIPS binary header.
////
////	@(#) $Id: mipsheader.hh,v 1.13 2001/03/31 23:40:36 gary Exp $
////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////
////	Definitions to ignore swapped-byte types in the
////	embedded environment.
////////////////////////////////////////////////////////////////////////

#ifndef _MIPSHEADER_HH

#define _MIPSHEADER_HH

#if (!defined(UNIX) && !defined(unix)) || defined(NEEDDHEADER)
typedef ulong elong;
typedef ushort eshort;
#endif


////////////////////////////////////////////////////////////////////////
////	Digi-standard MIPS header.
////////////////////////////////////////////////////////////////////////

struct digiheader
{
    uchar	type[2];		// File type.
    eshort	soft_version;		// Software version number
    eshort	lo_boot_rev;		// Lowest compatible boot revision
    eshort	hi_boot_rev;		// Highest compatible boot revision

    eshort	load_segment;		// Load address / 16
    eshort	length;			// Image Length / 256
    eshort	exec_start;		// Relative start address
    eshort	image_offset;		// Offset of compressed image

    elong	startup_code[2];	// Execution usually starts here
    elong	checksum;		// Text+Data checksum
};

////////////////////////////////////////////////////////////////////////
////	This is the "HO" style header.
////
////	Sadly, this is another legacy in the making.  The real solution
////	to this problem is a header that uses ASCII tag=value tag pairs.
////////////////////////////////////////////////////////////////////////

struct digiheader_ho
{
    uchar	type[2];		// 0x00: File type. ("HO")
    eshort	unused1;		// 0x02: Unused
    eshort	unused2;		// 0x04: Unused
    eshort	unused3;		// 0x06: Unused

    eshort	load_segment;		// 0x08: Start address / 4096
    eshort	length;			// 0x0A: Image Length / 4096
    eshort	exec_start;		// 0x0C: Relative start address
    eshort	image_offset;		// 0x0E: Offset of compressed image

    elong	startup_code[2];	// 0x10: Execution usually starts here
    elong	checksum;		// 0x18: Text+Data checksum
    elong	timestamp;		// 0x1C: Seconds since the Unix epoch
    elong	real_length;		// 0x20: Real image length
    elong	unused4;		// 0x24: Unused
    elong	unused5;		// 0x28: Unused
    elong	unused6;		// 0x2c: Unused
    char	tag_offset[32];		// 0x30-0x4f: offset to tags as tag val
					// (@(#)tags=0x00000000 (NUL)
};

#endif
