]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
x86: Record the start and end of the tables
authorSimon Glass <sjg@chromium.org>
Sun, 16 Jul 2023 03:39:10 +0000 (21:39 -0600)
committerBin Meng <bmeng@tinylab.org>
Mon, 17 Jul 2023 09:23:08 +0000 (17:23 +0800)
The ACPI tables are special in that they are passed to EFI as a separate
piece, independent of other tables.

Also they can be spread over two areas of memory, e.g. with QEMU we end
up with tables kept in high memory as well.

Add new global_data fields to hold this information and update the bdinfo
command to show the table areas.

Move the rom_table_end variable into the loop that uses it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
arch/sandbox/include/asm/global_data.h
arch/x86/include/asm/global_data.h
arch/x86/lib/bdinfo.c
arch/x86/lib/tables.c
drivers/misc/qfw.c

index f4ce72d56602c0b166ccf9a0beaf61852c142c90..f0ab3ba5c14641c8f3999ac3531624bdd57784d7 100644 (file)
 struct arch_global_data {
        uint8_t         *ram_buf;       /* emulated RAM buffer */
        void            *text_base;     /* pointer to base of text region */
+       ulong table_start;              /* Start address of x86 tables */
+       ulong table_end;                /* End address of x86 tables */
+       ulong table_start_high;         /* Start address of high x86 tables */
+       ulong table_end_high;           /* End address of high x86 tables */
 };
 
 #include <asm-generic/global_data.h>
index 22d103df4ee892be516c3be1dda750c38a6f93f7..ea58259ad774dacf39309f5831128dfe7b3b9e0a 100644 (file)
@@ -123,6 +123,10 @@ struct arch_global_data {
 #endif
        void *itss_priv;                /* Private ITSS data pointer */
        ulong coreboot_table;           /* Address of coreboot table */
+       ulong table_start;              /* Start address of x86 tables */
+       ulong table_end;                /* End address of x86 tables */
+       ulong table_start_high;         /* Start address of high x86 tables */
+       ulong table_end_high;           /* End address of high x86 tables */
 };
 
 #endif
index a20d0954416ad3f28d880627bf69e7a5c59e22a7..124058442c55a096b97c37790c01eaabaf33fd8b 100644 (file)
@@ -23,6 +23,10 @@ void arch_print_bdinfo(void)
        bdinfo_print_str(" name", cpu_vendor_name(gd->arch.x86_vendor));
        bdinfo_print_num_l("model", gd->arch.x86_model);
        bdinfo_print_num_l("phys_addr in bits", cpu_phys_address_size());
+       bdinfo_print_num_l("table start", gd->arch.table_start);
+       bdinfo_print_num_l("table end", gd->arch.table_end);
+       bdinfo_print_num_l(" high start", gd->arch.table_start_high);
+       bdinfo_print_num_l(" high end", gd->arch.table_end_high);
 
        if (IS_ENABLED(CONFIG_EFI_STUB))
                efi_show_bdinfo();
index 772c04f1e55681746ea264f9b623b18071ed09b7..67bc0a72aebc0d3a75375becb6b69dfc54757457 100644 (file)
@@ -54,6 +54,10 @@ static struct table_info table_list[] = {
 #ifdef CONFIG_GENERATE_MP_TABLE
        { "mp", write_mp_table, },
 #endif
+       /*
+        * tables which can go in the bloblist must be last in this list, so
+        * that the calculation of gd->table_end works properly
+        */
 #ifdef CONFIG_GENERATE_ACPI_TABLE
        { "acpi", write_acpi_tables, BLOBLISTT_ACPI_TABLES, 0x10000, 0x1000},
 #endif
@@ -80,10 +84,12 @@ int write_tables(void)
 {
        u32 high_table, table_size;
        struct memory_area cfg_tables[ARRAY_SIZE(table_list) + 1];
+       bool use_high = false;
        u32 rom_addr;
        int i;
 
-       rom_addr = ROM_TABLE_ADDR;
+       gd->arch.table_start = ROM_TABLE_ADDR;
+       rom_addr = gd->arch.table_start;
 
        debug("Writing tables to %x:\n", rom_addr);
        for (i = 0; i < ARRAY_SIZE(table_list); i++) {
@@ -92,10 +98,17 @@ int write_tables(void)
                u32 rom_table_end;
 
                if (IS_ENABLED(CONFIG_BLOBLIST_TABLES) && table->tag) {
+                       if (!gd->arch.table_end)
+                               gd->arch.table_end = rom_addr;
                        rom_addr = (ulong)bloblist_add(table->tag, size,
                                                       table->align);
                        if (!rom_addr)
                                return log_msg_ret("bloblist", -ENOBUFS);
+
+                       /* the bloblist is always in high memory */
+                       use_high = true;
+                       if (!gd->arch.table_start_high)
+                               gd->arch.table_start_high = rom_addr;
                }
                rom_table_end = table->write(rom_addr);
                if (!rom_table_end) {
@@ -132,6 +145,11 @@ int write_tables(void)
                rom_addr = rom_table_end;
        }
 
+       if (use_high)
+               gd->arch.table_end_high = rom_addr;
+       else
+               gd->arch.table_end = rom_addr;
+
        if (IS_ENABLED(CONFIG_SEABIOS)) {
                /* make sure the last item is zero */
                cfg_tables[i].size = 0;
index 0a93feeb4b2eed11e497bc3c7de3ce4eca063dae..7c01bf23d53bd2e085d2201d3c37e2d87184fcc5 100644 (file)
@@ -65,6 +65,11 @@ static int bios_linker_allocate(struct udevice *dev,
                        printf("error: allocating resource\n");
                        return -ENOMEM;
                }
+               if (aligned_addr < gd->arch.table_start_high)
+                       gd->arch.table_start_high = aligned_addr;
+               if (aligned_addr + size > gd->arch.table_end_high)
+                       gd->arch.table_end_high = aligned_addr + size;
+
        } else if (entry->alloc.zone == BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG) {
                aligned_addr = ALIGN(*addr, align);
        } else {
@@ -189,6 +194,10 @@ ulong write_acpi_tables(ulong addr)
                return addr;
        }
 
+       /* QFW always puts tables at high addresses */
+       gd->arch.table_start_high = (ulong)table_loader;
+       gd->arch.table_end_high = (ulong)table_loader;
+
        qfw_read_entry(dev, be16_to_cpu(file->cfg.select), size, table_loader);
 
        for (i = 0; i < (size / sizeof(*entry)); i++) {