efi_api.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. /* EFI Boot Services table */
  18. struct efi_boot_services {
  19. struct efi_table_hdr hdr;
  20. void *raise_tpl;
  21. void *restore_tpl;
  22. efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long,
  23. efi_physical_addr_t *);
  24. efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, unsigned long);
  25. efi_status_t (EFIAPI *get_memory_map)(unsigned long *memory_map_size,
  26. struct efi_mem_desc *desc, unsigned long *key,
  27. unsigned long *desc_size, u32 *desc_version);
  28. efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
  29. efi_status_t (EFIAPI *free_pool)(void *);
  30. void *create_event;
  31. void *set_timer;
  32. efi_status_t(EFIAPI *wait_for_event)(unsigned long number_of_events,
  33. void *event, unsigned long *index);
  34. void *signal_event;
  35. void *close_event;
  36. void *check_event;
  37. void *install_protocol_interface;
  38. void *reinstall_protocol_interface;
  39. void *uninstall_protocol_interface;
  40. efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *,
  41. void **);
  42. void *reserved;
  43. void *register_protocol_notify;
  44. efi_status_t (EFIAPI *locate_handle)(
  45. enum efi_locate_search_type search_type,
  46. efi_guid_t *protocol, void *search_key,
  47. unsigned long *buffer_size, efi_handle_t *buffer);
  48. efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol,
  49. struct efi_device_path **device_path,
  50. efi_handle_t *device);
  51. void *install_configuration_table;
  52. efi_status_t (EFIAPI *load_image)(bool boot_policiy,
  53. efi_handle_t parent_image,
  54. struct efi_device_path *file_path, void *source_buffer,
  55. unsigned long source_size, efi_handle_t *image);
  56. efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
  57. unsigned long *exitdata_size,
  58. s16 **exitdata);
  59. efi_status_t (EFIAPI *exit)(efi_handle_t handle,
  60. efi_status_t exit_status,
  61. unsigned long exitdata_size, s16 *exitdata);
  62. void *unload_image;
  63. efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
  64. efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
  65. efi_status_t (EFIAPI *stall)(unsigned long usecs);
  66. void *set_watchdog_timer;
  67. efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
  68. efi_handle_t *driver_image_handle,
  69. struct efi_device_path *remaining_device_path,
  70. bool recursive);
  71. void *disconnect_controller;
  72. #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
  73. #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
  74. #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
  75. #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
  76. #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
  77. #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
  78. efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
  79. efi_guid_t *protocol, void **interface,
  80. efi_handle_t agent_handle,
  81. efi_handle_t controller_handle, u32 attributes);
  82. void *close_protocol;
  83. efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
  84. efi_guid_t *protocol,
  85. struct efi_open_protocol_info_entry **entry_buffer,
  86. unsigned long *entry_count);
  87. efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
  88. efi_guid_t ***protocol_buffer,
  89. unsigned long *protocols_buffer_count);
  90. efi_status_t (EFIAPI *locate_handle_buffer) (
  91. enum efi_locate_search_type search_type,
  92. efi_guid_t *protocol, void *search_key,
  93. unsigned long *no_handles, efi_handle_t **buffer);
  94. void *locate_protocol;
  95. void *install_multiple_protocol_interfaces;
  96. void *uninstall_multiple_protocol_interfaces;
  97. void *calculate_crc32;
  98. void *copy_mem;
  99. void *set_mem;
  100. void *create_event_ex;
  101. };
  102. /* Types and defines for EFI ResetSystem */
  103. enum efi_reset_type {
  104. EFI_RESET_COLD = 0,
  105. EFI_RESET_WARM = 1,
  106. EFI_RESET_SHUTDOWN = 2
  107. };
  108. /* EFI Runtime Services table */
  109. #define EFI_RUNTIME_SERVICES_SIGNATURE 0x5652453544e5552ULL
  110. #define EFI_RUNTIME_SERVICES_REVISION 0x00010000
  111. struct efi_runtime_services {
  112. struct efi_table_hdr hdr;
  113. void *get_time;
  114. void *set_time;
  115. void *get_wakeup_time;
  116. void *set_wakeup_time;
  117. void *set_virtual_address_map;
  118. void *convert_pointer;
  119. efi_status_t (EFIAPI *get_variable)(s16 *variable_name,
  120. efi_guid_t *vendor, u32 *attributes,
  121. unsigned long *data_size, void *data);
  122. efi_status_t (EFIAPI *get_next_variable)(
  123. unsigned long *variable_name_size,
  124. s16 *variable_name, efi_guid_t *vendor);
  125. efi_status_t (EFIAPI *set_variable)(s16 *variable_name,
  126. efi_guid_t *vendor, u32 attributes,
  127. unsigned long data_size, void *data);
  128. void *get_next_high_mono_count;
  129. void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
  130. efi_status_t reset_status,
  131. unsigned long data_size, void *reset_data);
  132. void *update_capsule;
  133. void *query_capsule_caps;
  134. void *query_variable_info;
  135. };
  136. /* EFI Configuration Table and GUID definitions */
  137. #define NULL_GUID \
  138. EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
  139. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
  140. #define LOADED_IMAGE_PROTOCOL_GUID \
  141. EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \
  142. 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  143. struct efi_system_table {
  144. struct efi_table_hdr hdr;
  145. unsigned long fw_vendor; /* physical addr of wchar_t vendor string */
  146. u32 fw_revision;
  147. unsigned long con_in_handle;
  148. struct efi_simple_input_interface *con_in;
  149. unsigned long con_out_handle;
  150. struct efi_simple_text_output_protocol *con_out;
  151. unsigned long stderr_handle;
  152. unsigned long std_err;
  153. struct efi_runtime_services *runtime;
  154. struct efi_boot_services *boottime;
  155. unsigned long nr_tables;
  156. unsigned long tables;
  157. };
  158. struct efi_loaded_image {
  159. u32 revision;
  160. void *parent_handle;
  161. struct efi_system_table *system_table;
  162. void *device_handle;
  163. void *file_path;
  164. void *reserved;
  165. u32 load_options_size;
  166. void *load_options;
  167. void *image_base;
  168. aligned_u64 image_size;
  169. unsigned int image_code_type;
  170. unsigned int image_data_type;
  171. unsigned long unload;
  172. };
  173. struct efi_device_path {
  174. u8 type;
  175. u8 sub_type;
  176. u16 length;
  177. };
  178. struct simple_text_output_mode {
  179. s32 max_mode;
  180. s32 mode;
  181. s32 attribute;
  182. s32 cursor_column;
  183. s32 cursor_row;
  184. bool cursor_visible;
  185. };
  186. struct efi_simple_text_output_protocol {
  187. void *reset;
  188. efi_status_t (EFIAPI *output_string)(
  189. struct efi_simple_text_output_protocol *this,
  190. const unsigned short *str);
  191. void *test_string;
  192. efi_status_t(EFIAPI *query_mode)(
  193. struct efi_simple_text_output_protocol *this,
  194. unsigned long mode_number, unsigned long *columns,
  195. unsigned long *rows);
  196. efi_status_t(EFIAPI *set_mode)(
  197. struct efi_simple_text_output_protocol *this,
  198. unsigned long mode_number);
  199. efi_status_t(EFIAPI *set_attribute)(
  200. struct efi_simple_text_output_protocol *this,
  201. unsigned long attribute);
  202. efi_status_t(EFIAPI *clear_screen) (
  203. struct efi_simple_text_output_protocol *this);
  204. efi_status_t(EFIAPI *set_cursor_position) (
  205. struct efi_simple_text_output_protocol *this,
  206. unsigned long column, unsigned long row);
  207. efi_status_t(EFIAPI *enable_cursor)(void *, bool enable);
  208. struct simple_text_output_mode *mode;
  209. };
  210. struct efi_input_key {
  211. u16 scan_code;
  212. s16 unicode_char;
  213. };
  214. struct efi_simple_input_interface {
  215. efi_status_t(EFIAPI *reset)(struct efi_simple_input_interface *this,
  216. bool ExtendedVerification);
  217. efi_status_t(EFIAPI *read_key_stroke)(
  218. struct efi_simple_input_interface *this,
  219. struct efi_input_key *key);
  220. void *wait_for_key;
  221. };
  222. #endif