]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - include/efi_api.h
Makefile: Don't mess with .text section location for selected arches
[people/ms/u-boot.git] / include / efi_api.h
index fcd7483ab21a36fd65befa8c2b61afc16e9ecdae..3ba650e57e6dae5b6cb5e533a9ba9caab8166db1 100644 (file)
@@ -28,8 +28,7 @@ enum efi_timer_delay {
        EFI_TIMER_RELATIVE = 2
 };
 
-#define UINTN size_t
-typedef long INTN;
+#define efi_uintn_t size_t
 typedef uint16_t *efi_string_t;
 
 #define EVT_TIMER                              0x80000000
@@ -49,20 +48,22 @@ struct efi_event;
 /* EFI Boot Services table */
 struct efi_boot_services {
        struct efi_table_hdr hdr;
-       efi_status_t (EFIAPI *raise_tpl)(UINTN new_tpl);
-       void (EFIAPI *restore_tpl)(UINTN old_tpl);
+       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, unsigned long,
+       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, unsigned long);
-       efi_status_t (EFIAPI *get_memory_map)(unsigned long *memory_map_size,
-                       struct efi_mem_desc *desc, unsigned long *key,
-                       unsigned long *desc_size, u32 *desc_version);
-       efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
+       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,
-                       UINTN notify_tpl,
+                       efi_uintn_t notify_tpl,
                        void (EFIAPI *notify_function) (
                                        struct efi_event *event,
                                        void *context),
@@ -70,8 +71,9 @@ struct efi_boot_services {
        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)(unsigned long number_of_events,
-                       struct efi_event **event, size_t *index);
+       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);
@@ -82,11 +84,12 @@ struct efi_boot_services {
        efi_status_t (EFIAPI *reinstall_protocol_interface)(
                        void *handle, const efi_guid_t *protocol,
                        void *old_interface, void *new_interface);
-       efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle,
-                       const efi_guid_t *protocol, void *protocol_interface);
-       efi_status_t (EFIAPI *handle_protocol)(efi_handle_t,
-                                              const efi_guid_t *protocol,
-                                              void **protocol_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,
@@ -94,7 +97,7 @@ struct efi_boot_services {
        efi_status_t (EFIAPI *locate_handle)(
                        enum efi_locate_search_type search_type,
                        const efi_guid_t *protocol, void *search_key,
-                       unsigned long *buffer_size, efi_handle_t *buffer);
+                       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);
@@ -111,7 +114,7 @@ struct efi_boot_services {
        efi_status_t (EFIAPI *exit)(efi_handle_t handle,
                                    efi_status_t exit_status,
                                    unsigned long exitdata_size, s16 *exitdata);
-       efi_status_t (EFIAPI *unload_image)(void *image_handle);
+       efi_status_t (EFIAPI *unload_image)(efi_handle_t image_handle);
        efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
 
        efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
@@ -123,8 +126,10 @@ struct efi_boot_services {
                        efi_handle_t *driver_image_handle,
                        struct efi_device_path *remaining_device_path,
                        bool recursive);
-       efi_status_t (EFIAPI *disconnect_controller)(void *controller_handle,
-                       void *driver_image_handle, void *child_handle);
+       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
@@ -135,20 +140,21 @@ struct efi_boot_services {
                        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)(void *handle,
-                       const efi_guid_t *protocol, void *agent_handle,
-                       void *controller_handle);
+       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,
-                       unsigned long *entry_count);
+                       efi_uintn_t *entry_count);
        efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
                        efi_guid_t ***protocol_buffer,
-                       unsigned long *protocols_buffer_count);
+                       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,
-                       unsigned long *no_handles, efi_handle_t **buffer);
+                       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)(
@@ -160,7 +166,14 @@ struct efi_boot_services {
        void (EFIAPI *copy_mem)(void *destination, const void *source,
                        size_t length);
        void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value);
-       void *create_event_ex;
+       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,
+                               efi_guid_t *event_group,
+                               struct efi_event **event);
 };
 
 /* Types and defines for EFI ResetSystem */
