efi_api.h 26 KB

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