Made cpuboot compile for the K1OM architecture.
authorReto Achermann <reto.achermann@inf.ethz.ch>
Wed, 26 Nov 2014 15:52:12 +0000 (16:52 +0100)
committerReto Achermann <reto.achermann@inf.ethz.ch>
Wed, 26 Nov 2014 15:52:12 +0000 (16:52 +0100)
Adding of triplet parameter for the boot program:
corectrl boot {from:step:to}

usr/drivers/cpuboot/Hakefile
usr/drivers/cpuboot/coreboot.h
usr/drivers/cpuboot/main.c
usr/drivers/cpuboot/x86boot.c

index c3fd61e..be120bb 100644 (file)
@@ -28,6 +28,12 @@ in [
     },
     build template {
         addLibraries = libDeps ["vfs", "spawndomain", "elf", "octopus", "bench"],
+        cFiles = ["common.c", "main.c", "x86boot.c"],
+        assemblyFiles = ["init_ap_x86_64.S", "init_ap_x86_32.S"],
+        architectures = ["k1om"]
+    },
+    build template {
+        addLibraries = libDeps ["vfs", "spawndomain", "elf", "octopus", "bench"],
         cFiles = ["common.c", "main.c", "armboot.c"],
         architectures = ["armv7", "armv5"]
     }
index 0347262..3386b5a 100644 (file)
 #include <if/monitor_blocking_rpcclient_defs.h>
 #include <if/intermon_defs.h>
 
-#if defined(__x86__)
+#if defined(__x86__) && !defined(__k1om__)
 #include <acpi_client/acpi_client.h>
 #endif
 
 #define DEBUG_CPUBOOT 1
-#ifdef DEBUG_CPUBOOT
-#define DEBUG(x...) if (debug_flag) debug_printf(x)
+#ifdef __k1om__
+#define DEBUG(x...) debug_printf(x)
 #else
 #define DEBUG(x...) ((void)0)
 #endif
index 26bea7d..cb74694 100644 (file)
@@ -64,7 +64,7 @@ static void initialize(void)
     vfs_init();
     bench_arch_init();
 
-#if defined(__x86__)
+#if defined(__x86__) && !defined(__k1om__)
     err = connect_to_acpi();
     if (err_is_fail(err)) {
         USER_PANIC_ERR(err, "connect to acpi failed.");
@@ -91,6 +91,35 @@ struct cmd {
     int argc;
 };
 
+static int parse_core_list(char *list, coreid_t *from, coreid_t *to, coreid_t *step)
+{
+    assert(from && to && step);
+
+    int num, parsed_from,parsed_to,parsed_step;
+    num = sscanf(list, "%x:%x:%x", &parsed_from, &parsed_to, &parsed_step);
+    switch(num) {
+        case 1:
+            *from = (coreid_t)parsed_from;
+            *to = (coreid_t)parsed_from;
+            *step = 1;
+            break;
+        case 2:
+            *from = (coreid_t)parsed_from;
+            *to = (coreid_t)parsed_to;
+            *step = 1;
+            break;
+        case 3:
+            *from = (coreid_t)parsed_from;
+            *to = (coreid_t)parsed_to;
+            *step = (coreid_t)parsed_step;
+            break;
+        default:
+            return 0;
+            break;
+    }
+    return num;
+}
+
 static int list_kcb(int argc, char **argv) {
     char** names;
     size_t len;
@@ -110,7 +139,7 @@ static int list_kcb(int argc, char **argv) {
 
         printf("KCB %"PRIu64": CORE_ID=%"PRIu64" CAP_STORAGE_KEY=%s\n",
                kcb_id, barrelfish_id, cap_key);
-        
+
         free(cap_key);
         free(record);
     }
@@ -157,48 +186,52 @@ static int list_cpu(int argc, char **argv) {
 
 static int boot_cpu(int argc, char **argv)
 {
-    coreid_t target_id = (coreid_t) strtol(argv[1], NULL, 16);
-    assert(target_id < MAX_COREID);
-    
-    archid_t target_apic_id;
-    enum cpu_type cpu_type;
-    errval_t err = get_core_info(target_id, &target_apic_id, &cpu_type);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "get_apic_id failed.");
-    }
+    coreid_t core_from = 0, core_to = 0, core_step = 0;
+    parse_core_list(argv[1], &core_from, &core_to, &core_step);
+    for (coreid_t target_id = core_from; target_id<=core_to; target_id += core_step) {
+        //coreid_t target_id = (coreid_t) strtol(argv[1], NULL, 16);
+        assert(target_id < MAX_COREID);
+
+        archid_t target_apic_id;
+        enum cpu_type cpu_type;
+        errval_t err = get_core_info(target_id, &target_apic_id, &cpu_type);
+        if (err_is_fail(err)) {
+            USER_PANIC_ERR(err, "get_apic_id failed.");
+        }
 
-    struct capref kcb;
-    err = create_or_get_kcb_cap(target_id, &kcb);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "Can not get KCB.");
-    }
+        struct capref kcb;
+        err = create_or_get_kcb_cap(target_id, &kcb);
+        if (err_is_fail(err)) {
+            USER_PANIC_ERR(err, "Can not get KCB.");
+        }
 
-    struct capref frame;
-    size_t framesize;
-    struct frame_identity urpc_frame_id;
-    err = frame_alloc_identify(&frame, MON_URPC_SIZE, &framesize, &urpc_frame_id);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "frame_alloc_identify failed.");
-    }
+        struct capref frame;
+        size_t framesize;
+        struct frame_identity urpc_frame_id;
+        err = frame_alloc_identify(&frame, MON_URPC_SIZE, &framesize, &urpc_frame_id);
+        if (err_is_fail(err)) {
+            USER_PANIC_ERR(err, "frame_alloc_identify failed.");
+        }
 
