dm: core: Create a new header file for 'compat' features
[oweals/u-boot.git] / lib / efi / efi_stub.c
index 09023a2f67a525ae6a83066de5c4c7b9e34e36b6..7d650d512e30b142b0869adb5c3fd0e81cab496f 100644 (file)
@@ -14,6 +14,7 @@
 #include <efi.h>
 #include <efi_api.h>
 #include <errno.h>
+#include <malloc.h>
 #include <ns16550.h>
 #include <asm/cpu.h>
 #include <asm/io.h>
@@ -268,12 +269,17 @@ static void add_entry_addr(struct efi_priv *priv, enum efi_entry_t type,
  * This function is called by our EFI start-up code. It handles running
  * U-Boot. If it returns, EFI will continue.
  */
-efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
+efi_status_t EFIAPI efi_main(efi_handle_t image,
+                            struct efi_system_table *sys_table)
 {
        struct efi_priv local_priv, *priv = &local_priv;
        struct efi_boot_services *boot = sys_table->boottime;
        struct efi_mem_desc *desc;
        struct efi_entry_memmap map;
+       struct efi_gop *gop;
+       struct efi_entry_gopmode mode;
+       struct efi_entry_systable table;
+       efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
        efi_uintn_t key, desc_size, size;
        efi_status_t ret;
        u32 version;
@@ -312,6 +318,18 @@ efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
        if (ret)
                return ret;
 
+       ret = boot->locate_protocol(&efi_gop_guid, NULL, (void **)&gop);
+       if (ret) {
+               puts(" GOP unavailable\n");
+       } else {
+               mode.fb_base = gop->mode->fb_base;
+               mode.fb_size = gop->mode->fb_size;
+               mode.info_size = gop->mode->info_size;
+               add_entry_addr(priv, EFIET_GOP_MODE, &mode, sizeof(mode),
+                              gop->mode->info,
+                              sizeof(struct efi_gop_mode_info));
+       }
+
        ret = boot->get_memory_map(&size, desc, &key, &desc_size, &version);
        if (ret) {
                printhex2(ret);
@@ -319,6 +337,9 @@ efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
                return ret;
        }
 
+       table.sys_table = (ulong)sys_table;
+       add_entry_addr(priv, EFIET_SYS_TABLE, &table, sizeof(table), NULL, 0);
+
        ret = boot->exit_boot_services(image, key);
        if (ret) {
                /*
@@ -345,14 +366,14 @@ efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
                }
        }
 
+       /* The EFI UART won't work now, switch to a debug one */
+       use_uart = true;
+
        map.version = version;
        map.desc_size = desc_size;
        add_entry_addr(priv, EFIET_MEMORY_MAP, &map, sizeof(map), desc, size);
        add_entry_addr(priv, EFIET_END, NULL, 0, 0, 0);
 
-       /* The EFI UART won't work now, switch to a debug one */
-       use_uart = true;
-
        memcpy((void *)CONFIG_SYS_TEXT_BASE, _binary_u_boot_bin_start,
               (ulong)_binary_u_boot_bin_end -
               (ulong)_binary_u_boot_bin_start);