ARMv7: Coreboot paramaters through the SKB
authorDavid Cock <david.cock@inf.ethz.ch>
Wed, 31 Aug 2016 14:12:34 +0000 (16:12 +0200)
committerDavid Cock <david.cock@inf.ethz.ch>
Wed, 31 Aug 2016 14:12:34 +0000 (16:12 +0200)
For ARMv7 platforms, this patch modifies Kaluga and Coreboot to discover the
available CPUs, and their boot parameters (e.g. CPU driver binary) via the
SKB, where this data is preseeded, as we can't easily probe a lot of this
without ACPI.

This *should* let us implement Coreboot pretty easily for A15 and A17.

Signed-off-by: David Cock <david.cock@inf.ethz.ch>

12 files changed:
hake/menu.lst.armv7_a9ve_1 [copied from hake/menu.lst.armv7_a9ve with 95% similarity]
hake/menu.lst.armv7_a9ve_4 [moved from hake/menu.lst.armv7_a9ve with 95% similarity]
hake/menu.lst.armv7_omap44xx
platforms/Hakefile
usr/drivers/cpuboot/Hakefile
usr/drivers/cpuboot/armboot.c
usr/kaluga/armv7.c
usr/skb/Hakefile
usr/skb/programs/plat_FVP_VE_A9x1.pl [new file with mode: 0644]
usr/skb/programs/plat_FVP_VE_A9x4.pl [new file with mode: 0644]
usr/skb/programs/plat_PandaboardES.pl [new file with mode: 0644]
usr/skb/programs/queries.pl

similarity index 95%
copy from hake/menu.lst.armv7_a9ve
copy to hake/menu.lst.armv7_a9ve_1
index 1e1fd2d..6b3d0cc 100644 (file)
@@ -22,7 +22,7 @@ module /armv7/sbin/ramfsd boot
 module /armv7/sbin/skb boot
 modulenounzip /eclipseclp_ramfs.cpio.gz nospawn
 modulenounzip /skb_ramfs.cpio.gz nospawn
-module /armv7/sbin/kaluga boot
+module /armv7/sbin/kaluga boot add_device_db=plat_FVP_VE_A9x1
 module /armv7/sbin/spawnd boot
 module /armv7/sbin/startd boot
 
similarity index 95%
rename from hake/menu.lst.armv7_a9ve
rename to hake/menu.lst.armv7_a9ve_4
index 1e1fd2d..c4fb4b3 100644 (file)
@@ -22,7 +22,7 @@ module /armv7/sbin/ramfsd boot
 module /armv7/sbin/skb boot
 modulenounzip /eclipseclp_ramfs.cpio.gz nospawn
 modulenounzip /skb_ramfs.cpio.gz nospawn
-module /armv7/sbin/kaluga boot
+module /armv7/sbin/kaluga boot add_device_db=plat_FVP_VE_A9x4
 module /armv7/sbin/spawnd boot
 module /armv7/sbin/startd boot
 
index d2f5d03..f7980f5 100644 (file)
@@ -20,7 +20,7 @@ module /armv7/sbin/ramfsd boot
 module /armv7/sbin/skb boot
 modulenounzip /eclipseclp_ramfs.cpio.gz nospawn
 modulenounzip /skb_ramfs.cpio.gz nospawn
-module /armv7/sbin/kaluga boot
+module /armv7/sbin/kaluga boot add_device_db=plat_PandaboardES
 module /armv7/sbin/spawnd boot bootarm=0
 module /armv7/sbin/startd boot
 