-    err = cap_mark_remote(frame);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "Can not mark cap remote.");
-    }
+        err = cap_mark_remote(frame);
+        if (err_is_fail(err)) {
+            USER_PANIC_ERR(err, "Can not mark cap remote.");
+        }
 
-    struct monitor_binding *mb = get_monitor_binding();
-    err = mb->tx_vtbl.boot_core_request(mb, NOP_CONT, target_id, frame);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "boot_core_request failed");
-    }
+        struct monitor_binding *mb = get_monitor_binding();
+        err = mb->tx_vtbl.boot_core_request(mb, NOP_CONT, target_id, frame);
+        if (err_is_fail(err)) {
+            USER_PANIC_ERR(err, "boot_core_request failed");
+        }
 
-    err = spawn_xcore_monitor(target_id, target_apic_id, 
-                              cpu_type, cmd_kernel_args,
-                              urpc_frame_id, kcb);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "spawn xcore monitor failed.");
-    }
+        err = spawn_xcore_monitor(target_id, target_apic_id,
+                                  cpu_type, cmd_kernel_args,
+                                  urpc_frame_id, kcb);
+        if (err_is_fail(err)) {
+            USER_PANIC_ERR(err, "spawn xcore monitor failed.");
+        }
 
+    }
     return 0;
 }
 
