Convert CONFIG_SYS_INTERLAKEN et al to Kconfig
[platform/kernel/u-boot.git] / include / efi.h
index 0ec5913..42f4e58 100644 (file)
 #define EFIAPI __attribute__((ms_abi))
 #define efi_va_list __builtin_ms_va_list
 #define efi_va_start __builtin_ms_va_start
+#define efi_va_copy __builtin_ms_va_copy
 #define efi_va_arg __builtin_va_arg
 #define efi_va_end __builtin_ms_va_end
 #else
 #define EFIAPI asmlinkage
 #define efi_va_list va_list
 #define efi_va_start va_start
+#define efi_va_copy va_copy
 #define efi_va_arg va_arg
 #define efi_va_end va_end
 #endif /* __x86_64__ */
@@ -321,7 +323,7 @@ struct efi_info_hdr {
  * struct efi_entry_hdr - Header for a table entry
  *
  * @type:      enum eft_entry_t
- * @size       size of entry bytes excluding header and padding
+ * @size:      size of entry bytes excluding header and padding
  * @addr:      address of this entry (0 if it follows the header )
  * @link:      size of entry including header and padding
  * @spare1:    Spare space for expansion
@@ -395,20 +397,54 @@ struct efi_entry_systable {
 };
 
 static inline struct efi_mem_desc *efi_get_next_mem_desc(
-               struct efi_entry_memmap *map, struct efi_mem_desc *desc)
+               struct efi_mem_desc *desc, int desc_size)
 {
-       return (struct efi_mem_desc *)((ulong)desc + map->desc_size);
+       return (struct efi_mem_desc *)((ulong)desc + desc_size);
 }
 
