efi_api.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. /*
  2. * Extensible Firmware Interface
  3. * Based on 'Extensible Firmware Interface Specification' version 0.9,
  4. * April 30, 1999
  5. *
  6. * Copyright (C) 1999 VA Linux Systems
  7. * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
  8. * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
  9. * David Mosberger-Tang <davidm@hpl.hp.com>
  10. * Stephane Eranian <eranian@hpl.hp.com>
  11. *
  12. * From include/linux/efi.h in kernel 4.1 with some additions/subtractions
  13. */
  14. #ifndef _EFI_API_H
  15. #define _EFI_API_H
  16. #include <efi.h>
  17. #ifdef CONFIG_EFI_LOADER
  18. #include <asm/setjmp.h>
  19. #endif
  20. /* Types and defines for EFI CreateEvent */
  21. enum efi_timer_delay {
  22. EFI_TIMER_STOP = 0,
  23. EFI_TIMER_PERIODIC = 1,
  24. EFI_TIMER_RELATIVE = 2
  25. };
  26. #define efi_uintn_t size_t
  27. typedef uint16_t *efi_string_t;
  28. #define EVT_TIMER 0x80000000
  29. #define EVT_RUNTIME 0x40000000
  30. #define EVT_NOTIFY_WAIT 0x00000100
  31. #define EVT_NOTIFY_SIGNAL 0x00000200
  32. #define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
  33. #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
  34. #define TPL_APPLICATION 0x04
  35. #define TPL_CALLBACK 0x08
  36. #define TPL_NOTIFY 0x10
  37. #define TPL_HIGH_LEVEL 0x1F
  38. struct efi_event;
  39. /* EFI Boot Services table */
  40. struct efi_boot_services {
  41. struct efi_table_hdr hdr;
  42. efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl);
  43. void (EFIAPI *restore_tpl)(efi_uintn_t old_tpl);
  44. efi_status_t (EFIAPI *allocate_pages)(int, int, efi_uintn_t,
  45. efi_physical_addr_t *);
  46. efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, efi_uintn_t);
  47. efi_status_t (EFIAPI *get_memory_map)(efi_uintn_t *memory_map_size,
  48. struct efi_mem_desc *desc,
  49. efi_uintn_t *key,
  50. efi_uintn_t *desc_size,
  51. u32 *desc_version);
  52. efi_status_t (EFIAPI *allocate_pool)(int, efi_uintn_t, void **);
  53. efi_status_t (EFIAPI *free_pool)(void *);
  54. efi_status_t (EFIAPI *create_event)(uint32_t type,
  55. efi_uintn_t notify_tpl,
  56. void (EFIAPI *notify_function) (
  57. struct efi_event *event,
  58. void *context),
  59. void *notify_context, struct efi_event **event);
  60. efi_status_t (EFIAPI *set_timer)(struct efi_event *event,
  61. enum efi_timer_delay type,
  62. uint64_t trigger_time);
  63. efi_status_t (EFIAPI *wait_for_event)(efi_uintn_t number_of_events,
  64. struct efi_event **event,
  65. efi_uintn_t *index);
  66. efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
  67. efi_status_t (EFIAPI *close_event)(struct efi_event *event);
  68. efi_status_t (EFIAPI *check_event)(struct efi_event *event);
  69. #define EFI_NATIVE_INTERFACE 0x00000000
  70. efi_status_t (EFIAPI *install_protocol_interface)(
  71. void **handle, const efi_guid_t *protocol,
  72. int protocol_interface_type, void *protocol_interface);
  73. efi_status_t (EFIAPI *reinstall_protocol_interface)(
  74. void *handle, const efi_guid_t *protocol,
  75. void *old_interface, void *new_interface);
  76. efi_status_t (EFIAPI *uninstall_protocol_interface)(
  77. efi_handle_t handle, const efi_guid_t *protocol,
  78. void *protocol_interface);
  79. efi_status_t (EFIAPI *handle_protocol)(
  80. efi_handle_t handle, const efi_guid_t *protocol,
  81. void **protocol_interface);
  82. void *reserved;
  83. efi_status_t (EFIAPI *register_protocol_notify)(
  84. const efi_guid_t *protocol, struct efi_event *event,
  85. void **registration);
  86. efi_status_t (EFIAPI *locate_handle)(
  87. enum efi_locate_search_type search_type,
  88. const efi_guid_t *protocol, void *search_key,
  89. efi_uintn_t *buffer_size, efi_handle_t *buffer);
  90. efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol,
  91. struct efi_device_path **device_path,
  92. efi_handle_t *device);
  93. efi_status_t (EFIAPI *install_configuration_table)(
  94. efi_guid_t *guid, void *table);
  95. efi_status_t (EFIAPI *load_image)(bool boot_policiy,
  96. efi_handle_t parent_image,
  97. struct efi_device_path *file_path, void *source_buffer,
  98. unsigned long source_size, efi_handle_t *image);
  99. efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
  100. unsigned long *exitdata_size,
  101. s16 **exitdata);
  102. efi_status_t (EFIAPI *exit)(efi_handle_t handle,
  103. efi_status_t exit_status,
  104. unsigned long exitdata_size, s16 *exitdata);
  105. efi_status_t (EFIAPI *unload_image)(efi_handle_t image_handle);
  106. efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
  107. efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
  108. efi_status_t (EFIAPI *stall)(unsigned long usecs);
  109. efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout,
  110. uint64_t watchdog_code, unsigned long data_size,
  111. uint16_t *watchdog_data);
  112. efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
  113. efi_handle_t *driver_image_handle,
  114. struct efi_device_path *remaining_device_path,
  115. bool recursive);
  116. efi_status_t (EFIAPI *disconnect_controller)(
  117. efi_handle_t controller_handle,
  118. efi_handle_t driver_image_handle,
  119. efi_handle_t child_handle);
  120. #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
  121. #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
  122. #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
  123. #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
  124. #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
  125. #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
  126. efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
  127. const efi_guid_t *protocol, void **interface,
  128. efi_handle_t agent_handle,
  129. efi_handle_t controller_handle, u32 attributes);
  130. efi_status_t (EFIAPI *close_protocol)(
  131. efi_handle_t handle, const efi_guid_t *protocol,
  132. efi_handle_t agent_handle,
  133. efi_handle_t controller_handle);
  134. efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
  135. const efi_guid_t *protocol,
  136. struct efi_open_protocol_info_entry **entry_buffer,
  137. efi_uintn_t *entry_count);
  138. efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
  139. efi_guid_t ***protocol_buffer,
  140. efi_uintn_t *protocols_buffer_count);
  141. efi_status_t (EFIAPI *locate_handle_buffer) (
  142. enum efi_locate_search_type search_type,
  143. const efi_guid_t *protocol, void *search_key,
  144. efi_uintn_t *no_handles, efi_handle_t **buffer);
  145. efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol,
  146. void *registration, void **protocol_interface);
  147. efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
  148. void **handle, ...);
  149. efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
  150. void *handle, ...);
  151. efi_status_t (EFIAPI *calculate_crc32)(void *data,
  152. unsigned long data_size, uint32_t *crc32);
  153. void (EFIAPI *copy_mem)(void *destination, const void *source,
  154. size_t length);
  155. void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value);
  156. void *create_event_ex;
  157. };
  158. /* Types and defines for EFI ResetSystem */
  159. enum efi_reset_type {
  160. EFI_RESET_COLD = 0,
  161. EFI_RESET_WARM = 1,
  162. EFI_RESET_SHUTDOWN = 2
  163. };
  164. /* EFI Runtime Services table */
  165. #define EFI_RUNTIME_SERVICES_SIGNATURE 0x5652453544e5552ULL
  166. #define EFI_RUNTIME_SERVICES_REVISION 0x00010000
  167. struct efi_runtime_services {
  168. struct efi_table_hdr hdr;
  169. efi_status_t (EFIAPI *get_time)(struct efi_time *time,
  170. struct efi_time_cap *capabilities);
  171. efi_status_t (EFIAPI *set_time)(struct efi_time *time);
  172. efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
  173. struct efi_time *time);
  174. efi_status_t (EFIAPI *set_wakeup_time)(char enabled,
  175. struct efi_time *time);
  176. efi_status_t (EFIAPI *set_virtual_address_map)(
  177. unsigned long memory_map_size,
  178. unsigned long descriptor_size,
  179. uint32_t descriptor_version,
  180. struct efi_mem_desc *virtmap);
  181. efi_status_t (*convert_pointer)(unsigned long dbg, void **address);
  182. efi_status_t (EFIAPI *get_variable)(s16 *variable_name,
  183. efi_guid_t *vendor, u32 *attributes,
  184. unsigned long *data_size, void *data);
  185. efi_status_t (EFIAPI *get_next_variable)(
  186. unsigned long *variable_name_size,
  187. s16 *variable_name, efi_guid_t *vendor);
  188. efi_status_t (EFIAPI *set_variable)(s16 *variable_name,
  189. efi_guid_t *vendor, u32 attributes,
  190. unsigned long data_size, void *data);
  191. efi_status_t (EFIAPI *get_next_high_mono_count)(
  192. uint32_t *high_count);
  193. void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
  194. efi_status_t reset_status,
  195. unsigned long data_size, void *reset_data);
  196. void *update_capsule;
  197. void *query_capsule_caps;
  198. void *query_variable_info;
  199. };
  200. /* EFI Configuration Table and GUID definitions */
  201. #define NULL_GUID \
  202. EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
  203. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
  204. #define EFI_GLOBAL_VARIABLE_GUID \
  205. EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
  206. 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
  207. #define LOADED_IMAGE_PROTOCOL_GUID \
  208. EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \
  209. 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  210. #define EFI_FDT_GUID \
  211. EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
  212. 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
  213. #define SMBIOS_TABLE_GUID \
  214. EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, \
  215. 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  216. struct efi_configuration_table
  217. {
  218. efi_guid_t guid;
  219. void *table;
  220. };
  221. #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
  222. struct efi_system_table {
  223. struct efi_table_hdr hdr;
  224. unsigned long fw_vendor; /* physical addr of wchar_t vendor string */
  225. u32 fw_revision;
  226. unsigned long con_in_handle;
  227. struct efi_simple_input_interface *con_in;
  228. unsigned long con_out_handle;
  229. struct efi_simple_text_output_protocol *con_out;
  230. unsigned long stderr_handle;
  231. struct efi_simple_text_output_protocol *std_err;
  232. struct efi_runtime_services *runtime;
  233. struct efi_boot_services *boottime;
  234. efi_uintn_t nr_tables;
  235. struct efi_configuration_table *tables;
  236. };
  237. #define LOADED_IMAGE_GUID \
  238. EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
  239. 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  240. struct efi_loaded_image {
  241. u32 revision;
  242. void *parent_handle;
  243. struct efi_system_table *system_table;
  244. void *device_handle;
  245. void *file_path;
  246. void *reserved;
  247. u32 load_options_size;
  248. void *load_options;
  249. void *image_base;
  250. aligned_u64 image_size;
  251. unsigned int image_code_type;
  252. unsigned int image_data_type;
  253. unsigned long unload;
  254. /* Below are efi loader private fields */
  255. #ifdef CONFIG_EFI_LOADER
  256. efi_status_t exit_status;
  257. struct jmp_buf_data exit_jmp;
  258. #endif
  259. };
  260. #define DEVICE_PATH_GUID \
  261. EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \
  262. 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
  263. #define DEVICE_PATH_TYPE_END 0x7f
  264. # define DEVICE_PATH_SUB_TYPE_END 0xff
  265. struct efi_device_path {
  266. u8 type;
  267. u8 sub_type;
  268. u16 length;
  269. } __packed;
  270. struct efi_mac_addr {
  271. u8 addr[32];
  272. } __packed;
  273. #define DEVICE_PATH_TYPE_HARDWARE_DEVICE 0x01
  274. # define DEVICE_PATH_SUB_TYPE_MEMORY 0x03
  275. # define DEVICE_PATH_SUB_TYPE_VENDOR 0x04
  276. struct efi_device_path_memory {
  277. struct efi_device_path dp;
  278. u32 memory_type;
  279. u64 start_address;
  280. u64 end_address;
  281. } __packed;
  282. struct efi_device_path_vendor {
  283. struct efi_device_path dp;
  284. efi_guid_t guid;
  285. u8 vendor_data[];
  286. } __packed;
  287. #define DEVICE_PATH_TYPE_ACPI_DEVICE 0x02
  288. # define DEVICE_PATH_SUB_TYPE_ACPI_DEVICE 0x01
  289. #define EFI_PNP_ID(ID) (u32)(((ID) << 16) | 0x41D0)
  290. #define EISA_PNP_ID(ID) EFI_PNP_ID(ID)
  291. #define EISA_PNP_NUM(ID) ((ID) >> 16)
  292. struct efi_device_path_acpi_path {
  293. struct efi_device_path dp;
  294. u32 hid;
  295. u32 uid;
  296. } __packed;
  297. #define DEVICE_PATH_TYPE_MESSAGING_DEVICE 0x03
  298. # define DEVICE_PATH_SUB_TYPE_MSG_ATAPI 0x01
  299. # define DEVICE_PATH_SUB_TYPE_MSG_SCSI 0x02
  300. # define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05
  301. # define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b
  302. # define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f
  303. # define DEVICE_PATH_SUB_TYPE_MSG_SD 0x1a
  304. # define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d
  305. struct efi_device_path_atapi {
  306. struct efi_device_path dp;
  307. u8 primary_secondary;
  308. u8 slave_master;
  309. u16 logical_unit_number;
  310. } __packed;
  311. struct efi_device_path_scsi {
  312. struct efi_device_path dp;
  313. u16 target_id;
  314. u16 logical_unit_number;
  315. } __packed;
  316. struct efi_device_path_usb {
  317. struct efi_device_path dp;
  318. u8 parent_port_number;
  319. u8 usb_interface;
  320. } __packed;
  321. struct efi_device_path_mac_addr {
  322. struct efi_device_path dp;
  323. struct efi_mac_addr mac;
  324. u8 if_type;
  325. } __packed;
  326. struct efi_device_path_usb_class {
  327. struct efi_device_path dp;
  328. u16 vendor_id;
  329. u16 product_id;
  330. u8 device_class;
  331. u8 device_subclass;
  332. u8 device_protocol;
  333. } __packed;
  334. struct efi_device_path_sd_mmc_path {
  335. struct efi_device_path dp;
  336. u8 slot_number;
  337. } __packed;
  338. #define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04
  339. # define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01
  340. # define DEVICE_PATH_SUB_TYPE_CDROM_PATH 0x02
  341. # define DEVICE_PATH_SUB_TYPE_FILE_PATH 0x04
  342. struct efi_device_path_hard_drive_path {
  343. struct efi_device_path dp;
  344. u32 partition_number;
  345. u64 partition_start;
  346. u64 partition_end;
  347. u8 partition_signature[16];
  348. u8 partmap_type;
  349. u8 signature_type;
  350. } __packed;
  351. struct efi_device_path_cdrom_path {
  352. struct efi_device_path dp;
  353. u32 boot_entry;
  354. u64 partition_start;
  355. u64 partition_end;
  356. } __packed;
  357. struct efi_device_path_file_path {
  358. struct efi_device_path dp;
  359. u16 str[];
  360. } __packed;
  361. #define BLOCK_IO_GUID \
  362. EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
  363. 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  364. struct efi_block_io_media
  365. {
  366. u32 media_id;
  367. char removable_media;
  368. char media_present;
  369. char logical_partition;
  370. char read_only;
  371. char write_caching;
  372. u8 pad[3];
  373. u32 block_size;
  374. u32 io_align;
  375. u8 pad2[4];
  376. u64 last_block;
  377. };
  378. struct efi_block_io {
  379. u64 revision;
  380. struct efi_block_io_media *media;
  381. efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
  382. char extended_verification);
  383. efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
  384. u32 media_id, u64 lba, unsigned long buffer_size,
  385. void *buffer);
  386. efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
  387. u32 media_id, u64 lba, unsigned long buffer_size,
  388. void *buffer);
  389. efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
  390. };
  391. struct simple_text_output_mode {
  392. s32 max_mode;
  393. s32 mode;
  394. s32 attribute;
  395. s32 cursor_column;
  396. s32 cursor_row;
  397. bool cursor_visible;
  398. };
  399. #define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
  400. EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \
  401. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  402. #define EFI_BLACK 0x00
  403. #define EFI_BLUE 0x01
  404. #define EFI_GREEN 0x02
  405. #define EFI_CYAN 0x03
  406. #define EFI_RED 0x04
  407. #define EFI_MAGENTA 0x05
  408. #define EFI_BROWN 0x06
  409. #define EFI_LIGHTGRAY 0x07
  410. #define EFI_BRIGHT 0x08
  411. #define EFI_DARKGRAY 0x08
  412. #define EFI_LIGHTBLUE 0x09
  413. #define EFI_LIGHTGREEN 0x0a
  414. #define EFI_LIGHTCYAN 0x0b
  415. #define EFI_LIGHTRED 0x0c
  416. #define EFI_LIGHTMAGENTA 0x0d
  417. #define EFI_YELLOW 0x0e
  418. #define EFI_WHITE 0x0f
  419. #define EFI_BACKGROUND_BLACK 0x00
  420. #define EFI_BACKGROUND_BLUE 0x10
  421. #define EFI_BACKGROUND_GREEN 0x20
  422. #define EFI_BACKGROUND_CYAN 0x30
  423. #define EFI_BACKGROUND_RED 0x40
  424. #define EFI_BACKGROUND_MAGENTA 0x50
  425. #define EFI_BACKGROUND_BROWN 0x60
  426. #define EFI_BACKGROUND_LIGHTGRAY 0x70
  427. /* extract foreground color from EFI attribute */
  428. #define EFI_ATTR_FG(attr) ((attr) & 0x07)
  429. /* treat high bit of FG as bright/bold (similar to edk2) */
  430. #define EFI_ATTR_BOLD(attr) (((attr) >> 3) & 0x01)
  431. /* extract background color from EFI attribute */
  432. #define EFI_ATTR_BG(attr) (((attr) >> 4) & 0x7)
  433. struct efi_simple_text_output_protocol {
  434. void *reset;
  435. efi_status_t (EFIAPI *output_string)(
  436. struct efi_simple_text_output_protocol *this,
  437. const efi_string_t str);
  438. efi_status_t (EFIAPI *test_string)(
  439. struct efi_simple_text_output_protocol *this,
  440. const efi_string_t str);
  441. efi_status_t(EFIAPI *query_mode)(
  442. struct efi_simple_text_output_protocol *this,
  443. unsigned long mode_number, unsigned long *columns,
  444. unsigned long *rows);
  445. efi_status_t(EFIAPI *set_mode)(
  446. struct efi_simple_text_output_protocol *this,
  447. unsigned long mode_number);
  448. efi_status_t(EFIAPI *set_attribute)(
  449. struct efi_simple_text_output_protocol *this,
  450. unsigned long attribute);
  451. efi_status_t(EFIAPI *clear_screen) (
  452. struct efi_simple_text_output_protocol *this);
  453. efi_status_t(EFIAPI *set_cursor_position) (
  454. struct efi_simple_text_output_protocol *this,
  455. unsigned long column, unsigned long row);
  456. efi_status_t(EFIAPI *enable_cursor)(
  457. struct efi_simple_text_output_protocol *this,
  458. bool enable);
  459. struct simple_text_output_mode *mode;
  460. };
  461. struct efi_input_key {
  462. u16 scan_code;
  463. s16 unicode_char;
  464. };
  465. #define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
  466. EFI_GUID(0x387477c1, 0x69c7, 0x11d2, \
  467. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  468. struct efi_simple_input_interface {
  469. efi_status_t(EFIAPI *reset)(struct efi_simple_input_interface *this,
  470. bool ExtendedVerification);
  471. efi_status_t(EFIAPI *read_key_stroke)(
  472. struct efi_simple_input_interface *this,
  473. struct efi_input_key *key);
  474. struct efi_event *wait_for_key;
  475. };
  476. #define CONSOLE_CONTROL_GUID \
  477. EFI_GUID(0xf42f7782, 0x12e, 0x4c12, \
  478. 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21)
  479. #define EFI_CONSOLE_MODE_TEXT 0
  480. #define EFI_CONSOLE_MODE_GFX 1
  481. struct efi_console_control_protocol
  482. {
  483. efi_status_t (EFIAPI *get_mode)(
  484. struct efi_console_control_protocol *this, int *mode,
  485. char *uga_exists, char *std_in_locked);
  486. efi_status_t (EFIAPI *set_mode)(
  487. struct efi_console_control_protocol *this, int mode);
  488. efi_status_t (EFIAPI *lock_std_in)(
  489. struct efi_console_control_protocol *this,
  490. uint16_t *password);
  491. };
  492. #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
  493. EFI_GUID(0x8b843e20, 0x8132, 0x4852, \
  494. 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
  495. struct efi_device_path_to_text_protocol
  496. {
  497. uint16_t *(EFIAPI *convert_device_node_to_text)(
  498. struct efi_device_path *device_node,
  499. bool display_only,
  500. bool allow_shortcuts);
  501. uint16_t *(EFIAPI *convert_device_path_to_text)(
  502. struct efi_device_path *device_path,
  503. bool display_only,
  504. bool allow_shortcuts);
  505. };
  506. #define EFI_GOP_GUID \
  507. EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
  508. 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
  509. #define EFI_GOT_RGBA8 0
  510. #define EFI_GOT_BGRA8 1
  511. #define EFI_GOT_BITMASK 2
  512. struct efi_gop_mode_info
  513. {
  514. u32 version;
  515. u32 width;
  516. u32 height;
  517. u32 pixel_format;
  518. u32 pixel_bitmask[4];
  519. u32 pixels_per_scanline;
  520. };
  521. struct efi_gop_mode
  522. {
  523. u32 max_mode;
  524. u32 mode;
  525. struct efi_gop_mode_info *info;
  526. unsigned long info_size;
  527. efi_physical_addr_t fb_base;
  528. unsigned long fb_size;
  529. };
  530. #define EFI_BLT_VIDEO_FILL 0
  531. #define EFI_BLT_VIDEO_TO_BLT_BUFFER 1
  532. #define EFI_BLT_BUFFER_TO_VIDEO 2
  533. #define EFI_BLT_VIDEO_TO_VIDEO 3
  534. struct efi_gop
  535. {
  536. efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number,
  537. efi_uintn_t *size_of_info,
  538. struct efi_gop_mode_info **info);
  539. efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number);
  540. efi_status_t (EFIAPI *blt)(struct efi_gop *this, void *buffer,
  541. u32 operation, efi_uintn_t sx,
  542. efi_uintn_t sy, efi_uintn_t dx,
  543. efi_uintn_t dy, efi_uintn_t width,
  544. efi_uintn_t height, efi_uintn_t delta);
  545. struct efi_gop_mode *mode;
  546. };
  547. #define EFI_SIMPLE_NETWORK_GUID \
  548. EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \
  549. 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  550. struct efi_mac_address {
  551. char mac_addr[32];
  552. };
  553. struct efi_ip_address {
  554. u8 ip_addr[16];
  555. };
  556. enum efi_simple_network_state {
  557. EFI_NETWORK_STOPPED,
  558. EFI_NETWORK_STARTED,
  559. EFI_NETWORK_INITIALIZED,
  560. };
  561. struct efi_simple_network_mode {
  562. enum efi_simple_network_state state;
  563. u32 hwaddr_size;
  564. u32 media_header_size;
  565. u32 max_packet_size;
  566. u32 nvram_size;
  567. u32 nvram_access_size;
  568. u32 receive_filter_mask;
  569. u32 receive_filter_setting;
  570. u32 max_mcast_filter_count;
  571. u32 mcast_filter_count;
  572. struct efi_mac_address mcast_filter[16];
  573. struct efi_mac_address current_address;
  574. struct efi_mac_address broadcast_address;
  575. struct efi_mac_address permanent_address;
  576. u8 if_type;
  577. u8 mac_changeable;
  578. u8 multitx_supported;
  579. u8 media_present_supported;
  580. u8 media_present;
  581. };
  582. /* receive_filters bit mask */
  583. #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01
  584. #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02
  585. #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04
  586. #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08
  587. #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
  588. /* interrupt status bit mask */
  589. #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01
  590. #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02
  591. #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04
  592. #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08
  593. /* revision of the simple network protocol */
  594. #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
  595. struct efi_simple_network
  596. {
  597. u64 revision;
  598. efi_status_t (EFIAPI *start)(struct efi_simple_network *this);
  599. efi_status_t (EFIAPI *stop)(struct efi_simple_network *this);
  600. efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this,
  601. ulong extra_rx, ulong extra_tx);
  602. efi_status_t (EFIAPI *reset)(struct efi_simple_network *this,
  603. int extended_verification);
  604. efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this);
  605. efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this,
  606. u32 enable, u32 disable, int reset_mcast_filter,
  607. ulong mcast_filter_count,
  608. struct efi_mac_address *mcast_filter);
  609. efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this,
  610. int reset, struct efi_mac_address *new_mac);
  611. efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this,
  612. int reset, ulong *stat_size, void *stat_table);
  613. efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this,
  614. int ipv6, struct efi_ip_address *ip,
  615. struct efi_mac_address *mac);
  616. efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this,
  617. int read_write, ulong offset, ulong buffer_size,
  618. char *buffer);
  619. efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this,
  620. u32 *int_status, void **txbuf);
  621. efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this,
  622. size_t header_size, size_t buffer_size, void *buffer,
  623. struct efi_mac_address *src_addr,
  624. struct efi_mac_address *dest_addr, u16 *protocol);
  625. efi_status_t (EFIAPI *receive)(struct efi_simple_network *this,
  626. size_t *header_size, size_t *buffer_size, void *buffer,
  627. struct efi_mac_address *src_addr,
  628. struct efi_mac_address *dest_addr, u16 *protocol);
  629. struct efi_event *wait_for_packet;
  630. struct efi_simple_network_mode *mode;
  631. };
  632. #define EFI_PXE_GUID \
  633. EFI_GUID(0x03c4e603, 0xac28, 0x11d3, \
  634. 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  635. struct efi_pxe_packet {
  636. u8 packet[1472];
  637. };
  638. struct efi_pxe_mode
  639. {
  640. u8 unused[52];
  641. struct efi_pxe_packet dhcp_discover;
  642. struct efi_pxe_packet dhcp_ack;
  643. struct efi_pxe_packet proxy_offer;
  644. struct efi_pxe_packet pxe_discover;
  645. struct efi_pxe_packet pxe_reply;
  646. };
  647. struct efi_pxe {
  648. u64 rev;
  649. void (EFIAPI *start)(void);
  650. void (EFIAPI *stop)(void);
  651. void (EFIAPI *dhcp)(void);
  652. void (EFIAPI *discover)(void);
  653. void (EFIAPI *mftp)(void);
  654. void (EFIAPI *udpwrite)(void);
  655. void (EFIAPI *udpread)(void);
  656. void (EFIAPI *setipfilter)(void);
  657. void (EFIAPI *arp)(void);
  658. void (EFIAPI *setparams)(void);
  659. void (EFIAPI *setstationip)(void);
  660. void (EFIAPI *setpackets)(void);
  661. struct efi_pxe_mode *mode;
  662. };
  663. #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
  664. EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
  665. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  666. #define EFI_FILE_PROTOCOL_REVISION 0x00010000
  667. struct efi_file_handle {
  668. u64 rev;
  669. efi_status_t (EFIAPI *open)(struct efi_file_handle *file,
  670. struct efi_file_handle **new_handle,
  671. s16 *file_name, u64 open_mode, u64 attributes);
  672. efi_status_t (EFIAPI *close)(struct efi_file_handle *file);
  673. efi_status_t (EFIAPI *delete)(struct efi_file_handle *file);
  674. efi_status_t (EFIAPI *read)(struct efi_file_handle *file,
  675. u64 *buffer_size, void *buffer);
  676. efi_status_t (EFIAPI *write)(struct efi_file_handle *file,
  677. u64 *buffer_size, void *buffer);
  678. efi_status_t (EFIAPI *getpos)(struct efi_file_handle *file,
  679. u64 *pos);
  680. efi_status_t (EFIAPI *setpos)(struct efi_file_handle *file,
  681. u64 pos);
  682. efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *file,
  683. efi_guid_t *info_type, u64 *buffer_size, void *buffer);
  684. efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *file,
  685. efi_guid_t *info_type, u64 buffer_size, void *buffer);
  686. efi_status_t (EFIAPI *flush)(struct efi_file_handle *file);
  687. };
  688. #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
  689. EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
  690. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  691. #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
  692. struct efi_simple_file_system_protocol {
  693. u64 rev;
  694. efi_status_t (EFIAPI *open_volume)(struct efi_simple_file_system_protocol *this,
  695. struct efi_file_handle **root);
  696. };
  697. #define EFI_FILE_INFO_GUID \
  698. EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \
  699. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  700. #define EFI_FILE_MODE_READ 0x0000000000000001
  701. #define EFI_FILE_MODE_WRITE 0x0000000000000002
  702. #define EFI_FILE_MODE_CREATE 0x8000000000000000
  703. #define EFI_FILE_READ_ONLY 0x0000000000000001
  704. #define EFI_FILE_HIDDEN 0x0000000000000002
  705. #define EFI_FILE_SYSTEM 0x0000000000000004
  706. #define EFI_FILE_RESERVED 0x0000000000000008
  707. #define EFI_FILE_DIRECTORY 0x0000000000000010
  708. #define EFI_FILE_ARCHIVE 0x0000000000000020
  709. #define EFI_FILE_VALID_ATTR 0x0000000000000037
  710. struct efi_file_info {
  711. u64 size;
  712. u64 file_size;
  713. u64 physical_size;
  714. struct efi_time create_time;
  715. struct efi_time last_access_time;
  716. struct efi_time modification_time;
  717. u64 attribute;
  718. s16 file_name[0];
  719. };
  720. #define EFI_DRIVER_BINDING_PROTOCOL_GUID \
  721. EFI_GUID(0x18a031ab, 0xb443, 0x4d1a,\
  722. 0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71)
  723. struct efi_driver_binding_protocol {
  724. efi_status_t (EFIAPI * supported)(
  725. struct efi_driver_binding_protocol *this,
  726. efi_handle_t controller_handle,
  727. struct efi_device_path *remaining_device_path);
  728. efi_status_t (EFIAPI * start)(
  729. struct efi_driver_binding_protocol *this,
  730. efi_handle_t controller_handle,
  731. struct efi_device_path *remaining_device_path);
  732. efi_status_t (EFIAPI * stop)(
  733. struct efi_driver_binding_protocol *this,
  734. efi_handle_t controller_handle,
  735. efi_uintn_t number_of_children,
  736. efi_handle_t *child_handle_buffer);
  737. u32 version;
  738. efi_handle_t image_handle;
  739. efi_handle_t driver_binding_handle;
  740. };
  741. #endif