@@ -207,7 +240,7 @@ static int update_cpu(int argc, char** argv)
 {
     coreid_t target_id = (coreid_t) strtol(argv[1], NULL, 16);
     assert(target_id < MAX_COREID);
-    
+
     archid_t target_apic_id;
     enum cpu_type cpu_type;
     errval_t err = get_core_info(target_id, &target_apic_id, &cpu_type);
@@ -589,7 +622,7 @@ out:
     if (err_is_fail(err)) {
         USER_PANIC_ERR(err, "can not unlock corectrl.");
     }
-    // 
+    //
 #endif
 
     DEBUG("corectrl is done.");
index 366bc6f..28b31ec 100644 (file)
@@ -58,10 +58,11 @@ errval_t get_core_info(coreid_t core_id, archid_t* apic_id, enum cpu_type* cpu_t
     assert(step == 1 || step == 2 || step == 4);
 
     *apic_id = (core_id * step);
-    if (apic_id == my_arch_id) {
+    if (*apic_id == my_arch_id) {
         *apic_id += step;
     }
     *cpu_type = CPU_K1OM;
+    return SYS_ERR_OK;
 #else
     char* record = NULL;
     errval_t err = oct_get(&record, "hw.processor.%"PRIuCOREID"", core_id);
@@ -100,11 +101,11 @@ errval_t get_architecture_config(enum cpu_type type,
         *arch_page_size = X86_64_BASE_PAGE_SIZE;
         *monitor_binary = (cmd_kernel_binary == NULL) ?
                         "/x86_64/sbin/monitor" :
-                        get_binary_path("/x86_64/sbin/%s", 
+                        get_binary_path("/x86_64/sbin/%s",
                                         cmd_monitor_binary);
         *cpu_binary = (cmd_kernel_binary == NULL) ?
                         "/x86_64/sbin/cpu" :
-                        get_binary_path("/x86_64/sbin/%s", 
+                        get_binary_path("/x86_64/sbin/%s",
                                         cmd_kernel_binary);
     }
     break;
@@ -114,11 +115,11 @@ errval_t get_architecture_config(enum cpu_type type,
         *arch_page_size = X86_32_BASE_PAGE_SIZE;
         *monitor_binary = (cmd_kernel_binary == NULL) ?
                         "/x86_32/sbin/monitor" :
-                        get_binary_path("/x86_32/sbin/%s", 
+                        get_binary_path("/x86_32/sbin/%s",
                                         cmd_monitor_binary);
         *cpu_binary = (cmd_kernel_binary == NULL) ?
                         "/x86_32/sbin/cpu" :
-                        get_binary_path("/x86_32/sbin/%s", 
+                        get_binary_path("/x86_32/sbin/%s",
                                         cmd_kernel_binary);
     }
     break;
@@ -128,11 +129,11 @@ errval_t get_architecture_config(enum cpu_type type,
         *arch_page_size = X86_64_BASE_PAGE_SIZE;
         *monitor_binary = (cmd_kernel_binary == NULL) ?
                         "/k1om/sbin/monitor" :
-                        get_binary_path("/k1om/sbin/%s", 
+                        get_binary_path("/k1om/sbin/%s",
                                         cmd_monitor_binary);
         *cpu_binary = (cmd_kernel_binary == NULL) ?
                         "/k1om/sbin/cpu" :
-                        get_binary_path("/k1om/sbin/%s", 
+                        get_binary_path("/k1om/sbin/%s",
                                         cmd_kernel_binary);
     }
     break;
@@ -162,14 +163,21 @@ int start_aps_x86_64_start(uint8_t core_id, genvaddr_t entry)
 {
     DEBUG("%s:%d: start_aps_x86_64_start\n", __FILE__, __LINE__);
 
+    errval_t err;
+
     // Copy the startup code to the real-mode address
     uint8_t *real_src = (uint8_t *) &x86_64_start_ap;
     uint8_t *real_end = (uint8_t *) &x86_64_start_ap_end;
 
     struct capref bootcap;
+
+#ifdef __k1om__
+    frame_alloc(&bootcap, 1<<16, NULL);
+    // XXX: what's that
+#else
     struct acpi_rpc_client* acl = get_acpi_rpc_client();
     errval_t error_code;
-    errval_t err = acl->vtbl.mm_realloc_range_proxy(acl, 16, 0x0,
+    err = acl->vtbl.mm_realloc_range_proxy(acl, 16, 0x0,
                                                     &bootcap, &error_code);
     if (err_is_fail(err)) {
         USER_PANIC_ERR(err, "mm_alloc_range_proxy failed.");
@@ -177,6 +185,7 @@ int start_aps_x86_64_start(uint8_t core_id, genvaddr_t entry)
     if (err_is_fail(error_code)) {
         USER_PANIC_ERR(error_code, "mm_alloc_range_proxy return failed.");
     }
+#endif
 
     void* real_base;
     err = vspace_map_one_frame(&real_base, 1<<16, bootcap, NULL, NULL);
@@ -272,7 +281,7 @@ int start_aps_x86_64_start(uint8_t core_id, genvaddr_t entry)
     return -1;
 }
 
-
+#ifndef __k1om__
 int start_aps_x86_32_start(uint8_t core_id, genvaddr_t entry)
 {
     DEBUG("%s:%d: start_aps_x86_32_start\n", __FILE__, __LINE__);
@@ -376,6 +385,7 @@ int start_aps_x86_32_start(uint8_t core_id, genvaddr_t entry)
     assert(!"badness");
     return -1;
 }
+#endif
 
 /**
  * Allocates memory for kernel binary.
@@ -682,9 +692,12 @@ errval_t spawn_xcore_monitor(coreid_t coreid, int hwid,
     if (cpu_type == CPU_X86_64 || cpu_type == CPU_K1OM) {
         start_aps_x86_64_start(hwid, foreign_cpu_reloc_entry);
     }
+
+#ifndef __k1om__
     else if (cpu_type == CPU_X86_32) {
         start_aps_x86_32_start(hwid, foreign_cpu_reloc_entry);
     }
+#endif
 
     /* Clean up */
     // XXX: Should not delete the remote caps?