coreboot on the Xeon Phi:
authorReto Achermann <reto.achermann@inf.ethz.ch>
Fri, 28 Nov 2014 08:05:31 +0000 (09:05 +0100)
committerReto Achermann <reto.achermann@inf.ethz.ch>
Fri, 28 Nov 2014 08:05:31 +0000 (09:05 +0100)
added creating of the realmode segment capability in Kernel
added corectrl to the domains to be spawned by monitor on the Xeon Phi
adapted coreboot to use the predefined capability in taskcn/coreboot
slot.
added switch cases for the K1OM architecture in corectrl.

kernel/arch/k1om/startup_arch.c
usr/drivers/cpuboot/x86boot.c
usr/init/spawn.c
usr/monitor/main.c
usr/monitor/spawn.c
usr/startd/spawn.c

index a923134..0b0dc12 100644 (file)
@@ -151,7 +151,7 @@ static void create_phys_caps(lpaddr_t init_alloc_addr)
     errval_t err;
 
     // map first meg of RAM, which contains lots of crazy BIOS tables
-    err = create_caps_to_cnode(0, K1OM_START_KERNEL_PHYS, 
+    err = create_caps_to_cnode(0, K1OM_START_KERNEL_PHYS,
                                RegionType_PlatformData, &spawn_state, bootinfo);
     assert(err_is_ok(err));
 
@@ -364,7 +364,7 @@ static struct dcb *spawn_init_common(struct spawn_state *st, const char *name,
 
     // Map IO cap in task cnode
     struct cte *iocap = caps_locate_slot(CNODE(st->taskcn), TASKCN_SLOT_SYSMEM);
-    err = caps_create_new(ObjType_DevFrame, XEON_PHI_SYSMEM_BASE, 
+    err = caps_create_new(ObjType_DevFrame, XEON_PHI_SYSMEM_BASE,
                           XEON_PHI_SYSMEM_SIZE_BITS, XEON_PHI_SYSMEM_SIZE_BITS,
                           iocap);
     /*
@@ -372,10 +372,13 @@ static struct dcb *spawn_init_common(struct spawn_state *st, const char *name,
      *      capability to the host memory, as this can be seen as IO
      */
     struct cte *mmiocap = caps_locate_slot(CNODE(st->taskcn), TASKCN_SLOT_IO);
-    err = caps_create_new(ObjType_DevFrame, XEON_PHI_SBOX_BASE, 
+    err = caps_create_new(ObjType_DevFrame, XEON_PHI_SBOX_BASE,
                           XEON_PHI_SBOX_SIZE_BITS, XEON_PHI_SBOX_SIZE_BITS,
                           mmiocap);
 
+    struct cte *coreboot = caps_locate_slot(CNODE(st->taskcn), TASKCN_SLOT_COREBOOT);
+    err = caps_create_new(ObjType_DevFrame, 0, 16, 16, coreboot);
+
     assert(err_is_ok(err));
 
     /* Set fields in DCB */
index 28b31ec..191d3ca 100644 (file)
@@ -18,7 +18,9 @@
 #include <target/x86_64/barrelfish_kpi/paging_target.h>
 #include <barrelfish/deferred.h>
 
-
+#ifdef __k1om__
+#include <barrelfish_kpi/asm_inlines_arch.h>
+#endif
 #include <arch/x86/start_aps.h>
 #include <target/x86_64/offsets_target.h>
 #include <target/x86_32/offsets_target.h>
@@ -172,8 +174,21 @@ int start_aps_x86_64_start(uint8_t core_id, genvaddr_t entry)
     struct capref bootcap;
 
 #ifdef __k1om__
-    frame_alloc(&bootcap, 1<<16, NULL);
-    // XXX: what's that
+    struct capref realmodecap;
+
+    realmodecap.cnode = cnode_task;
+    realmodecap.slot  = TASKCN_SLOT_COREBOOT;
+    err = slot_alloc(&bootcap);
+    if (err_is_fail(err)) {
+        USER_PANIC_ERR(err, "Allocating a new slot");
+    }
+
+    err = cap_copy(bootcap, realmodecap);
+    if (err_is_fail(err)) {
+        USER_PANIC_ERR(err, "Copying capability");
+    }
+
+
 #else
     struct acpi_rpc_client* acl = get_acpi_rpc_client();
     errval_t error_code;
@@ -241,9 +256,8 @@ int start_aps_x86_64_start(uint8_t core_id, genvaddr_t entry)
     end = bench_tsc();
 
 #if  defined(__k1om__)
-    barrelfish_usleep(10*1000);
+    delay_ms(10);
 #endif
-
     err = invoke_send_init_ipi(ipi_cap, core_id);
     if (err_is_fail(err)) {
         DEBUG_ERR(err, "invoke send init ipi");
@@ -251,7 +265,7 @@ int start_aps_x86_64_start(uint8_t core_id, genvaddr_t entry)
     }
 
 #if  defined(__k1om__)
-    barrelfish_usleep(200*1000);
+    delay_ms(200);
 #endif
 
     // x86 protocol actually would like us to do this twice
@@ -444,7 +458,8 @@ static errval_t relocate_cpu_binary(lvaddr_t cpu_binary,
                                     genpaddr_t arch_page_size)
 {
     switch (cpu_head->e_machine) {
-    case EM_X86_64: {
+    case EM_X86_64:
+    case EM_K1OM: {
         struct Elf64_Shdr *rela, *symtab, *symhead =
             (struct Elf64_Shdr *)(cpu_binary + (uintptr_t)cpu_head->e_shoff);
 
@@ -639,6 +654,7 @@ errval_t spawn_xcore_monitor(coreid_t coreid, int hwid,
     struct x86_core_data *core_data = (struct x86_core_data *)cpu_buf_memory;
     switch (cpu_head->e_machine) {
     case EM_X86_64:
+    case EM_K1OM:
         core_data->elf.size = sizeof(struct Elf64_Shdr);
         core_data->elf.addr = cpu_binary_phys + (uintptr_t)cpu_head->e_shoff;
         core_data->elf.num  = cpu_head->e_shnum;
index a74dd7c..9c7e091 100644 (file)
@@ -117,14 +117,23 @@ errval_t initialize_monitor(struct spawninfo *si)
 
 #ifdef __k1om__
     /* Give monitor system memory cap */
-        dest.cnode = si->taskcn;
-        dest.slot  = TASKCN_SLOT_SYSMEM;
-        src.cnode = cnode_task;
-        src.slot  = TASKCN_SLOT_SYSMEM;
-        err = cap_copy(dest, src);
-        if (err_is_fail(err)) {
-            return err_push(err, INIT_ERR_COPY_IO_CAP);
-        }
+    dest.cnode = si->taskcn;
+    dest.slot  = TASKCN_SLOT_SYSMEM;
+    src.cnode = cnode_task;
+    src.slot  = TASKCN_SLOT_SYSMEM;
+    err = cap_copy(dest, src);
+    if (err_is_fail(err)) {
+        return err_push(err, INIT_ERR_COPY_IO_CAP);
+    }
+
+    dest.cnode = si->taskcn;
+    dest.slot  = TASKCN_SLOT_COREBOOT;
+    src.cnode = cnode_task;
+    src.slot  = TASKCN_SLOT_COREBOOT;
+    err = cap_copy(dest, src);
+    if (err_is_fail(err)) {
+        return err_push(err, INIT_ERR_COPY_IO_CAP);
+    }
 #endif
 
 #if __arm__
@@ -138,14 +147,14 @@ errval_t initialize_monitor(struct spawninfo *si)
            return err_push(err, INIT_ERR_COPY_IO_CAP);
        }
        /* Give monitor IRQ */
-           dest.cnode = si->taskcn;
-           dest.slot  = TASKCN_SLOT_IRQ;
-           src.cnode = cnode_task;
-           src.slot  = TASKCN_SLOT_IRQ;
-           err = cap_copy(dest, src);
-           if (err_is_fail(err)) {
-               return err_push(err, INIT_ERR_COPY_IRQ_CAP);
-           }
+       dest.cnode = si->taskcn;
+       dest.slot  = TASKCN_SLOT_IRQ;
+       src.cnode = cnode_task;
+       src.slot  = TASKCN_SLOT_IRQ;
+       err = cap_copy(dest, src);
+       if (err_is_fail(err)) {
+           return err_push(err, INIT_ERR_COPY_IRQ_CAP);
+       }
 #endif
 
 #ifdef CONFIG_INTERCONNECT_DRIVER_UMP
index 21894f1..4470e7a 100644 (file)
@@ -111,6 +111,14 @@ static errval_t boot_bsp_core(int argc, char *argv[])
         DEBUG_ERR(err, "failed spawning xeon_phi");
         return err;
     }
+
+    debug_printf("monitor spawning corectrl\n");
+    err = spawn_domain("corectrl");
+    if (err_is_fail(err)) {
+        DEBUG_ERR(err, "failed spawning xeon_phi");
+        return err;
+    }
+
 #endif
 
     /* initialise rcap_db */
index f40cf41..0e5db1e 100644 (file)
@@ -79,6 +79,17 @@ static errval_t set_special_caps(struct spawninfo *si, const char *pname)
             return err_push(err, SPAWN_ERR_COPY_IRQ_CAP);
         }
     }
+
+    if (!strcmp(name, "corectrl")) {
+        dest.cnode = si->taskcn;
+        dest.slot  = TASKCN_SLOT_COREBOOT;
+        src.cnode = cnode_task;
+        src.slot  = TASKCN_SLOT_COREBOOT;
+        err = cap_copy(dest, src);
+        if (err_is_fail(err)) {
+            return err_push(err, SPAWN_ERR_COPY_IRQ_CAP);
+        }
+    }
 #endif
 
     return SYS_ERR_OK;
@@ -247,7 +258,8 @@ errval_t spawn_all_domains(void)
            !strcmp(short_name, "cpu") ||
            !strcmp(short_name, "monitor") ||
            !strcmp(short_name, "mem_serv")||
-           !strcmp(short_name, "xeon_phi")) {
+           !strcmp(short_name, "xeon_phi") ||
+           !strcmp(short_name, "corectrl")) {
             continue;
         }
 
index ddadad3..5405280 100644 (file)
@@ -292,6 +292,9 @@ void spawn_app_domains(void)
             || strncmp(si.shortname, "cpu", strlen("cpu")) == 0
             || strncmp(si.shortname, "monitor", si.shortnamelen) == 0
             || strncmp(si.shortname, "mem_serv", si.shortnamelen) == 0
+#ifdef __k1om__
+            || strncmp(si.shortname, "corectrl", si.shortnamelen) == 0
+#endif
         ) {
             spawn_here = false;
         }