#ifndef __INC_POS_DEVICE_HARDBLOCKS_H
#define __INC_POS_DEVICE_HARDBLOCKS_H
/*******************************************************************
 Includes Release 24
 (C) Copyright 1995-1997 proDAD
     All Rights Reserved

 $AUT Holger Burkarth
 $DAT >>Hardblocks.h<<   22 Mar 1997    08:52:06 - (C) ProDAD
*******************************************************************/
#ifndef __INC_POS_PEXEC_TYPES_H
#include <pExec/Types.h>
#endif


/*\
*** Note
*** optional block addresses below contain $ffffffff to indicate
*** a NULL address, as zero is a valid address
\*/

/*----------------------------------
-----------------------------------*/
struct pOS_RigidDiskBlock
{
  ULONG rdb_ID;             /* 4 character identifier */
  ULONG rdb_SummedLongs;    /* size of this checksummed structure */
  ULONG rdb_ChkSum;         /* block checksum (longword sum to zero) */
  ULONG rdb_HostID;         /* SCSI Target ID of host */
  ULONG rdb_BlockBytes;     /* size of disk blocks */
  ULONG rdb_Flags;          /* (enum pOS_RigidDiskBlockFlags) */

/* block list heads */
  ULONG rdb_BadBlockList;   /* optional bad block list */
  ULONG rdb_PartitionList;  /* optional first partition block */
  ULONG rdb_FSHeaderList;   /* optional file system header block */
  ULONG rdb_DriveInit;      /* optional drive-specific init code */
  ULONG rdb_Reserved1[6];   /* set to $ffffffff */

/* physical drive characteristics */
  ULONG rdb_Cylinders;      /* number of drive cylinders */
  ULONG rdb_Sectors;        /* sectors per track */
  ULONG rdb_Heads;          /* number of drive heads */
  ULONG rdb_Interleave;     /* interleave */
  ULONG rdb_Park;           /* landing zone cylinder */
  ULONG rdb_Reserved2[3];
  ULONG rdb_WritePreComp;   /* starting cylinder: write precompensation */
  ULONG rdb_ReducedWrite;   /* starting cylinder: reduced write current */
  ULONG rdb_StepRate;       /* drive step rate */
  ULONG rdb_Reserved3[5];

/* logical drive characteristics */
  ULONG rdb_RDBBlocksLo;    /* low block of range reserved for hardblocks */
  ULONG rdb_RDBBlocksHi;    /* high block of range for these hardblocks */
  ULONG rdb_LoCylinder;     /* low cylinder of partitionable disk area */
  ULONG rdb_HiCylinder;     /* high cylinder of partitionable data area */
  ULONG rdb_CylBlocks;      /* number of blocks available per cylinder */
  ULONG rdb_AutoParkSeconds; /* zero for no auto park */
  ULONG rdb_HighRDSKBlock;  /* highest block used by RDSK */
                              /* (not including replacement bad blocks) */
  ULONG rdb_Reserved4;

/* drive identification */
  UBYTE rdb_DiskVendor[8];
  UBYTE rdb_DiskProduct[16];
  UBYTE rdb_DiskRevision[4];
  UBYTE rdb_ControllerVendor[8];
  UBYTE rdb_ControllerProduct[16];
  UBYTE rdb_ControllerRevision[4];
  ULONG rdb_Reserved5[10];
};

#define IDNAME_RIGIDDISK   0x5244534B /* 'RDSK' */
#define RDB_LOCATION_LIMIT 16

enum pOS_RigidDiskBlockFlags /** rdb_Flags **/
{
  RDBFB_Last      =0,       /* no disks exist to be configured after */
  RDBFF_Last      =0x01,    /*   this one on this controller */
  RDBFB_LastLun   =1,       /* no LUNs exist to be configured greater */
  RDBFF_LastLun   =0x02,    /*   than this one at this SCSI Target ID */
  RDBFB_LasttID   =2,       /* no Target IDs exist to be configured */
  RDBFF_LasttID   =0x04,    /*   greater than this one on this SCSI bus */
  RDBFB_NoReselect=3,       /* don't bother trying to perform reselection */
  RDBFF_NoReselect=0x08,    /*   when talking to this drive */
  RDBFB_DiskID    =4,       /* rdb_Disk... identification valid */
  RDBFF_DiskID    =0x10,
  RDBFB_CtrlRID   =5,       /* rdb_Controller... identification valid */
  RDBFF_CtrlRID   =0x20,
  RDBFB_Synch     =6,       /* drive supports scsi synchronous mode */
  RDBFF_Synch     =0x40     /* CAN BE DANGEROUS TO USE IF IT DOESN'T! */
};


/*----------------------------------
-----------------------------------*/
struct pOS_BadBlockEntry
{
  ULONG bbe_BadBlock;  /* block number of bad block */
  ULONG bbe_GoodBlock; /* block number of replacement block */
};


