efi.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  1. #ifndef _LINUX_EFI_H
  2. #define _LINUX_EFI_H
  3. /*
  4. * Extensible Firmware Interface
  5. * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999
  6. *
  7. * Copyright (C) 1999 VA Linux Systems
  8. * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
  9. * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
  10. * David Mosberger-Tang <davidm@hpl.hp.com>
  11. * Stephane Eranian <eranian@hpl.hp.com>
  12. */
  13. #include <linux/init.h>
  14. #include <linux/string.h>
  15. #include <linux/time.h>
  16. #include <linux/types.h>
  17. #include <linux/proc_fs.h>
  18. #include <linux/rtc.h>
  19. #include <linux/ioport.h>
  20. #include <linux/pfn.h>
  21. #include <linux/pstore.h>
  22. #include <linux/reboot.h>
  23. #include <asm/page.h>
  24. #define EFI_SUCCESS 0
  25. #define EFI_LOAD_ERROR ( 1 | (1UL << (BITS_PER_LONG-1)))
  26. #define EFI_INVALID_PARAMETER ( 2 | (1UL << (BITS_PER_LONG-1)))
  27. #define EFI_UNSUPPORTED ( 3 | (1UL << (BITS_PER_LONG-1)))
  28. #define EFI_BAD_BUFFER_SIZE ( 4 | (1UL << (BITS_PER_LONG-1)))
  29. #define EFI_BUFFER_TOO_SMALL ( 5 | (1UL << (BITS_PER_LONG-1)))
  30. #define EFI_NOT_READY ( 6 | (1UL << (BITS_PER_LONG-1)))
  31. #define EFI_DEVICE_ERROR ( 7 | (1UL << (BITS_PER_LONG-1)))
  32. #define EFI_WRITE_PROTECTED ( 8 | (1UL << (BITS_PER_LONG-1)))
  33. #define EFI_OUT_OF_RESOURCES ( 9 | (1UL << (BITS_PER_LONG-1)))
  34. #define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG-1)))
  35. #define EFI_SECURITY_VIOLATION (26 | (1UL << (BITS_PER_LONG-1)))
  36. typedef unsigned long efi_status_t;
  37. typedef u8 efi_bool_t;
  38. typedef u16 efi_char16_t; /* UNICODE character */
  39. typedef u64 efi_physical_addr_t;
  40. typedef void *efi_handle_t;
  41. typedef struct {
  42. u8 b[16];
  43. } efi_guid_t;
  44. #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
  45. ((efi_guid_t) \
  46. {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
  47. (b) & 0xff, ((b) >> 8) & 0xff, \
  48. (c) & 0xff, ((c) >> 8) & 0xff, \
  49. (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
  50. /*
  51. * Generic EFI table header
  52. */
  53. typedef struct {
  54. u64 signature;
  55. u32 revision;
  56. u32 headersize;
  57. u32 crc32;
  58. u32 reserved;
  59. } efi_table_hdr_t;
  60. /*
  61. * Memory map descriptor:
  62. */
  63. /* Memory types: */
  64. #define EFI_RESERVED_TYPE 0
  65. #define EFI_LOADER_CODE 1
  66. #define EFI_LOADER_DATA 2
  67. #define EFI_BOOT_SERVICES_CODE 3
  68. #define EFI_BOOT_SERVICES_DATA 4
  69. #define EFI_RUNTIME_SERVICES_CODE 5
  70. #define EFI_RUNTIME_SERVICES_DATA 6
  71. #define EFI_CONVENTIONAL_MEMORY 7
  72. #define EFI_UNUSABLE_MEMORY 8
  73. #define EFI_ACPI_RECLAIM_MEMORY 9
  74. #define EFI_ACPI_MEMORY_NVS 10
  75. #define EFI_MEMORY_MAPPED_IO 11
  76. #define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12
  77. #define EFI_PAL_CODE 13
  78. #define EFI_MAX_MEMORY_TYPE 14
  79. /* Attribute values: */
  80. #define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */
  81. #define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */
  82. #define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */
  83. #define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */
  84. #define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */
  85. #define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */
  86. #define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */
  87. #define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */
  88. #define EFI_MEMORY_DESCRIPTOR_VERSION 1
  89. #define EFI_PAGE_SHIFT 12
  90. #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT)
  91. typedef struct {
  92. u32 type;
  93. u32 pad;
  94. u64 phys_addr;
  95. u64 virt_addr;
  96. u64 num_pages;
  97. u64 attribute;
  98. } efi_memory_desc_t;
  99. typedef struct {
  100. efi_guid_t guid;
  101. u32 headersize;
  102. u32 flags;
  103. u32 imagesize;
  104. } efi_capsule_header_t;
  105. /*
  106. * Allocation types for calls to boottime->allocate_pages.
  107. */
  108. #define EFI_ALLOCATE_ANY_PAGES 0
  109. #define EFI_ALLOCATE_MAX_ADDRESS 1
  110. #define EFI_ALLOCATE_ADDRESS 2
  111. #define EFI_MAX_ALLOCATE_TYPE 3
  112. typedef int (*efi_freemem_callback_t) (u64 start, u64 end, void *arg);
  113. /*
  114. * Types and defines for Time Services
  115. */
  116. #define EFI_TIME_ADJUST_DAYLIGHT 0x1
  117. #define EFI_TIME_IN_DAYLIGHT 0x2
  118. #define EFI_UNSPECIFIED_TIMEZONE 0x07ff
  119. typedef struct {
  120. u16 year;
  121. u8 month;
  122. u8 day;
  123. u8 hour;
  124. u8 minute;
  125. u8 second;
  126. u8 pad1;
  127. u32 nanosecond;
  128. s16 timezone;
  129. u8 daylight;
  130. u8 pad2;
  131. } efi_time_t;
  132. typedef struct {
  133. u32 resolution;
  134. u32 accuracy;
  135. u8 sets_to_zero;
  136. } efi_time_cap_t;
  137. typedef struct {
  138. efi_table_hdr_t hdr;
  139. u32 raise_tpl;
  140. u32 restore_tpl;
  141. u32 allocate_pages;
  142. u32 free_pages;
  143. u32 get_memory_map;
  144. u32 allocate_pool;
  145. u32 free_pool;
  146. u32 create_event;
  147. u32 set_timer;
  148. u32 wait_for_event;
  149. u32 signal_event;
  150. u32 close_event;
  151. u32 check_event;
  152. u32 install_protocol_interface;
  153. u32 reinstall_protocol_interface;
  154. u32 uninstall_protocol_interface;
  155. u32 handle_protocol;
  156. u32 __reserved;
  157. u32 register_protocol_notify;
  158. u32 locate_handle;
  159. u32 locate_device_path;
  160. u32 install_configuration_table;
  161. u32 load_image;
  162. u32 start_image;
  163. u32 exit;
  164. u32 unload_image;
  165. u32 exit_boot_services;
  166. u32 get_next_monotonic_count;
  167. u32 stall;
  168. u32 set_watchdog_timer;
  169. u32 connect_controller;
  170. u32 disconnect_controller;
  171. u32 open_protocol;
  172. u32 close_protocol;
  173. u32 open_protocol_information;
  174. u32 protocols_per_handle;
  175. u32 locate_handle_buffer;
  176. u32 locate_protocol;
  177. u32 install_multiple_protocol_interfaces;
  178. u32 uninstall_multiple_protocol_interfaces;
  179. u32 calculate_crc32;
  180. u32 copy_mem;
  181. u32 set_mem;
  182. u32 create_event_ex;
  183. } __packed efi_boot_services_32_t;
  184. typedef struct {
  185. efi_table_hdr_t hdr;
  186. u64 raise_tpl;
  187. u64 restore_tpl;
  188. u64 allocate_pages;
  189. u64 free_pages;
  190. u64 get_memory_map;
  191. u64 allocate_pool;
  192. u64 free_pool;
  193. u64 create_event;
  194. u64 set_timer;
  195. u64 wait_for_event;
  196. u64 signal_event;
  197. u64 close_event;
  198. u64 check_event;
  199. u64 install_protocol_interface;
  200. u64 reinstall_protocol_interface;
  201. u64 uninstall_protocol_interface;
  202. u64 handle_protocol;
  203. u64 __reserved;
  204. u64 register_protocol_notify;
  205. u64 locate_handle;
  206. u64 locate_device_path;
  207. u64 install_configuration_table;
  208. u64 load_image;
  209. u64 start_image;
  210. u64 exit;
  211. u64 unload_image;
  212. u64 exit_boot_services;
  213. u64 get_next_monotonic_count;
  214. u64 stall;
  215. u64 set_watchdog_timer;
  216. u64 connect_controller;
  217. u64 disconnect_controller;
  218. u64 open_protocol;
  219. u64 close_protocol;
  220. u64 open_protocol_information;
  221. u64 protocols_per_handle;
  222. u64 locate_handle_buffer;
  223. u64 locate_protocol;
  224. u64 install_multiple_protocol_interfaces;
  225. u64 uninstall_multiple_protocol_interfaces;
  226. u64 calculate_crc32;
  227. u64 copy_mem;
  228. u64 set_mem;
  229. u64 create_event_ex;
  230. } __packed efi_boot_services_64_t;
  231. /*
  232. * EFI Boot Services table
  233. */
  234. typedef struct {
  235. efi_table_hdr_t hdr;
  236. void *raise_tpl;
  237. void *restore_tpl;
  238. efi_status_t (*allocate_pages)(int, int, unsigned long,
  239. efi_physical_addr_t *);
  240. efi_status_t (*free_pages)(efi_physical_addr_t, unsigned long);
  241. efi_status_t (*get_memory_map)(unsigned long *, void *, unsigned long *,
  242. unsigned long *, u32 *);
  243. efi_status_t (*allocate_pool)(int, unsigned long, void **);
  244. efi_status_t (*free_pool)(void *);
  245. void *create_event;
  246. void *set_timer;
  247. void *wait_for_event;
  248. void *signal_event;
  249. void *close_event;
  250. void *check_event;
  251. void *install_protocol_interface;
  252. void *reinstall_protocol_interface;
  253. void *uninstall_protocol_interface;
  254. efi_status_t (*handle_protocol)(efi_handle_t, efi_guid_t *, void **);
  255. void *__reserved;
  256. void *register_protocol_notify;
  257. void *locate_handle;
  258. void *locate_device_path;
  259. void *install_configuration_table;
  260. void *load_image;
  261. void *start_image;
  262. void *exit;
  263. void *unload_image;
  264. efi_status_t (*exit_boot_services)(efi_handle_t, unsigned long);
  265. void *get_next_monotonic_count;
  266. void *stall;
  267. void *set_watchdog_timer;
  268. void *connect_controller;
  269. void *disconnect_controller;
  270. void *open_protocol;
  271. void *close_protocol;
  272. void *open_protocol_information;
  273. void *protocols_per_handle;
  274. void *locate_handle_buffer;
  275. void *locate_protocol;
  276. void *install_multiple_protocol_interfaces;
  277. void *uninstall_multiple_protocol_interfaces;
  278. void *calculate_crc32;
  279. void *copy_mem;
  280. void *set_mem;
  281. void *create_event_ex;
  282. } efi_boot_services_t;
  283. typedef enum {
  284. EfiPciIoWidthUint8,
  285. EfiPciIoWidthUint16,
  286. EfiPciIoWidthUint32,
  287. EfiPciIoWidthUint64,
  288. EfiPciIoWidthFifoUint8,
  289. EfiPciIoWidthFifoUint16,
  290. EfiPciIoWidthFifoUint32,
  291. EfiPciIoWidthFifoUint64,
  292. EfiPciIoWidthFillUint8,
  293. EfiPciIoWidthFillUint16,
  294. EfiPciIoWidthFillUint32,
  295. EfiPciIoWidthFillUint64,
  296. EfiPciIoWidthMaximum
  297. } EFI_PCI_IO_PROTOCOL_WIDTH;
  298. typedef enum {
  299. EfiPciIoAttributeOperationGet,
  300. EfiPciIoAttributeOperationSet,
  301. EfiPciIoAttributeOperationEnable,
  302. EfiPciIoAttributeOperationDisable,
  303. EfiPciIoAttributeOperationSupported,
  304. EfiPciIoAttributeOperationMaximum
  305. } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;
  306. typedef struct {
  307. u32 read;
  308. u32 write;
  309. } efi_pci_io_protocol_access_32_t;
  310. typedef struct {
  311. u64 read;
  312. u64 write;
  313. } efi_pci_io_protocol_access_64_t;
  314. typedef struct {
  315. void *read;
  316. void *write;
  317. } efi_pci_io_protocol_access_t;
  318. typedef struct {
  319. u32 poll_mem;
  320. u32 poll_io;
  321. efi_pci_io_protocol_access_32_t mem;
  322. efi_pci_io_protocol_access_32_t io;
  323. efi_pci_io_protocol_access_32_t pci;
  324. u32 copy_mem;
  325. u32 map;
  326. u32 unmap;
  327. u32 allocate_buffer;
  328. u32 free_buffer;
  329. u32 flush;
  330. u32 get_location;
  331. u32 attributes;
  332. u32 get_bar_attributes;
  333. u32 set_bar_attributes;
  334. uint64_t romsize;
  335. void *romimage;
  336. } efi_pci_io_protocol_32;
  337. typedef struct {
  338. u64 poll_mem;
  339. u64 poll_io;
  340. efi_pci_io_protocol_access_64_t mem;
  341. efi_pci_io_protocol_access_64_t io;
  342. efi_pci_io_protocol_access_64_t pci;
  343. u64 copy_mem;
  344. u64 map;
  345. u64 unmap;
  346. u64 allocate_buffer;
  347. u64 free_buffer;
  348. u64 flush;
  349. u64 get_location;
  350. u64 attributes;
  351. u64 get_bar_attributes;
  352. u64 set_bar_attributes;
  353. uint64_t romsize;
  354. void *romimage;
  355. } efi_pci_io_protocol_64;
  356. typedef struct {
  357. void *poll_mem;
  358. void *poll_io;
  359. efi_pci_io_protocol_access_t mem;
  360. efi_pci_io_protocol_access_t io;
  361. efi_pci_io_protocol_access_t pci;
  362. void *copy_mem;
  363. void *map;
  364. void *unmap;
  365. void *allocate_buffer;
  366. void *free_buffer;
  367. void *flush;
  368. void *get_location;
  369. void *attributes;
  370. void *get_bar_attributes;
  371. void *set_bar_attributes;
  372. uint64_t romsize;
  373. void *romimage;
  374. } efi_pci_io_protocol;
  375. #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
  376. #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002
  377. #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004
  378. #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008
  379. #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010
  380. #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
  381. #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
  382. #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
  383. #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100
  384. #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200
  385. #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400
  386. #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800
  387. #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000
  388. #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000
  389. #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000
  390. #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
  391. #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000
  392. #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
  393. #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000
  394. /*
  395. * Types and defines for EFI ResetSystem
  396. */
  397. #define EFI_RESET_COLD 0
  398. #define EFI_RESET_WARM 1
  399. #define EFI_RESET_SHUTDOWN 2
  400. /*
  401. * EFI Runtime Services table
  402. */
  403. #define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL)
  404. #define EFI_RUNTIME_SERVICES_REVISION 0x00010000
  405. typedef struct {
  406. efi_table_hdr_t hdr;
  407. u32 get_time;
  408. u32 set_time;
  409. u32 get_wakeup_time;
  410. u32 set_wakeup_time;
  411. u32 set_virtual_address_map;
  412. u32 convert_pointer;
  413. u32 get_variable;
  414. u32 get_next_variable;
  415. u32 set_variable;
  416. u32 get_next_high_mono_count;
  417. u32 reset_system;
  418. u32 update_capsule;
  419. u32 query_capsule_caps;
  420. u32 query_variable_info;
  421. } efi_runtime_services_32_t;
  422. typedef struct {
  423. efi_table_hdr_t hdr;
  424. u64 get_time;
  425. u64 set_time;
  426. u64 get_wakeup_time;
  427. u64 set_wakeup_time;
  428. u64 set_virtual_address_map;
  429. u64 convert_pointer;
  430. u64 get_variable;
  431. u64 get_next_variable;
  432. u64 set_variable;
  433. u64 get_next_high_mono_count;
  434. u64 reset_system;
  435. u64 update_capsule;
  436. u64 query_capsule_caps;
  437. u64 query_variable_info;
  438. } efi_runtime_services_64_t;
  439. typedef struct {
  440. efi_table_hdr_t hdr;
  441. void *get_time;
  442. void *set_time;
  443. void *get_wakeup_time;
  444. void *set_wakeup_time;
  445. void *set_virtual_address_map;
  446. void *convert_pointer;
  447. void *get_variable;
  448. void *get_next_variable;
  449. void *set_variable;
  450. void *get_next_high_mono_count;
  451. void *reset_system;
  452. void *update_capsule;
  453. void *query_capsule_caps;
  454. void *query_variable_info;
  455. } efi_runtime_services_t;
  456. typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc);
  457. typedef efi_status_t efi_set_time_t (efi_time_t *tm);
  458. typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending,
  459. efi_time_t *tm);
  460. typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm);
  461. typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr,
  462. unsigned long *data_size, void *data);
  463. typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name,
  464. efi_guid_t *vendor);
  465. typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor,
  466. u32 attr, unsigned long data_size,
  467. void *data);
  468. typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count);
  469. typedef void efi_reset_system_t (int reset_type, efi_status_t status,
  470. unsigned long data_size, efi_char16_t *data);
  471. typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size,
  472. unsigned long descriptor_size,
  473. u32 descriptor_version,
  474. efi_memory_desc_t *virtual_map);
  475. typedef efi_status_t efi_query_variable_info_t(u32 attr,
  476. u64 *storage_space,
  477. u64 *remaining_space,
  478. u64 *max_variable_size);
  479. typedef efi_status_t efi_update_capsule_t(efi_capsule_header_t **capsules,
  480. unsigned long count,
  481. unsigned long sg_list);
  482. typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules,
  483. unsigned long count,
  484. u64 *max_size,
  485. int *reset_type);
  486. typedef efi_status_t efi_query_variable_store_t(u32 attributes, unsigned long size);
  487. void efi_native_runtime_setup(void);
  488. /*
  489. * EFI Configuration Table and GUID definitions
  490. */
  491. #define NULL_GUID \
  492. EFI_GUID( 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )
  493. #define MPS_TABLE_GUID \
  494. EFI_GUID( 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
  495. #define ACPI_TABLE_GUID \
  496. EFI_GUID( 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
  497. #define ACPI_20_TABLE_GUID \
  498. EFI_GUID( 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 )
  499. #define SMBIOS_TABLE_GUID \
  500. EFI_GUID( 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
  501. #define SAL_SYSTEM_TABLE_GUID \
  502. EFI_GUID( 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
  503. #define HCDP_TABLE_GUID \
  504. EFI_GUID( 0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 )
  505. #define UGA_IO_PROTOCOL_GUID \
  506. EFI_GUID( 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 )
  507. #define EFI_GLOBAL_VARIABLE_GUID \
  508. EFI_GUID( 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c )
  509. #define UV_SYSTEM_TABLE_GUID \
  510. EFI_GUID( 0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 )
  511. #define LINUX_EFI_CRASH_GUID \
  512. EFI_GUID( 0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0 )
  513. #define LOADED_IMAGE_PROTOCOL_GUID \
  514. EFI_GUID( 0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
  515. #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
  516. EFI_GUID( 0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a )
  517. #define EFI_UGA_PROTOCOL_GUID \
  518. EFI_GUID( 0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 )
  519. #define EFI_PCI_IO_PROTOCOL_GUID \
  520. EFI_GUID( 0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a )
  521. #define EFI_FILE_INFO_ID \
  522. EFI_GUID( 0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
  523. #define EFI_FILE_SYSTEM_GUID \
  524. EFI_GUID( 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
  525. #define DEVICE_TREE_GUID \
  526. EFI_GUID( 0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 )
  527. typedef struct {
  528. efi_guid_t guid;
  529. u64 table;
  530. } efi_config_table_64_t;
  531. typedef struct {
  532. efi_guid_t guid;
  533. u32 table;
  534. } efi_config_table_32_t;
  535. typedef struct {
  536. efi_guid_t guid;
  537. unsigned long table;
  538. } efi_config_table_t;
  539. typedef struct {
  540. efi_guid_t guid;
  541. const char *name;
  542. unsigned long *ptr;
  543. } efi_config_table_type_t;
  544. #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
  545. #define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30))
  546. #define EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20))
  547. #define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10))
  548. #define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00))
  549. #define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10))
  550. #define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02))
  551. typedef struct {
  552. efi_table_hdr_t hdr;
  553. u64 fw_vendor; /* physical addr of CHAR16 vendor string */
  554. u32 fw_revision;
  555. u32 __pad1;
  556. u64 con_in_handle;
  557. u64 con_in;
  558. u64 con_out_handle;
  559. u64 con_out;
  560. u64 stderr_handle;
  561. u64 stderr;
  562. u64 runtime;
  563. u64 boottime;
  564. u32 nr_tables;
  565. u32 __pad2;
  566. u64 tables;
  567. } efi_system_table_64_t;
  568. typedef struct {
  569. efi_table_hdr_t hdr;
  570. u32 fw_vendor; /* physical addr of CHAR16 vendor string */
  571. u32 fw_revision;
  572. u32 con_in_handle;
  573. u32 con_in;
  574. u32 con_out_handle;
  575. u32 con_out;
  576. u32 stderr_handle;
  577. u32 stderr;
  578. u32 runtime;
  579. u32 boottime;
  580. u32 nr_tables;
  581. u32 tables;
  582. } efi_system_table_32_t;
  583. typedef struct {
  584. efi_table_hdr_t hdr;
  585. unsigned long fw_vendor; /* physical addr of CHAR16 vendor string */
  586. u32 fw_revision;
  587. unsigned long con_in_handle;
  588. unsigned long con_in;
  589. unsigned long con_out_handle;
  590. unsigned long con_out;
  591. unsigned long stderr_handle;
  592. unsigned long stderr;
  593. efi_runtime_services_t *runtime;
  594. efi_boot_services_t *boottime;
  595. unsigned long nr_tables;
  596. unsigned long tables;
  597. } efi_system_table_t;
  598. struct efi_memory_map {
  599. void *phys_map;
  600. void *map;
  601. void *map_end;
  602. int nr_map;
  603. unsigned long desc_version;
  604. unsigned long desc_size;
  605. };
  606. struct efi_fdt_params {
  607. u64 system_table;
  608. u64 mmap;
  609. u32 mmap_size;
  610. u32 desc_size;
  611. u32 desc_ver;
  612. };
  613. typedef struct {
  614. u32 revision;
  615. u32 parent_handle;
  616. u32 system_table;
  617. u32 device_handle;
  618. u32 file_path;
  619. u32 reserved;
  620. u32 load_options_size;
  621. u32 load_options;
  622. u32 image_base;
  623. __aligned_u64 image_size;
  624. unsigned int image_code_type;
  625. unsigned int image_data_type;
  626. unsigned long unload;
  627. } efi_loaded_image_32_t;
  628. typedef struct {
  629. u32 revision;
  630. u64 parent_handle;
  631. u64 system_table;
  632. u64 device_handle;
  633. u64 file_path;
  634. u64 reserved;
  635. u32 load_options_size;
  636. u64 load_options;
  637. u64 image_base;
  638. __aligned_u64 image_size;
  639. unsigned int image_code_type;
  640. unsigned int image_data_type;
  641. unsigned long unload;
  642. } efi_loaded_image_64_t;
  643. typedef struct {
  644. u32 revision;
  645. void *parent_handle;
  646. efi_system_table_t *system_table;
  647. void *device_handle;
  648. void *file_path;
  649. void *reserved;
  650. u32 load_options_size;
  651. void *load_options;
  652. void *image_base;
  653. __aligned_u64 image_size;
  654. unsigned int image_code_type;
  655. unsigned int image_data_type;
  656. unsigned long unload;
  657. } efi_loaded_image_t;
  658. typedef struct {
  659. u64 size;
  660. u64 file_size;
  661. u64 phys_size;
  662. efi_time_t create_time;
  663. efi_time_t last_access_time;
  664. efi_time_t modification_time;
  665. __aligned_u64 attribute;
  666. efi_char16_t filename[1];
  667. } efi_file_info_t;
  668. typedef struct {
  669. u64 revision;
  670. u32 open;
  671. u32 close;
  672. u32 delete;
  673. u32 read;
  674. u32 write;
  675. u32 get_position;
  676. u32 set_position;
  677. u32 get_info;
  678. u32 set_info;
  679. u32 flush;
  680. } efi_file_handle_32_t;
  681. typedef struct {
  682. u64 revision;
  683. u64 open;
  684. u64 close;
  685. u64 delete;
  686. u64 read;
  687. u64 write;
  688. u64 get_position;
  689. u64 set_position;
  690. u64 get_info;
  691. u64 set_info;
  692. u64 flush;
  693. } efi_file_handle_64_t;
  694. typedef struct _efi_file_handle {
  695. u64 revision;
  696. efi_status_t (*open)(struct _efi_file_handle *,
  697. struct _efi_file_handle **,
  698. efi_char16_t *, u64, u64);
  699. efi_status_t (*close)(struct _efi_file_handle *);
  700. void *delete;
  701. efi_status_t (*read)(struct _efi_file_handle *, unsigned long *,
  702. void *);
  703. void *write;
  704. void *get_position;
  705. void *set_position;
  706. efi_status_t (*get_info)(struct _efi_file_handle *, efi_guid_t *,
  707. unsigned long *, void *);
  708. void *set_info;
  709. void *flush;
  710. } efi_file_handle_t;
  711. typedef struct _efi_file_io_interface {
  712. u64 revision;
  713. int (*open_volume)(struct _efi_file_io_interface *,
  714. efi_file_handle_t **);
  715. } efi_file_io_interface_t;
  716. #define EFI_FILE_MODE_READ 0x0000000000000001
  717. #define EFI_FILE_MODE_WRITE 0x0000000000000002
  718. #define EFI_FILE_MODE_CREATE 0x8000000000000000
  719. #define EFI_INVALID_TABLE_ADDR (~0UL)
  720. /*
  721. * All runtime access to EFI goes through this structure:
  722. */
  723. extern struct efi {
  724. efi_system_table_t *systab; /* EFI system table */
  725. unsigned int runtime_version; /* Runtime services version */
  726. unsigned long mps; /* MPS table */
  727. unsigned long acpi; /* ACPI table (IA64 ext 0.71) */
  728. unsigned long acpi20; /* ACPI table (ACPI 2.0) */
  729. unsigned long smbios; /* SM BIOS table */
  730. unsigned long sal_systab; /* SAL system table */
  731. unsigned long boot_info; /* boot info table */
  732. unsigned long hcdp; /* HCDP table */
  733. unsigned long uga; /* UGA table */
  734. unsigned long uv_systab; /* UV system table */
  735. unsigned long fw_vendor; /* fw_vendor */
  736. unsigned long runtime; /* runtime table */
  737. unsigned long config_table; /* config tables */
  738. efi_get_time_t *get_time;
  739. efi_set_time_t *set_time;
  740. efi_get_wakeup_time_t *get_wakeup_time;
  741. efi_set_wakeup_time_t *set_wakeup_time;
  742. efi_get_variable_t *get_variable;
  743. efi_get_next_variable_t *get_next_variable;
  744. efi_set_variable_t *set_variable;
  745. efi_query_variable_info_t *query_variable_info;
  746. efi_update_capsule_t *update_capsule;
  747. efi_query_capsule_caps_t *query_capsule_caps;
  748. efi_get_next_high_mono_count_t *get_next_high_mono_count;
  749. efi_reset_system_t *reset_system;
  750. efi_set_virtual_address_map_t *set_virtual_address_map;
  751. struct efi_memory_map *memmap;
  752. unsigned long flags;
  753. } efi;
  754. static inline int
  755. efi_guidcmp (efi_guid_t left, efi_guid_t right)
  756. {
  757. return memcmp(&left, &right, sizeof (efi_guid_t));
  758. }
  759. static inline char *
  760. efi_guid_unparse(efi_guid_t *guid, char *out)
  761. {
  762. sprintf(out, "%pUl", guid->b);
  763. return out;
  764. }
  765. extern void efi_init (void);
  766. extern void *efi_get_pal_addr (void);
  767. extern void efi_map_pal_code (void);
  768. extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
  769. extern void efi_gettimeofday (struct timespec *ts);
  770. extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */
  771. #ifdef CONFIG_X86
  772. extern void efi_late_init(void);
  773. extern void efi_free_boot_services(void);
  774. extern efi_status_t efi_query_variable_store(u32 attributes, unsigned long size);
  775. #else
  776. static inline void efi_late_init(void) {}
  777. static inline void efi_free_boot_services(void) {}
  778. static inline efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
  779. {
  780. return EFI_SUCCESS;
  781. }
  782. #endif
  783. extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr);
  784. extern int efi_config_init(efi_config_table_type_t *arch_tables);
  785. extern u64 efi_get_iobase (void);
  786. extern u32 efi_mem_type (unsigned long phys_addr);
  787. extern u64 efi_mem_attributes (unsigned long phys_addr);
  788. extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
  789. extern int __init efi_uart_console_only (void);
  790. extern void efi_initialize_iomem_resources(struct resource *code_resource,
  791. struct resource *data_resource, struct resource *bss_resource);
  792. extern void efi_get_time(struct timespec *now);
  793. extern void efi_reserve_boot_services(void);
  794. extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose);
  795. extern struct efi_memory_map memmap;
  796. extern int efi_reboot_quirk_mode;
  797. extern bool efi_poweroff_required(void);
  798. /* Iterate through an efi_memory_map */
  799. #define for_each_efi_memory_desc(m, md) \
  800. for ((md) = (m)->map; \
  801. (md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \
  802. (md) = (void *)(md) + (m)->desc_size)
  803. /**
  804. * efi_range_is_wc - check the WC bit on an address range
  805. * @start: starting kvirt address
  806. * @len: length of range
  807. *
  808. * Consult the EFI memory map and make sure it's ok to set this range WC.
  809. * Returns true or false.
  810. */
  811. static inline int efi_range_is_wc(unsigned long start, unsigned long len)
  812. {
  813. unsigned long i;
  814. for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) {
  815. unsigned long paddr = __pa(start + i);
  816. if (!(efi_mem_attributes(paddr) & EFI_MEMORY_WC))
  817. return 0;
  818. }
  819. /* The range checked out */
  820. return 1;
  821. }
  822. #ifdef CONFIG_EFI_PCDP
  823. extern int __init efi_setup_pcdp_console(char *);
  824. #endif
  825. /*
  826. * We play games with efi_enabled so that the compiler will, if
  827. * possible, remove EFI-related code altogether.
  828. */
  829. #define EFI_BOOT 0 /* Were we booted from EFI? */
  830. #define EFI_SYSTEM_TABLES 1 /* Can we use EFI system tables? */
  831. #define EFI_CONFIG_TABLES 2 /* Can we use EFI config tables? */
  832. #define EFI_RUNTIME_SERVICES 3 /* Can we use runtime services? */
  833. #define EFI_MEMMAP 4 /* Can we use EFI memory map? */
  834. #define EFI_64BIT 5 /* Is the firmware 64-bit? */
  835. #define EFI_PARAVIRT 6 /* Access is via a paravirt interface */
  836. #define EFI_ARCH_1 7 /* First arch-specific bit */
  837. #ifdef CONFIG_EFI
  838. /*
  839. * Test whether the above EFI_* bits are enabled.
  840. */
  841. static inline bool efi_enabled(int feature)
  842. {
  843. return test_bit(feature, &efi.flags) != 0;
  844. }
  845. extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
  846. #else
  847. static inline bool efi_enabled(int feature)
  848. {
  849. return false;
  850. }
  851. static inline void
  852. efi_reboot(enum reboot_mode reboot_mode, const char *__unused) {}
  853. #endif
  854. /*
  855. * Variable Attributes
  856. */
  857. #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
  858. #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
  859. #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
  860. #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008
  861. #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010
  862. #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020
  863. #define EFI_VARIABLE_APPEND_WRITE 0x0000000000000040
  864. #define EFI_VARIABLE_MASK (EFI_VARIABLE_NON_VOLATILE | \
  865. EFI_VARIABLE_BOOTSERVICE_ACCESS | \
  866. EFI_VARIABLE_RUNTIME_ACCESS | \
  867. EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
  868. EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \
  869. EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
  870. EFI_VARIABLE_APPEND_WRITE)
  871. /*
  872. * Length of a GUID string (strlen("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"))
  873. * not including trailing NUL
  874. */
  875. #define EFI_VARIABLE_GUID_LEN 36
  876. /*
  877. * The type of search to perform when calling boottime->locate_handle
  878. */
  879. #define EFI_LOCATE_ALL_HANDLES 0
  880. #define EFI_LOCATE_BY_REGISTER_NOTIFY 1
  881. #define EFI_LOCATE_BY_PROTOCOL 2
  882. /*
  883. * EFI Device Path information
  884. */
  885. #define EFI_DEV_HW 0x01
  886. #define EFI_DEV_PCI 1
  887. #define EFI_DEV_PCCARD 2
  888. #define EFI_DEV_MEM_MAPPED 3
  889. #define EFI_DEV_VENDOR 4
  890. #define EFI_DEV_CONTROLLER 5
  891. #define EFI_DEV_ACPI 0x02
  892. #define EFI_DEV_BASIC_ACPI 1
  893. #define EFI_DEV_EXPANDED_ACPI 2
  894. #define EFI_DEV_MSG 0x03
  895. #define EFI_DEV_MSG_ATAPI 1
  896. #define EFI_DEV_MSG_SCSI 2
  897. #define EFI_DEV_MSG_FC 3
  898. #define EFI_DEV_MSG_1394 4
  899. #define EFI_DEV_MSG_USB 5
  900. #define EFI_DEV_MSG_USB_CLASS 15
  901. #define EFI_DEV_MSG_I20 6
  902. #define EFI_DEV_MSG_MAC 11
  903. #define EFI_DEV_MSG_IPV4 12
  904. #define EFI_DEV_MSG_IPV6 13
  905. #define EFI_DEV_MSG_INFINIBAND 9
  906. #define EFI_DEV_MSG_UART 14
  907. #define EFI_DEV_MSG_VENDOR 10
  908. #define EFI_DEV_MEDIA 0x04
  909. #define EFI_DEV_MEDIA_HARD_DRIVE 1
  910. #define EFI_DEV_MEDIA_CDROM 2
  911. #define EFI_DEV_MEDIA_VENDOR 3
  912. #define EFI_DEV_MEDIA_FILE 4
  913. #define EFI_DEV_MEDIA_PROTOCOL 5
  914. #define EFI_DEV_BIOS_BOOT 0x05
  915. #define EFI_DEV_END_PATH 0x7F
  916. #define EFI_DEV_END_PATH2 0xFF
  917. #define EFI_DEV_END_INSTANCE 0x01
  918. #define EFI_DEV_END_ENTIRE 0xFF
  919. struct efi_generic_dev_path {
  920. u8 type;
  921. u8 sub_type;
  922. u16 length;
  923. } __attribute ((packed));
  924. static inline void memrange_efi_to_native(u64 *addr, u64 *npages)
  925. {
  926. *npages = PFN_UP(*addr + (*npages<<EFI_PAGE_SHIFT)) - PFN_DOWN(*addr);
  927. *addr &= PAGE_MASK;
  928. }
  929. /*
  930. * EFI Variable support.
  931. *
  932. * Different firmware drivers can expose their EFI-like variables using
  933. * the following.
  934. */
  935. struct efivar_operations {
  936. efi_get_variable_t *get_variable;
  937. efi_get_next_variable_t *get_next_variable;
  938. efi_set_variable_t *set_variable;
  939. efi_query_variable_store_t *query_variable_store;
  940. };
  941. struct efivars {
  942. /*
  943. * ->lock protects two things:
  944. * 1) efivarfs_list and efivars_sysfs_list
  945. * 2) ->ops calls
  946. */
  947. spinlock_t lock;
  948. struct kset *kset;
  949. struct kobject *kobject;
  950. const struct efivar_operations *ops;
  951. };
  952. /*
  953. * The maximum size of VariableName + Data = 1024
  954. * Therefore, it's reasonable to save that much
  955. * space in each part of the structure,
  956. * and we use a page for reading/writing.
  957. */
  958. #define EFI_VAR_NAME_LEN 1024
  959. struct efi_variable {
  960. efi_char16_t VariableName[EFI_VAR_NAME_LEN/sizeof(efi_char16_t)];
  961. efi_guid_t VendorGuid;
  962. unsigned long DataSize;
  963. __u8 Data[1024];
  964. efi_status_t Status;
  965. __u32 Attributes;
  966. } __attribute__((packed));
  967. struct efivar_entry {
  968. struct efi_variable var;
  969. struct list_head list;
  970. struct kobject kobj;
  971. bool scanning;
  972. bool deleting;
  973. };
  974. struct efi_simple_text_output_protocol_32 {
  975. u32 reset;
  976. u32 output_string;
  977. u32 test_string;
  978. };
  979. struct efi_simple_text_output_protocol_64 {
  980. u64 reset;
  981. u64 output_string;
  982. u64 test_string;
  983. };
  984. struct efi_simple_text_output_protocol {
  985. void *reset;
  986. efi_status_t (*output_string)(void *, void *);
  987. void *test_string;
  988. };
  989. extern struct list_head efivar_sysfs_list;
  990. static inline void
  991. efivar_unregister(struct efivar_entry *var)
  992. {
  993. kobject_put(&var->kobj);
  994. }
  995. int efivars_register(struct efivars *efivars,
  996. const struct efivar_operations *ops,
  997. struct kobject *kobject);
  998. int efivars_unregister(struct efivars *efivars);
  999. struct kobject *efivars_kobject(void);
  1000. int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
  1001. void *data, bool atomic, bool duplicates,
  1002. struct list_head *head);
  1003. void efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
  1004. void efivar_entry_remove(struct efivar_entry *entry);
  1005. int __efivar_entry_delete(struct efivar_entry *entry);
  1006. int efivar_entry_delete(struct efivar_entry *entry);
  1007. int efivar_entry_size(struct efivar_entry *entry, unsigned long *size);
  1008. int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
  1009. unsigned long *size, void *data);
  1010. int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
  1011. unsigned long *size, void *data);
  1012. int efivar_entry_set(struct efivar_entry *entry, u32 attributes,
  1013. unsigned long size, void *data, struct list_head *head);
  1014. int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
  1015. unsigned long *size, void *data, bool *set);
  1016. int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
  1017. bool block, unsigned long size, void *data);
  1018. void efivar_entry_iter_begin(void);
  1019. void efivar_entry_iter_end(void);
  1020. int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
  1021. struct list_head *head, void *data,
  1022. struct efivar_entry **prev);
  1023. int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
  1024. struct list_head *head, void *data);
  1025. struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid,
  1026. struct list_head *head, bool remove);
  1027. bool efivar_validate(efi_char16_t *var_name, u8 *data, unsigned long len);
  1028. extern struct work_struct efivar_work;
  1029. void efivar_run_worker(void);
  1030. #if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE)
  1031. int efivars_sysfs_init(void);
  1032. #define EFIVARS_DATA_SIZE_MAX 1024
  1033. #endif /* CONFIG_EFI_VARS */
  1034. #ifdef CONFIG_EFI_RUNTIME_MAP
  1035. int efi_runtime_map_init(struct kobject *);
  1036. void efi_runtime_map_setup(void *, int, u32);
  1037. int efi_get_runtime_map_size(void);
  1038. int efi_get_runtime_map_desc_size(void);
  1039. int efi_runtime_map_copy(void *buf, size_t bufsz);
  1040. #else
  1041. static inline int efi_runtime_map_init(struct kobject *kobj)
  1042. {
  1043. return 0;
  1044. }
  1045. static inline void
  1046. efi_runtime_map_setup(void *map, int nr_entries, u32 desc_size) {}
  1047. static inline int efi_get_runtime_map_size(void)
  1048. {
  1049. return 0;
  1050. }
  1051. static inline int efi_get_runtime_map_desc_size(void)
  1052. {
  1053. return 0;
  1054. }
  1055. static inline int efi_runtime_map_copy(void *buf, size_t bufsz)
  1056. {
  1057. return 0;
  1058. }
  1059. #endif
  1060. /* prototypes shared between arch specific and generic stub code */
  1061. #define pr_efi(sys_table, msg) efi_printk(sys_table, "EFI stub: "msg)
  1062. #define pr_efi_err(sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg)
  1063. void efi_printk(efi_system_table_t *sys_table_arg, char *str);
  1064. void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,
  1065. unsigned long addr);
  1066. char *efi_convert_cmdline(efi_system_table_t *sys_table_arg,
  1067. efi_loaded_image_t *image, int *cmd_line_len);
  1068. efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
  1069. efi_memory_desc_t **map,
  1070. unsigned long *map_size,
  1071. unsigned long *desc_size,
  1072. u32 *desc_ver,
  1073. unsigned long *key_ptr);
  1074. efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,
  1075. unsigned long size, unsigned long align,
  1076. unsigned long *addr);
  1077. efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg,
  1078. unsigned long size, unsigned long align,
  1079. unsigned long *addr, unsigned long max);
  1080. efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg,
  1081. unsigned long *image_addr,
  1082. unsigned long image_size,
  1083. unsigned long alloc_size,
  1084. unsigned long preferred_addr,
  1085. unsigned long alignment);
  1086. efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
  1087. efi_loaded_image_t *image,
  1088. char *cmd_line, char *option_string,
  1089. unsigned long max_addr,
  1090. unsigned long *load_addr,
  1091. unsigned long *load_size);
  1092. efi_status_t efi_parse_options(char *cmdline);
  1093. bool efi_runtime_disabled(void);
  1094. #endif /* _LINUX_EFI_H */