efi_api.h 24 KB

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