-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
efi_api.h
2165 lines (1943 loc) · 68.4 KB
/
efi_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Extensible Firmware Interface
* Based on 'Extensible Firmware Interface Specification' version 0.9,
* April 30, 1999
*
* Copyright (C) 1999 VA Linux Systems
* Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
* Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
* David Mosberger-Tang <davidm@hpl.hp.com>
* Stephane Eranian <eranian@hpl.hp.com>
*
* From include/linux/efi.h in kernel 4.1 with some additions/subtractions
*/
#ifndef _EFI_API_H
#define _EFI_API_H
#include <efi.h>
#include <charset.h>
#include <pe.h>
/* UEFI spec version 2.9 */
#define EFI_SPECIFICATION_VERSION (2 << 16 | 100)
/* Types and defines for EFI CreateEvent */
enum efi_timer_delay {
EFI_TIMER_STOP = 0,
EFI_TIMER_PERIODIC = 1,
EFI_TIMER_RELATIVE = 2
};
typedef void *efi_hii_handle_t;
typedef u16 *efi_string_t;
typedef u16 efi_string_id_t;
typedef u32 efi_hii_font_style_t;
typedef u16 efi_question_id_t;
typedef u16 efi_image_id_t;
typedef u16 efi_form_id_t;
#define EVT_TIMER 0x80000000
#define EVT_RUNTIME 0x40000000
#define EVT_NOTIFY_WAIT 0x00000100
#define EVT_NOTIFY_SIGNAL 0x00000200
#define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
#define TPL_APPLICATION 0x04
#define TPL_CALLBACK 0x08
#define TPL_NOTIFY 0x10
#define TPL_HIGH_LEVEL 0x1F
struct efi_event;
/* OsIndicationsSupported flags */
#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001
#define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002
#define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED 0x0000000000000004
#define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED 0x0000000000000008
#define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED 0x0000000000000010
#define EFI_OS_INDICATIONS_START_OS_RECOVERY 0x0000000000000020
#define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY 0x0000000000000040
#define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH 0x0000000000000080
/* EFI Boot Services table */
#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
struct efi_boot_services {
struct efi_table_hdr hdr;
efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl);
void (EFIAPI *restore_tpl)(efi_uintn_t old_tpl);
efi_status_t (EFIAPI *allocate_pages)(int, int, efi_uintn_t,
efi_physical_addr_t *);
efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, efi_uintn_t);
efi_status_t (EFIAPI *get_memory_map)(efi_uintn_t *memory_map_size,
struct efi_mem_desc *desc,
efi_uintn_t *key,
efi_uintn_t *desc_size,
u32 *desc_version);
efi_status_t (EFIAPI *allocate_pool)(int, efi_uintn_t, void **);
efi_status_t (EFIAPI *free_pool)(void *);
efi_status_t (EFIAPI *create_event)(uint32_t type,
efi_uintn_t notify_tpl,
void (EFIAPI *notify_function) (
struct efi_event *event,
void *context),
void *notify_context, struct efi_event **event);
efi_status_t (EFIAPI *set_timer)(struct efi_event *event,
enum efi_timer_delay type,
uint64_t trigger_time);
efi_status_t (EFIAPI *wait_for_event)(efi_uintn_t number_of_events,
struct efi_event **event,
efi_uintn_t *index);
efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
efi_status_t (EFIAPI *close_event)(struct efi_event *event);
efi_status_t (EFIAPI *check_event)(struct efi_event *event);
#define EFI_NATIVE_INTERFACE 0x00000000
efi_status_t (EFIAPI *install_protocol_interface)(
efi_handle_t *handle, const efi_guid_t *protocol,
int protocol_interface_type, void *protocol_interface);
efi_status_t (EFIAPI *reinstall_protocol_interface)(
efi_handle_t handle, const efi_guid_t *protocol,
void *old_interface, void *new_interface);
efi_status_t (EFIAPI *uninstall_protocol_interface)(
efi_handle_t handle, const efi_guid_t *protocol,
void *protocol_interface);
efi_status_t (EFIAPI *handle_protocol)(
efi_handle_t handle, const efi_guid_t *protocol,
void **protocol_interface);
void *reserved;
efi_status_t (EFIAPI *register_protocol_notify)(
const efi_guid_t *protocol, struct efi_event *event,
void **registration);
efi_status_t (EFIAPI *locate_handle)(
enum efi_locate_search_type search_type,
const efi_guid_t *protocol, void *search_key,
efi_uintn_t *buffer_size, efi_handle_t *buffer);
efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol,
struct efi_device_path **device_path,
efi_handle_t *device);
efi_status_t (EFIAPI *install_configuration_table)(
const efi_guid_t *guid, void *table);
efi_status_t (EFIAPI *load_image)(bool boot_policiy,
efi_handle_t parent_image,
struct efi_device_path *file_path, void *source_buffer,
efi_uintn_t source_size, efi_handle_t *image);
efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
efi_uintn_t *exitdata_size,
u16 **exitdata);
efi_status_t (EFIAPI *exit)(efi_handle_t handle,
efi_status_t exit_status,
efi_uintn_t exitdata_size, u16 *exitdata);
efi_status_t (EFIAPI *unload_image)(efi_handle_t image_handle);
efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t image_handle,
efi_uintn_t map_key);
efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
efi_status_t (EFIAPI *stall)(unsigned long usecs);
efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout,
uint64_t watchdog_code, unsigned long data_size,
uint16_t *watchdog_data);
efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
efi_handle_t *driver_image_handle,
struct efi_device_path *remaining_device_path,
bool recursive);
efi_status_t (EFIAPI *disconnect_controller)(
efi_handle_t controller_handle,
efi_handle_t driver_image_handle,
efi_handle_t child_handle);
#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
const efi_guid_t *protocol, void **interface,
efi_handle_t agent_handle,
efi_handle_t controller_handle, u32 attributes);
efi_status_t (EFIAPI *close_protocol)(
efi_handle_t handle, const efi_guid_t *protocol,
efi_handle_t agent_handle,
efi_handle_t controller_handle);
efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
const efi_guid_t *protocol,
struct efi_open_protocol_info_entry **entry_buffer,
efi_uintn_t *entry_count);
efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
efi_guid_t ***protocol_buffer,
efi_uintn_t *protocols_buffer_count);
efi_status_t (EFIAPI *locate_handle_buffer) (
enum efi_locate_search_type search_type,
const efi_guid_t *protocol, void *search_key,
efi_uintn_t *no_handles, efi_handle_t **buffer);
efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol,
void *registration, void **protocol_interface);
efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
efi_handle_t *handle, ...);
efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
efi_handle_t handle, ...);
efi_status_t (EFIAPI *calculate_crc32)(const void *data,
efi_uintn_t data_size,
u32 *crc32);
void (EFIAPI *copy_mem)(void *destination, const void *source,
size_t length);
void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value);
efi_status_t (EFIAPI *create_event_ex)(
uint32_t type, efi_uintn_t notify_tpl,
void (EFIAPI *notify_function) (
struct efi_event *event,
void *context),
void *notify_context,
const efi_guid_t *event_group,
struct efi_event **event);
};
/* Types and defines for EFI ResetSystem */
enum efi_reset_type {
EFI_RESET_COLD = 0,
EFI_RESET_WARM = 1,
EFI_RESET_SHUTDOWN = 2,
EFI_RESET_PLATFORM_SPECIFIC = 3,
};
/* EFI Runtime Services table */
#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552ULL
#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000
#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000
#define CAPSULE_FLAGS_INITIATE_RESET 0x00040000
#define CAPSULE_SUPPORT_AUTHENTICATION 0x0000000000000001
#define CAPSULE_SUPPORT_DEPENDENCY 0x0000000000000002
#define EFI_CAPSULE_REPORT_GUID \
EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \
0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3)
#define EFI_MEMORY_RANGE_CAPSULE_GUID \
EFI_GUID(0xde9f0ec, 0x88b6, 0x428f, 0x97, 0x7a, \
0x25, 0x8f, 0x1d, 0xe, 0x5e, 0x72)
#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \
EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
#define EFI_CONFORMANCE_PROFILES_TABLE_GUID \
EFI_GUID(0x36122546, 0xf7ef, 0x4c8f, 0xbd, 0x9b, \
0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b)
#define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1
#define EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID \
EFI_GUID(0xcce33c35, 0x74ac, 0x4087, 0xbc, 0xe7, \
0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27)
struct efi_conformance_profiles_table {
u16 version;
u16 number_of_profiles;
efi_guid_t conformance_profiles[];
} __packed;
struct efi_capsule_header {
efi_guid_t capsule_guid;
u32 header_size;
u32 flags;
u32 capsule_image_size;
} __packed;
struct efi_capsule_result_variable_header {
u32 variable_total_size;
u32 reserved;
efi_guid_t capsule_guid;
struct efi_time capsule_processed;
efi_status_t capsule_status;
} __packed;
struct efi_memory_range {
efi_physical_addr_t address;
u64 length;
};
struct efi_memory_range_capsule {
struct efi_capsule_header *header;
/* EFI_MEMORY_TYPE: 0x80000000-0xFFFFFFFF */
enum efi_memory_type os_requested_memory_type;
u64 number_of_memory_ranges;
struct efi_memory_range memory_ranges[];
} __packed;
struct efi_firmware_management_capsule_header {
u32 version;
u16 embedded_driver_count;
u16 payload_item_count;
u64 item_offset_list[];
} __packed;
struct efi_firmware_management_capsule_image_header {
u32 version;
efi_guid_t update_image_type_id;
u8 update_image_index;
u8 reserved[3];
u32 update_image_size;
u32 update_vendor_code_size;
u64 update_hardware_instance;
u64 image_capsule_support;
} __packed;
struct efi_capsule_result_variable_fmp {
u16 version;
u8 payload_index;
u8 update_image_index;
efi_guid_t update_image_type_id;
// u16 capsule_file_name[];
// u16 capsule_target[];
} __packed;
#define EFI_RT_SUPPORTED_GET_TIME 0x0001
#define EFI_RT_SUPPORTED_SET_TIME 0x0002
#define EFI_RT_SUPPORTED_GET_WAKEUP_TIME 0x0004
#define EFI_RT_SUPPORTED_SET_WAKEUP_TIME 0x0008
#define EFI_RT_SUPPORTED_GET_VARIABLE 0x0010
#define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME 0x0020
#define EFI_RT_SUPPORTED_SET_VARIABLE 0x0040
#define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP 0x0080
#define EFI_RT_SUPPORTED_CONVERT_POINTER 0x0100
#define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT 0x0200
#define EFI_RT_SUPPORTED_RESET_SYSTEM 0x0400
#define EFI_RT_SUPPORTED_UPDATE_CAPSULE 0x0800
#define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES 0x1000
#define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO 0x2000
#define EFI_RT_PROPERTIES_TABLE_GUID \
EFI_GUID(0xeb66918a, 0x7eef, 0x402a, 0x84, 0x2e, \
0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9)
#define EFI_RT_PROPERTIES_TABLE_VERSION 0x1
struct efi_rt_properties_table {
u16 version;
u16 length;
u32 runtime_services_supported;
};
#define EFI_OPTIONAL_PTR 0x00000001
struct efi_runtime_services {
struct efi_table_hdr hdr;
efi_status_t (EFIAPI *get_time)(struct efi_time *time,
struct efi_time_cap *capabilities);
efi_status_t (EFIAPI *set_time)(struct efi_time *time);
efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
struct efi_time *time);
efi_status_t (EFIAPI *set_wakeup_time)(char enabled,
struct efi_time *time);
efi_status_t (EFIAPI *set_virtual_address_map)(
efi_uintn_t memory_map_size,
efi_uintn_t descriptor_size,
uint32_t descriptor_version,
struct efi_mem_desc *virtmap);
efi_status_t (EFIAPI *convert_pointer)(
efi_uintn_t debug_disposition, void **address);
efi_status_t (EFIAPI *get_variable)(u16 *variable_name,
const efi_guid_t *vendor,
u32 *attributes,
efi_uintn_t *data_size, void *data);
efi_status_t (EFIAPI *get_next_variable_name)(
efi_uintn_t *variable_name_size,
u16 *variable_name, efi_guid_t *vendor);
efi_status_t (EFIAPI *set_variable)(u16 *variable_name,
const efi_guid_t *vendor,
u32 attributes,
efi_uintn_t data_size,
const void *data);
efi_status_t (EFIAPI *get_next_high_mono_count)(
uint32_t *high_count);
void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
efi_status_t reset_status,
unsigned long data_size, void *reset_data);
efi_status_t (EFIAPI *update_capsule)(
struct efi_capsule_header **capsule_header_array,
efi_uintn_t capsule_count,
u64 scatter_gather_list);
efi_status_t (EFIAPI *query_capsule_caps)(
struct efi_capsule_header **capsule_header_array,
efi_uintn_t capsule_count,
u64 *maximum_capsule_size,
u32 *reset_type);
efi_status_t (EFIAPI *query_variable_info)(
u32 attributes,
u64 *maximum_variable_storage_size,
u64 *remaining_variable_storage_size,
u64 *maximum_variable_size);
};
/* EFI event group GUID definitions */
#define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \
EFI_GUID(0x27abf055, 0xb1b8, 0x4c26, 0x80, 0x48, \
0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf)
#define EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES \
EFI_GUID(0x8be0e274, 0x3970, 0x4b44, 0x80, 0xc5, \
0x1a, 0xb9, 0x50, 0x2f, 0x3b, 0xfc)
#define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \
EFI_GUID(0x13fa7698, 0xc831, 0x49c7, 0x87, 0xea, \
0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96)
#define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \
EFI_GUID(0x78bee926, 0x692f, 0x48fd, 0x9e, 0xdb, \
0x01, 0x42, 0x2e, 0xf0, 0xd7, 0xab)
#define EFI_EVENT_GROUP_READY_TO_BOOT \
EFI_GUID(0x7ce88fb3, 0x4bd7, 0x4679, 0x87, 0xa8, \
0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b)
#define EFI_EVENT_GROUP_AFTER_READY_TO_BOOT \
EFI_GUID(0x3a2a00ad, 0x98b9, 0x4cdf, 0xa4, 0x78, \
0x70, 0x27, 0x77, 0xf1, 0xc1, 0xb)
#define EFI_EVENT_GROUP_RESET_SYSTEM \
EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \
0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b)
#define EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR \
EFI_GUID(0xb4a40fe6, 0x9149, 0x4f29, 0x94, 0x47, \
0x49, 0x38, 0x7a, 0x7f, 0xab, 0x87)
/* EFI Configuration Table and GUID definitions */
#define NULL_GUID \
EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
#define EFI_GLOBAL_VARIABLE_GUID \
EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
#define EFI_IMAGE_SECURITY_DATABASE_GUID \
EFI_GUID(0xd719b2cb, 0x3d3a, 0x4596, 0xa3, 0xbc, \
0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f)
#define EFI_FDT_GUID \
EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
#define EFI_ACPI_TABLE_GUID \
EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, \
0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)
#define SMBIOS_TABLE_GUID \
EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, \
0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
#define SMBIOS3_TABLE_GUID \
EFI_GUID(0xf2fd1544, 0x9794, 0x4a2c, \
0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94)
#define EFI_LOAD_FILE_PROTOCOL_GUID \
EFI_GUID(0x56ec3091, 0x954c, 0x11d2, \
0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
#define EFI_LOAD_FILE2_PROTOCOL_GUID \
EFI_GUID(0x4006c0c1, 0xfcb3, 0x403e, \
0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d)
#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID \
EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, \
0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25)
#define EFI_RNG_PROTOCOL_GUID \
EFI_GUID(0x3152bca5, 0xeade, 0x433d, 0x86, 0x2e, \
0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44)
#define EFI_DT_FIXUP_PROTOCOL_GUID \
EFI_GUID(0xe617d64c, 0xfe08, 0x46da, 0xf4, 0xdc, \
0xbb, 0xd5, 0x87, 0x0c, 0x73, 0x00)
#define EFI_TCG2_PROTOCOL_GUID \
EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
#define RISCV_EFI_BOOT_PROTOCOL_GUID \
EFI_GUID(0xccd15fec, 0x6f73, 0x4eec, 0x83, \
0x95, 0x3e, 0x69, 0xe4, 0xb9, 0x40, 0xbf)
/**
* struct efi_configuration_table - EFI Configuration Table
*
* This table contains a set of GUID/pointer pairs.
* The EFI Configuration Table may contain at most one instance of each table type.
*
* @guid: GUID that uniquely identifies the system configuration table
* @table: A pointer to the table associated with guid
*/
struct efi_configuration_table {
efi_guid_t guid;
void *table;
} __packed;
#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
/**
* struct efi_system_table - EFI System Table
*
* EFI System Table contains pointers to the runtime and boot services tables.
*
* @hdr: The table header for the EFI System Table
* @fw_vendor: A pointer to a null terminated string that identifies the vendor
* that produces the system firmware
* @fw_revision: The revision of the system firmware
* @con_in_handle: The handle for the active console input device
* @con_in: A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface
* that is associated with con_in_handle
* @con_out_handle: The handle for the active console output device
* @con_out: A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface
* that is associated with con_out_handle
* @stderr_handle: The handle for the active standard error console device
* @std_err: A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface
* that is associated with stderr_handle
* @runtime: A pointer to the EFI Runtime Services Table
* @boottime: A pointer to the EFI Boot Services Table
* @nr_tables: The number of system configuration tables
* @tables: A pointer to the system configuration tables
*/
struct efi_system_table {
struct efi_table_hdr hdr;
u16 *fw_vendor; /* physical addr of wchar_t vendor string */
u32 fw_revision;
efi_handle_t con_in_handle;
struct efi_simple_text_input_protocol *con_in;
efi_handle_t con_out_handle;
struct efi_simple_text_output_protocol *con_out;
efi_handle_t stderr_handle;
struct efi_simple_text_output_protocol *std_err;
struct efi_runtime_services *runtime;
struct efi_boot_services *boottime;
efi_uintn_t nr_tables;
struct efi_configuration_table *tables;
};
/**
* efi_main() - entry point of EFI applications
*
* @image_handle: handle with the Loaded Image Protocol
* @systab: pointer to the system table
* Return: status code
*/
efi_status_t EFIAPI efi_main(efi_handle_t image_handle,
struct efi_system_table *systab);
#define EFI_LOADED_IMAGE_PROTOCOL_GUID \
EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \
EFI_GUID(0xbc62157e, 0x3e33, 0x4fec, \
0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf)
#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000
struct efi_loaded_image {
u32 revision;
void *parent_handle;
struct efi_system_table *system_table;
efi_handle_t device_handle;
struct efi_device_path *file_path;
void *reserved;
u32 load_options_size;
void *load_options;
void *image_base;
aligned_u64 image_size;
unsigned int image_code_type;
unsigned int image_data_type;
efi_status_t (EFIAPI *unload)(efi_handle_t image_handle);
};
#define EFI_DEVICE_PATH_PROTOCOL_GUID \
EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \
0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
#define DEVICE_PATH_TYPE_END 0x7f
# define DEVICE_PATH_SUB_TYPE_INSTANCE_END 0x01
# define DEVICE_PATH_SUB_TYPE_END 0xff
struct efi_mac_addr {
u8 addr[32];
} __packed;
#define DEVICE_PATH_TYPE_HARDWARE_DEVICE 0x01
# define DEVICE_PATH_SUB_TYPE_MEMORY 0x03
# define DEVICE_PATH_SUB_TYPE_VENDOR 0x04
# define DEVICE_PATH_SUB_TYPE_CONTROLLER 0x05
struct efi_device_path_memory {
struct efi_device_path dp;
u32 memory_type;
u64 start_address;
u64 end_address;
} __packed;
struct efi_device_path_vendor {
struct efi_device_path dp;
efi_guid_t guid;
u8 vendor_data[];
} __packed;
struct efi_device_path_udevice {
struct efi_device_path dp;
efi_guid_t guid;
int uclass_id;
int dev_number;
} __packed;
struct efi_device_path_controller {
struct efi_device_path dp;
u32 controller_number;
} __packed;
#define DEVICE_PATH_TYPE_ACPI_DEVICE 0x02
# define DEVICE_PATH_SUB_TYPE_ACPI_DEVICE 0x01
#define EFI_PNP_ID(ID) (u32)(((ID) << 16) | 0x41D0)
#define EISA_PNP_ID(ID) EFI_PNP_ID(ID)
#define EISA_PNP_NUM(ID) ((ID) >> 16)
struct efi_device_path_acpi_path {
struct efi_device_path dp;
u32 hid;
u32 uid;
} __packed;
#define DEVICE_PATH_TYPE_MESSAGING_DEVICE 0x03
# define DEVICE_PATH_SUB_TYPE_MSG_ATAPI 0x01
# define DEVICE_PATH_SUB_TYPE_MSG_SCSI 0x02
# define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05
# define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b
# define DEVICE_PATH_SUB_TYPE_MSG_UART 0x0e
# define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f
# define DEVICE_PATH_SUB_TYPE_MSG_USB_WWI 0x10
# define DEVICE_PATH_SUB_TYPE_MSG_SATA 0x12
# define DEVICE_PATH_SUB_TYPE_MSG_NVME 0x17
# define DEVICE_PATH_SUB_TYPE_MSG_URI 0x18
# define DEVICE_PATH_SUB_TYPE_MSG_SD 0x1a
# define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d
struct efi_device_path_atapi {
struct efi_device_path dp;
u8 primary_secondary;
u8 slave_master;
u16 logical_unit_number;
} __packed;
struct efi_device_path_scsi {
struct efi_device_path dp;
u16 target_id;
u16 logical_unit_number;
} __packed;
struct efi_device_path_uart {
struct efi_device_path dp;
u32 reserved;
u64 baud_rate;
u8 data_bits;
u8 parity;
u8 stop_bits;
} __packed;
struct efi_device_path_usb {
struct efi_device_path dp;
u8 parent_port_number;
u8 usb_interface;
} __packed;
struct efi_device_path_sata {
struct efi_device_path dp;
u16 hba_port;
u16 port_multiplier_port;
u16 logical_unit_number;
} __packed;
struct efi_device_path_mac_addr {
struct efi_device_path dp;
struct efi_mac_addr mac;
u8 if_type;
} __packed;
struct efi_device_path_usb_class {
struct efi_device_path dp;
u16 vendor_id;
u16 product_id;
u8 device_class;
u8 device_subclass;
u8 device_protocol;
} __packed;
struct efi_device_path_sd_mmc_path {
struct efi_device_path dp;
u8 slot_number;
} __packed;
struct efi_device_path_nvme {
struct efi_device_path dp;
u32 ns_id;
u8 eui64[8];
} __packed;
struct efi_device_path_uri {
struct efi_device_path dp;
u8 uri[];
} __packed;
#define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04
# define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01
# define DEVICE_PATH_SUB_TYPE_CDROM_PATH 0x02
# define DEVICE_PATH_SUB_TYPE_VENDOR_PATH 0x03
# define DEVICE_PATH_SUB_TYPE_FILE_PATH 0x04
struct efi_device_path_hard_drive_path {
struct efi_device_path dp;
u32 partition_number;
u64 partition_start;
u64 partition_end;
u8 partition_signature[16];
u8 partmap_type;
u8 signature_type;
} __packed;
struct efi_device_path_cdrom_path {
struct efi_device_path dp;
u32 boot_entry;
u64 partition_start;
u64 partition_size;
} __packed;
struct efi_device_path_file_path {
struct efi_device_path dp;
u16 str[];
} __packed;
#define EFI_BLOCK_IO_PROTOCOL_GUID \
EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
struct efi_block_io_media {
u32 media_id;
char removable_media;
char media_present;
char logical_partition;
char read_only;
char write_caching;
u8 pad[3];
u32 block_size;
u32 io_align;
u8 pad2[4];
u64 last_block;
/* Added in revision 2 of the protocol */
u64 lowest_aligned_lba;
u32 logical_blocks_per_physical_block;
/* Added in revision 3 of the protocol */
u32 optimal_transfer_length_granualarity;
};
#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
#define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x0002001f
struct efi_block_io {
u64 revision;
struct efi_block_io_media *media;
efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
char extended_verification);
efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
u32 media_id, u64 lba, efi_uintn_t buffer_size,
void *buffer);
efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
u32 media_id, u64 lba, efi_uintn_t buffer_size,
void *buffer);
efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
};
struct simple_text_output_mode {
s32 max_mode;
s32 mode;
s32 attribute;
s32 cursor_column;
s32 cursor_row;
bool cursor_visible;
};
#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \
0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
#define EFI_BLACK 0x00
#define EFI_BLUE 0x01
#define EFI_GREEN 0x02
#define EFI_CYAN 0x03
#define EFI_RED 0x04
#define EFI_MAGENTA 0x05
#define EFI_BROWN 0x06
#define EFI_LIGHTGRAY 0x07
#define EFI_BRIGHT 0x08
#define EFI_DARKGRAY 0x08
#define EFI_LIGHTBLUE 0x09
#define EFI_LIGHTGREEN 0x0a
#define EFI_LIGHTCYAN 0x0b
#define EFI_LIGHTRED 0x0c
#define EFI_LIGHTMAGENTA 0x0d
#define EFI_YELLOW 0x0e
#define EFI_WHITE 0x0f
#define EFI_BACKGROUND_BLACK 0x00
#define EFI_BACKGROUND_BLUE 0x10
#define EFI_BACKGROUND_GREEN 0x20
#define EFI_BACKGROUND_CYAN 0x30
#define EFI_BACKGROUND_RED 0x40
#define EFI_BACKGROUND_MAGENTA 0x50
#define EFI_BACKGROUND_BROWN 0x60
#define EFI_BACKGROUND_LIGHTGRAY 0x70
/* extract foreground color from EFI attribute */
#define EFI_ATTR_FG(attr) ((attr) & 0x07)
/* treat high bit of FG as bright/bold (similar to edk2) */
#define EFI_ATTR_BOLD(attr) (((attr) >> 3) & 0x01)
/* extract background color from EFI attribute */
#define EFI_ATTR_BG(attr) (((attr) >> 4) & 0x7)
struct efi_simple_text_output_protocol {
efi_status_t (EFIAPI *reset)(
struct efi_simple_text_output_protocol *this,
char extended_verification);
efi_status_t (EFIAPI *output_string)(
struct efi_simple_text_output_protocol *this,
const u16 *str);
efi_status_t (EFIAPI *test_string)(
struct efi_simple_text_output_protocol *this,
const u16 *str);
efi_status_t(EFIAPI *query_mode)(
struct efi_simple_text_output_protocol *this,
unsigned long mode_number, unsigned long *columns,
unsigned long *rows);
efi_status_t(EFIAPI *set_mode)(
struct efi_simple_text_output_protocol *this,
unsigned long mode_number);
efi_status_t(EFIAPI *set_attribute)(
struct efi_simple_text_output_protocol *this,
unsigned long attribute);
efi_status_t(EFIAPI *clear_screen) (
struct efi_simple_text_output_protocol *this);
efi_status_t(EFIAPI *set_cursor_position) (
struct efi_simple_text_output_protocol *this,
unsigned long column, unsigned long row);
efi_status_t(EFIAPI *enable_cursor)(
struct efi_simple_text_output_protocol *this,
bool enable);
struct simple_text_output_mode *mode;
};
#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
EFI_GUID(0xdd9e7534, 0x7762, 0x4698, \
0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa)
struct efi_input_key {
u16 scan_code;
u16 unicode_char;
};
#define EFI_SHIFT_STATE_INVALID 0x00000000
#define EFI_RIGHT_SHIFT_PRESSED 0x00000001
#define EFI_LEFT_SHIFT_PRESSED 0x00000002
#define EFI_RIGHT_CONTROL_PRESSED 0x00000004
#define EFI_LEFT_CONTROL_PRESSED 0x00000008
#define EFI_RIGHT_ALT_PRESSED 0x00000010
#define EFI_LEFT_ALT_PRESSED 0x00000020
#define EFI_RIGHT_LOGO_PRESSED 0x00000040
#define EFI_LEFT_LOGO_PRESSED 0x00000080
#define EFI_MENU_KEY_PRESSED 0x00000100
#define EFI_SYS_REQ_PRESSED 0x00000200
#define EFI_SHIFT_STATE_VALID 0x80000000
#define EFI_TOGGLE_STATE_INVALID 0x00
#define EFI_SCROLL_LOCK_ACTIVE 0x01
#define EFI_NUM_LOCK_ACTIVE 0x02
#define EFI_CAPS_LOCK_ACTIVE 0x04
#define EFI_KEY_STATE_EXPOSED 0x40
#define EFI_TOGGLE_STATE_VALID 0x80
struct efi_key_state {
u32 key_shift_state;
u8 key_toggle_state;
};
struct efi_key_data {
struct efi_input_key key;
struct efi_key_state key_state;
};
struct efi_simple_text_input_ex_protocol {
efi_status_t (EFIAPI *reset) (
struct efi_simple_text_input_ex_protocol *this,
bool extended_verification);
efi_status_t (EFIAPI *read_key_stroke_ex) (
struct efi_simple_text_input_ex_protocol *this,
struct efi_key_data *key_data);
struct efi_event *wait_for_key_ex;
efi_status_t (EFIAPI *set_state) (
struct efi_simple_text_input_ex_protocol *this,
u8 *key_toggle_state);
efi_status_t (EFIAPI *register_key_notify) (
struct efi_simple_text_input_ex_protocol *this,
struct efi_key_data *key_data,
efi_status_t (EFIAPI *key_notify_function)(
struct efi_key_data *key_data),
void **notify_handle);
efi_status_t (EFIAPI *unregister_key_notify) (
struct efi_simple_text_input_ex_protocol *this,
void *notification_handle);
};
#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
EFI_GUID(0x387477c1, 0x69c7, 0x11d2, \
0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
struct efi_simple_text_input_protocol {
efi_status_t(EFIAPI *reset)(struct efi_simple_text_input_protocol *this,
bool extended_verification);
efi_status_t(EFIAPI *read_key_stroke)(
struct efi_simple_text_input_protocol *this,
struct efi_input_key *key);
struct efi_event *wait_for_key;
};
#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
EFI_GUID(0x8b843e20, 0x8132, 0x4852, \
0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
struct efi_device_path_to_text_protocol {
uint16_t *(EFIAPI *convert_device_node_to_text)(
struct efi_device_path *device_node,
bool display_only,
bool allow_shortcuts);
uint16_t *(EFIAPI *convert_device_path_to_text)(
struct efi_device_path *device_path,
bool display_only,
bool allow_shortcuts);
};
#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
EFI_GUID(0x0379be4e, 0xd706, 0x437d, \
0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4)
struct efi_device_path_utilities_protocol {
efi_uintn_t (EFIAPI *get_device_path_size)(
const struct efi_device_path *device_path);
struct efi_device_path *(EFIAPI *duplicate_device_path)(
const struct efi_device_path *device_path);
struct efi_device_path *(EFIAPI *append_device_path)(
const struct efi_device_path *src1,
const struct efi_device_path *src2);
struct efi_device_path *(EFIAPI *append_device_node)(
const struct efi_device_path *device_path,
const struct efi_device_path *device_node);
struct efi_device_path *(EFIAPI *append_device_path_instance)(
const struct efi_device_path *device_path,
const struct efi_device_path *device_path_instance);
struct efi_device_path *(EFIAPI *get_next_device_path_instance)(
struct efi_device_path **device_path_instance,
efi_uintn_t *device_path_instance_size);
bool (EFIAPI *is_device_path_multi_instance)(
const struct efi_device_path *device_path);
struct efi_device_path *(EFIAPI *create_device_node)(
uint8_t node_type,
uint8_t node_sub_type,
uint16_t node_length);
};
/*
* Human Interface Infrastructure (HII)
*/
struct efi_hii_package_list_header {
efi_guid_t package_list_guid;
u32 package_length;
} __packed;
/**
* struct efi_hii_package_header - EFI HII package header
*
* @fields: 'fields' replaces the bit-fields defined in the EFI
* specification to to avoid possible compiler incompatibilities::
*
* u32 length:24;
* u32 type:8;
*/
struct efi_hii_package_header {
u32 fields;
} __packed;
#define __EFI_HII_PACKAGE_LEN_SHIFT 0
#define __EFI_HII_PACKAGE_TYPE_SHIFT 24
#define __EFI_HII_PACKAGE_LEN_MASK 0xffffff
#define __EFI_HII_PACKAGE_TYPE_MASK 0xff
#define EFI_HII_PACKAGE_TYPE_ALL 0x00
#define EFI_HII_PACKAGE_TYPE_GUID 0x01
#define EFI_HII_PACKAGE_FORMS 0x02
#define EFI_HII_PACKAGE_STRINGS 0x04
#define EFI_HII_PACKAGE_FONTS 0x05
#define EFI_HII_PACKAGE_IMAGES 0x06
#define EFI_HII_PACKAGE_SIMPLE_FONTS 0x07
#define EFI_HII_PACKAGE_DEVICE_PATH 0x08
#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT 0x09
#define EFI_HII_PACKAGE_ANIMATIONS 0x0A
#define EFI_HII_PACKAGE_END 0xDF
#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0
#define EFI_HII_PACKAGE_TYPE_SYSTEM_END 0xFF
/*
* HII GUID package
*/
struct efi_hii_guid_package {