efi_api.h 24 KB

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