efi_api.h 24 KB

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