efi_api.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  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_VENDOR 0x04
  269. struct efi_device_path_vendor {
  270. struct efi_device_path dp;
  271. efi_guid_t guid;
  272. u8 vendor_data[];
  273. } __packed;
  274. #define DEVICE_PATH_TYPE_ACPI_DEVICE 0x02
  275. # define DEVICE_PATH_SUB_TYPE_ACPI_DEVICE 0x01
  276. #define EFI_PNP_ID(ID) (u32)(((ID) << 16) | 0x41D0)
  277. #define EISA_PNP_ID(ID) EFI_PNP_ID(ID)
  278. #define EISA_PNP_NUM(ID) ((ID) >> 16)
  279. struct efi_device_path_acpi_path {
  280. struct efi_device_path dp;
  281. u32 hid;
  282. u32 uid;
  283. } __packed;
  284. #define DEVICE_PATH_TYPE_MESSAGING_DEVICE 0x03
  285. # define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05
  286. # define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b
  287. # define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f
  288. # define DEVICE_PATH_SUB_TYPE_MSG_SD 0x1a
  289. # define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d
  290. struct efi_device_path_usb {
  291. struct efi_device_path dp;
  292. u8 parent_port_number;
  293. u8 usb_interface;
  294. } __packed;
  295. struct efi_device_path_mac_addr {
  296. struct efi_device_path dp;
  297. struct efi_mac_addr mac;
  298. u8 if_type;
  299. } __packed;
  300. struct efi_device_path_usb_class {
  301. struct efi_device_path dp;
  302. u16 vendor_id;
  303. u16 product_id;
  304. u8 device_class;
  305. u8 device_subclass;
  306. u8 device_protocol;
  307. } __packed;
  308. struct efi_device_path_sd_mmc_path {
  309. struct efi_device_path dp;
  310. u8 slot_number;
  311. } __packed;
  312. #define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04
  313. # define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01
  314. # define DEVICE_PATH_SUB_TYPE_CDROM_PATH 0x02
  315. # define DEVICE_PATH_SUB_TYPE_FILE_PATH 0x04
  316. struct efi_device_path_hard_drive_path {
  317. struct efi_device_path dp;
  318. u32 partition_number;
  319. u64 partition_start;
  320. u64 partition_end;
  321. u8 partition_signature[16];
  322. u8 partmap_type;
  323. u8 signature_type;
  324. } __packed;
  325. struct efi_device_path_cdrom_path {
  326. struct efi_device_path dp;
  327. u32 boot_entry;
  328. u64 partition_start;
  329. u64 partition_end;
  330. } __packed;
  331. struct efi_device_path_file_path {
  332. struct efi_device_path dp;
  333. u16 str[];
  334. } __packed;
  335. #define BLOCK_IO_GUID \
  336. EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
  337. 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  338. struct efi_block_io_media
  339. {
  340. u32 media_id;
  341. char removable_media;
  342. char media_present;
  343. char logical_partition;
  344. char read_only;
  345. char write_caching;
  346. u8 pad[3];
  347. u32 block_size;
  348. u32 io_align;
  349. u8 pad2[4];
  350. u64 last_block;
  351. };
  352. struct efi_block_io {
  353. u64 revision;
  354. struct efi_block_io_media *media;
  355. efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
  356. char extended_verification);
  357. efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
  358. u32 media_id, u64 lba, unsigned long buffer_size,
  359. void *buffer);
  360. efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
  361. u32 media_id, u64 lba, unsigned long buffer_size,
  362. void *buffer);
  363. efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
  364. };
  365. struct simple_text_output_mode {
  366. s32 max_mode;
  367. s32 mode;
  368. s32 attribute;
  369. s32 cursor_column;
  370. s32 cursor_row;
  371. bool cursor_visible;
  372. };
  373. #define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
  374. EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \
  375. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  376. struct efi_simple_text_output_protocol {
  377. void *reset;
  378. efi_status_t (EFIAPI *output_string)(
  379. struct efi_simple_text_output_protocol *this,
  380. const efi_string_t str);
  381. efi_status_t (EFIAPI *test_string)(
  382. struct efi_simple_text_output_protocol *this,
  383. const efi_string_t str);
  384. efi_status_t(EFIAPI *query_mode)(
  385. struct efi_simple_text_output_protocol *this,
  386. unsigned long mode_number, unsigned long *columns,
  387. unsigned long *rows);
  388. efi_status_t(EFIAPI *set_mode)(
  389. struct efi_simple_text_output_protocol *this,
  390. unsigned long mode_number);
  391. efi_status_t(EFIAPI *set_attribute)(
  392. struct efi_simple_text_output_protocol *this,
  393. unsigned long attribute);
  394. efi_status_t(EFIAPI *clear_screen) (
  395. struct efi_simple_text_output_protocol *this);
  396. efi_status_t(EFIAPI *set_cursor_position) (
  397. struct efi_simple_text_output_protocol *this,
  398. unsigned long column, unsigned long row);
  399. efi_status_t(EFIAPI *enable_cursor)(
  400. struct efi_simple_text_output_protocol *this,
  401. bool enable);
  402. struct simple_text_output_mode *mode;
  403. };
  404. struct efi_input_key {
  405. u16 scan_code;
  406. s16 unicode_char;
  407. };
  408. #define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
  409. EFI_GUID(0x387477c1, 0x69c7, 0x11d2, \
  410. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  411. struct efi_simple_input_interface {
  412. efi_status_t(EFIAPI *reset)(struct efi_simple_input_interface *this,
  413. bool ExtendedVerification);
  414. efi_status_t(EFIAPI *read_key_stroke)(
  415. struct efi_simple_input_interface *this,
  416. struct efi_input_key *key);
  417. struct efi_event *wait_for_key;
  418. };
  419. #define CONSOLE_CONTROL_GUID \
  420. EFI_GUID(0xf42f7782, 0x12e, 0x4c12, \
  421. 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21)
  422. #define EFI_CONSOLE_MODE_TEXT 0
  423. #define EFI_CONSOLE_MODE_GFX 1
  424. struct efi_console_control_protocol
  425. {
  426. efi_status_t (EFIAPI *get_mode)(
  427. struct efi_console_control_protocol *this, int *mode,
  428. char *uga_exists, char *std_in_locked);
  429. efi_status_t (EFIAPI *set_mode)(
  430. struct efi_console_control_protocol *this, int mode);
  431. efi_status_t (EFIAPI *lock_std_in)(
  432. struct efi_console_control_protocol *this,
  433. uint16_t *password);
  434. };
  435. #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
  436. EFI_GUID(0x8b843e20, 0x8132, 0x4852, \
  437. 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
  438. struct efi_device_path_to_text_protocol
  439. {
  440. uint16_t *(EFIAPI *convert_device_node_to_text)(
  441. struct efi_device_path *device_node,
  442. bool display_only,
  443. bool allow_shortcuts);
  444. uint16_t *(EFIAPI *convert_device_path_to_text)(
  445. struct efi_device_path *device_path,
  446. bool display_only,
  447. bool allow_shortcuts);
  448. };
  449. #define EFI_GOP_GUID \
  450. EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
  451. 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
  452. #define EFI_GOT_RGBA8 0
  453. #define EFI_GOT_BGRA8 1
  454. #define EFI_GOT_BITMASK 2
  455. struct efi_gop_mode_info
  456. {
  457. u32 version;
  458. u32 width;
  459. u32 height;
  460. u32 pixel_format;
  461. u32 pixel_bitmask[4];
  462. u32 pixels_per_scanline;
  463. };
  464. struct efi_gop_mode
  465. {
  466. u32 max_mode;
  467. u32 mode;
  468. struct efi_gop_mode_info *info;
  469. unsigned long info_size;
  470. efi_physical_addr_t fb_base;
  471. unsigned long fb_size;
  472. };
  473. #define EFI_BLT_VIDEO_FILL 0
  474. #define EFI_BLT_VIDEO_TO_BLT_BUFFER 1
  475. #define EFI_BLT_BUFFER_TO_VIDEO 2
  476. #define EFI_BLT_VIDEO_TO_VIDEO 3
  477. struct efi_gop
  478. {
  479. efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number,
  480. unsigned long *size_of_info,
  481. struct efi_gop_mode_info **info);
  482. efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number);
  483. efi_status_t (EFIAPI *blt)(struct efi_gop *this, void *buffer,
  484. unsigned long operation, unsigned long sx,
  485. unsigned long sy, unsigned long dx,
  486. unsigned long dy, unsigned long width,
  487. unsigned long height, unsigned long delta);
  488. struct efi_gop_mode *mode;
  489. };
  490. #define EFI_SIMPLE_NETWORK_GUID \
  491. EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \
  492. 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  493. struct efi_mac_address {
  494. char mac_addr[32];
  495. };
  496. struct efi_ip_address {
  497. u8 ip_addr[16];
  498. };
  499. enum efi_simple_network_state {
  500. EFI_NETWORK_STOPPED,
  501. EFI_NETWORK_STARTED,
  502. EFI_NETWORK_INITIALIZED,
  503. };
  504. struct efi_simple_network_mode {
  505. enum efi_simple_network_state state;
  506. u32 hwaddr_size;
  507. u32 media_header_size;
  508. u32 max_packet_size;
  509. u32 nvram_size;
  510. u32 nvram_access_size;
  511. u32 receive_filter_mask;
  512. u32 receive_filter_setting;
  513. u32 max_mcast_filter_count;
  514. u32 mcast_filter_count;
  515. struct efi_mac_address mcast_filter[16];
  516. struct efi_mac_address current_address;
  517. struct efi_mac_address broadcast_address;
  518. struct efi_mac_address permanent_address;
  519. u8 if_type;
  520. u8 mac_changeable;
  521. u8 multitx_supported;
  522. u8 media_present_supported;
  523. u8 media_present;
  524. };
  525. #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01,
  526. #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02,
  527. #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04,
  528. #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08,
  529. #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10,
  530. struct efi_simple_network
  531. {
  532. u64 revision;
  533. efi_status_t (EFIAPI *start)(struct efi_simple_network *this);
  534. efi_status_t (EFIAPI *stop)(struct efi_simple_network *this);
  535. efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this,
  536. ulong extra_rx, ulong extra_tx);
  537. efi_status_t (EFIAPI *reset)(struct efi_simple_network *this,
  538. int extended_verification);
  539. efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this);
  540. efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this,
  541. u32 enable, u32 disable, int reset_mcast_filter,
  542. ulong mcast_filter_count,
  543. struct efi_mac_address *mcast_filter);
  544. efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this,
  545. int reset, struct efi_mac_address *new_mac);
  546. efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this,
  547. int reset, ulong *stat_size, void *stat_table);
  548. efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this,
  549. int ipv6, struct efi_ip_address *ip,
  550. struct efi_mac_address *mac);
  551. efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this,
  552. int read_write, ulong offset, ulong buffer_size,
  553. char *buffer);
  554. efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this,
  555. u32 *int_status, void **txbuf);
  556. efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this,
  557. ulong header_size, ulong buffer_size, void *buffer,
  558. struct efi_mac_address *src_addr,
  559. struct efi_mac_address *dest_addr, u16 *protocol);
  560. efi_status_t (EFIAPI *receive)(struct efi_simple_network *this,
  561. ulong *header_size, ulong *buffer_size, void *buffer,
  562. struct efi_mac_address *src_addr,
  563. struct efi_mac_address *dest_addr, u16 *protocol);
  564. void (EFIAPI *waitforpacket)(void);
  565. struct efi_simple_network_mode *mode;
  566. };
  567. #define EFI_PXE_GUID \
  568. EFI_GUID(0x03c4e603, 0xac28, 0x11d3, \
  569. 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  570. struct efi_pxe_packet {
  571. u8 packet[1472];
  572. };
  573. struct efi_pxe_mode
  574. {
  575. u8 unused[52];
  576. struct efi_pxe_packet dhcp_discover;
  577. struct efi_pxe_packet dhcp_ack;
  578. struct efi_pxe_packet proxy_offer;
  579. struct efi_pxe_packet pxe_discover;
  580. struct efi_pxe_packet pxe_reply;
  581. };
  582. struct efi_pxe {
  583. u64 rev;
  584. void (EFIAPI *start)(void);
  585. void (EFIAPI *stop)(void);
  586. void (EFIAPI *dhcp)(void);
  587. void (EFIAPI *discover)(void);
  588. void (EFIAPI *mftp)(void);
  589. void (EFIAPI *udpwrite)(void);
  590. void (EFIAPI *udpread)(void);
  591. void (EFIAPI *setipfilter)(void);
  592. void (EFIAPI *arp)(void);
  593. void (EFIAPI *setparams)(void);
  594. void (EFIAPI *setstationip)(void);
  595. void (EFIAPI *setpackets)(void);
  596. struct efi_pxe_mode *mode;
  597. };
  598. #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
  599. EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
  600. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  601. #define EFI_FILE_PROTOCOL_REVISION 0x00010000
  602. struct efi_file_handle {
  603. u64 rev;
  604. efi_status_t (EFIAPI *open)(struct efi_file_handle *file,
  605. struct efi_file_handle **new_handle,
  606. s16 *file_name, u64 open_mode, u64 attributes);
  607. efi_status_t (EFIAPI *close)(struct efi_file_handle *file);
  608. efi_status_t (EFIAPI *delete)(struct efi_file_handle *file);
  609. efi_status_t (EFIAPI *read)(struct efi_file_handle *file,
  610. u64 *buffer_size, void *buffer);
  611. efi_status_t (EFIAPI *write)(struct efi_file_handle *file,
  612. u64 *buffer_size, void *buffer);
  613. efi_status_t (EFIAPI *getpos)(struct efi_file_handle *file,
  614. u64 *pos);
  615. efi_status_t (EFIAPI *setpos)(struct efi_file_handle *file,
  616. u64 pos);
  617. efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *file,
  618. efi_guid_t *info_type, u64 *buffer_size, void *buffer);
  619. efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *file,
  620. efi_guid_t *info_type, u64 buffer_size, void *buffer);
  621. efi_status_t (EFIAPI *flush)(struct efi_file_handle *file);
  622. };
  623. #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
  624. EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
  625. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  626. #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
  627. struct efi_simple_file_system_protocol {
  628. u64 rev;
  629. efi_status_t (EFIAPI *open_volume)(struct efi_simple_file_system_protocol *this,
  630. struct efi_file_handle **root);
  631. };
  632. #define EFI_FILE_INFO_GUID \
  633. EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \
  634. 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  635. #define EFI_FILE_MODE_READ 0x0000000000000001
  636. #define EFI_FILE_MODE_WRITE 0x0000000000000002
  637. #define EFI_FILE_MODE_CREATE 0x8000000000000000
  638. #define EFI_FILE_READ_ONLY 0x0000000000000001
  639. #define EFI_FILE_HIDDEN 0x0000000000000002
  640. #define EFI_FILE_SYSTEM 0x0000000000000004
  641. #define EFI_FILE_RESERVED 0x0000000000000008
  642. #define EFI_FILE_DIRECTORY 0x0000000000000010
  643. #define EFI_FILE_ARCHIVE 0x0000000000000020
  644. #define EFI_FILE_VALID_ATTR 0x0000000000000037
  645. struct efi_file_info {
  646. u64 size;
  647. u64 file_size;
  648. u64 physical_size;
  649. struct efi_time create_time;
  650. struct efi_time last_access_time;
  651. struct efi_time modification_time;
  652. u64 attribute;
  653. s16 file_name[0];
  654. };
  655. #endif