+/**
+ * struct efi_priv - Information about the environment provided by EFI
+ *
+ * @parent_image: image passed into the EFI app or stub
+ * @sys_table: Pointer to system table
+ * @boot: Pointer to boot-services table
+ * @run: Pointer to runtime-services table
+ * @memmap_key: Key returned from get_memory_map()
+ * @memmap_desc: List of memory-map records
+ * @memmap_alloc: Amount of memory allocated for memory map list
+ * @memmap_size Size of memory-map list in bytes
+ * @memmap_desc_size: Size of an individual memory-map record, in bytes
+ * @memmap_version: Memory-map version
+ *
+ * @use_pool_for_malloc: true if all allocation should go through the EFI 'pool'
+ *     methods allocate_pool() and free_pool(); false to use 'pages' methods
+ *     allocate_pages() and free_pages()
+ * @ram_base: Base address of RAM (size CONFIG_EFI_RAM_SIZE)
+ * @image_data_type: Type of the loaded image (e.g. EFI_LOADER_CODE)
+ *
+ * @info: Header of the info list, holding info collected by the stub and passed
+ *     to U-Boot
+ * @info_size: Size of the info list @info in bytes
+ * @next_hdr: Pointer to where to put the next header when adding to the list
+ */
 struct efi_priv {
        efi_handle_t parent_image;
-       struct efi_device_path *device_path;
        struct efi_system_table *sys_table;
        struct efi_boot_services *boot;
        struct efi_runtime_services *run;
+       efi_uintn_t memmap_key;
+       struct efi_mem_desc *memmap_desc;
+       efi_uintn_t memmap_alloc;
+       efi_uintn_t memmap_size;
+       efi_uintn_t memmap_desc_size;
+       u32 memmap_version;
+
+       /* app: */
        bool use_pool_for_malloc;
        unsigned long ram_base;
        unsigned int image_data_type;
+
+       /* stub: */
        struct efi_info_hdr *info;
        unsigned int info_size;
        void *next_hdr;
@@ -419,10 +455,12 @@ struct efi_priv {
  *
  * @handle: handle of the controller on which this driver is installed
  * @blkio: block io protocol proxied by this driver
+ * @device_path: EFI path to the device
  */
 struct efi_media_plat {
-       efi_handle_t            handle;
-       struct efi_block_io     *blkio;
+       efi_handle_t handle;
+       struct efi_block_io *blkio;
+       struct efi_device_path *device_path;
 };
 
 /* Base address of the EFI image */
@@ -451,16 +489,37 @@ extern char _binary_u_boot_bin_start[], _binary_u_boot_bin_end[];
                                EFI_VARIABLE_APPEND_WRITE)
 
 /**
+ * efi_get_priv() - Get access to the EFI-private information
+ *
+ * This struct it used by both the stub and the app to record things about the
+ * EFI environment. It is not available in U-Boot proper after the stub has
+ * jumped there. Use efi_info_get() to obtain info in that case.
+ *
+ * Return: pointer to private info
+ */
+struct efi_priv *efi_get_priv(void);
+
+/**
+ * efi_set_priv() - Set up a pointer to the EFI-private information
+ *
+ * This is called in the stub and app to record the location of this
+ * information.
+ *
+ * @priv: New location of private data
+ */
+void efi_set_priv(struct efi_priv *priv);
+
+/**
  * efi_get_sys_table() - Get access to the main EFI system table
  *
- * @return pointer to EFI system table
+ * Returns: pointer to EFI system table
  */
 struct efi_system_table *efi_get_sys_table(void);
 
 /**
  * efi_get_boot() - Get access to the EFI boot services table
  *
- * @return pointer to EFI boot services table
+ * Returns: pointer to EFI boot services table
  */
 struct efi_boot_services *efi_get_boot(void);
 
@@ -469,7 +528,7 @@ struct efi_boot_services *efi_get_boot(void);
  *
  * This is used when U-Boot is built as an EFI application.
  *
- * @return the base of RAM as known to U-Boot
+ * Returns: the base of RAM as known to U-Boot
  */
 unsigned long efi_get_ram_base(void);
 
@@ -480,6 +539,7 @@ unsigned long efi_get_ram_base(void);
  * @banner:    Banner to display when starting
  * @image:     The image handle passed to efi_main()
  * @sys_table: The EFI system table pointer passed to efi_main()
+ * Return: 0 on succcess, EFI error code on failure
  */
 int efi_init(struct efi_priv *priv, const char *banner, efi_handle_t image,
             struct efi_system_table *sys_table);
@@ -490,7 +550,7 @@ int efi_init(struct efi_priv *priv, const char *banner, efi_handle_t image,
  * @priv:      Pointer to private EFI structure
  * @size:      Number of bytes to allocate
  * @retp:      Return EFI status result
- * @return pointer to memory allocated, or NULL on error
+ * Returns: pointer to memory allocated, or NULL on error
  */
 void *efi_malloc(struct efi_priv *priv, int size, efi_status_t *retp);
 
@@ -521,12 +581,51 @@ void efi_putc(struct efi_priv *priv, const char ch);
 /**
  * efi_info_get() - get an entry from an EFI table
  *
+ * This function is called from U-Boot proper to read information set up by the
+ * EFI stub. It can only be used when running from the EFI stub, not when U-Boot
+ * is running as an app.
+ *
  * @type:      Entry type to search for
  * @datap:     Returns pointer to entry data
- * @sizep:     Returns pointer to entry size
- * @return 0 if OK, -ENODATA if there is no table, -ENOENT if there is no entry
+ * @sizep:     Returns entry size
+ * Return: 0 if OK, -ENODATA if there is no table, -ENOENT if there is no entry
  * of the requested type, -EPROTONOSUPPORT if the table has the wrong version
  */
 int efi_info_get(enum efi_entry_t type, void **datap, int *sizep);
 
+/**
+ * efi_store_memory_map() - Collect the memory-map info from EFI
+ *
+ * Collect the memory info and store it for later use, e.g. in calling
+ * exit_boot_services()
+ *
+ * @priv:      Pointer to private EFI structure
+ * Returns: 0 if OK, non-zero on error
+ */
+int efi_store_memory_map(struct efi_priv *priv);
+
+/**
+ * efi_call_exit_boot_services() - Handle the exit-boot-service procedure
+ *
+ * Tell EFI we don't want their boot services anymore
+ *
+ * Return: 0 if OK, non-zero on error
+ */
+int efi_call_exit_boot_services(void);
+
+/**
+ * efi_get_mmap() - Get the memory map from EFI
+ *
+ * This is used in the app. The caller must free *@descp when done
+ *
+ * @descp:     Returns allocated pointer to EFI memory map table
+ * @sizep:     Returns size of table in bytes
+ * @keyp:      Returns memory-map key
+ * @desc_sizep:        Returns size of each @desc_base record
+ * @versionp:  Returns version number of memory map
+ * Returns: 0 on success, -ve on error
+ */
+int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp,
+                int *desc_sizep, uint *versionp);
+
 #endif /* _LINUX_EFI_H */