/*----------------------------------
-----------------------------------*/
struct pOS_BadBlockBlock
{
  ULONG   bbb_ID;             /* 4 character identifier */
  ULONG   bbb_SummedLongs;    /* size of this checksummed structure */
  ULONG   bbb_ChkSum;         /* block checksum (longword sum to zero) */
  ULONG   bbb_HostID;         /* SCSI Target ID of host */
  ULONG   bbb_Next;           /* block number of the next BadBlockBlock */
  ULONG   bbb_Reserved;
  struct pOS_BadBlockEntry bbb_BlockPairs[61]; /* bad block entry pairs */
  /* note [61] assumes 512 byte blocks */
};

#define IDNAME_BADBLOCK 0x42414442 /* 'BADB' */


/*----------------------------------
-----------------------------------*/
struct pOS_PartitionBlock
{
  ULONG pb_ID;              /* 4 character identifier */
  ULONG pb_SummedLongs;     /* size of this checksummed structure */
  ULONG pb_ChkSum;          /* block checksum (longword sum to zero) */
  ULONG pb_HostID;          /* SCSI Target ID of host */
  ULONG pb_Next;            /* block number of the next PartitionBlock */
  ULONG pb_Flags;           /* (enum pOS_PartitionBlockFlags) */
  ULONG pb_Reserved1[2];
  ULONG pb_DevFlags;        /* preferred flags for OpenDevice */
  UBYTE pb_DriveName[32];   /* preferred DOS device name: BSTR form */
                            /* (not used if this name is in use) */
  ULONG pb_Reserved2[15];   /* filler to 32 longwords */

  struct {
    ULONG pbde_TableSize;       /* Size of pb_Env */
    ULONG pbde_SizeBlock;       /* in longwords: standard value is 128 */
    ULONG pbde_Pad1;            /* 0 */
    ULONG pbde_Surfaces;        /* # of heads (surfaces). drive specific */
    ULONG pbde_Pad2;            /* 1 */
    ULONG pbde_BlocksPerTrack;  /* blocks per track. drive specific */
    ULONG pbde_Reserved;        /* DOS reserved blocks at start of partition. */
    ULONG pbde_PreAlloc;        /* DOS reserved blocks at end of partition */
    ULONG pbde_Interleave;      /* usually 0 */
    ULONG pbde_LowCyl;          /* starting cylinder. typically 0 */
    ULONG pbde_HighCyl;         /* max cylinder. drive specific */
    ULONG pbde_NumBuffers;      /* Initial # DOS of buffers.  */
    ULONG pbde_BufMemType;      /* type of mem to allocate for buffers */
    ULONG pbde_MaxTransfer;     /* Max number of bytes to transfer at a time */
    ULONG pbde_Mask;            /* Address Mask to block out certain memory */
    SLONG pbde_BootPri;         /* Boot priority for autoboot */
    ULONG pbde_DosType;
    ULONG pbde_Pad[2];
    ULONG pbde_BootBlocks;
  } pb_Env;

  ULONG pb_EReserved[12];   /* reserved for future environment vector */
};

#define IDNAME_PARTITION 0x50415254 /* 'PART' */


enum pOS_PartitionBlockFlags /** pb_Flags **/
{
  PBFB_Bootable=0,       /* this partition is intended to be bootable */
  PBFF_Bootable=0x01,    /*   (expected directories and files exist) */
  PBFB_NoMount =1,       /* do not mount this partition (e.g. manually */
  PBFF_NoMount =0x02     /*   mounted, but space reserved here) */
};


/*----------------------------------
-----------------------------------*/
struct pOS_FileSysHeaderBlock
{
  ULONG   fhb_ID;             /* 4 character identifier */
  ULONG   fhb_SummedLongs;    /* size of this checksummed structure */
  ULONG   fhb_ChkSum;         /* block checksum (longword sum to zero) */
  ULONG   fhb_HostID;         /* SCSI Target ID of host */
  ULONG   fhb_Next;           /* block number of next FileSysHeaderBlock */
  ULONG   fhb_Flags;          /* see below for defines */
  ULONG   fhb_Reserved1[2];
  ULONG   fhb_DosType;        /* file system description: match this with */
                              /* partition environment's DE_DOSTYPE entry */
  ULONG   fhb_Version;        /* release version of this code */
  ULONG   fhb_PatchFlags;     /* bits set for those of the following that */
                              /*   need to be substituted into a standard */
                              /*   device node for this file system: e.g. */
                              /*   0x180 to substitute SegList & GlobalVec */
  ULONG   fhb_Type;           /* device node type: zero */
  ULONG   fhb_Task;           /* standard dos "task" field: zero */
  ULONG   fhb_Pad0;
  ULONG   fhb_Handler;        /* filename to loadseg: zero placeholder */
  ULONG   fhb_StackSize;      /* stacksize to use when starting task */
  SLONG   fhb_Priority;       /* task priority when starting task */
  ULONG   fhb_Pad[3];
  ULONG   fhb_Reserved2[23];
  ULONG   fhb_Reserved3[21];
};

#define IDNAME_FILESYSHEADER 0x46534844 /* 'FSHD' */


#endif
