api.h 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849
  1. /* efi.h - declare EFI types and functions */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
  5. *
  6. * GRUB is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef GRUB_EFI_API_HEADER
  20. #define GRUB_EFI_API_HEADER 1
  21. #include <grub/types.h>
  22. #include <grub/symbol.h>
  23. /* For consistency and safety, we name the EFI-defined types differently.
  24. All names are transformed into lower case, _t appended, and
  25. grub_efi_ prepended. */
  26. /* Constants. */
  27. #define GRUB_EFI_EVT_TIMER 0x80000000
  28. #define GRUB_EFI_EVT_RUNTIME 0x40000000
  29. #define GRUB_EFI_EVT_RUNTIME_CONTEXT 0x20000000
  30. #define GRUB_EFI_EVT_NOTIFY_WAIT 0x00000100
  31. #define GRUB_EFI_EVT_NOTIFY_SIGNAL 0x00000200
  32. #define GRUB_EFI_EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
  33. #define GRUB_EFI_EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
  34. #define GRUB_EFI_TPL_APPLICATION 4
  35. #define GRUB_EFI_TPL_CALLBACK 8
  36. #define GRUB_EFI_TPL_NOTIFY 16
  37. #define GRUB_EFI_TPL_HIGH_LEVEL 31
  38. #define GRUB_EFI_MEMORY_UC 0x0000000000000001LL
  39. #define GRUB_EFI_MEMORY_WC 0x0000000000000002LL
  40. #define GRUB_EFI_MEMORY_WT 0x0000000000000004LL
  41. #define GRUB_EFI_MEMORY_WB 0x0000000000000008LL
  42. #define GRUB_EFI_MEMORY_UCE 0x0000000000000010LL
  43. #define GRUB_EFI_MEMORY_WP 0x0000000000001000LL
  44. #define GRUB_EFI_MEMORY_RP 0x0000000000002000LL
  45. #define GRUB_EFI_MEMORY_XP 0x0000000000004000LL
  46. #define GRUB_EFI_MEMORY_NV 0x0000000000008000LL
  47. #define GRUB_EFI_MEMORY_MORE_RELIABLE 0x0000000000010000LL
  48. #define GRUB_EFI_MEMORY_RO 0x0000000000020000LL
  49. #define GRUB_EFI_MEMORY_RUNTIME 0x8000000000000000LL
  50. #define GRUB_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
  51. #define GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
  52. #define GRUB_EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
  53. #define GRUB_EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
  54. #define GRUB_EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
  55. #define GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE 0x00000020
  56. #define GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL
  57. #define GRUB_EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
  58. #define GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
  59. #define GRUB_EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
  60. #define GRUB_EFI_TIME_ADJUST_DAYLIGHT 0x01
  61. #define GRUB_EFI_TIME_IN_DAYLIGHT 0x02
  62. #define GRUB_EFI_UNSPECIFIED_TIMEZONE 0x07FF
  63. #define GRUB_EFI_OPTIONAL_PTR 0x00000001
  64. #define GRUB_EFI_LOADED_IMAGE_GUID \
  65. { 0x5b1b31a1, 0x9562, 0x11d2, \
  66. { 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
  67. }
  68. #define GRUB_EFI_DISK_IO_GUID \
  69. { 0xce345171, 0xba0b, 0x11d2, \
  70. { 0x8e, 0x4f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
  71. }
  72. #define GRUB_EFI_BLOCK_IO_GUID \
  73. { 0x964e5b21, 0x6459, 0x11d2, \
  74. { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
  75. }
  76. #define GRUB_EFI_SERIAL_IO_GUID \
  77. { 0xbb25cf6f, 0xf1d4, 0x11d2, \
  78. { 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0xfd } \
  79. }
  80. #define GRUB_EFI_SIMPLE_NETWORK_GUID \
  81. { 0xa19832b9, 0xac25, 0x11d3, \
  82. { 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  83. }
  84. #define GRUB_EFI_PXE_GUID \
  85. { 0x03c4e603, 0xac28, 0x11d3, \
  86. { 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  87. }
  88. #define GRUB_EFI_DEVICE_PATH_GUID \
  89. { 0x09576e91, 0x6d3f, 0x11d2, \
  90. { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
  91. }
  92. #define GRUB_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
  93. { 0x387477c1, 0x69c7, 0x11d2, \
  94. { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
  95. }
  96. #define GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
  97. { 0xdd9e7534, 0x7762, 0x4698, \
  98. { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } \
  99. }
  100. #define GRUB_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
  101. { 0x387477c2, 0x69c7, 0x11d2, \
  102. { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
  103. }
  104. #define GRUB_EFI_SIMPLE_POINTER_PROTOCOL_GUID \
  105. { 0x31878c87, 0xb75, 0x11d5, \
  106. { 0x9a, 0x4f, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  107. }
  108. #define GRUB_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \
  109. { 0x8D59D32B, 0xC655, 0x4AE9, \
  110. { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } \
  111. }
  112. #define GRUB_EFI_DRIVER_BINDING_PROTOCOL_GUID \
  113. { 0x18A031AB, 0xB443, 0x4D1A, \
  114. { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71 } \
  115. }
  116. #define GRUB_EFI_LOADED_IMAGE_PROTOCOL_GUID \
  117. { 0x5B1B31A1, 0x9562, 0x11d2, \
  118. { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
  119. }
  120. #define GRUB_EFI_LOAD_FILE_PROTOCOL_GUID \
  121. { 0x56EC3091, 0x954C, 0x11d2, \
  122. { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
  123. }
  124. #define GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID \
  125. { 0x4006c0c1, 0xfcb3, 0x403e, \
  126. { 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d } \
  127. }
  128. #define GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
  129. { 0x0964e5b22, 0x6459, 0x11d2, \
  130. { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
  131. }
  132. #define GRUB_EFI_TAPE_IO_PROTOCOL_GUID \
  133. { 0x1e93e633, 0xd65a, 0x459e, \
  134. { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } \
  135. }
  136. #define GRUB_EFI_UNICODE_COLLATION_PROTOCOL_GUID \
  137. { 0x1d85cd7f, 0xf43d, 0x11d2, \
  138. { 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  139. }
  140. #define GRUB_EFI_SCSI_IO_PROTOCOL_GUID \
  141. { 0x932f47e6, 0x2362, 0x4002, \
  142. { 0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \
  143. }
  144. #define GRUB_EFI_USB2_HC_PROTOCOL_GUID \
  145. { 0x3e745226, 0x9818, 0x45b6, \
  146. { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } \
  147. }
  148. #define GRUB_EFI_DEBUG_SUPPORT_PROTOCOL_GUID \
  149. { 0x2755590C, 0x6F3C, 0x42FA, \
  150. { 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 } \
  151. }
  152. #define GRUB_EFI_DEBUGPORT_PROTOCOL_GUID \
  153. { 0xEBA4E8D2, 0x3858, 0x41EC, \
  154. { 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 } \
  155. }
  156. #define GRUB_EFI_DECOMPRESS_PROTOCOL_GUID \
  157. { 0xd8117cfe, 0x94a6, 0x11d4, \
  158. { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  159. }
  160. #define GRUB_EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
  161. { 0x8b843e20, 0x8132, 0x4852, \
  162. { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } \
  163. }
  164. #define GRUB_EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
  165. { 0x379be4e, 0xd706, 0x437d, \
  166. { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \
  167. }
  168. #define GRUB_EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \
  169. { 0x5c99a21, 0xc70f, 0x4ad2, \
  170. { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } \
  171. }
  172. #define GRUB_EFI_ACPI_TABLE_PROTOCOL_GUID \
  173. { 0xffe06bdd, 0x6107, 0x46a6, \
  174. { 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c} \
  175. }
  176. #define GRUB_EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \
  177. { 0x587e72d7, 0xcc50, 0x4f79, \
  178. { 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f } \
  179. }
  180. #define GRUB_EFI_HII_DATABASE_PROTOCOL_GUID \
  181. { 0xef9fc172, 0xa1b2, 0x4693, \
  182. { 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 } \
  183. }
  184. #define GRUB_EFI_HII_STRING_PROTOCOL_GUID \
  185. { 0xfd96974, 0x23aa, 0x4cdc, \
  186. { 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a } \
  187. }
  188. #define GRUB_EFI_HII_IMAGE_PROTOCOL_GUID \
  189. { 0x31a6406a, 0x6bdf, 0x4e46, \
  190. { 0xb2, 0xa2, 0xeb, 0xaa, 0x89, 0xc4, 0x9, 0x20 } \
  191. }
  192. #define GRUB_EFI_HII_FONT_PROTOCOL_GUID \
  193. { 0xe9ca4775, 0x8657, 0x47fc, \
  194. { 0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x8, 0x43, 0x24 } \
  195. }
  196. #define GRUB_EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID \
  197. { 0x330d4706, 0xf2a0, 0x4e4f, \
  198. { 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85 } \
  199. }
  200. #define GRUB_EFI_COMPONENT_NAME2_PROTOCOL_GUID \
  201. { 0x6a7a5cff, 0xe8d9, 0x4f70, \
  202. { 0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14} \
  203. }
  204. #define GRUB_EFI_USB_IO_PROTOCOL_GUID \
  205. { 0x2B2F68D6, 0x0CD2, 0x44cf, \
  206. { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \
  207. }
  208. #define GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID \
  209. { 0xa31280ad, 0x481e, 0x41b6, \
  210. { 0x95, 0xe8, 0x12, 0x7f, 0x4c, 0x98, 0x47, 0x79 } \
  211. }
  212. #define GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID \
  213. { 0xfc1bcdb0, 0x7d31, 0x49aa, \
  214. { 0x93, 0x6a, 0xa4, 0x60, 0x0d, 0x9d, 0xd0, 0x83 } \
  215. }
  216. #define GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID \
  217. { 0xee4e5898, 0x3914, 0x4259, \
  218. { 0x9d, 0x6e, 0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf } \
  219. }
  220. #define GRUB_EFI_TSC_FREQUENCY_GUID \
  221. { 0xdba6a7e3, 0xbb57, 0x4be7, \
  222. { 0x8a, 0xf8, 0xd5, 0x78, 0xdb, 0x7e, 0x56, 0x87 } \
  223. }
  224. #define GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID \
  225. { 0xb122a263, 0x3661, 0x4f68, \
  226. { 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 } \
  227. }
  228. #define GRUB_EFI_DXE_SERVICES_TABLE_GUID \
  229. { 0x05ad34ba, 0x6f02, 0x4214, \
  230. { 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } \
  231. }
  232. #define GRUB_EFI_HOB_LIST_GUID \
  233. { 0x7739f24c, 0x93d7, 0x11d4, \
  234. { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  235. }
  236. #define GRUB_EFI_IMAGE_SECURITY_DATABASE_GUID \
  237. { 0xd719b2cb, 0x3d3a, 0x4596, \
  238. { 0xa3, 0xbc, 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f } \
  239. }
  240. #define GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID \
  241. { 0x4c19049f, 0x4137, 0x4dd3, \
  242. { 0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa } \
  243. }
  244. #define GRUB_EFI_CONFORMANCE_PROFILES_TABLE_GUID \
  245. { 0x36122546, 0xf7e7, 0x4c8f, \
  246. { 0xbd, 0x9b, 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b } \
  247. }
  248. #define GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID \
  249. { 0x49152e77, 0x1ada, 0x4764, \
  250. { 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } \
  251. }
  252. #define GRUB_EFI_MPS_TABLE_GUID \
  253. { 0xeb9d2d2f, 0x2d88, 0x11d3, \
  254. { 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  255. }
  256. #define GRUB_EFI_ACPI_TABLE_GUID \
  257. { 0xeb9d2d30, 0x2d88, 0x11d3, \
  258. { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  259. }
  260. #define GRUB_EFI_ACPI_20_TABLE_GUID \
  261. { 0x8868e871, 0xe4f1, 0x11d3, \
  262. { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
  263. }
  264. #define GRUB_EFI_SMBIOS_TABLE_GUID \
  265. { 0xeb9d2d31, 0x2d88, 0x11d3, \
  266. { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  267. }
  268. #define GRUB_EFI_SMBIOS3_TABLE_GUID \
  269. { 0xf2fd1544, 0x9794, 0x4a2c, \
  270. { 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 } \
  271. }
  272. #define GRUB_EFI_SAL_TABLE_GUID \
  273. { 0xeb9d2d32, 0x2d88, 0x11d3, \
  274. { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
  275. }
  276. #define GRUB_EFI_HCDP_TABLE_GUID \
  277. { 0xf951938d, 0x620b, 0x42ef, \
  278. { 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \
  279. }
  280. #define GRUB_EFI_RT_PROPERTIES_TABLE_GUID \
  281. { 0xeb66918a, 0x7eef, 0x402a, \
  282. { 0x84, 0x2e, 0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9 } \
  283. }
  284. #define GRUB_EFI_DEVICE_TREE_GUID \
  285. { 0xb1b621d5, 0xf19c, 0x41a5, \
  286. { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } \
  287. }
  288. #define GRUB_EFI_VENDOR_APPLE_GUID \
  289. { 0x2B0585EB, 0xD8B8, 0x49A9, \
  290. { 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \
  291. }
  292. #define GRUB_EFI_SHIM_LOCK_GUID \
  293. { 0x605dab50, 0xe046, 0x4300, \
  294. { 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } \
  295. }
  296. #define GRUB_EFI_SHIM_IMAGE_LOADER_GUID \
  297. { 0x1f492041, 0xfadb, 0x4e59, \
  298. {0x9e, 0x57, 0x7c, 0xaf, 0xe7, 0x3a, 0x55, 0xab } \
  299. }
  300. #define GRUB_EFI_RNG_PROTOCOL_GUID \
  301. { 0x3152bca5, 0xeade, 0x433d, \
  302. { 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \
  303. }
  304. #define LINUX_EFI_INITRD_MEDIA_GUID \
  305. { 0x5568e427, 0x68fc, 0x4f3d, \
  306. { 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68 } \
  307. }
  308. #define GRUB_EFI_VENDOR_BOOT_LOADER_INTERFACE_GUID \
  309. { 0x4a67b082, 0x0a4c, 0x41cf, \
  310. {0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f } \
  311. }
  312. #define GRUB_EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID \
  313. { 0xf4560cf6, 0x40ec, 0x4b4a, \
  314. { 0xa1, 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, 0x89 } \
  315. }
  316. struct grub_efi_sal_system_table
  317. {
  318. grub_uint32_t signature;
  319. grub_uint32_t total_table_len;
  320. grub_uint16_t sal_rev;
  321. grub_uint16_t entry_count;
  322. grub_uint8_t checksum;
  323. grub_uint8_t reserved1[7];
  324. grub_uint16_t sal_a_version;
  325. grub_uint16_t sal_b_version;
  326. grub_uint8_t oem_id[32];
  327. grub_uint8_t product_id[32];
  328. grub_uint8_t reserved2[8];
  329. grub_uint8_t entries[0];
  330. };
  331. enum
  332. {
  333. GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR = 0,
  334. GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR = 1,
  335. GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES = 2,
  336. GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR = 3,
  337. GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE = 4,
  338. GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP = 5
  339. };
  340. struct grub_efi_sal_system_table_entrypoint_descriptor
  341. {
  342. grub_uint8_t type;
  343. grub_uint8_t pad[7];
  344. grub_uint64_t pal_proc_addr;
  345. grub_uint64_t sal_proc_addr;
  346. grub_uint64_t global_data_ptr;
  347. grub_uint64_t reserved[2];
  348. };
  349. struct grub_efi_sal_system_table_memory_descriptor
  350. {
  351. grub_uint8_t type;
  352. grub_uint8_t sal_used;
  353. grub_uint8_t attr;
  354. grub_uint8_t ar;
  355. grub_uint8_t attr_mask;
  356. grub_uint8_t mem_type;
  357. grub_uint8_t usage;
  358. grub_uint8_t unknown;
  359. grub_uint64_t addr;
  360. grub_uint64_t len;
  361. grub_uint64_t unknown2;
  362. };
  363. struct grub_efi_sal_system_table_platform_features
  364. {
  365. grub_uint8_t type;
  366. grub_uint8_t flags;
  367. grub_uint8_t reserved[14];
  368. };
  369. struct grub_efi_sal_system_table_translation_register_descriptor
  370. {
  371. grub_uint8_t type;
  372. grub_uint8_t register_type;
  373. grub_uint8_t register_number;
  374. grub_uint8_t reserved[5];
  375. grub_uint64_t addr;
  376. grub_uint64_t page_size;
  377. grub_uint64_t reserver;
  378. };
  379. struct grub_efi_sal_system_table_purge_translation_coherence
  380. {
  381. grub_uint8_t type;
  382. grub_uint8_t reserved[3];
  383. grub_uint32_t ndomains;
  384. grub_uint64_t coherence;
  385. };
  386. struct grub_efi_sal_system_table_ap_wakeup
  387. {
  388. grub_uint8_t type;
  389. grub_uint8_t mechanism;
  390. grub_uint8_t reserved[6];
  391. grub_uint64_t vector;
  392. };
  393. enum
  394. {
  395. GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK = 1,
  396. GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT = 2,
  397. GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT = 4,
  398. GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT = 8,
  399. };
  400. typedef enum grub_efi_parity_type
  401. {
  402. GRUB_EFI_SERIAL_DEFAULT_PARITY,
  403. GRUB_EFI_SERIAL_NO_PARITY,
  404. GRUB_EFI_SERIAL_EVEN_PARITY,
  405. GRUB_EFI_SERIAL_ODD_PARITY
  406. }
  407. grub_efi_parity_type_t;
  408. typedef enum grub_efi_stop_bits
  409. {
  410. GRUB_EFI_SERIAL_DEFAULT_STOP_BITS,
  411. GRUB_EFI_SERIAL_1_STOP_BIT,
  412. GRUB_EFI_SERIAL_1_5_STOP_BITS,
  413. GRUB_EFI_SERIAL_2_STOP_BITS
  414. }
  415. grub_efi_stop_bits_t;
  416. /* Enumerations. */
  417. enum grub_efi_timer_delay
  418. {
  419. GRUB_EFI_TIMER_CANCEL,
  420. GRUB_EFI_TIMER_PERIODIC,
  421. GRUB_EFI_TIMER_RELATIVE
  422. };
  423. typedef enum grub_efi_timer_delay grub_efi_timer_delay_t;
  424. enum grub_efi_allocate_type
  425. {
  426. GRUB_EFI_ALLOCATE_ANY_PAGES,
  427. GRUB_EFI_ALLOCATE_MAX_ADDRESS,
  428. GRUB_EFI_ALLOCATE_ADDRESS,
  429. GRUB_EFI_MAX_ALLOCATION_TYPE
  430. };
  431. typedef enum grub_efi_allocate_type grub_efi_allocate_type_t;
  432. enum grub_efi_memory_type
  433. {
  434. GRUB_EFI_RESERVED_MEMORY_TYPE,
  435. GRUB_EFI_LOADER_CODE,
  436. GRUB_EFI_LOADER_DATA,
  437. GRUB_EFI_BOOT_SERVICES_CODE,
  438. GRUB_EFI_BOOT_SERVICES_DATA,
  439. GRUB_EFI_RUNTIME_SERVICES_CODE,
  440. GRUB_EFI_RUNTIME_SERVICES_DATA,
  441. GRUB_EFI_CONVENTIONAL_MEMORY,
  442. GRUB_EFI_UNUSABLE_MEMORY,
  443. GRUB_EFI_ACPI_RECLAIM_MEMORY,
  444. GRUB_EFI_ACPI_MEMORY_NVS,
  445. GRUB_EFI_MEMORY_MAPPED_IO,
  446. GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
  447. GRUB_EFI_PAL_CODE,
  448. GRUB_EFI_PERSISTENT_MEMORY,
  449. GRUB_EFI_MAX_MEMORY_TYPE
  450. };
  451. typedef enum grub_efi_memory_type grub_efi_memory_type_t;
  452. enum grub_efi_interface_type
  453. {
  454. GRUB_EFI_NATIVE_INTERFACE
  455. };
  456. typedef enum grub_efi_interface_type grub_efi_interface_type_t;
  457. enum grub_efi_locate_search_type
  458. {
  459. GRUB_EFI_ALL_HANDLES,
  460. GRUB_EFI_BY_REGISTER_NOTIFY,
  461. GRUB_EFI_BY_PROTOCOL
  462. };
  463. typedef enum grub_efi_locate_search_type grub_efi_locate_search_type_t;
  464. enum grub_efi_reset_type
  465. {
  466. GRUB_EFI_RESET_COLD,
  467. GRUB_EFI_RESET_WARM,
  468. GRUB_EFI_RESET_SHUTDOWN
  469. };
  470. typedef enum grub_efi_reset_type grub_efi_reset_type_t;
  471. /* Types. */
  472. typedef char grub_efi_boolean_t;
  473. #if GRUB_CPU_SIZEOF_VOID_P == 8
  474. typedef grub_int64_t grub_efi_intn_t;
  475. typedef grub_uint64_t grub_efi_uintn_t;
  476. #define PRIxGRUB_EFI_UINTN_T PRIxGRUB_UINT64_T
  477. #define PRIuGRUB_EFI_UINTN_T PRIuGRUB_UINT64_T
  478. #else
  479. typedef grub_int32_t grub_efi_intn_t;
  480. typedef grub_uint32_t grub_efi_uintn_t;
  481. #define PRIxGRUB_EFI_UINTN_T PRIxGRUB_UINT32_T
  482. #define PRIuGRUB_EFI_UINTN_T PRIuGRUB_UINT32_T
  483. #endif
  484. typedef grub_int8_t grub_efi_int8_t;
  485. typedef grub_uint8_t grub_efi_uint8_t;
  486. typedef grub_int16_t grub_efi_int16_t;
  487. typedef grub_uint16_t grub_efi_uint16_t;
  488. typedef grub_int32_t grub_efi_int32_t;
  489. typedef grub_uint32_t grub_efi_uint32_t;
  490. #define PRIxGRUB_EFI_UINT32_T PRIxGRUB_UINT32_T
  491. #define PRIuGRUB_EFI_UINT32_T PRIuGRUB_UINT32_T
  492. typedef grub_int64_t grub_efi_int64_t;
  493. typedef grub_uint64_t grub_efi_uint64_t;
  494. typedef grub_uint8_t grub_efi_char8_t;
  495. typedef grub_uint16_t grub_efi_char16_t;
  496. typedef grub_efi_uintn_t grub_efi_status_t;
  497. /*
  498. * On x86, the EFI calling convention may deviate from the local one, so
  499. * callback functions exposed to the firmware must carry the follow attribute
  500. * annotation. (This includes protocols implemented by GRUB that are installed
  501. * into the EFI protocol database.)
  502. */
  503. #if defined(__i386__)
  504. #define __grub_efi_api __attribute__((regparm(0)))
  505. #elif defined(__x86_64__)
  506. #define __grub_efi_api __attribute__((ms_abi))
  507. #else
  508. #define __grub_efi_api
  509. #endif
  510. #define GRUB_EFI_ERROR_CODE(value) \
  511. ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value))
  512. #define GRUB_EFI_WARNING_CODE(value) (value)
  513. #define GRUB_EFI_SUCCESS 0
  514. #define GRUB_EFI_LOAD_ERROR GRUB_EFI_ERROR_CODE (1)
  515. #define GRUB_EFI_INVALID_PARAMETER GRUB_EFI_ERROR_CODE (2)
  516. #define GRUB_EFI_UNSUPPORTED GRUB_EFI_ERROR_CODE (3)
  517. #define GRUB_EFI_BAD_BUFFER_SIZE GRUB_EFI_ERROR_CODE (4)
  518. #define GRUB_EFI_BUFFER_TOO_SMALL GRUB_EFI_ERROR_CODE (5)
  519. #define GRUB_EFI_NOT_READY GRUB_EFI_ERROR_CODE (6)
  520. #define GRUB_EFI_DEVICE_ERROR GRUB_EFI_ERROR_CODE (7)
  521. #define GRUB_EFI_WRITE_PROTECTED GRUB_EFI_ERROR_CODE (8)
  522. #define GRUB_EFI_OUT_OF_RESOURCES GRUB_EFI_ERROR_CODE (9)
  523. #define GRUB_EFI_VOLUME_CORRUPTED GRUB_EFI_ERROR_CODE (10)
  524. #define GRUB_EFI_VOLUME_FULL GRUB_EFI_ERROR_CODE (11)
  525. #define GRUB_EFI_NO_MEDIA GRUB_EFI_ERROR_CODE (12)
  526. #define GRUB_EFI_MEDIA_CHANGED GRUB_EFI_ERROR_CODE (13)
  527. #define GRUB_EFI_NOT_FOUND GRUB_EFI_ERROR_CODE (14)
  528. #define GRUB_EFI_ACCESS_DENIED GRUB_EFI_ERROR_CODE (15)
  529. #define GRUB_EFI_NO_RESPONSE GRUB_EFI_ERROR_CODE (16)
  530. #define GRUB_EFI_NO_MAPPING GRUB_EFI_ERROR_CODE (17)
  531. #define GRUB_EFI_TIMEOUT GRUB_EFI_ERROR_CODE (18)
  532. #define GRUB_EFI_NOT_STARTED GRUB_EFI_ERROR_CODE (19)
  533. #define GRUB_EFI_ALREADY_STARTED GRUB_EFI_ERROR_CODE (20)
  534. #define GRUB_EFI_ABORTED GRUB_EFI_ERROR_CODE (21)
  535. #define GRUB_EFI_ICMP_ERROR GRUB_EFI_ERROR_CODE (22)
  536. #define GRUB_EFI_TFTP_ERROR GRUB_EFI_ERROR_CODE (23)
  537. #define GRUB_EFI_PROTOCOL_ERROR GRUB_EFI_ERROR_CODE (24)
  538. #define GRUB_EFI_INCOMPATIBLE_VERSION GRUB_EFI_ERROR_CODE (25)
  539. #define GRUB_EFI_SECURITY_VIOLATION GRUB_EFI_ERROR_CODE (26)
  540. #define GRUB_EFI_CRC_ERROR GRUB_EFI_ERROR_CODE (27)
  541. #define GRUB_EFI_WARN_UNKNOWN_GLYPH GRUB_EFI_WARNING_CODE (1)
  542. #define GRUB_EFI_WARN_DELETE_FAILURE GRUB_EFI_WARNING_CODE (2)
  543. #define GRUB_EFI_WARN_WRITE_FAILURE GRUB_EFI_WARNING_CODE (3)
  544. #define GRUB_EFI_WARN_BUFFER_TOO_SMALL GRUB_EFI_WARNING_CODE (4)
  545. typedef void *grub_efi_handle_t;
  546. typedef void *grub_efi_event_t;
  547. typedef grub_efi_uint64_t grub_efi_lba_t;
  548. typedef grub_efi_uintn_t grub_efi_tpl_t;
  549. typedef grub_uint8_t grub_efi_mac_address_t[32];
  550. typedef grub_uint8_t grub_efi_ipv4_address_t[4];
  551. typedef grub_uint16_t grub_efi_ipv6_address_t[8];
  552. typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4)));
  553. typedef grub_efi_uint64_t grub_efi_physical_address_t;
  554. typedef grub_efi_uint64_t grub_efi_virtual_address_t;
  555. /* XXX although the spec does not specify the padding, this actually
  556. must have the padding! */
  557. struct grub_efi_memory_descriptor
  558. {
  559. grub_efi_uint32_t type;
  560. grub_efi_uint32_t padding;
  561. grub_efi_physical_address_t physical_start;
  562. grub_efi_virtual_address_t virtual_start;
  563. grub_efi_uint64_t num_pages;
  564. grub_efi_uint64_t attribute;
  565. } GRUB_PACKED;
  566. typedef struct grub_efi_memory_descriptor grub_efi_memory_descriptor_t;
  567. /* Device Path definitions. */
  568. struct grub_efi_device_path
  569. {
  570. grub_efi_uint8_t type;
  571. grub_efi_uint8_t subtype;
  572. grub_efi_uint16_t length;
  573. } GRUB_PACKED;
  574. typedef struct grub_efi_device_path grub_efi_device_path_t;
  575. /* XXX EFI does not define EFI_DEVICE_PATH_PROTOCOL but uses it.
  576. It seems to be identical to EFI_DEVICE_PATH. */
  577. typedef struct grub_efi_device_path grub_efi_device_path_protocol_t;
  578. #define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f)
  579. #define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype)
  580. #define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length)
  581. #define GRUB_EFI_DEVICE_PATH_VALID(dp) ((dp) != NULL && GRUB_EFI_DEVICE_PATH_LENGTH (dp) >= 4)
  582. /* The End of Device Path nodes. */
  583. #define GRUB_EFI_END_DEVICE_PATH_TYPE (0xff & 0x7f)
  584. #define GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff
  585. #define GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE 0x01
  586. #define GRUB_EFI_END_ENTIRE_DEVICE_PATH(dp) \
  587. (!GRUB_EFI_DEVICE_PATH_VALID (dp) || \
  588. (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \
  589. && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \
  590. == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)))
  591. #define GRUB_EFI_NEXT_DEVICE_PATH(dp) \
  592. (GRUB_EFI_DEVICE_PATH_VALID (dp) \
  593. ? ((grub_efi_device_path_t *) \
  594. ((char *) (dp) + GRUB_EFI_DEVICE_PATH_LENGTH (dp))) \
  595. : NULL)
  596. /* Hardware Device Path. */
  597. #define GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE 1
  598. #define GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE 1
  599. struct grub_efi_pci_device_path
  600. {
  601. grub_efi_device_path_t header;
  602. grub_efi_uint8_t function;
  603. grub_efi_uint8_t device;
  604. } GRUB_PACKED;
  605. typedef struct grub_efi_pci_device_path grub_efi_pci_device_path_t;
  606. #define GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE 2
  607. struct grub_efi_pccard_device_path
  608. {
  609. grub_efi_device_path_t header;
  610. grub_efi_uint8_t function;
  611. } GRUB_PACKED;
  612. typedef struct grub_efi_pccard_device_path grub_efi_pccard_device_path_t;
  613. #define GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE 3
  614. struct grub_efi_memory_mapped_device_path
  615. {
  616. grub_efi_device_path_t header;
  617. grub_efi_uint32_t memory_type;
  618. grub_efi_physical_address_t start_address;
  619. grub_efi_physical_address_t end_address;
  620. } GRUB_PACKED;
  621. typedef struct grub_efi_memory_mapped_device_path grub_efi_memory_mapped_device_path_t;
  622. #define GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE 4
  623. struct grub_efi_vendor_device_path
  624. {
  625. grub_efi_device_path_t header;
  626. grub_packed_guid_t vendor_guid;
  627. grub_efi_uint8_t vendor_defined_data[0];
  628. } GRUB_PACKED;
  629. typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;
  630. #define GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE 5
  631. struct grub_efi_controller_device_path
  632. {
  633. grub_efi_device_path_t header;
  634. grub_efi_uint32_t controller_number;
  635. } GRUB_PACKED;
  636. typedef struct grub_efi_controller_device_path grub_efi_controller_device_path_t;
  637. /* ACPI Device Path. */
  638. #define GRUB_EFI_ACPI_DEVICE_PATH_TYPE 2
  639. #define GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE 1
  640. struct grub_efi_acpi_device_path
  641. {
  642. grub_efi_device_path_t header;
  643. grub_efi_uint32_t hid;
  644. grub_efi_uint32_t uid;
  645. } GRUB_PACKED;
  646. typedef struct grub_efi_acpi_device_path grub_efi_acpi_device_path_t;
  647. #define GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE 2
  648. struct grub_efi_expanded_acpi_device_path
  649. {
  650. grub_efi_device_path_t header;
  651. grub_efi_uint32_t hid;
  652. grub_efi_uint32_t uid;
  653. grub_efi_uint32_t cid;
  654. char hidstr[0];
  655. } GRUB_PACKED;
  656. typedef struct grub_efi_expanded_acpi_device_path grub_efi_expanded_acpi_device_path_t;
  657. #define GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \
  658. (((grub_efi_expanded_acpi_device_path_t *) dp)->hidstr)
  659. #define GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \
  660. (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \
  661. + grub_strlen (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp)) + 1)
  662. #define GRUB_EFI_EXPANDED_ACPI_CIDSTR(dp) \
  663. (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \
  664. + grub_strlen (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp)) + 1)
  665. /* Messaging Device Path. */
  666. #define GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE 3
  667. #define GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE 1
  668. struct grub_efi_atapi_device_path
  669. {
  670. grub_efi_device_path_t header;
  671. grub_efi_uint8_t primary_secondary;
  672. grub_efi_uint8_t slave_master;
  673. grub_efi_uint16_t lun;
  674. } GRUB_PACKED;
  675. typedef struct grub_efi_atapi_device_path grub_efi_atapi_device_path_t;
  676. #define GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE 2
  677. struct grub_efi_scsi_device_path
  678. {
  679. grub_efi_device_path_t header;
  680. grub_efi_uint16_t pun;
  681. grub_efi_uint16_t lun;
  682. } GRUB_PACKED;
  683. typedef struct grub_efi_scsi_device_path grub_efi_scsi_device_path_t;
  684. #define GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE 3
  685. struct grub_efi_fibre_channel_device_path
  686. {
  687. grub_efi_device_path_t header;
  688. grub_efi_uint32_t reserved;
  689. grub_efi_uint64_t wwn;
  690. grub_efi_uint64_t lun;
  691. } GRUB_PACKED;
  692. typedef struct grub_efi_fibre_channel_device_path grub_efi_fibre_channel_device_path_t;
  693. #define GRUB_EFI_1394_DEVICE_PATH_SUBTYPE 4
  694. struct grub_efi_1394_device_path
  695. {
  696. grub_efi_device_path_t header;
  697. grub_efi_uint32_t reserved;
  698. grub_efi_uint64_t guid;
  699. } GRUB_PACKED;
  700. typedef struct grub_efi_1394_device_path grub_efi_1394_device_path_t;
  701. #define GRUB_EFI_USB_DEVICE_PATH_SUBTYPE 5
  702. struct grub_efi_usb_device_path
  703. {
  704. grub_efi_device_path_t header;
  705. grub_efi_uint8_t parent_port_number;
  706. grub_efi_uint8_t usb_interface;
  707. } GRUB_PACKED;
  708. typedef struct grub_efi_usb_device_path grub_efi_usb_device_path_t;
  709. #define GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE 15
  710. struct grub_efi_usb_class_device_path
  711. {
  712. grub_efi_device_path_t header;
  713. grub_efi_uint16_t vendor_id;
  714. grub_efi_uint16_t product_id;
  715. grub_efi_uint8_t device_class;
  716. grub_efi_uint8_t device_subclass;
  717. grub_efi_uint8_t device_protocol;
  718. } GRUB_PACKED;
  719. typedef struct grub_efi_usb_class_device_path grub_efi_usb_class_device_path_t;
  720. #define GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE 6
  721. struct grub_efi_i2o_device_path
  722. {
  723. grub_efi_device_path_t header;
  724. grub_efi_uint32_t tid;
  725. } GRUB_PACKED;
  726. typedef struct grub_efi_i2o_device_path grub_efi_i2o_device_path_t;
  727. #define GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE 11
  728. struct grub_efi_mac_address_device_path
  729. {
  730. grub_efi_device_path_t header;
  731. grub_efi_mac_address_t mac_address;
  732. grub_efi_uint8_t if_type;
  733. } GRUB_PACKED;
  734. typedef struct grub_efi_mac_address_device_path grub_efi_mac_address_device_path_t;
  735. #define GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE 12
  736. struct grub_efi_ipv4_device_path
  737. {
  738. grub_efi_device_path_t header;
  739. grub_efi_ipv4_address_t local_ip_address;
  740. grub_efi_ipv4_address_t remote_ip_address;
  741. grub_efi_uint16_t local_port;
  742. grub_efi_uint16_t remote_port;
  743. grub_efi_uint16_t protocol;
  744. grub_efi_uint8_t static_ip_address;
  745. } GRUB_PACKED;
  746. typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t;
  747. #define GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE 13
  748. struct grub_efi_ipv6_device_path
  749. {
  750. grub_efi_device_path_t header;
  751. grub_efi_ipv6_address_t local_ip_address;
  752. grub_efi_ipv6_address_t remote_ip_address;
  753. grub_efi_uint16_t local_port;
  754. grub_efi_uint16_t remote_port;
  755. grub_efi_uint16_t protocol;
  756. grub_efi_uint8_t static_ip_address;
  757. } GRUB_PACKED;
  758. typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t;
  759. #define GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE 9
  760. struct grub_efi_infiniband_device_path
  761. {
  762. grub_efi_device_path_t header;
  763. grub_efi_uint32_t resource_flags;
  764. grub_efi_uint8_t port_gid[16];
  765. grub_efi_uint64_t remote_id;
  766. grub_efi_uint64_t target_port_id;
  767. grub_efi_uint64_t device_id;
  768. } GRUB_PACKED;
  769. typedef struct grub_efi_infiniband_device_path grub_efi_infiniband_device_path_t;
  770. #define GRUB_EFI_UART_DEVICE_PATH_SUBTYPE 14
  771. struct grub_efi_uart_device_path
  772. {
  773. grub_efi_device_path_t header;
  774. grub_efi_uint32_t reserved;
  775. grub_efi_uint64_t baud_rate;
  776. grub_efi_uint8_t data_bits;
  777. grub_efi_uint8_t parity;
  778. grub_efi_uint8_t stop_bits;
  779. } GRUB_PACKED;
  780. typedef struct grub_efi_uart_device_path grub_efi_uart_device_path_t;
  781. #define GRUB_EFI_SATA_DEVICE_PATH_SUBTYPE 18
  782. struct grub_efi_sata_device_path
  783. {
  784. grub_efi_device_path_t header;
  785. grub_efi_uint16_t hba_port;
  786. grub_efi_uint16_t multiplier_port;
  787. grub_efi_uint16_t lun;
  788. } GRUB_PACKED;
  789. typedef struct grub_efi_sata_device_path grub_efi_sata_device_path_t;
  790. #define GRUB_EFI_VLAN_DEVICE_PATH_SUBTYPE 20
  791. struct grub_efi_vlan_device_path
  792. {
  793. grub_efi_device_path_t header;
  794. grub_efi_uint16_t vlan_id;
  795. } GRUB_PACKED;
  796. typedef struct grub_efi_vlan_device_path grub_efi_vlan_device_path_t;
  797. #define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
  798. /* Media Device Path. */
  799. #define GRUB_EFI_MEDIA_DEVICE_PATH_TYPE 4
  800. #define GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE 1
  801. struct grub_efi_hard_drive_device_path
  802. {
  803. grub_efi_device_path_t header;
  804. grub_efi_uint32_t partition_number;
  805. grub_efi_lba_t partition_start;
  806. grub_efi_lba_t partition_size;
  807. grub_efi_uint8_t partition_signature[16];
  808. grub_efi_uint8_t partmap_type;
  809. grub_efi_uint8_t signature_type;
  810. } GRUB_PACKED;
  811. typedef struct grub_efi_hard_drive_device_path grub_efi_hard_drive_device_path_t;
  812. #define GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE 2
  813. struct grub_efi_cdrom_device_path
  814. {
  815. grub_efi_device_path_t header;
  816. grub_efi_uint32_t boot_entry;
  817. grub_efi_lba_t partition_start;
  818. grub_efi_lba_t partition_size;
  819. } GRUB_PACKED;
  820. typedef struct grub_efi_cdrom_device_path grub_efi_cdrom_device_path_t;
  821. #define GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE 3
  822. struct grub_efi_vendor_media_device_path
  823. {
  824. grub_efi_device_path_t header;
  825. grub_packed_guid_t vendor_guid;
  826. grub_efi_uint8_t vendor_defined_data[0];
  827. } GRUB_PACKED;
  828. typedef struct grub_efi_vendor_media_device_path grub_efi_vendor_media_device_path_t;
  829. #define GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE 4
  830. struct grub_efi_file_path_device_path
  831. {
  832. grub_efi_device_path_t header;
  833. grub_efi_char16_t path_name[0];
  834. } GRUB_PACKED;
  835. typedef struct grub_efi_file_path_device_path grub_efi_file_path_device_path_t;
  836. #define GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE 5
  837. struct grub_efi_protocol_device_path
  838. {
  839. grub_efi_device_path_t header;
  840. grub_packed_guid_t guid;
  841. } GRUB_PACKED;
  842. typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
  843. #define GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE 6
  844. struct grub_efi_piwg_device_path
  845. {
  846. grub_efi_device_path_t header;
  847. grub_packed_guid_t guid;
  848. } GRUB_PACKED;
  849. typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t;
  850. /* BIOS Boot Specification Device Path. */
  851. #define GRUB_EFI_BIOS_DEVICE_PATH_TYPE 5
  852. #define GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE 1
  853. struct grub_efi_bios_device_path
  854. {
  855. grub_efi_device_path_t header;
  856. grub_efi_uint16_t device_type;
  857. grub_efi_uint16_t status_flags;
  858. char description[0];
  859. } GRUB_PACKED;
  860. typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t;
  861. struct grub_efi_open_protocol_information_entry
  862. {
  863. grub_efi_handle_t agent_handle;
  864. grub_efi_handle_t controller_handle;
  865. grub_efi_uint32_t attributes;
  866. grub_efi_uint32_t open_count;
  867. };
  868. typedef struct grub_efi_open_protocol_information_entry grub_efi_open_protocol_information_entry_t;
  869. struct grub_efi_time
  870. {
  871. grub_efi_uint16_t year;
  872. grub_efi_uint8_t month;
  873. grub_efi_uint8_t day;
  874. grub_efi_uint8_t hour;
  875. grub_efi_uint8_t minute;
  876. grub_efi_uint8_t second;
  877. grub_efi_uint8_t pad1;
  878. grub_efi_uint32_t nanosecond;
  879. grub_efi_int16_t time_zone;
  880. grub_efi_uint8_t daylight;
  881. grub_efi_uint8_t pad2;
  882. } GRUB_PACKED;
  883. typedef struct grub_efi_time grub_efi_time_t;
  884. struct grub_efi_time_capabilities
  885. {
  886. grub_efi_uint32_t resolution;
  887. grub_efi_uint32_t accuracy;
  888. grub_efi_boolean_t sets_to_zero;
  889. };
  890. typedef struct grub_efi_time_capabilities grub_efi_time_capabilities_t;
  891. struct grub_efi_input_key
  892. {
  893. grub_efi_uint16_t scan_code;
  894. grub_efi_char16_t unicode_char;
  895. };
  896. typedef struct grub_efi_input_key grub_efi_input_key_t;
  897. typedef grub_efi_uint8_t grub_efi_key_toggle_state_t;
  898. struct grub_efi_key_state
  899. {
  900. grub_efi_uint32_t key_shift_state;
  901. grub_efi_key_toggle_state_t key_toggle_state;
  902. };
  903. typedef struct grub_efi_key_state grub_efi_key_state_t;
  904. #define GRUB_EFI_SHIFT_STATE_VALID 0x80000000
  905. #define GRUB_EFI_RIGHT_SHIFT_PRESSED 0x00000001
  906. #define GRUB_EFI_LEFT_SHIFT_PRESSED 0x00000002
  907. #define GRUB_EFI_RIGHT_CONTROL_PRESSED 0x00000004
  908. #define GRUB_EFI_LEFT_CONTROL_PRESSED 0x00000008
  909. #define GRUB_EFI_RIGHT_ALT_PRESSED 0x00000010
  910. #define GRUB_EFI_LEFT_ALT_PRESSED 0x00000020
  911. #define GRUB_EFI_RIGHT_LOGO_PRESSED 0x00000040
  912. #define GRUB_EFI_LEFT_LOGO_PRESSED 0x00000080
  913. #define GRUB_EFI_MENU_KEY_PRESSED 0x00000100
  914. #define GRUB_EFI_SYS_REQ_PRESSED 0x00000200
  915. #define GRUB_EFI_TOGGLE_STATE_VALID 0x80
  916. #define GRUB_EFI_KEY_STATE_EXPOSED 0x40
  917. #define GRUB_EFI_SCROLL_LOCK_ACTIVE 0x01
  918. #define GRUB_EFI_NUM_LOCK_ACTIVE 0x02
  919. #define GRUB_EFI_CAPS_LOCK_ACTIVE 0x04
  920. struct grub_efi_simple_text_output_mode
  921. {
  922. grub_efi_int32_t max_mode;
  923. grub_efi_int32_t mode;
  924. grub_efi_int32_t attribute;
  925. grub_efi_int32_t cursor_column;
  926. grub_efi_int32_t cursor_row;
  927. grub_efi_boolean_t cursor_visible;
  928. };
  929. typedef struct grub_efi_simple_text_output_mode grub_efi_simple_text_output_mode_t;
  930. /* Tables. */
  931. struct grub_efi_table_header
  932. {
  933. grub_efi_uint64_t signature;
  934. grub_efi_uint32_t revision;
  935. grub_efi_uint32_t header_size;
  936. grub_efi_uint32_t crc32;
  937. grub_efi_uint32_t reserved;
  938. };
  939. typedef struct grub_efi_table_header grub_efi_table_header_t;
  940. struct grub_efi_boot_services
  941. {
  942. grub_efi_table_header_t hdr;
  943. grub_efi_tpl_t
  944. (__grub_efi_api *raise_tpl) (grub_efi_tpl_t new_tpl);
  945. void
  946. (__grub_efi_api *restore_tpl) (grub_efi_tpl_t old_tpl);
  947. grub_efi_status_t
  948. (__grub_efi_api *allocate_pages) (grub_efi_allocate_type_t type,
  949. grub_efi_memory_type_t memory_type,
  950. grub_efi_uintn_t pages,
  951. grub_efi_physical_address_t *memory);
  952. grub_efi_status_t
  953. (__grub_efi_api *free_pages) (grub_efi_physical_address_t memory,
  954. grub_efi_uintn_t pages);
  955. grub_efi_status_t
  956. (__grub_efi_api *get_memory_map) (grub_efi_uintn_t *memory_map_size,
  957. grub_efi_memory_descriptor_t *memory_map,
  958. grub_efi_uintn_t *map_key,
  959. grub_efi_uintn_t *descriptor_size,
  960. grub_efi_uint32_t *descriptor_version);
  961. grub_efi_status_t
  962. (__grub_efi_api *allocate_pool) (grub_efi_memory_type_t pool_type,
  963. grub_efi_uintn_t size,
  964. void **buffer);
  965. grub_efi_status_t
  966. (__grub_efi_api *free_pool) (void *buffer);
  967. grub_efi_status_t
  968. (__grub_efi_api *create_event) (grub_efi_uint32_t type,
  969. grub_efi_tpl_t notify_tpl,
  970. void (__grub_efi_api *notify_function) (grub_efi_event_t,
  971. void *context),
  972. void *notify_context,
  973. grub_efi_event_t *event);
  974. grub_efi_status_t
  975. (__grub_efi_api *set_timer) (grub_efi_event_t event,
  976. grub_efi_timer_delay_t type,
  977. grub_efi_uint64_t trigger_time);
  978. grub_efi_status_t
  979. (__grub_efi_api *wait_for_event) (grub_efi_uintn_t num_events,
  980. grub_efi_event_t *event,
  981. grub_efi_uintn_t *index);
  982. grub_efi_status_t
  983. (__grub_efi_api *signal_event) (grub_efi_event_t event);
  984. grub_efi_status_t
  985. (__grub_efi_api *close_event) (grub_efi_event_t event);
  986. grub_efi_status_t
  987. (__grub_efi_api *check_event) (grub_efi_event_t event);
  988. grub_efi_status_t
  989. (__grub_efi_api *install_protocol_interface) (grub_efi_handle_t *handle,
  990. grub_guid_t *protocol,
  991. grub_efi_interface_type_t protocol_interface_type,
  992. void *protocol_interface);
  993. grub_efi_status_t
  994. (__grub_efi_api *reinstall_protocol_interface) (grub_efi_handle_t handle,
  995. grub_guid_t *protocol,
  996. void *old_interface,
  997. void *new_interface);
  998. grub_efi_status_t
  999. (__grub_efi_api *uninstall_protocol_interface) (grub_efi_handle_t handle,
  1000. grub_guid_t *protocol,
  1001. void *protocol_interface);
  1002. grub_efi_status_t
  1003. (__grub_efi_api *handle_protocol) (grub_efi_handle_t handle,
  1004. grub_guid_t *protocol,
  1005. void **protocol_interface);
  1006. void *reserved;
  1007. grub_efi_status_t
  1008. (__grub_efi_api *register_protocol_notify) (grub_guid_t *protocol,
  1009. grub_efi_event_t event,
  1010. void **registration);
  1011. grub_efi_status_t
  1012. (__grub_efi_api *locate_handle) (grub_efi_locate_search_type_t search_type,
  1013. grub_guid_t *protocol,
  1014. void *search_key,
  1015. grub_efi_uintn_t *buffer_size,
  1016. grub_efi_handle_t *buffer);
  1017. grub_efi_status_t
  1018. (__grub_efi_api *locate_device_path) (grub_guid_t *protocol,
  1019. grub_efi_device_path_t **device_path,
  1020. grub_efi_handle_t *device);
  1021. grub_efi_status_t
  1022. (__grub_efi_api *install_configuration_table) (grub_guid_t *guid,
  1023. void *table);
  1024. grub_efi_status_t
  1025. (__grub_efi_api *load_image) (grub_efi_boolean_t boot_policy,
  1026. grub_efi_handle_t parent_image_handle,
  1027. grub_efi_device_path_t *file_path,
  1028. void *source_buffer,
  1029. grub_efi_uintn_t source_size,
  1030. grub_efi_handle_t *image_handle);
  1031. grub_efi_status_t
  1032. (__grub_efi_api *start_image) (grub_efi_handle_t image_handle,
  1033. grub_efi_uintn_t *exit_data_size,
  1034. grub_efi_char16_t **exit_data);
  1035. grub_efi_status_t
  1036. (__grub_efi_api *exit) (grub_efi_handle_t image_handle,
  1037. grub_efi_status_t exit_status,
  1038. grub_efi_uintn_t exit_data_size,
  1039. grub_efi_char16_t *exit_data);
  1040. grub_efi_status_t
  1041. (__grub_efi_api *unload_image) (grub_efi_handle_t image_handle);
  1042. grub_efi_status_t
  1043. (__grub_efi_api *exit_boot_services) (grub_efi_handle_t image_handle,
  1044. grub_efi_uintn_t map_key);
  1045. grub_efi_status_t
  1046. (__grub_efi_api *get_next_monotonic_count) (grub_efi_uint64_t *count);
  1047. grub_efi_status_t
  1048. (__grub_efi_api *stall) (grub_efi_uintn_t microseconds);
  1049. grub_efi_status_t
  1050. (__grub_efi_api *set_watchdog_timer) (grub_efi_uintn_t timeout,
  1051. grub_efi_uint64_t watchdog_code,
  1052. grub_efi_uintn_t data_size,
  1053. grub_efi_char16_t *watchdog_data);
  1054. grub_efi_status_t
  1055. (__grub_efi_api *connect_controller) (grub_efi_handle_t controller_handle,
  1056. grub_efi_handle_t *driver_image_handle,
  1057. grub_efi_device_path_protocol_t *remaining_device_path,
  1058. grub_efi_boolean_t recursive);
  1059. grub_efi_status_t
  1060. (__grub_efi_api *disconnect_controller) (grub_efi_handle_t controller_handle,
  1061. grub_efi_handle_t driver_image_handle,
  1062. grub_efi_handle_t child_handle);
  1063. grub_efi_status_t
  1064. (__grub_efi_api *open_protocol) (grub_efi_handle_t handle,
  1065. grub_guid_t *protocol,
  1066. void **protocol_interface,
  1067. grub_efi_handle_t agent_handle,
  1068. grub_efi_handle_t controller_handle,
  1069. grub_efi_uint32_t attributes);
  1070. grub_efi_status_t
  1071. (__grub_efi_api *close_protocol) (grub_efi_handle_t handle,
  1072. grub_guid_t *protocol,
  1073. grub_efi_handle_t agent_handle,
  1074. grub_efi_handle_t controller_handle);
  1075. grub_efi_status_t
  1076. (__grub_efi_api *open_protocol_information) (grub_efi_handle_t handle,
  1077. grub_guid_t *protocol,
  1078. grub_efi_open_protocol_information_entry_t **entry_buffer,
  1079. grub_efi_uintn_t *entry_count);
  1080. grub_efi_status_t
  1081. (__grub_efi_api *protocols_per_handle) (grub_efi_handle_t handle,
  1082. grub_packed_guid_t ***protocol_buffer,
  1083. grub_efi_uintn_t *protocol_buffer_count);
  1084. grub_efi_status_t
  1085. (__grub_efi_api *locate_handle_buffer) (grub_efi_locate_search_type_t search_type,
  1086. grub_guid_t *protocol,
  1087. void *search_key,
  1088. grub_efi_uintn_t *no_handles,
  1089. grub_efi_handle_t **buffer);
  1090. grub_efi_status_t
  1091. (__grub_efi_api *locate_protocol) (grub_guid_t *protocol,
  1092. void *registration,
  1093. void **protocol_interface);
  1094. grub_efi_status_t
  1095. (__grub_efi_api *install_multiple_protocol_interfaces) (grub_efi_handle_t *handle, ...);
  1096. grub_efi_status_t
  1097. (__grub_efi_api *uninstall_multiple_protocol_interfaces) (grub_efi_handle_t handle, ...);
  1098. grub_efi_status_t
  1099. (__grub_efi_api *calculate_crc32) (void *data,
  1100. grub_efi_uintn_t data_size,
  1101. grub_efi_uint32_t *crc32);
  1102. void
  1103. (__grub_efi_api *copy_mem) (void *destination, void *source, grub_efi_uintn_t length);
  1104. void
  1105. (__grub_efi_api *set_mem) (void *buffer, grub_efi_uintn_t size, grub_efi_uint8_t value);
  1106. };
  1107. typedef struct grub_efi_boot_services grub_efi_boot_services_t;
  1108. struct grub_efi_runtime_services
  1109. {
  1110. grub_efi_table_header_t hdr;
  1111. grub_efi_status_t
  1112. (__grub_efi_api *get_time) (grub_efi_time_t *time,
  1113. grub_efi_time_capabilities_t *capabilities);
  1114. grub_efi_status_t
  1115. (__grub_efi_api *set_time) (grub_efi_time_t *time);
  1116. grub_efi_status_t
  1117. (__grub_efi_api *get_wakeup_time) (grub_efi_boolean_t *enabled,
  1118. grub_efi_boolean_t *pending,
  1119. grub_efi_time_t *time);
  1120. grub_efi_status_t
  1121. (__grub_efi_api *set_wakeup_time) (grub_efi_boolean_t enabled,
  1122. grub_efi_time_t *time);
  1123. grub_efi_status_t
  1124. (__grub_efi_api *set_virtual_address_map) (grub_efi_uintn_t memory_map_size,
  1125. grub_efi_uintn_t descriptor_size,
  1126. grub_efi_uint32_t descriptor_version,
  1127. grub_efi_memory_descriptor_t *virtual_map);
  1128. grub_efi_status_t
  1129. (__grub_efi_api *convert_pointer) (grub_efi_uintn_t debug_disposition, void **address);
  1130. #define GRUB_EFI_GLOBAL_VARIABLE_GUID \
  1131. { 0x8BE4DF61, 0x93CA, 0x11d2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }}
  1132. grub_efi_status_t
  1133. (__grub_efi_api *get_variable) (grub_efi_char16_t *variable_name,
  1134. const grub_guid_t *vendor_guid,
  1135. grub_efi_uint32_t *attributes,
  1136. grub_efi_uintn_t *data_size,
  1137. void *data);
  1138. grub_efi_status_t
  1139. (__grub_efi_api *get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
  1140. grub_efi_char16_t *variable_name,
  1141. grub_guid_t *vendor_guid);
  1142. grub_efi_status_t
  1143. (__grub_efi_api *set_variable) (grub_efi_char16_t *variable_name,
  1144. const grub_guid_t *vendor_guid,
  1145. grub_efi_uint32_t attributes,
  1146. grub_efi_uintn_t data_size,
  1147. void *data);
  1148. grub_efi_status_t
  1149. (__grub_efi_api *get_next_high_monotonic_count) (grub_efi_uint32_t *high_count);
  1150. void
  1151. (__grub_efi_api *reset_system) (grub_efi_reset_type_t reset_type,
  1152. grub_efi_status_t reset_status,
  1153. grub_efi_uintn_t data_size,
  1154. grub_efi_char16_t *reset_data);
  1155. };
  1156. typedef struct grub_efi_runtime_services grub_efi_runtime_services_t;
  1157. struct grub_efi_configuration_table
  1158. {
  1159. grub_packed_guid_t vendor_guid;
  1160. void *vendor_table;
  1161. } GRUB_PACKED;
  1162. typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
  1163. #define GRUB_EFIEMU_SYSTEM_TABLE_SIGNATURE 0x5453595320494249LL
  1164. #define GRUB_EFIEMU_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552LL
  1165. struct grub_efi_serial_io_interface
  1166. {
  1167. grub_efi_uint32_t revision;
  1168. void (*reset) (void);
  1169. grub_efi_status_t
  1170. (__grub_efi_api *set_attributes) (struct grub_efi_serial_io_interface *this,
  1171. grub_efi_uint64_t speed,
  1172. grub_efi_uint32_t fifo_depth,
  1173. grub_efi_uint32_t timeout,
  1174. grub_efi_parity_type_t parity,
  1175. grub_uint8_t word_len,
  1176. grub_efi_stop_bits_t stop_bits);
  1177. grub_efi_status_t
  1178. (__grub_efi_api *set_control_bits) (struct grub_efi_serial_io_interface *this,
  1179. grub_efi_uint32_t flags);
  1180. void (__grub_efi_api *get_control_bits) (void);
  1181. grub_efi_status_t
  1182. (__grub_efi_api *write) (struct grub_efi_serial_io_interface *this,
  1183. grub_efi_uintn_t *buf_size,
  1184. void *buffer);
  1185. grub_efi_status_t
  1186. (__grub_efi_api *read) (struct grub_efi_serial_io_interface *this,
  1187. grub_efi_uintn_t *buf_size,
  1188. void *buffer);
  1189. };
  1190. struct grub_efi_simple_input_interface
  1191. {
  1192. grub_efi_status_t
  1193. (__grub_efi_api *reset) (struct grub_efi_simple_input_interface *this,
  1194. grub_efi_boolean_t extended_verification);
  1195. grub_efi_status_t
  1196. (__grub_efi_api *read_key_stroke) (struct grub_efi_simple_input_interface *this,
  1197. grub_efi_input_key_t *key);
  1198. grub_efi_event_t wait_for_key;
  1199. };
  1200. typedef struct grub_efi_simple_input_interface grub_efi_simple_input_interface_t;
  1201. struct grub_efi_key_data {
  1202. grub_efi_input_key_t key;
  1203. grub_efi_key_state_t key_state;
  1204. };
  1205. typedef struct grub_efi_key_data grub_efi_key_data_t;
  1206. typedef grub_efi_status_t (__grub_efi_api *grub_efi_key_notify_function_t) (
  1207. grub_efi_key_data_t *key_data
  1208. );
  1209. struct grub_efi_simple_text_input_ex_interface
  1210. {
  1211. grub_efi_status_t
  1212. (__grub_efi_api *reset) (struct grub_efi_simple_text_input_ex_interface *this,
  1213. grub_efi_boolean_t extended_verification);
  1214. grub_efi_status_t
  1215. (__grub_efi_api *read_key_stroke) (struct grub_efi_simple_text_input_ex_interface *this,
  1216. grub_efi_key_data_t *key_data);
  1217. grub_efi_event_t wait_for_key;
  1218. grub_efi_status_t
  1219. (__grub_efi_api *set_state) (struct grub_efi_simple_text_input_ex_interface *this,
  1220. grub_efi_key_toggle_state_t *key_toggle_state);
  1221. grub_efi_status_t
  1222. (__grub_efi_api *register_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
  1223. grub_efi_key_data_t *key_data,
  1224. grub_efi_key_notify_function_t key_notification_function,
  1225. void **notify_handle);
  1226. grub_efi_status_t
  1227. (__grub_efi_api *unregister_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
  1228. void *notification_handle);
  1229. };
  1230. typedef struct grub_efi_simple_text_input_ex_interface grub_efi_simple_text_input_ex_interface_t;
  1231. struct grub_efi_simple_text_output_interface
  1232. {
  1233. grub_efi_status_t
  1234. (__grub_efi_api *reset) (struct grub_efi_simple_text_output_interface *this,
  1235. grub_efi_boolean_t extended_verification);
  1236. grub_efi_status_t
  1237. (__grub_efi_api *output_string) (struct grub_efi_simple_text_output_interface *this,
  1238. grub_efi_char16_t *string);
  1239. grub_efi_status_t
  1240. (__grub_efi_api *test_string) (struct grub_efi_simple_text_output_interface *this,
  1241. grub_efi_char16_t *string);
  1242. grub_efi_status_t
  1243. (__grub_efi_api *query_mode) (struct grub_efi_simple_text_output_interface *this,
  1244. grub_efi_uintn_t mode_number,
  1245. grub_efi_uintn_t *columns,
  1246. grub_efi_uintn_t *rows);
  1247. grub_efi_status_t
  1248. (__grub_efi_api *set_mode) (struct grub_efi_simple_text_output_interface *this,
  1249. grub_efi_uintn_t mode_number);
  1250. grub_efi_status_t
  1251. (__grub_efi_api *set_attributes) (struct grub_efi_simple_text_output_interface *this,
  1252. grub_efi_uintn_t attribute);
  1253. grub_efi_status_t
  1254. (__grub_efi_api *clear_screen) (struct grub_efi_simple_text_output_interface *this);
  1255. grub_efi_status_t
  1256. (__grub_efi_api *set_cursor_position) (struct grub_efi_simple_text_output_interface *this,
  1257. grub_efi_uintn_t column,
  1258. grub_efi_uintn_t row);
  1259. grub_efi_status_t
  1260. (__grub_efi_api *enable_cursor) (struct grub_efi_simple_text_output_interface *this,
  1261. grub_efi_boolean_t visible);
  1262. grub_efi_simple_text_output_mode_t *mode;
  1263. };
  1264. typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t;
  1265. typedef grub_uint8_t grub_efi_pxe_packet_t[1472];
  1266. typedef struct grub_efi_pxe_mode
  1267. {
  1268. grub_uint8_t unused[52];
  1269. grub_efi_pxe_packet_t dhcp_discover;
  1270. grub_efi_pxe_packet_t dhcp_ack;
  1271. grub_efi_pxe_packet_t proxy_offer;
  1272. grub_efi_pxe_packet_t pxe_discover;
  1273. grub_efi_pxe_packet_t pxe_reply;
  1274. } grub_efi_pxe_mode_t;
  1275. typedef struct grub_efi_pxe
  1276. {
  1277. grub_uint64_t rev;
  1278. void *start;
  1279. void *stop;
  1280. void *dhcp;
  1281. void *discover;
  1282. void *mftp;
  1283. void *udpwrite;
  1284. void *udpread;
  1285. void *setipfilter;
  1286. void *arp;
  1287. void *setparams;
  1288. void *setstationip;
  1289. void *setpackets;
  1290. struct grub_efi_pxe_mode *mode;
  1291. } grub_efi_pxe_t;
  1292. #define GRUB_EFI_BLACK 0x00
  1293. #define GRUB_EFI_BLUE 0x01
  1294. #define GRUB_EFI_GREEN 0x02
  1295. #define GRUB_EFI_CYAN 0x03
  1296. #define GRUB_EFI_RED 0x04
  1297. #define GRUB_EFI_MAGENTA 0x05
  1298. #define GRUB_EFI_BROWN 0x06
  1299. #define GRUB_EFI_LIGHTGRAY 0x07
  1300. #define GRUB_EFI_BRIGHT 0x08
  1301. #define GRUB_EFI_DARKGRAY 0x08
  1302. #define GRUB_EFI_LIGHTBLUE 0x09
  1303. #define GRUB_EFI_LIGHTGREEN 0x0A
  1304. #define GRUB_EFI_LIGHTCYAN 0x0B
  1305. #define GRUB_EFI_LIGHTRED 0x0C
  1306. #define GRUB_EFI_LIGHTMAGENTA 0x0D
  1307. #define GRUB_EFI_YELLOW 0x0E
  1308. #define GRUB_EFI_WHITE 0x0F
  1309. #define GRUB_EFI_BACKGROUND_BLACK 0x00
  1310. #define GRUB_EFI_BACKGROUND_BLUE 0x10
  1311. #define GRUB_EFI_BACKGROUND_GREEN 0x20
  1312. #define GRUB_EFI_BACKGROUND_CYAN 0x30
  1313. #define GRUB_EFI_BACKGROUND_RED 0x40
  1314. #define GRUB_EFI_BACKGROUND_MAGENTA 0x50
  1315. #define GRUB_EFI_BACKGROUND_BROWN 0x60
  1316. #define GRUB_EFI_BACKGROUND_LIGHTGRAY 0x70
  1317. #define GRUB_EFI_TEXT_ATTR(fg, bg) ((fg) | ((bg)))
  1318. struct grub_efi_system_table
  1319. {
  1320. grub_efi_table_header_t hdr;
  1321. grub_efi_char16_t *firmware_vendor;
  1322. grub_efi_uint32_t firmware_revision;
  1323. grub_efi_handle_t console_in_handler;
  1324. grub_efi_simple_input_interface_t *con_in;
  1325. grub_efi_handle_t console_out_handler;
  1326. grub_efi_simple_text_output_interface_t *con_out;
  1327. grub_efi_handle_t standard_error_handle;
  1328. grub_efi_simple_text_output_interface_t *std_err;
  1329. grub_efi_runtime_services_t *runtime_services;
  1330. grub_efi_boot_services_t *boot_services;
  1331. grub_efi_uintn_t num_table_entries;
  1332. grub_efi_configuration_table_t *configuration_table;
  1333. };
  1334. typedef struct grub_efi_system_table grub_efi_system_table_t;
  1335. struct grub_efi_loaded_image
  1336. {
  1337. grub_efi_uint32_t revision;
  1338. grub_efi_handle_t parent_handle;
  1339. grub_efi_system_table_t *system_table;
  1340. grub_efi_handle_t device_handle;
  1341. grub_efi_device_path_t *file_path;
  1342. void *reserved;
  1343. grub_efi_uint32_t load_options_size;
  1344. void *load_options;
  1345. void *image_base;
  1346. grub_efi_uint64_t image_size;
  1347. grub_efi_memory_type_t image_code_type;
  1348. grub_efi_memory_type_t image_data_type;
  1349. grub_efi_status_t (__grub_efi_api *unload) (grub_efi_handle_t image_handle);
  1350. };
  1351. typedef struct grub_efi_loaded_image grub_efi_loaded_image_t;
  1352. struct grub_efi_disk_io
  1353. {
  1354. grub_efi_uint64_t revision;
  1355. grub_efi_status_t (__grub_efi_api *read) (struct grub_efi_disk_io *this,
  1356. grub_efi_uint32_t media_id,
  1357. grub_efi_uint64_t offset,
  1358. grub_efi_uintn_t buffer_size,
  1359. void *buffer);
  1360. grub_efi_status_t (__grub_efi_api *write) (struct grub_efi_disk_io *this,
  1361. grub_efi_uint32_t media_id,
  1362. grub_efi_uint64_t offset,
  1363. grub_efi_uintn_t buffer_size,
  1364. void *buffer);
  1365. };
  1366. typedef struct grub_efi_disk_io grub_efi_disk_io_t;
  1367. struct grub_efi_block_io_media
  1368. {
  1369. grub_efi_uint32_t media_id;
  1370. grub_efi_boolean_t removable_media;
  1371. grub_efi_boolean_t media_present;
  1372. grub_efi_boolean_t logical_partition;
  1373. grub_efi_boolean_t read_only;
  1374. grub_efi_boolean_t write_caching;
  1375. grub_efi_uint8_t pad[3];
  1376. grub_efi_uint32_t block_size;
  1377. grub_efi_uint32_t io_align;
  1378. grub_efi_uint8_t pad2[4];
  1379. grub_efi_lba_t last_block;
  1380. };
  1381. typedef struct grub_efi_block_io_media grub_efi_block_io_media_t;
  1382. typedef grub_uint8_t grub_efi_mac_t[32];
  1383. struct grub_efi_simple_network_mode
  1384. {
  1385. grub_uint32_t state;
  1386. grub_uint32_t hwaddr_size;
  1387. grub_uint32_t media_header_size;
  1388. grub_uint32_t max_packet_size;
  1389. grub_uint32_t nvram_size;
  1390. grub_uint32_t nvram_access_size;
  1391. grub_uint32_t receive_filter_mask;
  1392. grub_uint32_t receive_filter_setting;
  1393. grub_uint32_t max_mcast_filter_count;
  1394. grub_uint32_t mcast_filter_count;
  1395. grub_efi_mac_t mcast_filter[16];
  1396. grub_efi_mac_t current_address;
  1397. grub_efi_mac_t broadcast_address;
  1398. grub_efi_mac_t permanent_address;
  1399. grub_uint8_t if_type;
  1400. grub_uint8_t mac_changeable;
  1401. grub_uint8_t multitx_supported;
  1402. grub_uint8_t media_present_supported;
  1403. grub_uint8_t media_present;
  1404. };
  1405. enum
  1406. {
  1407. GRUB_EFI_NETWORK_STOPPED,
  1408. GRUB_EFI_NETWORK_STARTED,
  1409. GRUB_EFI_NETWORK_INITIALIZED,
  1410. };
  1411. enum
  1412. {
  1413. GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST = 0x01,
  1414. GRUB_EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST = 0x02,
  1415. GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST = 0x04,
  1416. GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS = 0x08,
  1417. GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST = 0x10,
  1418. };
  1419. struct grub_efi_simple_network
  1420. {
  1421. grub_uint64_t revision;
  1422. grub_efi_status_t
  1423. (__grub_efi_api *start) (struct grub_efi_simple_network *this);
  1424. grub_efi_status_t
  1425. (__grub_efi_api *stop) (struct grub_efi_simple_network *this);
  1426. grub_efi_status_t
  1427. (__grub_efi_api *initialize) (struct grub_efi_simple_network *this,
  1428. grub_efi_uintn_t extra_rx,
  1429. grub_efi_uintn_t extra_tx);
  1430. void (__grub_efi_api *reset) (void);
  1431. grub_efi_status_t
  1432. (__grub_efi_api *shutdown) (struct grub_efi_simple_network *this);
  1433. grub_efi_status_t
  1434. (__grub_efi_api *receive_filters) (struct grub_efi_simple_network *this,
  1435. grub_uint32_t enable,
  1436. grub_uint32_t disable,
  1437. grub_efi_boolean_t reset_mcast_filter,
  1438. grub_efi_uintn_t mcast_filter_count,
  1439. grub_efi_mac_address_t *mcast_filter);
  1440. void (__grub_efi_api *station_address) (void);
  1441. void (__grub_efi_api *statistics) (void);
  1442. void (__grub_efi_api *mcastiptomac) (void);
  1443. void (__grub_efi_api *nvdata) (void);
  1444. grub_efi_status_t
  1445. (__grub_efi_api *get_status) (struct grub_efi_simple_network *this,
  1446. grub_uint32_t *int_status,
  1447. void **txbuf);
  1448. grub_efi_status_t
  1449. (__grub_efi_api *transmit) (struct grub_efi_simple_network *this,
  1450. grub_efi_uintn_t header_size,
  1451. grub_efi_uintn_t buffer_size,
  1452. void *buffer,
  1453. grub_efi_mac_t *src_addr,
  1454. grub_efi_mac_t *dest_addr,
  1455. grub_efi_uint16_t *protocol);
  1456. grub_efi_status_t
  1457. (__grub_efi_api *receive) (struct grub_efi_simple_network *this,
  1458. grub_efi_uintn_t *header_size,
  1459. grub_efi_uintn_t *buffer_size,
  1460. void *buffer,
  1461. grub_efi_mac_t *src_addr,
  1462. grub_efi_mac_t *dest_addr,
  1463. grub_uint16_t *protocol);
  1464. void (__grub_efi_api *waitforpacket) (void);
  1465. struct grub_efi_simple_network_mode *mode;
  1466. };
  1467. typedef struct grub_efi_simple_network grub_efi_simple_network_t;
  1468. struct grub_efi_block_io
  1469. {
  1470. grub_efi_uint64_t revision;
  1471. grub_efi_block_io_media_t *media;
  1472. grub_efi_status_t (__grub_efi_api *reset) (struct grub_efi_block_io *this,
  1473. grub_efi_boolean_t extended_verification);
  1474. grub_efi_status_t (__grub_efi_api *read_blocks) (struct grub_efi_block_io *this,
  1475. grub_efi_uint32_t media_id,
  1476. grub_efi_lba_t lba,
  1477. grub_efi_uintn_t buffer_size,
  1478. void *buffer);
  1479. grub_efi_status_t (__grub_efi_api *write_blocks) (struct grub_efi_block_io *this,
  1480. grub_efi_uint32_t media_id,
  1481. grub_efi_lba_t lba,
  1482. grub_efi_uintn_t buffer_size,
  1483. void *buffer);
  1484. grub_efi_status_t (__grub_efi_api *flush_blocks) (struct grub_efi_block_io *this);
  1485. };
  1486. typedef struct grub_efi_block_io grub_efi_block_io_t;
  1487. struct grub_efi_shim_lock_protocol
  1488. {
  1489. /*
  1490. * verify() function (surprisingly) does not use specific EFI calling convention.
  1491. * So, it does not need to be tagged with __grub_efi_api attribute.
  1492. */
  1493. grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size);
  1494. };
  1495. typedef struct grub_efi_shim_lock_protocol grub_efi_shim_lock_protocol_t;
  1496. typedef grub_guid_t grub_efi_rng_algorithm_t;
  1497. struct grub_efi_rng_protocol
  1498. {
  1499. grub_efi_status_t (__grub_efi_api *get_info) (struct grub_efi_rng_protocol *this,
  1500. grub_efi_uintn_t *rng_algorithm_list_size,
  1501. grub_efi_rng_algorithm_t *rng_algorithm_list);
  1502. grub_efi_status_t (__grub_efi_api *get_rng) (struct grub_efi_rng_protocol *this,
  1503. grub_efi_rng_algorithm_t *rng_algorithm,
  1504. grub_efi_uintn_t rng_value_length,
  1505. grub_efi_uint8_t *rng_value);
  1506. };
  1507. typedef struct grub_efi_rng_protocol grub_efi_rng_protocol_t;
  1508. struct grub_efi_load_file2
  1509. {
  1510. grub_efi_status_t (__grub_efi_api *load_file)(struct grub_efi_load_file2 *this,
  1511. grub_efi_device_path_t *file_path,
  1512. grub_efi_boolean_t boot_policy,
  1513. grub_efi_uintn_t *buffer_size,
  1514. void *buffer);
  1515. };
  1516. typedef struct grub_efi_load_file2 grub_efi_load_file2_t;
  1517. struct initrd_media_device_path {
  1518. grub_efi_vendor_media_device_path_t vendor;
  1519. grub_efi_device_path_t end;
  1520. } GRUB_PACKED;
  1521. typedef struct initrd_media_device_path initrd_media_device_path_t;
  1522. struct grub_efi_memory_attribute_protocol
  1523. {
  1524. grub_efi_status_t (__grub_efi_api *get_memory_attributes) (
  1525. struct grub_efi_memory_attribute_protocol *this,
  1526. grub_efi_physical_address_t base_address,
  1527. grub_efi_uint64_t length,
  1528. grub_efi_uint64_t *attributes);
  1529. grub_efi_status_t (__grub_efi_api *set_memory_attributes) (
  1530. struct grub_efi_memory_attribute_protocol *this,
  1531. grub_efi_physical_address_t base_address,
  1532. grub_efi_uint64_t length,
  1533. grub_efi_uint64_t attributes);
  1534. grub_efi_status_t (__grub_efi_api *clear_memory_attributes) (
  1535. struct grub_efi_memory_attribute_protocol *this,
  1536. grub_efi_physical_address_t base_address,
  1537. grub_efi_uint64_t length,
  1538. grub_efi_uint64_t attributes);
  1539. };
  1540. typedef struct grub_efi_memory_attribute_protocol grub_efi_memory_attribute_protocol_t;
  1541. #endif /* ! GRUB_EFI_API_HEADER */