part.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. part.h
  5. Abstract:
  6. This header contains internal definitions for the UEFI partition driver.
  7. Author:
  8. Evan Green 19-Mar-2014
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. #include "partfmt.h"
  14. #include <minoca/uefi/protocol/blockio.h>
  15. #include <minoca/uefi/protocol/diskio.h>
  16. #include <minoca/uefi/protocol/drvbind.h>
  17. //
  18. // --------------------------------------------------------------------- Macros
  19. //
  20. //
  21. // This macro returns a pointer to the partition data given a pointer to the
  22. // block I/O protocol instance.
  23. //
  24. #define EFI_PARTITION_DATA_FROM_THIS(_BlockIo) \
  25. PARENT_STRUCTURE(_BlockIo, EFI_PARTITION_DATA, BlockIo)
  26. //
  27. // ---------------------------------------------------------------- Definitions
  28. //
  29. #define EFI_PARTITION_DATA_MAGIC 0x74726150 // 'traP'
  30. //
  31. // ------------------------------------------------------ Data Type Definitions
  32. //
  33. typedef
  34. EFI_STATUS
  35. (*EFI_PARTITION_DETECT_ROUTINE) (
  36. EFI_DRIVER_BINDING_PROTOCOL *This,
  37. EFI_HANDLE Handle,
  38. EFI_DISK_IO_PROTOCOL *DiskIo,
  39. EFI_BLOCK_IO_PROTOCOL *BlockIo,
  40. EFI_DEVICE_PATH_PROTOCOL *DevicePath
  41. );
  42. /*++
  43. Routine Description:
  44. This routine attempts to detect a partitioned disk, and exposes child
  45. block devices for each partition it finds.
  46. Arguments:
  47. This - Supplies the driver binding protocol instance.
  48. Handle - Supplies the new controller handle.
  49. DiskIo - Supplies a pointer to the disk I/O protocol.
  50. BlockIo - Supplies a pointer to the block I/O protocol.
  51. DevicePath - Supplies a pointer to the device path.
  52. Return Value:
  53. EFI status code.
  54. --*/
  55. /*++
  56. Structure Description:
  57. This structure defines the internal data stored for a partition device.
  58. Members:
  59. Magic - Stores the magic constant EFI_PARTITION_DATA_MAGIC.
  60. Handle - Stores the device handle.
  61. DevicePath - Stores the device path.
  62. BlockIo - Stores the block I/O protocol.
  63. Media - Stores the media information.
  64. ParentDiskIo - Stores a pointer to the disk I/O protocol of the parent.
  65. ParentBlockIo - Stores a pointer to the block I/O protocol of the parent
  66. disk.
  67. Start - Stores the start offset of the logical partition.
  68. End - Stores the end offset of the logical partition.
  69. BlockSize - Stores the size of a block on the partition.
  70. EspGuid - Stores a pointer to the EFI System Partition GUID.
  71. --*/
  72. typedef struct _EFI_PARTITION_DATA {
  73. UINT64 Magic;
  74. EFI_HANDLE Handle;
  75. EFI_DEVICE_PATH_PROTOCOL *DevicePath;
  76. EFI_BLOCK_IO_PROTOCOL BlockIo;
  77. EFI_BLOCK_IO_MEDIA Media;
  78. EFI_DISK_IO_PROTOCOL *ParentDiskIo;
  79. EFI_BLOCK_IO_PROTOCOL *ParentBlockIo;
  80. UINT64 Start;
  81. UINT64 End;
  82. UINT32 BlockSize;
  83. EFI_GUID *EspGuid;
  84. } EFI_PARTITION_DATA, *PEFI_PARTITION_DATA;
  85. /*++
  86. Structure Description:
  87. This structure defines the validity status of a GPT partition entry.
  88. Members:
  89. OutOfRange - Stores a boolean indicating if the GPT partition goes outside
  90. the valid boundaries of the disk.
  91. Overlap - Stores a boolean indicating if the GPT partition overlaps with
  92. another GPT partition.
  93. OsSpecific - Stores a boolean indicating if the OS-specific attribute (bit
  94. 1) is set and therefore the partition should not be enumerated by
  95. firmware.
  96. --*/
  97. typedef struct _EFI_PARTITION_ENTRY_STATUS {
  98. BOOLEAN OutOfRange;
  99. BOOLEAN Overlap;
  100. BOOLEAN OsSpecific;
  101. } EFI_PARTITION_ENTRY_STATUS, *PEFI_PARTITION_ENTRY_STATUS;
  102. //
  103. // -------------------------------------------------------------------- Globals
  104. //
  105. //
  106. // -------------------------------------------------------- Function Prototypes
  107. //
  108. EFI_STATUS
  109. EfiPartitionDetectGpt (
  110. EFI_DRIVER_BINDING_PROTOCOL *This,
  111. EFI_HANDLE Handle,
  112. EFI_DISK_IO_PROTOCOL *DiskIo,
  113. EFI_BLOCK_IO_PROTOCOL *BlockIo,
  114. EFI_DEVICE_PATH_PROTOCOL *DevicePath
  115. );
  116. /*++
  117. Routine Description:
  118. This routine attempts to detect a GPT partitioned disk, and exposes child
  119. block devices for each partition it finds.
  120. Arguments:
  121. This - Supplies the driver binding protocol instance.
  122. Handle - Supplies the new controller handle.
  123. DiskIo - Supplies a pointer to the disk I/O protocol.
  124. BlockIo - Supplies a pointer to the block I/O protocol.
  125. DevicePath - Supplies a pointer to the device path.
  126. Return Value:
  127. EFI status code.
  128. --*/
  129. EFI_STATUS
  130. EfiPartitionDetectElTorito (
  131. EFI_DRIVER_BINDING_PROTOCOL *This,
  132. EFI_HANDLE Handle,
  133. EFI_DISK_IO_PROTOCOL *DiskIo,
  134. EFI_BLOCK_IO_PROTOCOL *BlockIo,
  135. EFI_DEVICE_PATH_PROTOCOL *DevicePath
  136. );
  137. /*++
  138. Routine Description:
  139. This routine attempts to detect an El Torito partitioned disk, and exposes
  140. child block devices for each partition it finds.
  141. Arguments:
  142. This - Supplies the driver binding protocol instance.
  143. Handle - Supplies the new controller handle.
  144. DiskIo - Supplies a pointer to the disk I/O protocol.
  145. BlockIo - Supplies a pointer to the block I/O protocol.
  146. DevicePath - Supplies a pointer to the device path.
  147. Return Value:
  148. EFI status code.
  149. --*/
  150. EFI_STATUS
  151. EfiPartitionDetectMbr (
  152. EFI_DRIVER_BINDING_PROTOCOL *This,
  153. EFI_HANDLE Handle,
  154. EFI_DISK_IO_PROTOCOL *DiskIo,
  155. EFI_BLOCK_IO_PROTOCOL *BlockIo,
  156. EFI_DEVICE_PATH_PROTOCOL *DevicePath
  157. );
  158. /*++
  159. Routine Description:
  160. This routine attempts to detect an El Torito partitioned disk, and exposes
  161. child block devices for each partition it finds.
  162. Arguments:
  163. This - Supplies the driver binding protocol instance.
  164. Handle - Supplies the new controller handle.
  165. DiskIo - Supplies a pointer to the disk I/O protocol.
  166. BlockIo - Supplies a pointer to the block I/O protocol.
  167. DevicePath - Supplies a pointer to the device path.
  168. Return Value:
  169. EFI status code.
  170. --*/
  171. EFI_STATUS
  172. EfiPartitionInstallChildHandle (
  173. EFI_DRIVER_BINDING_PROTOCOL *This,
  174. EFI_HANDLE ParentHandle,
  175. EFI_DISK_IO_PROTOCOL *DiskIo,
  176. EFI_BLOCK_IO_PROTOCOL *BlockIo,
  177. EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
  178. EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
  179. EFI_LBA Start,
  180. EFI_LBA End,
  181. UINT32 BlockSize,
  182. BOOLEAN EfiSystemPartition
  183. );
  184. /*++
  185. Routine Description:
  186. This routine creates a new partition child handle for a logical block
  187. device that represents a partition.
  188. Arguments:
  189. This - Supplies a pointer to the driver binding protocol instance.
  190. ParentHandle - Supplies the parent handle for the new child.
  191. DiskIo - Supplies a pointer to the parent disk I/O protocol.
  192. BlockIo - Supplies a pointer to the block I/O protocol.
  193. ParentDevicePath - Supplies a pointer to the parent device path.
  194. DevicePathNode - Supplies the child device path node.
  195. Start - Supplies the starting LBA of the partition.
  196. End - Supplies the ending LBA of the partition, inclusive.
  197. BlockSize - Supplies the disk block size.
  198. EfiSystemPartition - Supplies a boolean indicating if this is an EFI
  199. system partition.
  200. Return Value:
  201. EFI status code.
  202. --*/