efi_api.h 22 KB

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