Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
6.3 KiB

  1. // Storage Device Image Format
  2. //
  3. #ifndef __SDI_H__
  4. #define __SDI_H__
  5. #if defined(_MSC_VER) && (_MSC_VER >= 1000)
  6. #pragma pack (push, sdi_include, 1)
  7. #endif
  8. #include "basetyps.h"
  9. #ifdef _NTDDDISK_H_
  10. #define _SDIDDKINCED_
  11. #endif
  12. #ifdef _WINIOCTL_
  13. #define _SDIDDKINCED_
  14. #endif
  15. #ifndef _SDIDDKINCED_
  16. // These are from ntdddisk.h & also defined in winioctl.h
  17. typedef enum _MEDIA_TYPE {
  18. Unknown, // Format is unknown
  19. F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
  20. F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
  21. F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
  22. F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
  23. F3_720_512, // 3.5", 720KB, 512 bytes/sector
  24. F5_360_512, // 5.25", 360KB, 512 bytes/sector
  25. F5_320_512, // 5.25", 320KB, 512 bytes/sector
  26. F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
  27. F5_180_512, // 5.25", 180KB, 512 bytes/sector
  28. F5_160_512, // 5.25", 160KB, 512 bytes/sector
  29. RemovableMedia, // Removable media other than floppy
  30. FixedMedia, // Fixed hard disk media
  31. F3_120M_512, // 3.5", 120M Floppy
  32. F3_640_512, // 3.5" , 640KB, 512 bytes/sector
  33. F5_640_512, // 5.25", 640KB, 512 bytes/sector
  34. F5_720_512, // 5.25", 720KB, 512 bytes/sector
  35. F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
  36. F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
  37. F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
  38. F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
  39. F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
  40. F8_256_128, // 8", 256KB, 128 bytes/sector
  41. F3_200Mb_512 // 3.5", 200M Floppy (HiFD)
  42. } MEDIA_TYPE, *PMEDIA_TYPE;
  43. typedef struct _DISK_GEOMETRY {
  44. LARGE_INTEGER Cylinders;
  45. MEDIA_TYPE MediaType;
  46. ULONG TracksPerCylinder;
  47. ULONG SectorsPerTrack;
  48. ULONG BytesPerSector;
  49. } DISK_GEOMETRY, *PDISK_GEOMETRY;
  50. #endif
  51. #define SDIUINT8 UCHAR
  52. #define SDIUINT16 USHORT
  53. #define SDIUINT32 ULONG
  54. #define SDIUINT64 LARGE_INTEGER
  55. #define SDI_BLOCK_SIZE 4096 // This is fixed.
  56. #define SDI_UNDEFINED 0
  57. #define SDI_UNUSED 0
  58. #define SDI_RESERVED 0
  59. #define SDI_NOBOOTCODE 0
  60. #define SDI_READYFORDISCARD 0
  61. #define SDI_INVALIDVENDORID -1
  62. #define SDI_CHECKSUMSTARTOFFSET 0
  63. #define SDI_CHECKSUMENDOFFSET 0x01FF
  64. #define SDI_DEFAULTPAGEALIGNMENT 1
  65. #define SDI_SIZEOF_SIGNATURE 8
  66. #define SDI_SIGNATURE "$SDI0001"
  67. #define SDI_MDBTYPE_VOLATILE 1
  68. #define SDI_MDBTYPE_NONVOLATILE 2
  69. #define SDI_SIZEOF_DEVICEMODEL 16
  70. #define SDI_SIZEOF_RUNTIMEGUID 16
  71. #define SDI_SIZEOF_PARAMETERLIST 2048
  72. // TOC Entry Definitions
  73. #define SDI_TOCMAXENTRIES 8
  74. // Type
  75. #define SDI_BLOBTYPE_BOOT 0x544F4F42
  76. #define SDI_BLOBTYPE_LOAD 0x44414F4C
  77. #define SDI_BLOBTYPE_PART 0x54524150
  78. #define SDI_BLOBTYPE_DISK 0x4B534944
  79. #define SDI_BLOBTYPE_READYTOBEDISCARDED (SDI_UNUSED | SDI_READYFORDISCARD)
  80. // Attribute Masks
  81. #define SDI_BLOBATTRIBUTE_TYPE_DEPENDENT_BITMASK 0xFFFF0000
  82. #define SDI_BLOBATTRIBUTE_TYPE_INDEPENDENT_BITMASK 0x0000FFFF
  83. // Attribute Bit Definitions
  84. #define SDI_DISKBLOBATTRIBUTE_ACTIVEDISK_BIT 0x00020000
  85. #define SDI_DISKBLOBATTRIBUTE_MOUNTABLE_BIT 0x00010000
  86. typedef struct _SDI_TOC_ENTRY {
  87. SDIUINT32 dwType; // Blob Type 'BOOT', 'LOAD', 'PART', 'DISK'
  88. SDIUINT8 Reserved_1[4]; // Reserved. MBZ
  89. SDIUINT32 dwAttribute; // Attribute (custom field | SDI_UNUSED)
  90. SDIUINT8 Reserved_2[4]; // Reserved. MBZ
  91. SDIUINT64 llOffset; // Offset in Bytes
  92. SDIUINT64 llSize; // Size in Bytes
  93. union _ste_u {
  94. struct _ste_typeSpecific {
  95. SDIUINT64 liTypeData; // Type specific data
  96. SDIUINT8 Reserved_5[24]; // Reserved. MBZ
  97. } typeSpecific;
  98. struct _ste_PartBlob {
  99. SDIUINT8 byType; // Partition Type
  100. } PartBlob;
  101. struct _ste_BinaryBlob {
  102. SDIUINT64 liBaseAddress; // Base Address / Sector size etc type specific data
  103. SDIUINT8 Reserved_5[24]; // Reserved. MBZ
  104. } BinaryBlob;
  105. } u;
  106. } SDITOC_ENTRY, *PSDITOC_ENTRY;
  107. // #if !defined(__MKTYPLIB__) && !defined(__midl)
  108. typedef struct _SDI_HEADER {
  109. SDIUINT8 Signature[SDI_SIZEOF_SIGNATURE]; // $SDI0001
  110. SDIUINT32 dwMDBType; // Type of Memory this SDI is supposed to boot from
  111. SDIUINT8 Reserved_1[4]; // Reserved. MBZ
  112. SDIUINT64 liBootCodeOffset; // Offset to boot code from beginning of the SDI
  113. SDIUINT64 liBootCodeSize; // Size of the boot code
  114. SDIUINT16 wVendorID; // Vendor Id
  115. SDIUINT8 Reserved_2[6]; // Reserved. MBZ
  116. SDIUINT16 wDeviceID; // Device Id
  117. SDIUINT8 Reserved_3[6]; // Reserved. MBZ
  118. SDIUINT8 DeviceModel[SDI_SIZEOF_DEVICEMODEL]; // Device Model
  119. SDIUINT32 dwDeviceRole; // Device Role
  120. SDIUINT8 Reserved_4[12]; // Reserved. MBZ
  121. SDIUINT8 RuntimeGUID[SDI_SIZEOF_RUNTIMEGUID]; // Runtime GUID
  122. SDIUINT32 dwRuntimeOEMRev; // Runtime OEM Revision Number
  123. SDIUINT8 Reserved_4_1[12]; // Reserved. MBZ
  124. SDIUINT32 dwPageAlignmentFactor; // Page Alignment Factor
  125. SDIUINT8 Reserved_5[388]; // Reserved. MBZ
  126. SDIUINT8 ucCheckSum; // CheckSum
  127. SDIUINT8 Reserved_6[7]; // Reserved. MBZ
  128. SDIUINT8 Reserved_7[512]; // Reserved. MBZ
  129. SDITOC_ENTRY ToC[SDI_TOCMAXENTRIES]; // Table of Contents
  130. SDIUINT8 Reserved_8[512]; // Reserved. MBZ
  131. SDIUINT8 ParameterList[SDI_SIZEOF_PARAMETERLIST];// Parameter List
  132. } SDI_HEADER, *PSDI_HEADER;
  133. typedef struct _SDI_BLOBDEFINITION {
  134. SDIUINT32 dwType; // Blob Type 'BOOT', 'LOAD', 'PART', 'DISK'
  135. SDIUINT32 dwAttribute; // Attribute (custom field | SDI_UNUSED)
  136. SDIUINT64 llSize; // Size in Bytes
  137. union _sbd_u {
  138. struct _sbd_typeSpecific {
  139. SDIUINT64 liTypeData; // Type specific data
  140. SDIUINT8 Reserved_5[24]; // Reserved. MBZ
  141. } typeSpecific;
  142. struct _sbd_PartBlob {
  143. SDIUINT8 byType; // Partition Type
  144. } PartBlob;
  145. struct _sbd_BinaryBlob {
  146. SDIUINT64 liBaseAddress; // Base Address / Sector size etc type specific data
  147. SDIUINT8 Reserved_5[24]; // Reserved. MBZ
  148. } BinaryBlob;
  149. } u;
  150. } SDI_BLOBDEFINITION, *PSDI_BLOBDEFINITION;
  151. // #endif
  152. #if defined(_MSC_VER) && (_MSC_VER >= 1000)
  153. #pragma pack (pop, sdi_include)
  154. #endif
  155. #endif //__SDI_H__