1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

include/efi_api.h: Add more detailed API definitions

The EFI API header is great, but missing a good chunk of function prototype,
GUID defines and enum declarations.

This patch extends it to cover more of the EFI API. It's still not 100%
complete, but sufficient enough for our EFI payload interface.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Alexander Graf
2016-03-04 01:09:57 +01:00
committed by Tom Rini
parent d96a98045a
commit 2bb9b79d64
2 changed files with 162 additions and 36 deletions

View File

@@ -38,6 +38,7 @@ struct efi_device_path;
#define EFI_WRITE_PROTECTED (8 | (1UL << (BITS_PER_LONG - 1))) #define EFI_WRITE_PROTECTED (8 | (1UL << (BITS_PER_LONG - 1)))
#define EFI_OUT_OF_RESOURCES (9 | (1UL << (BITS_PER_LONG - 1))) #define EFI_OUT_OF_RESOURCES (9 | (1UL << (BITS_PER_LONG - 1)))
#define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG - 1))) #define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG - 1)))
#define EFI_ACCESS_DENIED (15 | (1UL << (BITS_PER_LONG - 1)))
#define EFI_SECURITY_VIOLATION (26 | (1UL << (BITS_PER_LONG - 1))) #define EFI_SECURITY_VIOLATION (26 | (1UL << (BITS_PER_LONG - 1)))
typedef unsigned long efi_status_t; typedef unsigned long efi_status_t;
@@ -139,6 +140,7 @@ enum {
#define EFI_PAGE_SHIFT 12 #define EFI_PAGE_SHIFT 12
#define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT)
#define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1)
struct efi_mem_desc { struct efi_mem_desc {
u32 type; u32 type;

View File

@@ -17,11 +17,18 @@
#include <efi.h> #include <efi.h>
/* Types and defines for EFI CreateEvent */
enum efi_event_type {
EFI_TIMER_STOP = 0,
EFI_TIMER_PERIODIC = 1,
EFI_TIMER_RELATIVE = 2
};
/* EFI Boot Services table */ /* EFI Boot Services table */
struct efi_boot_services { struct efi_boot_services {
struct efi_table_hdr hdr; struct efi_table_hdr hdr;
void *raise_tpl; efi_status_t (EFIAPI *raise_tpl)(unsigned long new_tpl);
void *restore_tpl; void (EFIAPI *restore_tpl)(unsigned long old_tpl);
efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long, efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long,
efi_physical_addr_t *); efi_physical_addr_t *);
@@ -32,21 +39,33 @@ struct efi_boot_services {
efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **); efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
efi_status_t (EFIAPI *free_pool)(void *); efi_status_t (EFIAPI *free_pool)(void *);
void *create_event; efi_status_t (EFIAPI *create_event)(enum efi_event_type type,
void *set_timer; unsigned long notify_tpl,
efi_status_t(EFIAPI *wait_for_event)(unsigned long number_of_events, void (EFIAPI *notify_function) (void *event,
void *event, unsigned long *index); void *context),
void *signal_event; void *notify_context, void **event);
void *close_event; efi_status_t (EFIAPI *set_timer)(void *event, int type,
void *check_event; uint64_t trigger_time);
efi_status_t (EFIAPI *wait_for_event)(unsigned long number_of_events,
void *event, unsigned long *index);
efi_status_t (EFIAPI *signal_event)(void *event);
efi_status_t (EFIAPI *close_event)(void *event);
efi_status_t (EFIAPI *check_event)(void *event);
void *install_protocol_interface; efi_status_t (EFIAPI *install_protocol_interface)(
void *reinstall_protocol_interface; void **handle, efi_guid_t *protocol,
void *uninstall_protocol_interface; int protocol_interface_type, void *protocol_interface);
efi_status_t (EFIAPI *reinstall_protocol_interface)(
void *handle, efi_guid_t *protocol,
void *old_interface, void *new_interface);
efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle,
efi_guid_t *protocol, void *protocol_interface);
efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *, efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *,
void **); void **);
void *reserved; void *reserved;
void *register_protocol_notify; efi_status_t (EFIAPI *register_protocol_notify)(
efi_guid_t *protocol, void *event,
void **registration);
efi_status_t (EFIAPI *locate_handle)( efi_status_t (EFIAPI *locate_handle)(
enum efi_locate_search_type search_type, enum efi_locate_search_type search_type,
efi_guid_t *protocol, void *search_key, efi_guid_t *protocol, void *search_key,
@@ -54,7 +73,8 @@ struct efi_boot_services {
efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol, efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol,
struct efi_device_path **device_path, struct efi_device_path **device_path,
efi_handle_t *device); efi_handle_t *device);
void *install_configuration_table; efi_status_t (EFIAPI *install_configuration_table)(
efi_guid_t *guid, void *table);
efi_status_t (EFIAPI *load_image)(bool boot_policiy, efi_status_t (EFIAPI *load_image)(bool boot_policiy,
efi_handle_t parent_image, efi_handle_t parent_image,
@@ -66,17 +86,20 @@ struct efi_boot_services {
efi_status_t (EFIAPI *exit)(efi_handle_t handle, efi_status_t (EFIAPI *exit)(efi_handle_t handle,
efi_status_t exit_status, efi_status_t exit_status,
unsigned long exitdata_size, s16 *exitdata); unsigned long exitdata_size, s16 *exitdata);
void *unload_image; efi_status_t (EFIAPI *unload_image)(void *image_handle);
efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long); efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count); efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
efi_status_t (EFIAPI *stall)(unsigned long usecs); efi_status_t (EFIAPI *stall)(unsigned long usecs);
void *set_watchdog_timer; 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_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
efi_handle_t *driver_image_handle, efi_handle_t *driver_image_handle,
struct efi_device_path *remaining_device_path, struct efi_device_path *remaining_device_path,
bool recursive); bool recursive);
void *disconnect_controller; efi_status_t (EFIAPI *disconnect_controller)(void *controller_handle,
void *driver_image_handle, void *child_handle);
#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
@@ -87,7 +110,9 @@ struct efi_boot_services {
efi_guid_t *protocol, void **interface, efi_guid_t *protocol, void **interface,
efi_handle_t agent_handle, efi_handle_t agent_handle,
efi_handle_t controller_handle, u32 attributes); efi_handle_t controller_handle, u32 attributes);
void *close_protocol; efi_status_t (EFIAPI *close_protocol)(void *handle,
efi_guid_t *protocol, void *agent_handle,
void *controller_handle);
efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle, efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
efi_guid_t *protocol, efi_guid_t *protocol,
struct efi_open_protocol_info_entry **entry_buffer, struct efi_open_protocol_info_entry **entry_buffer,
@@ -99,12 +124,18 @@ struct efi_boot_services {
enum efi_locate_search_type search_type, enum efi_locate_search_type search_type,
efi_guid_t *protocol, void *search_key, efi_guid_t *protocol, void *search_key,
unsigned long *no_handles, efi_handle_t **buffer); unsigned long *no_handles, efi_handle_t **buffer);
void *locate_protocol; efi_status_t (EFIAPI *locate_protocol)(efi_guid_t *protocol,
void *install_multiple_protocol_interfaces; void *registration, void **protocol_interface);
void *uninstall_multiple_protocol_interfaces; efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
void *calculate_crc32; void **handle, ...);
void *copy_mem; efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
void *set_mem; void *handle, ...);
efi_status_t (EFIAPI *calculate_crc32)(void *data,
unsigned long data_size, uint32_t *crc32);
void (EFIAPI *copy_mem)(void *destination, void *source,
unsigned long length);
void (EFIAPI *set_mem)(void *buffer, unsigned long size,
uint8_t value);
void *create_event_ex; void *create_event_ex;
}; };
@@ -121,12 +152,19 @@ enum efi_reset_type {
struct efi_runtime_services { struct efi_runtime_services {
struct efi_table_hdr hdr; struct efi_table_hdr hdr;
void *get_time; efi_status_t (EFIAPI *get_time)(struct efi_time *time,
void *set_time; struct efi_time_cap *capabilities);
void *get_wakeup_time; efi_status_t (EFIAPI *set_time)(struct efi_time *time);
void *set_wakeup_time; efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
void *set_virtual_address_map; struct efi_time *time);
void *convert_pointer; efi_status_t (EFIAPI *set_wakeup_time)(char enabled,
struct efi_time *time);
efi_status_t (EFIAPI *set_virtual_address_map)(
unsigned long memory_map_size,
unsigned long descriptor_size,
uint32_t descriptor_version,
struct efi_mem_desc *virtmap);
efi_status_t (*convert_pointer)(unsigned long dbg, void **address);
efi_status_t (EFIAPI *get_variable)(s16 *variable_name, efi_status_t (EFIAPI *get_variable)(s16 *variable_name,
efi_guid_t *vendor, u32 *attributes, efi_guid_t *vendor, u32 *attributes,
unsigned long *data_size, void *data); unsigned long *data_size, void *data);
@@ -136,7 +174,8 @@ struct efi_runtime_services {
efi_status_t (EFIAPI *set_variable)(s16 *variable_name, efi_status_t (EFIAPI *set_variable)(s16 *variable_name,
efi_guid_t *vendor, u32 attributes, efi_guid_t *vendor, u32 attributes,
unsigned long data_size, void *data); unsigned long data_size, void *data);
void *get_next_high_mono_count; efi_status_t (EFIAPI *get_next_high_mono_count)(
uint32_t *high_count);
void (EFIAPI *reset_system)(enum efi_reset_type reset_type, void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
efi_status_t reset_status, efi_status_t reset_status,
unsigned long data_size, void *reset_data); unsigned long data_size, void *reset_data);
@@ -154,6 +193,18 @@ struct efi_runtime_services {
EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \ EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \
0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
#define EFI_FDT_GUID \
EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
struct efi_configuration_table
{
efi_guid_t guid;
void *table;
};
#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
struct efi_system_table { struct efi_system_table {
struct efi_table_hdr hdr; struct efi_table_hdr hdr;
unsigned long fw_vendor; /* physical addr of wchar_t vendor string */ unsigned long fw_vendor; /* physical addr of wchar_t vendor string */
@@ -163,13 +214,17 @@ struct efi_system_table {
unsigned long con_out_handle; unsigned long con_out_handle;
struct efi_simple_text_output_protocol *con_out; struct efi_simple_text_output_protocol *con_out;
unsigned long stderr_handle; unsigned long stderr_handle;
unsigned long std_err; struct efi_simple_text_output_protocol *std_err;
struct efi_runtime_services *runtime; struct efi_runtime_services *runtime;
struct efi_boot_services *boottime; struct efi_boot_services *boottime;
unsigned long nr_tables; unsigned long nr_tables;
unsigned long tables; struct efi_configuration_table *tables;
}; };
#define LOADED_IMAGE_GUID \
EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
struct efi_loaded_image { struct efi_loaded_image {
u32 revision; u32 revision;
void *parent_handle; void *parent_handle;
@@ -186,12 +241,60 @@ struct efi_loaded_image {
unsigned long unload; unsigned long unload;
}; };
#define DEVICE_PATH_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_END 0xff
struct efi_device_path { struct efi_device_path {
u8 type; u8 type;
u8 sub_type; u8 sub_type;
u16 length; u16 length;
}; };
#define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04
# define DEVICE_PATH_SUB_TYPE_FILE_PATH 0x04
struct efi_device_path_file_path {
struct efi_device_path dp;
u16 str[16];
};
#define BLOCK_IO_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;
};
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, unsigned long buffer_size,
void *buffer);
efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
u32 media_id, u64 lba, unsigned long buffer_size,
void *buffer);
efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
};
struct simple_text_output_mode { struct simple_text_output_mode {
s32 max_mode; s32 max_mode;
s32 mode; s32 mode;
@@ -206,8 +309,9 @@ struct efi_simple_text_output_protocol {
efi_status_t (EFIAPI *output_string)( efi_status_t (EFIAPI *output_string)(
struct efi_simple_text_output_protocol *this, struct efi_simple_text_output_protocol *this,
const unsigned short *str); const unsigned short *str);
void *test_string; efi_status_t (EFIAPI *test_string)(
struct efi_simple_text_output_protocol *this,
const unsigned short *str);
efi_status_t(EFIAPI *query_mode)( efi_status_t(EFIAPI *query_mode)(
struct efi_simple_text_output_protocol *this, struct efi_simple_text_output_protocol *this,
unsigned long mode_number, unsigned long *columns, unsigned long mode_number, unsigned long *columns,
@@ -223,7 +327,9 @@ struct efi_simple_text_output_protocol {
efi_status_t(EFIAPI *set_cursor_position) ( efi_status_t(EFIAPI *set_cursor_position) (
struct efi_simple_text_output_protocol *this, struct efi_simple_text_output_protocol *this,
unsigned long column, unsigned long row); unsigned long column, unsigned long row);
efi_status_t(EFIAPI *enable_cursor)(void *, bool enable); efi_status_t(EFIAPI *enable_cursor)(
struct efi_simple_text_output_protocol *this,
bool enable);
struct simple_text_output_mode *mode; struct simple_text_output_mode *mode;
}; };
@@ -241,4 +347,22 @@ struct efi_simple_input_interface {
void *wait_for_key; void *wait_for_key;
}; };
#define CONSOLE_CONTROL_GUID \
EFI_GUID(0xf42f7782, 0x12e, 0x4c12, \
0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21)
#define EFI_CONSOLE_MODE_TEXT 0
#define EFI_CONSOLE_MODE_GFX 1
struct efi_console_control_protocol
{
efi_status_t (EFIAPI *get_mode)(
struct efi_console_control_protocol *this, int *mode,
char *uga_exists, char *std_in_locked);
efi_status_t (EFIAPI *set_mode)(
struct efi_console_control_protocol *this, int mode);
efi_status_t (EFIAPI *lock_std_in)(
struct efi_console_control_protocol *this,
uint16_t *password);
};
#endif #endif