@@ -174,6 +187,17 @@ enum efi_reset_type {
 #define EFI_RUNTIME_SERVICES_SIGNATURE 0x5652453544e5552ULL
 #define EFI_RUNTIME_SERVICES_REVISION  0x00010000
 
+#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET     0x00010000
+#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE    0x00020000
+#define CAPSULE_FLAGS_INITIATE_RESET           0x00040000
+
+struct efi_capsule_header {
+       efi_guid_t *capsule_guid;
+       u32 header_size;
+       u32 flags;
+       u32 capsule_image_size;
+};
+
 struct efi_runtime_services {
        struct efi_table_hdr hdr;
        efi_status_t (EFIAPI *get_time)(struct efi_time *time,
@@ -203,9 +227,20 @@ struct efi_runtime_services {
        void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
                                    efi_status_t reset_status,
                                    unsigned long data_size, void *reset_data);
-       void *update_capsule;
-       void *query_capsule_caps;
-       void *query_variable_info;
+       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 Configuration Table and GUID definitions */
@@ -241,15 +276,15 @@ struct efi_system_table {
        struct efi_table_hdr hdr;
        unsigned long fw_vendor;   /* physical addr of wchar_t vendor string */
        u32 fw_revision;
-       unsigned long con_in_handle;
+       efi_handle_t con_in_handle;
        struct efi_simple_input_interface *con_in;
-       unsigned long con_out_handle;
+       efi_handle_t con_out_handle;
        struct efi_simple_text_output_protocol *con_out;
-       unsigned long stderr_handle;
+       efi_handle_t stderr_handle;
        struct efi_simple_text_output_protocol *std_err;
        struct efi_runtime_services *runtime;
        struct efi_boot_services *boottime;
-       unsigned long nr_tables;
+       efi_uintn_t nr_tables;
        struct efi_configuration_table *tables;
 };
 
@@ -327,12 +362,27 @@ struct efi_device_path_acpi_path {
 } __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_USB_CLASS   0x0f
 #  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_usb {
        struct efi_device_path dp;
        u8 parent_port_number;
@@ -403,18 +453,26 @@ struct efi_block_io_media
        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, unsigned long buffer_size,
+                       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, unsigned long buffer_size,
+                       u32 media_id, u64 lba, efi_uintn_t buffer_size,
                        void *buffer);
        efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
 };
@@ -583,14 +641,14 @@ struct efi_gop_mode
 struct efi_gop
 {
        efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number,
-                                         unsigned long *size_of_info,
+                                         efi_uintn_t *size_of_info,
                                          struct efi_gop_mode_info **info);
        efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number);
        efi_status_t (EFIAPI *blt)(struct efi_gop *this, void *buffer,
-                                  unsigned long operation, unsigned long sx,
-                                  unsigned long sy, unsigned long dx,
-                                  unsigned long dy, unsigned long width,
-                                  unsigned long height, unsigned long delta);
+                                  u32 operation, efi_uintn_t sx,
+                                  efi_uintn_t sy, efi_uintn_t dx,
+                                  efi_uintn_t dy, efi_uintn_t width,
+                                  efi_uintn_t height, efi_uintn_t delta);
        struct efi_gop_mode *mode;
 };
 
@@ -788,4 +846,26 @@ struct efi_file_info {
        s16 file_name[0];
 };
 
+#define EFI_DRIVER_BINDING_PROTOCOL_GUID \
+       EFI_GUID(0x18a031ab, 0xb443, 0x4d1a,\
+                0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71)
+struct efi_driver_binding_protocol {
+       efi_status_t (EFIAPI * supported)(
+                       struct efi_driver_binding_protocol *this,
+                       efi_handle_t controller_handle,
+                       struct efi_device_path *remaining_device_path);
+       efi_status_t (EFIAPI * start)(
+                       struct efi_driver_binding_protocol *this,
+                       efi_handle_t controller_handle,
+                       struct efi_device_path *remaining_device_path);
+       efi_status_t (EFIAPI * stop)(
+                       struct efi_driver_binding_protocol *this,
+                       efi_handle_t controller_handle,
+                       efi_uintn_t number_of_children,
+                       efi_handle_t *child_handle_buffer);
+       u32 version;
+       efi_handle_t image_handle;
+       efi_handle_t driver_binding_handle;
+};
+
 #endif