/************************************************************************/
/* Copyright 2003 MBARI													*/
/************************************************************************/
/* Summary	: Definitions for Diagnostics for OASIS3 Mooring Controller */
/* Summary	: Definitions for Utility library for OASIS					*/
/* Filename : diag.h													*/
/* Author	: Robert Herlien (rah)										*/
/* Project	: OASIS Mooring Replacement (OASIS3)						*/
/* Revision: 0.1														*/
/* Created	: 09/03/2003												*/
/*																			*/
/* MBARI provides this documentation and code "as is", with no warranty,	*/
/* express or implied, of its quality or consistency. It is provided without*/
/* support and without obligation on the part of the Monterey Bay Aquarium	*/
/* Research Institute to assist in its use, correction, modification, or	*/
/* enhancement. This information should not be published or distributed to	*/
/* third parties without specific written permission from MBARI.			*/
/*																			*/
/************************************************************************/
/* Modification History:												*/
/* 03sept2003 rah - created												*/
/************************************************************************/

#ifndef INCdiagh
#define INCdiagh		1

#define CTRL_C			3
#define CTRL_D			4

/*********************************************************/
/* Following Definitions are used for the format routine */
/*********************************************************/

#define DIR_ENTRY_SIZE	 32

#ifndef UInt8
#define UInt8	unsigned char
#endif
#ifndef UInt16
#define UInt16	unsigned short
#endif
#ifndef UInt32
#define UInt32	unsigned long
#endif

typedef struct					/****************************************/
{								/* Partition Table struct of MBR		*/
  UInt8			state;			/* 00 = inactive, 80h = active			*/
  UInt8			startHead;		/* Beginning of Partition - Head		*/
  UInt16		startCylSect;	/* Beginning of Partition - Cyl/Sector	*/
  UInt8			partType;		/* 00=Unk, 01=FAT12, 04=FAT16 < 32 MB	*/
								/* 05=Extended, 06= FAT16 > 32 MB		*/
								/* 0B=FAT32, 0C=FAT32 LBA, 0E=FAT16 LBA */
								/* 0F=Extended MSDOS LBA				*/
  UInt8			endHead;		/* End of Partition - Head				*/
  UInt16		endCylSect;		/* End of Partition - Cyl/Sector		*/
  UInt32		sectStartOffset; /* Num Sectors between MBR & partition start*/
  UInt32		numSects;		/* Num Sectors in partition				*/
} PartitionTable;				/****************************************/

typedef struct					/****************************************/
{								/* Master Boot Record					*/
  char			bootcode[446];	/* Boot code							*/
  PartitionTable partition[4];	/* Four Partition Tables				*/
  UInt16		signature;		/* Must be 55AAh (Intel order)			*/
} MBR;							/****************************************/

typedef struct					/****************************************/
{								/* Boot Record common to FAT16 and FAT32*/
								/* 36 bytes total						*/
  char			jmpcode[3];		/* Jump to boot code					*/
  char			OEMname[8];		/* OEM Name								*/
  UInt8			bytesPerSect_low; /* Low byte of Bytes per sector		*/
  UInt8			bytesPerSect_hi;  /* High byte of Bytes per sector		*/
  UInt8			sectorsPerCluster;/* Sectors per cluster				*/
  UInt16		reservedSectors;  /* Reserved Sectors					*/
  UInt8			numberOfFats;	  /* Number of FATs						*/
  UInt8			rootDirEntries_low; /* Low byte of # of root dir entries*/
  UInt8			rootDirEntries_hi;	/* Hi byte of # of root dir entries */
  UInt8			sectorsSmall_low;	/* Low byte of # sects in partition < 32 MB*/
  UInt8			sectorsSmall_hi;	/* High byte of # sects in part < 32 MB*/
  UInt8			mediaDescriptor;  /* Media descriptor byte				*/
  UInt16		sectorsPerFat;	  /* Sectors per FAT					*/
  UInt16		sectorsPerTrack;  /* Sectors per Track					*/
  UInt16		numberHeads;	/* Number of heads						*/
  UInt32		hiddenSectors;	/* Number of hidden sectors in Partition*/
  UInt32		numberSectors;	/* Number of sectors in Partition		*/
} FatBRCommon;					/*************************************((*/

typedef struct					/****************************************/
{								/* FAT16 Boot Record					*/
  FatBRCommon	fatBR;			/* Area common to FAT16 and FAT32		*/
  UInt8			logicalDrive;	/* Int 0x13 logical drv number			*/
								/* Usu. 0 for floppies, 0x80 for HDs	*/
  UInt8			reserved1;		/* Should be 0							*/
  UInt8			extSignature;	/* Extended signature (s/b 0x29)		*/
  char			volumeID[4];	/* Usually gen by date/time at format	*/
  char			volumeName[11]; /* Volume Name							*/
  char			fatName[8];		/* FAT Name ("FAT16	  ")				*/
  char			bootcode[448];	/* Boot code							*/
  UInt16		signature;		/* Must be 55AAh (Intel order)			*/
} Fat16BR;						/*************************************((*/

typedef struct					/****************************************/
{								/* FAT32 Boot Record					*/
  FatBRCommon	fatBR;			/* Area common to FAT16 and FAT32		*/
  UInt32		sectsPerFat32;	/* Sectors per FAT for FAT32			*/
  UInt16		flags;			/* [0..3] active FAT number.			*/
  UInt16		fsVersion;		/* File system version number			*/
  UInt32		rootDirCluster; /* Cluster number of root directory		*/
  UInt16		fsInfo;			/* Usually 1 according to MS			*/
  UInt16		backupBootSect; /* Sect nmbr of backup boot sector. Usu. 6*/
  char			reserved[12];	/* Reserved, unused						*/
  UInt8			logDrive32;		/* Same usage as logicalDrive in FAT16	*/
  UInt8			reserved1;		/* Should be 0							*/
  UInt8			extSignature;	/* Extended signature (s/b 0x29)		*/
  char			volumeID[4];	/* Usually gen by date/time at format	*/
  char			volumeName[11]; /* Volume Name							*/
  char			fatName[8];		/* FAT Name ("FAT32	  ")				*/
  char			bootcode[420];	/* Boot code							*/
  UInt16		signature;		/* Must be 55AAh (Intel order)			*/
} Fat32BR;						/*************************************((*/


/****************************************/
/* Function Declarations				*/
/****************************************/

Int16	o3Diagnostic(Nat16 pmask);

#endif	/* INCdiagh */
