part.h 7.2 KB

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