arm: imx7d: add support for Compulab cl-som-imx7
[oweals/u-boot.git] / include / efi_api.h
index a1f8221111ace2157afbd4ead01bcdf4f0442c0d..c3b9032a48d2919d6c0cf5a673bc9319f6a5ce1f 100644 (file)
 #endif
 
 /* Types and defines for EFI CreateEvent */
-enum efi_event_type {
+enum efi_timer_delay {
        EFI_TIMER_STOP = 0,
        EFI_TIMER_PERIODIC = 1,
        EFI_TIMER_RELATIVE = 2
 };
 
-#define EVT_NOTIFY_WAIT                0x00000100
-#define EVT_NOTIFY_SIGNAL      0x00000200
+#define UINTN size_t
+typedef long INTN;
+typedef uint16_t *efi_string_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;
 
 /* EFI Boot Services table */
 struct efi_boot_services {
        struct efi_table_hdr hdr;
-       efi_status_t (EFIAPI *raise_tpl)(unsigned long new_tpl);
-       void (EFIAPI *restore_tpl)(unsigned long old_tpl);
+       efi_status_t (EFIAPI *raise_tpl)(UINTN new_tpl);
+       void (EFIAPI *restore_tpl)(UINTN old_tpl);
 
        efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long,
                                              efi_physical_addr_t *);
@@ -48,14 +61,15 @@ struct efi_boot_services {
        efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
        efi_status_t (EFIAPI *free_pool)(void *);
 
-       efi_status_t (EFIAPI *create_event)(enum efi_event_type type,
-                       unsigned long notify_tpl,
+       efi_status_t (EFIAPI *create_event)(uint32_t type,
+                       UINTN 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, int type,
-                       uint64_t trigger_time);
+       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, unsigned long *index);
        efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
@@ -199,6 +213,10 @@ struct efi_runtime_services {
        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 LOADED_IMAGE_PROTOCOL_GUID \
        EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \
                 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
@@ -272,28 +290,93 @@ struct efi_device_path {
        u8 type;
        u8 sub_type;
        u16 length;
-};
+} __packed;
 
 struct efi_mac_addr {
        u8 addr[32];
-};
+} __packed;
+
+#define DEVICE_PATH_TYPE_HARDWARE_DEVICE       0x01
+#  define DEVICE_PATH_SUB_TYPE_VENDOR          0x04
+
+struct efi_device_path_vendor {
+       struct efi_device_path dp;
+       efi_guid_t guid;
+       u8 vendor_data[];
+} __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_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_usb {
+       struct efi_device_path dp;
+       u8 parent_port_number;
+       u8 usb_interface;
+} __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;
 
 #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_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_end;
+} __packed;
+
 struct efi_device_path_file_path {
        struct efi_device_path dp;
-       u16 str[32];
-};
+       u16 str[];
+} __packed;
 
 #define BLOCK_IO_GUID \
        EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
@@ -337,14 +420,19 @@ struct simple_text_output_mode {
        bool cursor_visible;
 };
 
+
+#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
+       EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \
+                0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+
 struct efi_simple_text_output_protocol {
        void *reset;
        efi_status_t (EFIAPI *output_string)(
                        struct efi_simple_text_output_protocol *this,
-                       const unsigned short *str);
+                       const efi_string_t str);
        efi_status_t (EFIAPI *test_string)(
                        struct efi_simple_text_output_protocol *this,
-                       const unsigned short *str);
+                       const efi_string_t str);
        efi_status_t(EFIAPI *query_mode)(
                        struct efi_simple_text_output_protocol *this,
                        unsigned long mode_number, unsigned long *columns,
@@ -371,6 +459,10 @@ struct efi_input_key {
        s16 unicode_char;
 };
 
+#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
+       EFI_GUID(0x387477c1, 0x69c7, 0x11d2, \
+                0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+
 struct efi_simple_input_interface {
        efi_status_t(EFIAPI *reset)(struct efi_simple_input_interface *this,
                        bool ExtendedVerification);
@@ -402,22 +494,14 @@ struct efi_console_control_protocol
        EFI_GUID(0x8b843e20, 0x8132, 0x4852, \
                 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
 
-struct efi_device_path_protocol
-{
-       uint8_t type;
-       uint8_t sub_type;
-       uint16_t length;
-       uint8_t data[];
-};
-
 struct efi_device_path_to_text_protocol
 {
        uint16_t *(EFIAPI *convert_device_node_to_text)(
-                       struct efi_device_path_protocol *device_node,
+                       struct efi_device_path *device_node,
                        bool display_only,
                        bool allow_shortcuts);
        uint16_t *(EFIAPI *convert_device_path_to_text)(
-                       struct efi_device_path_protocol *device_path,
+                       struct efi_device_path *device_path,
                        bool display_only,
                        bool allow_shortcuts);
 };
@@ -588,4 +672,69 @@ struct efi_pxe {
        struct efi_pxe_mode *mode;
 };
 
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
+       EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
+                0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+#define EFI_FILE_PROTOCOL_REVISION 0x00010000
+
+struct efi_file_handle {
+       u64 rev;
+       efi_status_t (EFIAPI *open)(struct efi_file_handle *file,
+                       struct efi_file_handle **new_handle,
+                       s16 *file_name, u64 open_mode, u64 attributes);
+       efi_status_t (EFIAPI *close)(struct efi_file_handle *file);
+       efi_status_t (EFIAPI *delete)(struct efi_file_handle *file);
+       efi_status_t (EFIAPI *read)(struct efi_file_handle *file,
+                       u64 *buffer_size, void *buffer);
+       efi_status_t (EFIAPI *write)(struct efi_file_handle *file,
+                       u64 *buffer_size, void *buffer);
+       efi_status_t (EFIAPI *getpos)(struct efi_file_handle *file,
+                       u64 *pos);
+       efi_status_t (EFIAPI *setpos)(struct efi_file_handle *file,
+                       u64 pos);
+       efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *file,
+                       efi_guid_t *info_type, u64 *buffer_size, void *buffer);
+       efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *file,
+                       efi_guid_t *info_type, u64 buffer_size, void *buffer);
+       efi_status_t (EFIAPI *flush)(struct efi_file_handle *file);
+};
+
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
+       EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
+                0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
+
+struct efi_simple_file_system_protocol {
+       u64 rev;
+       efi_status_t (EFIAPI *open_volume)(struct efi_simple_file_system_protocol *this,
+                       struct efi_file_handle **root);
+};
+
+#define EFI_FILE_INFO_GUID \
+       EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \
+                0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+
+#define EFI_FILE_MODE_READ     0x0000000000000001
+#define EFI_FILE_MODE_WRITE    0x0000000000000002
+#define EFI_FILE_MODE_CREATE   0x8000000000000000
+
+#define EFI_FILE_READ_ONLY     0x0000000000000001
+#define EFI_FILE_HIDDEN                0x0000000000000002
+#define EFI_FILE_SYSTEM                0x0000000000000004
+#define EFI_FILE_RESERVED      0x0000000000000008
+#define EFI_FILE_DIRECTORY     0x0000000000000010
+#define EFI_FILE_ARCHIVE       0x0000000000000020
+#define EFI_FILE_VALID_ATTR    0x0000000000000037
+
+struct efi_file_info {
+       u64 size;
+       u64 file_size;
+       u64 physical_size;
+       struct efi_time create_time;
+       struct efi_time last_access_time;
+       struct efi_time modification_time;
+       u64 attribute;
+       s16 file_name[0];
+};
+
 #endif