index c4b12e5..e58f9b7 100644 (file)
@@ -499,8 +499,10 @@ let bin_rcce_lu = [ "/sbin/" ++ f | f <- [
 
     platform "VExpressEMM-A9" [ "armv7" ]
     ([ ("armv7", f) | f <- vExpressEMMModules_A9 ] ++
-     [ ("root", "/armv7_a9ve_image"),
-       ("root", "/armv7_a9ve_image-gdb.gdb") ])
+     [ ("root", "/armv7_a9ve_1_image"),
+       ("root", "/armv7_a9ve_1_image-gdb.gdb"),
+       ("root", "/armv7_a9ve_4_image"),
+       ("root", "/armv7_a9ve_4_image-gdb.gdb") ])
     "VersatileExpress EMM board for ARMv7-A Fixed Virtual Platforms",
 
     platform "Zynq7000" [ "armv7" ]
@@ -527,8 +529,11 @@ let bin_rcce_lu = [ "/sbin/" ++ f | f <- [
     -- quirks)
     armv7Image "armv7_a15ve_gem5" "ve" "a15ve" "0x80000000" vExpressEMMModules_A15,
 
-    -- Build the A9 simulation image (VersatileExpress EMM board)
-    armv7Image "armv7_a9ve" "ve" "a9ve" "0x80000000" vExpressEMMModules_A9,
+    -- Build the A9 simulation image (VersatileExpress EMM board, 1 core)
+    armv7Image "armv7_a9ve_1" "ve" "a9ve" "0x80000000" vExpressEMMModules_A9,
+
+    -- Build the A9 simulation image (VersatileExpress EMM board, 4 cores)
+    armv7Image "armv7_a9ve_4" "ve" "a9ve" "0x80000000" vExpressEMMModules_A9,
 
     -- Build the Zynq7000 image
     armv7Image "armv7_zynq7" "zynq7" "zynq7" "0x00000000" zynq7Modules,
@@ -555,7 +560,8 @@ let bin_rcce_lu = [ "/sbin/" ++ f | f <- [
                      "root" ("/platforms/arm/menu.lst." ++ p)
             | p <- [ "armv8_gem5",
                      "armv8_qemu",
-                     "armv7_a9ve",
+                     "armv7_a9ve_1",
+                     "armv7_a9ve_4",
                      "armv7_a15ve",
                      "armv7_a15ve_gem5",
                      "armv7_omap44xx",
@@ -592,12 +598,12 @@ let bin_rcce_lu = [ "/sbin/" ++ f | f <- [
 
     boot "FVP_VE_A9x1" [ "armv7" ] [
       Str "FVP_VE_Cortex-A9x1",
-      In BuildTree "root" "/armv7_a9ve_image" ]
+      In BuildTree "root" "/armv7_a9ve_1_image" ]
     "Boot on a single-core Cortex-A9 FVP model",
 
     boot "FVP_VE_A9x4" [ "armv7" ] [
       Str "FVP_VE_Cortex-A9x4",
-      In BuildTree "root" "/armv7_a9ve_image" ]
+      In BuildTree "root" "/armv7_a9ve_4_image" ]
     "Boot on a four-core Cortex-A9 FVP model",
 
     boot "qemu_x86_64" [ "x86_64" ] [
index 92ccf5d..e8da584 100644 (file)
@@ -50,7 +50,7 @@ let commonCFiles = [ "common.c", "main.c" ]
 
     --- libraries ---
 
-    commonLibraries = [ "spawndomain", "elf", "octopus", "bench" ]
+    commonLibraries = [ "spawndomain", "elf", "octopus", "bench", "skb" ]
 
     archLibraries arch = case arch of 
         "x86_64" -> [ "vfs", "acpi_client" ]
@@ -77,7 +77,7 @@ let commonCFiles = [ "common.c", "main.c" ]
             addLibraries = libDeps (commonLibraries ++ (archLibraries arch)),
             flounderDefs = commonFlounderDefs ++ (archFlounderDefs arch),
             flounderExtraDefs = archFlounderExtraDefs arch, 
-            flounderBindings = ["intermon"],
+            flounderBindings = [ "intermon", "octopus" ],
             architectures = [ arch ] 
         } | arch <- allArchitectures
 
index 666e3d9..fa3082c 100644 (file)
@@ -18,6 +18,8 @@
 #include <barrelfish/syscall_arch.h>
 #include <target/arm/barrelfish_kpi/arm_core_data.h>
 
+#include <skb/skb.h>
+
 /// Round up n to the next multiple of size
 #define ROUND_UP(n, size)           ((((n) + (size) - 1)) & (~((size) - 1)))
 
@@ -36,67 +38,20 @@ extern coreid_t my_arch_id;
 extern struct capref ipi_cap;
 
 errval_t get_core_info(coreid_t core_id, 
-                       archid_t* apic_id, 
+                       archid_t* hw_id, 
                        enum cpu_type* cpu_type) {
+    char* record = NULL;
+    errval_t err = oct_get(&record, "hw.processor.%"PRIuCOREID"", core_id);
+    if (err_is_fail(err)) return err;
 
-    *apic_id = core_id;
-    *cpu_type = CPU_ARM7;
-    return SYS_ERR_OK;
-}
-
-errval_t get_architecture_config(enum cpu_type type,
-                                genpaddr_t *arch_page_size,
-                                const char **monitor_binary,
-                                const char **cpu_binary)
-{
-    errval_t err;
-    extern char* cmd_monitor_binary;
-    extern char* cmd_kernel_binary;
-
-    struct monitor_blocking_rpc_client *cl = get_monitor_blocking_rpc_client();
-    assert(cl != NULL);
-
-    uint32_t arch, platform;
-    err = cl->vtbl.get_platform(cl, &arch, &platform);
-    assert(err_is_ok(err));
-
-    switch (type) {
-
-    case CPU_ARM7:
-        assert(arch == PI_ARCH_ARMV7A);
-
-        *arch_page_size = BASE_PAGE_SIZE;
-        *monitor_binary = (cmd_monitor_binary == NULL) ?
-                          "/" BF_BINARY_PREFIX "armv7/sbin/monitor" :
-                          get_binary_path("/" BF_BINARY_PREFIX "armv7/sbin/%s", 
-                                          cmd_monitor_binary);
-        switch(platform) {
-        /* This needs to vary based on CPU, or the CPU driver needs to be
-         * unified. */
-        case PI_PLATFORM_VEXPRESS:
-            *cpu_binary = (cmd_kernel_binary == NULL) ?
-                          "/" BF_BINARY_PREFIX "armv7/sbin/cpu_a9ve" :
-                          get_binary_path("/" BF_BINARY_PREFIX "armv7/sbin/%s",
-                                          cmd_kernel_binary);
-            break;
-
-        case PI_PLATFORM_OMAP44XX:
-            *cpu_binary = (cmd_kernel_binary == NULL) ?
-                "/" BF_BINARY_PREFIX "armv7/sbin/cpu_omap44xx" :
-                get_binary_path("/" BF_BINARY_PREFIX "armv7/sbin/%s",
-                        cmd_kernel_binary);
-            break;
-
-        default:
-            return SPAWN_ERR_UNKNOWN_TARGET_ARCH;
-        }
-        break;
-
-    default:
-        return SPAWN_ERR_UNKNOWN_TARGET_ARCH;
-    }
-    DEBUG("Selected CPU binary %s\n", *cpu_binary);
+    int apic, enabled, type;
+    err = oct_read(record, "_ { hw_id: %d, enabled: %d, type: %d}",
+                   &apic, &enabled, &type);
+    assert (enabled);
+    if (err_is_fail(err)) return err;
 
+    *hw_id = (archid_t) apic;
+    *cpu_type = (enum cpu_type) type;
     return SYS_ERR_OK;
 }
 
@@ -510,16 +465,36 @@ errval_t spawn_xcore_monitor(coreid_t coreid, int hwid,
                              struct frame_identity urpc_frame_id,
                              struct capref kcb)
 {
-    const char *monitorname = NULL, *cpuname = NULL;
+    char cpuname[256], monitorname[256];
     genpaddr_t arch_page_size;
     errval_t err;
 
+    if(cpu_type != CPU_ARM7)
+        return SPAWN_ERR_UNKNOWN_TARGET_ARCH;
+
     /* XXX - ignore command line passed in.  Fixing this requires
      * cross-architecture changes. */
     cmdline= NULL;
 
-    err = get_architecture_config(cpu_type, &arch_page_size,
-                                  &monitorname, &cpuname);
+    err = skb_client_connect();
+    if (err_is_fail(err)) {
+        USER_PANIC_ERR(err, "Connect to SKB.");
+    }
+
+    arch_page_size= BASE_PAGE_SIZE;
+
+    /* Query the SKB for the CPU driver to use. */
+    err= skb_execute_query("arm_core(%d,T), cpu_driver(T,S), write(res(S)).",
+                           hwid);
+    if (err_is_fail(err)) return err;
+    err= skb_read_output("res(%255[^)])", cpuname);
+    if (err_is_fail(err)) return err;
+
+    /* Query the SKB for the monitor binary to use. */
+    err= skb_execute_query("arm_core(%d,T), monitor(T,S), write(res(S)).",
+                           hwid);
+    if (err_is_fail(err)) return err;
+    err= skb_read_output("res(%255[^)])", monitorname);
     if (err_is_fail(err)) return err;
 
     // map cpu and monitor module
index 7c26cea..91f58e6 100644 (file)
@@ -115,11 +115,26 @@ errval_t arch_startup(char * add_device_db_file)
 {
     errval_t err = SYS_ERR_OK;
 
+    KALUGA_DEBUG("Kaluga running on ARMv7.\n");
+
     err = skb_client_connect();
     if (err_is_fail(err)) {
         USER_PANIC_ERR(err, "Connect to SKB.");
     }
 
+    // Make sure the driver db is loaded
+    err = skb_execute("[device_db].");
+    if (err_is_fail(err)) {
+        USER_PANIC_SKB_ERR(err, "Device DB not loaded.");
+    }
+    if(add_device_db_file != NULL){
+        err = skb_execute_query("[%s].", add_device_db_file);
+        if(err_is_fail(err)){
+            USER_PANIC_SKB_ERR(err, "Additional device db file %s not loaded.",
+                               add_device_db_file);
+        }
+    }
+
     struct monitor_blocking_rpc_client *m = get_monitor_blocking_rpc_client();
     assert(m != NULL);
 
@@ -135,11 +150,23 @@ errval_t arch_startup(char * add_device_db_file)
     err = m->vtbl.get_platform_arch(m, buf, &buflen);
     assert(buflen == sizeof(struct arch_info_armv7));
 
-    debug_printf("CPU driver reports %u core(s).\n", arch_info->ncores);
+    /* Query the SKB for the available cores on this platform - we can't
+     * generally discover this on ARMv7. */
+    err= skb_execute_query("arm_mpids(L) ,write(L).");
+    if (err_is_fail(err)) {
+        USER_PANIC_SKB_ERR(err, "Finding cores.");
+    }
 
-    /* Add SKB records for all cores. */
-    for(coreid_t i= 0; i < arch_info->ncores; i++) {
-        oct_set(HW_PROCESSOR_ARM_RECORD_FORMAT, i, 1, i, i, CPU_ARM7);
+    /* Create Octopus records for the known cores. */
+    debug_printf("CPU driver reports %u core(s).\n", arch_info->ncores);
+    int mpidr_raw;
+    struct list_parser_status skb_list;
+    skb_read_list_init(&skb_list);
+    uint32_t bf_core_id= 0;
+    while(skb_read_list(&skb_list, "mpid(%d)", &mpidr_raw)) {
+        oct_set(HW_PROCESSOR_ARM_RECORD_FORMAT,
+                bf_core_id, 1, bf_core_id, (uint32_t)mpidr_raw, CPU_ARM7);
+        bf_core_id++;
     }
 
     KALUGA_DEBUG("Kaluga: watch_for_cores\n");
index e4f23b7..d2a3dd1 100644 (file)
@@ -10,7 +10,8 @@
 --
 --------------------------------------------------------------------------
 
-let ramfs_files = find inDir "programs" ".pl"
+let ramfs_files = find inDir "programs" ".pl" ++
+                  find inDir ("programs" </> "platforms") ".pl"
     ramdisk = "/skb_ramfs.cpio.gz"
     args arch = application {
                         target = "skb",
diff --git a/usr/skb/programs/plat_FVP_VE_A9x1.pl b/usr/skb/programs/plat_FVP_VE_A9x1.pl
new file mode 100644 (file)
index 0000000..fa400b6
--- /dev/null
@@ -0,0 +1,16 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Copyright (c) 2016, ETH Zurich.
+% All rights reserved.
+%
+% This file is distributed under the terms in the attached LICENSE file.
+% If you do not find this file, copies can be found by writing to:
+% ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Statically-initialised hardware facts for the Fixed Virtual Platform A9x1
+
+cpu_driver(cortexA9, "/armv7/sbin/cpu_a9ve").
+monitor(cortexA9, "/armv7/sbin/monitor").
+
+% One cluster of one Cortex A9
+arm_core(16'000000,cortexA9).
diff --git a/usr/skb/programs/plat_FVP_VE_A9x4.pl b/usr/skb/programs/plat_FVP_VE_A9x4.pl
new file mode 100644 (file)
index 0000000..379f9e4
--- /dev/null
@@ -0,0 +1,19 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Copyright (c) 2016, ETH Zurich.
+% All rights reserved.
+%
+% This file is distributed under the terms in the attached LICENSE file.
+% If you do not find this file, copies can be found by writing to:
+% ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Statically-initialised hardware facts for the Fixed Virtual Platform A9x4
+
+cpu_driver(cortexA9, "/armv7/sbin/cpu_a9ve").
+monitor(cortexA9, "/armv7/sbin/monitor").
+
+% One cluster of four Cortex A9s
+arm_core(16'000000,cortexA9).
+arm_core(16'000001,cortexA9).
+arm_core(16'000002,cortexA9).
+arm_core(16'000003,cortexA9).
diff --git a/usr/skb/programs/plat_PandaboardES.pl b/usr/skb/programs/plat_PandaboardES.pl
new file mode 100644 (file)
index 0000000..bb8d586
--- /dev/null
@@ -0,0 +1,17 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Copyright (c) 2016, ETH Zurich.
+% All rights reserved.
+%
+% This file is distributed under the terms in the attached LICENSE file.
+% If you do not find this file, copies can be found by writing to:
+% ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Statically-initialised hardware facts for the Pandaboard ES
+
+cpu_driver(cortexA9, "/armv7/sbin/cpu_omap44xx").
+monitor(cortexA9, "/armv7/sbin/monitor").
+
+% One cluster of two Cortex A9s
+arm_core(16'000000,cortexA9).
+arm_core(16'000001,cortexA9).
index 646d568..f268ed4 100644 (file)
@@ -132,6 +132,8 @@ get_core_info(ProxDomain, CoreID, Arch, ApicID) :-
         ProxDomain = 0  
     ).
 
+arm_mpids(L) :-
+    findall(mpid(MPID), arm_core(MPID,_), L).
 
 
 % this function gets the system RAM size