efi: Add a flags parameter to efi_memory_map
[linux-2.6-microblaze.git] / include / linux / efi.h
index d8e9879..f117d68 100644 (file)
@@ -48,6 +48,14 @@ typedef u16 efi_char16_t;            /* UNICODE character */
 typedef u64 efi_physical_addr_t;
 typedef void *efi_handle_t;
 
+#if defined(CONFIG_X86_64)
+#define __efiapi __attribute__((ms_abi))
+#elif defined(CONFIG_X86_32)
+#define __efiapi __attribute__((regparm(0)))
+#else
+#define __efiapi
+#endif
+
 #define efi_get_handle_at(array, idx)                                  \
        (efi_is_native() ? (array)[idx]                                 \
                : (efi_handle_t)(unsigned long)((u32 *)(array))[idx])
@@ -272,13 +280,16 @@ typedef union {
                efi_table_hdr_t hdr;
                void *raise_tpl;
                void *restore_tpl;
-               efi_status_t (*allocate_pages)(int, int, unsigned long,
-                                              efi_physical_addr_t *);
-               efi_status_t (*free_pages)(efi_physical_addr_t, unsigned long);
-               efi_status_t (*get_memory_map)(unsigned long *, void *, unsigned long *,
-                                              unsigned long *, u32 *);
-               efi_status_t (*allocate_pool)(int, unsigned long, void **);
-               efi_status_t (*free_pool)(void *);
+               efi_status_t (__efiapi *allocate_pages)(int, int, unsigned long,
+                                                       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 *, void *,
+                                                       unsigned long *,
+                                                       unsigned long *, u32 *);
+               efi_status_t (__efiapi *allocate_pool)(int, unsigned long,
+                                                      void **);
+               efi_status_t (__efiapi *free_pool)(void *);
                void *create_event;
                void *set_timer;
                void *wait_for_event;
@@ -288,29 +299,36 @@ typedef union {
                void *install_protocol_interface;
                void *reinstall_protocol_interface;
                void *uninstall_protocol_interface;
-               efi_status_t (*handle_protocol)(efi_handle_t, efi_guid_t *, void **);
+               efi_status_t (__efiapi *handle_protocol)(efi_handle_t,
+                                                        efi_guid_t *, void **);
                void *__reserved;
                void *register_protocol_notify;
-               efi_status_t (*locate_handle)(int, efi_guid_t *, void *,
-                                             unsigned long *, efi_handle_t *);
+               efi_status_t (__efiapi *locate_handle)(int, efi_guid_t *,
+                                                      void *, unsigned long *,
+                                                      efi_handle_t *);
                void *locate_device_path;
-               efi_status_t (*install_configuration_table)(efi_guid_t *, void *);
+               efi_status_t (__efiapi *install_configuration_table)(efi_guid_t *,
+                                                                    void *);
                void *load_image;
                void *start_image;
                void *exit;
                void *unload_image;
-               efi_status_t (*exit_boot_services)(efi_handle_t, unsigned long);
+               efi_status_t (__efiapi *exit_boot_services)(efi_handle_t,
+                                                           unsigned long);
                void *get_next_monotonic_count;
                void *stall;
                void *set_watchdog_timer;
                void *connect_controller;
-               void *disconnect_controller;
+               efi_status_t (__efiapi *disconnect_controller)(efi_handle_t,
+                                                              efi_handle_t,
+                                                              efi_handle_t);
                void *open_protocol;
                void *close_protocol;
                void *open_protocol_information;
                void *protocols_per_handle;
                void *locate_handle_buffer;
-               efi_status_t (*locate_protocol)(efi_guid_t *, void *, void **);
+               efi_status_t (__efiapi *locate_protocol)(efi_guid_t *, void *,
+                                                        void **);
                void *install_multiple_protocol_interfaces;
                void *uninstall_multiple_protocol_interfaces;
                void *calculate_crc32;
@@ -354,10 +372,11 @@ typedef struct {
 typedef union efi_pci_io_protocol efi_pci_io_protocol_t;
 
 typedef
-efi_status_t (*efi_pci_io_protocol_cfg_t)(efi_pci_io_protocol_t *,
-                                         EFI_PCI_IO_PROTOCOL_WIDTH,
-                                         u32 offset, unsigned long count,
-                                         void *buffer);
+efi_status_t (__efiapi *efi_pci_io_protocol_cfg_t)(efi_pci_io_protocol_t *,
+                                                  EFI_PCI_IO_PROTOCOL_WIDTH,
+                                                  u32 offset,
+                                                  unsigned long count,
+                                                  void *buffer);
 
 typedef struct {
        void *read;
@@ -382,7 +401,11 @@ union efi_pci_io_protocol {
                void *allocate_buffer;
                void *free_buffer;
                void *flush;
-               void *get_location;
+               efi_status_t (__efiapi *get_location)(efi_pci_io_protocol_t *,
+                                                     unsigned long *segment_nr,
+                                                     unsigned long *bus_nr,
+                                                     unsigned long *device_nr,
+                                                     unsigned long *func_nr);
                void *attributes;
                void *get_bar_attributes;
                void *set_bar_attributes;
@@ -437,16 +460,17 @@ typedef union apple_properties_protocol apple_properties_protocol_t;
 union apple_properties_protocol {
        struct {
                unsigned long version;
-               efi_status_t (*get)(apple_properties_protocol_t *,
-                                   struct efi_dev_path *, efi_char16_t *,
-                                   void *, u32 *);
-               efi_status_t (*set)(apple_properties_protocol_t *,
-                                   struct efi_dev_path *, efi_char16_t *,
-                                   void *, u32);
-               efi_status_t (*del)(apple_properties_protocol_t *,
-                                   struct efi_dev_path *, efi_char16_t *);
-               efi_status_t (*get_all)(apple_properties_protocol_t *,
-                                       void *buffer, u32 *);
+               efi_status_t (__efiapi *get)(apple_properties_protocol_t *,
+                                            struct efi_dev_path *,
+                                            efi_char16_t *, void *, u32 *);
+               efi_status_t (__efiapi *set)(apple_properties_protocol_t *,
+                                            struct efi_dev_path *,
+                                            efi_char16_t *, void *, u32);
+               efi_status_t (__efiapi *del)(apple_properties_protocol_t *,
+                                            struct efi_dev_path *,
+                                            efi_char16_t *);
+               efi_status_t (__efiapi *get_all)(apple_properties_protocol_t *,
+                                                void *buffer, u32 *);
        };
        struct {
                u32 version;
@@ -464,11 +488,11 @@ typedef union efi_tcg2_protocol efi_tcg2_protocol_t;
 union efi_tcg2_protocol {
        struct {
                void *get_capability;
-               efi_status_t (*get_event_log)(efi_handle_t,
-                                             efi_tcg2_event_log_format,
-                                             efi_physical_addr_t *,
-                                             efi_physical_addr_t *,
-                                             efi_bool_t *);
+               efi_status_t (__efiapi *get_event_log)(efi_handle_t,
+                                                      efi_tcg2_event_log_format,
+                                                      efi_physical_addr_t *,
+                                                      efi_physical_addr_t *,
+                                                      efi_bool_t *);
                void *hash_log_extend_event;
                void *submit_command;
                void *get_active_pcr_banks;
@@ -517,24 +541,6 @@ typedef struct {
        u32 query_variable_info;
 } efi_runtime_services_32_t;
 
-typedef struct {
-       efi_table_hdr_t hdr;
-       u64 get_time;
-       u64 set_time;
-       u64 get_wakeup_time;
-       u64 set_wakeup_time;
-       u64 set_virtual_address_map;
-       u64 convert_pointer;
-       u64 get_variable;
-       u64 get_next_variable;
-       u64 set_variable;
-       u64 get_next_high_mono_count;
-       u64 reset_system;
-       u64 update_capsule;
-       u64 query_capsule_caps;
-       u64 query_variable_info;
-} efi_runtime_services_64_t;
-
 typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc);
 typedef efi_status_t efi_set_time_t (efi_time_t *tm);
 typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending,
@@ -571,21 +577,21 @@ typedef efi_status_t efi_query_variable_store_t(u32 attributes,
 
 typedef union {
        struct {
-               efi_table_hdr_t                 hdr;
-               efi_get_time_t                  *get_time;
-               efi_set_time_t                  *set_time;
-               efi_get_wakeup_time_t           *get_wakeup_time;
-               efi_set_wakeup_time_t           *set_wakeup_time;
-               efi_set_virtual_address_map_t   *set_virtual_address_map;
-               void                            *convert_pointer;
-               efi_get_variable_t              *get_variable;
-               efi_get_next_variable_t         *get_next_variable;
-               efi_set_variable_t              *set_variable;
-               efi_get_next_high_mono_count_t  *get_next_high_mono_count;
-               efi_reset_system_t              *reset_system;
-               efi_update_capsule_t            *update_capsule;
-               efi_query_capsule_caps_t        *query_capsule_caps;
-               efi_query_variable_info_t       *query_variable_info;
+               efi_table_hdr_t                         hdr;
+               efi_get_time_t __efiapi                 *get_time;
+               efi_set_time_t __efiapi                 *set_time;
+               efi_get_wakeup_time_t __efiapi          *get_wakeup_time;
+               efi_set_wakeup_time_t __efiapi          *set_wakeup_time;
+               efi_set_virtual_address_map_t __efiapi  *set_virtual_address_map;
+               void                                    *convert_pointer;
+               efi_get_variable_t __efiapi             *get_variable;
+               efi_get_next_variable_t __efiapi        *get_next_variable;
+               efi_set_variable_t __efiapi             *set_variable;
+               efi_get_next_high_mono_count_t __efiapi *get_next_high_mono_count;
+               efi_reset_system_t __efiapi             *reset_system;
+               efi_update_capsule_t __efiapi           *update_capsule;
+               efi_query_capsule_caps_t __efiapi       *query_capsule_caps;
+               efi_query_variable_info_t __efiapi      *query_variable_info;
        };
        efi_runtime_services_32_t mixed_mode;
 } efi_runtime_services_t;
@@ -730,6 +736,8 @@ typedef struct {
        u32 tables;
 } efi_system_table_32_t;
 
+typedef union efi_simple_text_output_protocol efi_simple_text_output_protocol_t;
+
 typedef union {
        struct {
                efi_table_hdr_t hdr;
@@ -738,7 +746,7 @@ typedef union {
                unsigned long con_in_handle;
                unsigned long con_in;
                unsigned long con_out_handle;
-               unsigned long con_out;
+               efi_simple_text_output_protocol_t *con_out;
                unsigned long stderr_handle;
                unsigned long stderr;
                efi_runtime_services_t *runtime;
@@ -759,6 +767,7 @@ struct efi_memory_map_data {
        unsigned long size;
        unsigned long desc_version;
        unsigned long desc_size;
+       unsigned long flags;
 };
 
 struct efi_memory_map {
@@ -768,7 +777,8 @@ struct efi_memory_map {
        int nr_map;
        unsigned long desc_version;
        unsigned long desc_size;
-       bool late;
+#define EFI_MEMMAP_LATE (1UL << 0)
+       unsigned long flags;
 };
 
 struct efi_mem_range {
@@ -784,40 +794,21 @@ struct efi_fdt_params {
        u32 desc_ver;
 };
 
-typedef union efi_loaded_image efi_loaded_image_t;
-
-union efi_loaded_image {
-       struct {
-               u32 revision;
-               efi_handle_t parent_handle;
-               efi_system_table_t *system_table;
-               efi_handle_t device_handle;
-               void *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 (*unload)(efi_handle_t image_handle);
-       };
-       struct {
-               u32 revision;
-               u32 parent_handle;
-               u32 system_table;
-               u32 device_handle;
-               u32 file_path;
-               u32 reserved;
-               u32 load_options_size;
-               u32 load_options;
-               u32 image_base;
-               __aligned_u64 image_size;
-               unsigned int image_code_type;
-               unsigned int image_data_type;
-               u32 unload;
-       } mixed_mode;
-};
+typedef struct {
+       u32 revision;
+       efi_handle_t parent_handle;
+       efi_system_table_t *system_table;
+       efi_handle_t device_handle;
+       void *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);
+} efi_loaded_image_t;
 
 typedef struct {
        u64 size;
@@ -830,53 +821,33 @@ typedef struct {
        efi_char16_t filename[1];
 } efi_file_info_t;
 
-typedef union efi_file_handle efi_file_handle_t;
-
-union efi_file_handle {
-       struct {
-               u64 revision;
-               efi_status_t (*open)(efi_file_handle_t *,
-                                    efi_file_handle_t **,
-                                    efi_char16_t *, u64, u64);
-               efi_status_t (*close)(efi_file_handle_t *);
-               void *delete;
-               efi_status_t (*read)(efi_file_handle_t *, unsigned long *,
-                                    void *);
-               void *write;
-               void *get_position;
-               void *set_position;
-               efi_status_t (*get_info)(efi_file_handle_t *, efi_guid_t *,
-                               unsigned long *, void *);
-               void *set_info;
-               void *flush;
-       };
-       struct {
-               u64 revision;
-               u32 open;
-               u32 close;
-               u32 delete;
-               u32 read;
-               u32 write;
-               u32 get_position;
-               u32 set_position;
-               u32 get_info;
-               u32 set_info;
-               u32 flush;
-       } mixed_mode;
+typedef struct efi_file_handle efi_file_handle_t;
+
+struct efi_file_handle {
+       u64 revision;
+       efi_status_t (__efiapi *open)(efi_file_handle_t *,
+                                     efi_file_handle_t **,
+                                     efi_char16_t *, u64, u64);
+       efi_status_t (__efiapi *close)(efi_file_handle_t *);
+       void *delete;
+       efi_status_t (__efiapi *read)(efi_file_handle_t *,
+                                     unsigned long *, void *);
+       void *write;
+       void *get_position;
+       void *set_position;
+       efi_status_t (__efiapi *get_info)(efi_file_handle_t *,
+                                         efi_guid_t *, unsigned long *,
+                                         void *);
+       void *set_info;
+       void *flush;
 };
 
-typedef union efi_file_io_interface efi_file_io_interface_t;
+typedef struct efi_file_io_interface efi_file_io_interface_t;
 
-union efi_file_io_interface {
-       struct {
-               u64 revision;
-               int (*open_volume)(efi_file_io_interface_t *,
-                                  efi_file_handle_t **);
-       };
-       struct {
-               u64 revision;
-               u32 open_volume;
-       } mixed_mode;
+struct efi_file_io_interface {
+       u64 revision;
+       int (__efiapi *open_volume)(efi_file_io_interface_t *,
+                                   efi_file_handle_t **);
 };
 
 #define EFI_FILE_MODE_READ     0x0000000000000001
@@ -961,7 +932,6 @@ extern struct efi {
        efi_query_capsule_caps_t *query_capsule_caps;
        efi_get_next_high_mono_count_t *get_next_high_mono_count;
        efi_reset_system_t *reset_system;
-       efi_set_virtual_address_map_t *set_virtual_address_map;
        struct efi_memory_map memmap;
        unsigned long flags;
 } efi;
@@ -1337,13 +1307,11 @@ struct efivar_entry {
        bool deleting;
 };
 
-typedef union efi_simple_text_output_protocol efi_simple_text_output_protocol_t;
-
 union efi_simple_text_output_protocol {
        struct {
                void *reset;
-               efi_status_t (*output_string)(efi_simple_text_output_protocol_t *,
-                                             efi_char16_t *);
+               efi_status_t (__efiapi *output_string)(efi_simple_text_output_protocol_t *,
+                                                      efi_char16_t *);
                void *test_string;
        };
        struct {
@@ -1512,24 +1480,19 @@ static inline int efi_runtime_map_copy(void *buf, size_t bufsz)
 
 /* prototypes shared between arch specific and generic stub code */
 
-void efi_printk(efi_system_table_t *sys_table_arg, char *str);
+void efi_printk(char *str);
 
-void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,
-             unsigned long addr);
+void efi_free(unsigned long size, unsigned long addr);
 
-char *efi_convert_cmdline(efi_system_table_t *sys_table_arg,
-                         efi_loaded_image_t *image, int *cmd_line_len);
+char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len);
 
-efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
-                               struct efi_boot_memmap *map);
+efi_status_t efi_get_memory_map(struct efi_boot_memmap *map);
 
-efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg,
-                                unsigned long size, unsigned long align,
+efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
                                 unsigned long *addr, unsigned long min);
 
 static inline
-efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,
-                          unsigned long size, unsigned long align,
+efi_status_t efi_low_alloc(unsigned long size, unsigned long align,
                           unsigned long *addr)
 {
        /*
@@ -1537,23 +1500,20 @@ efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,
         * checks pointers against NULL. Skip the first 8
         * bytes so we start at a nice even number.
         */
-       return efi_low_alloc_above(sys_table_arg, size, align, addr, 0x8);
+       return efi_low_alloc_above(size, align, addr, 0x8);
 }
 
-efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg,
-                           unsigned long size, unsigned long align,
+efi_status_t efi_high_alloc(unsigned long size, unsigned long align,
                            unsigned long *addr, unsigned long max);
 
-efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg,
-                                unsigned long *image_addr,
+efi_status_t efi_relocate_kernel(unsigned long *image_addr,
                                 unsigned long image_size,
                                 unsigned long alloc_size,
                                 unsigned long preferred_addr,
                                 unsigned long alignment,
                                 unsigned long min_addr);
 
-efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
-                                 efi_loaded_image_t *image,
+efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
                                  char *cmd_line, char *option_string,
                                  unsigned long max_addr,
                                  unsigned long *load_addr,
@@ -1561,8 +1521,7 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
 
 efi_status_t efi_parse_options(char const *cmdline);
 
-efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg,
-                          struct screen_info *si, efi_guid_t *proto,
+efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto,
                           unsigned long size);
 
 #ifdef CONFIG_EFI
@@ -1580,18 +1539,18 @@ enum efi_secureboot_mode {
        efi_secureboot_mode_disabled,
        efi_secureboot_mode_enabled,
 };
-enum efi_secureboot_mode efi_get_secureboot(efi_system_table_t *sys_table);
+enum efi_secureboot_mode efi_get_secureboot(void);
 
 #ifdef CONFIG_RESET_ATTACK_MITIGATION
-void efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg);
+void efi_enable_reset_attack_mitigation(void);
 #else
 static inline void
-efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg) { }
+efi_enable_reset_attack_mitigation(void) { }
 #endif
 
-efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
+efi_status_t efi_random_get_seed(void);
 
-void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table);
+void efi_retrieve_tpm2_eventlog(void);
 
 /*
  * Arch code can implement the following three template macros, avoiding
@@ -1643,12 +1602,10 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table);
 })
 
 typedef efi_status_t (*efi_exit_boot_map_processing)(
-       efi_system_table_t *sys_table_arg,
        struct efi_boot_memmap *map,
        void *priv);
 
-efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table,
-                                   void *handle,
+efi_status_t efi_exit_boot_services(void *handle,
                                    struct efi_boot_memmap *map,
                                    void *priv,
                                    efi_exit_boot_map_processing priv_func);
@@ -1739,4 +1696,6 @@ struct linux_efi_memreserve {
 #define EFI_MEMRESERVE_COUNT(size) (((size) - sizeof(struct linux_efi_memreserve)) \
        / sizeof(((struct linux_efi_memreserve *)0)->entry[0]))
 
+void efi_pci_disable_bridge_busmaster(void);
+
 #endif /* _LINUX_EFI_H */