hardblocks.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit hardblocks;
  13. {
  14. History:
  15. Updated for AmigaOs 3.9.
  16. A few changes in records.
  17. 28 Jan 2003.
  18. [email protected] Nils Sjoholm
  19. }
  20. INTERFACE
  21. uses exec;
  22. { Changes
  23. ** Expanded envec
  24. ** Added storage for driveinit name up to 31 letters.
  25. ** Added storage for filesysten name up to 83 letters.
  26. **}
  27. {--------------------------------------------------------------------
  28. *
  29. * This file describes blocks of data that exist on a hard disk
  30. * to describe that disk. They are not generically accessable to
  31. * the user as they do not appear on any DOS drive. The blocks
  32. * are tagged with a unique identifier, checksummed, and linked
  33. * together. The root of these blocks is the RigidDiskBlock.
  34. *
  35. * The RigidDiskBlock must exist on the disk within the first
  36. * RDB_LOCATION_LIMIT blocks. This inhibits the use of the zero
  37. * cylinder in an AmigaDOS partition: although it is strictly
  38. * possible to store the RigidDiskBlock data in the reserved
  39. * area of a partition, this practice is discouraged since the
  40. * reserved blocks of a partition are overwritten by "Format",
  41. * "Install", "DiskCopy", etc. The recommended disk layout,
  42. * then, is to use the first cylinder(s) to store all the drive
  43. * data specified by these blocks: i.e. partition descriptions,
  44. * file system load images, drive bad block maps, spare blocks,
  45. * etc.
  46. *
  47. * Though all descriptions in this file contemplate 512 blocks
  48. * per track this desecription works functionally with any block
  49. * size. The LSEG blocks should make most efficient use of the
  50. * disk block size possible, for example. While this specification
  51. * can support 256 byte sectors that is deprecated at this time.
  52. *
  53. * This version adds some modest storage spaces for inserting
  54. * the actual source filename for files installed on the RDBs
  55. * as either DriveInit code or Filesystem code. This makes
  56. * creating a mountfile suitable for use with the "C:Mount"
  57. * command that can be used for manually mounting the disk if
  58. * ever required.
  59. *
  60. *
  61. *------------------------------------------------------------------}
  62. {
  63. * NOTE
  64. * optional block addresses below contain $ffffffff to indicate
  65. * a NULL address, as zero is a valid address
  66. }
  67. type
  68. pRigidDiskBlock = ^tRigidDiskBlock;
  69. tRigidDiskBlock = record
  70. rdb_ID : ULONG; { 4 character identifier }
  71. rdb_SummedLongs : ULONG; { size of this checksummed structure }
  72. rdb_ChkSum : ULONG; { block checksum (longword sum to zero) }
  73. rdb_HostID : ULONG; { SCSI Target ID of host }
  74. rdb_BlockBytes : ULONG; { size of disk blocks }
  75. rdb_Flags : ULONG; { see below for defines }
  76. { block list heads }
  77. rdb_BadBlockList : ULONG; { optional bad block list }
  78. rdb_PartitionList : ULONG; { optional first partition block }
  79. rdb_FileSysHeaderList : ULONG; { optional file system header block }
  80. rdb_DriveInit : ULONG; { optional drive-specific init code }
  81. { DriveInit(lun,rdb,ior): "C" stk & d0/a0/a1 }
  82. rdb_Reserved1 : Array [0..5] of ULONG; { set to $ffffffff }
  83. { physical drive characteristics }
  84. rdb_Cylinders : ULONG; { number of drive cylinders }
  85. rdb_Sectors : ULONG; { sectors per track }
  86. rdb_Heads : ULONG; { number of drive heads }
  87. rdb_Interleave : ULONG; { interleave }
  88. rdb_Park : ULONG; { landing zone cylinder }
  89. rdb_Reserved2 : Array [0..2] of ULONG;
  90. rdb_WritePreComp : ULONG; { starting cylinder: write precompensation }
  91. rdb_ReducedWrite : ULONG; { starting cylinder: reduced write current }
  92. rdb_StepRate : ULONG; { drive step rate }
  93. rdb_Reserved3 : Array [0..4] of ULONG;
  94. { logical drive characteristics }
  95. rdb_RDBBlocksLo : ULONG; { low block of range reserved for hardblocks }
  96. rdb_RDBBlocksHi : ULONG; { high block of range for these hardblocks }
  97. rdb_LoCylinder : ULONG; { low cylinder of partitionable disk area }
  98. rdb_HiCylinder : ULONG; { high cylinder of partitionable data area }
  99. rdb_CylBlocks : ULONG; { number of blocks available per cylinder }
  100. rdb_AutoParkSeconds : ULONG; { zero for no auto park }
  101. rdb_Reserved4 : Array [0..1] of ULONG;
  102. { drive identification }
  103. rdb_DiskVendor : Array [0..7] of Char;
  104. rdb_DiskProduct : Array [0..15] of Char;
  105. rdb_DiskRevision : Array [0..3] of Char;
  106. rdb_ControllerVendor : Array [0..7] of Char;
  107. rdb_ControllerProduct : Array [0..15] of Char;
  108. rdb_ControllerRevision : Array [0..3] of Char;
  109. rdb_DriveInitName : array[0..39] of char;
  110. end;
  111. const
  112. IDNAME_RIGIDDISK = $5244534B; { RDSK }
  113. RDB_LOCATION_LIMIT = 16;
  114. RDBFB_LAST = 0; { no disks exist to be configured after }
  115. RDBFF_LAST = $01; { this one on this controller }
  116. RDBFB_LASTLUN = 1; { no LUNs exist to be configured greater }
  117. RDBFF_LASTLUN = $02; { than this one at this SCSI Target ID }
  118. RDBFB_LASTTID = 2; { no Target IDs exist to be configured }
  119. RDBFF_LASTTID = $04; { greater than this one on this SCSI bus }
  120. RDBFB_NORESELECT = 3; { don't bother trying to perform reselection }
  121. RDBFF_NORESELECT = $08; { when talking to this drive }
  122. RDBFB_DISKID = 4; { rdb_Disk... identification valid }
  123. RDBFF_DISKID = $10;
  124. RDBFB_CTRLRID = 5; { rdb_Controller... identification valid }
  125. RDBFF_CTRLRID = $20;
  126. { added 7/20/89 by commodore: }
  127. RDBFB_SYNCH = 6; { drive supports scsi synchronous mode }
  128. RDBFF_SYNCH = $40; { CAN BE DANGEROUS TO USE IF IT DOESN'T! }
  129. {------------------------------------------------------------------}
  130. type
  131. pBadBlockEntry = ^tBadBlockEntry;
  132. tBadBlockEntry = record
  133. bbe_BadBlock : ULONG; { block number of bad block }
  134. bbe_GoodBlock : ULONG; { block number of replacement block }
  135. end;
  136. pBadBlockBlock = ^tBadBlockBlock;
  137. tBadBlockBlock = record
  138. bbb_ID : ULONG; { 4 character identifier }
  139. bbb_SummedLongs : ULONG; { size of this checksummed structure }
  140. bbb_ChkSum : Longint; { block checksum (longword sum to zero) }
  141. bbb_HostID : ULONG; { SCSI Target ID of host }
  142. bbb_Next : ULONG; { block number of the next BadBlockBlock }
  143. bbb_Reserved : ULONG;
  144. bbb_BlockPairs : Array [0..60] of tBadBlockEntry; { bad block entry pairs }
  145. { note [61] assumes 512 byte blocks }
  146. end;
  147. const
  148. IDNAME_BADBLOCK = $42414442; { BADB }
  149. {------------------------------------------------------------------}
  150. type
  151. pPartitionBlock = ^tPartitionBlock;
  152. tPartitionBlock = record
  153. pb_ID : ULONG; { 4 character identifier }
  154. pb_SummedLongs : ULONG; { size of this checksummed structure }
  155. pb_ChkSum : Longint; { block checksum (longword sum to zero) }
  156. pb_HostID : ULONG; { SCSI Target ID of host }
  157. pb_Next : ULONG; { block number of the next PartitionBlock }
  158. pb_Flags : ULONG; { see below for defines }
  159. pb_Reserved1 : Array [0..1] of ULONG;
  160. pb_DevFlags : ULONG; { preferred flags for OpenDevice }
  161. pb_DriveName : Array [0..31] of Char; { preferred DOS device name: BSTR form }
  162. { (not used if this name is in use) }
  163. pb_Reserved2 : Array [0..14] of ULONG; { filler to 32 longwords }
  164. pb_Environment : Array [0..19] of ULONG; { environment vector for this partition }
  165. pb_EReserved : Array [0..11] of ULONG; { reserved for future environment vector }
  166. end;
  167. const
  168. IDNAME_PARTITION = $50415254; { PART }
  169. PBFB_BOOTABLE = 0; { this partition is intended to be bootable }
  170. PBFF_BOOTABLE = 1; { (expected directories and files exist) }
  171. PBFB_NOMOUNT = 1; { do not mount this partition (e.g. manually }
  172. PBFF_NOMOUNT = 2; { mounted, but space reserved here) }
  173. {------------------------------------------------------------------}
  174. type
  175. pFileSysHeaderBlock = ^tFileSysHeaderBlock;
  176. tFileSysHeaderBlock = record
  177. fhb_ID : ULONG; { 4 character identifier }
  178. fhb_SummedLongs : ULONG; { size of this checksummed structure }
  179. fhb_ChkSum : Longint; { block checksum (longword sum to zero) }
  180. fhb_HostID : ULONG; { SCSI Target ID of host }
  181. fhb_Next : ULONG; { block number of next FileSysHeaderBlock }
  182. fhb_Flags : ULONG; { see below for defines }
  183. fhb_Reserved1 : Array [0..1] of ULONG;
  184. fhb_DosType : ULONG; { file system description: match this with }
  185. { partition environment's DE_DOSTYPE entry }
  186. fhb_Version : ULONG; { release version of this code }
  187. fhb_PatchFlags : ULONG; { bits set for those of the following that }
  188. { need to be substituted into a standard }
  189. { device node for this file system: e.g. }
  190. { 0x180 to substitute SegList & GlobalVec }
  191. fhb_Type : ULONG; { device node type: zero }
  192. fhb_Task : ULONG; { standard dos "task" field: zero }
  193. fhb_Lock : ULONG; { not used for devices: zero }
  194. fhb_Handler : ULONG; { filename to loadseg: zero placeholder }
  195. fhb_StackSize : ULONG; { stacksize to use when starting task }
  196. fhb_Priority : Longint; { task priority when starting task }
  197. fhb_Startup : Longint; { startup msg: zero placeholder }
  198. fhb_SegListBlocks : Longint; { first of linked list of LoadSegBlocks: }
  199. { note that this entry requires some }
  200. { processing before substitution }
  201. fhb_GlobalVec : Longint; { BCPL global vector when starting task }
  202. fhb_Reserved2 : Array [0..22] of ULONG; { (those reserved by PatchFlags) }
  203. fhb_FileSysName : array[0..83] of char; { File system file name as loaded. }
  204. end;
  205. const
  206. IDNAME_FILESYSHEADER = $46534844; { FSHD }
  207. {------------------------------------------------------------------}
  208. Type
  209. pLoadSegBlock = ^tLoadSegBlock;
  210. tLoadSegBlock = record
  211. lsb_ID : ULONG; { 4 character identifier }
  212. lsb_SummedLongs : ULONG; { size of this checksummed structure }
  213. lsb_ChkSum : Longint; { block checksum (longword sum to zero) }
  214. lsb_HostID : ULONG; { SCSI Target ID of host }
  215. lsb_Next : ULONG; { block number of the next LoadSegBlock }
  216. lsb_LoadData : Array [0..122] of ULONG; { data for "loadseg" }
  217. { note [123] assumes 512 byte blocks }
  218. end;
  219. const
  220. IDNAME_LOADSEG = $4C534547; { LSEG }
  221. IMPLEMENTATION
  222. end.