Merge Aurel and Sandro proress
This commit is contained in:
parent
ea92f78fca
commit
1e225bac85
@ -18,6 +18,7 @@
|
||||
#include <aos/aos.h>
|
||||
|
||||
#define RPC_SHARED_SIZE PAGE_SIZE
|
||||
#define RPC_URPC_FRAME_SIZE PAGE_SIZE
|
||||
|
||||
// define some message types
|
||||
enum rpc_mtype {
|
||||
|
||||
@ -198,7 +198,7 @@ errval_t coreboot(coreid_t mpid,
|
||||
// Note that it should at least OBJSIZE_KCB, and it should also be aligned
|
||||
// to a multiple of 16k.
|
||||
struct capref kcb_ram_cap;
|
||||
err = ram_alloc_aligned(&kcb_ram_cap, OBJSIZE_KCB, 4 * BASE_PAGE_SIZE);
|
||||
err = ram_alloc_aligned(&kcb_ram_cap, OBJSIZE_KCB, PAGE_SIZE_16K);
|
||||
if (err_is_fail(err)) return err;
|
||||
|
||||
struct capref kcb_cap;
|
||||
@ -206,15 +206,15 @@ errval_t coreboot(coreid_t mpid,
|
||||
if (err_is_fail(err)) return err;
|
||||
err = cap_retype(kcb_cap, kcb_ram_cap, 0, ObjType_KernelControlBlock, OBJSIZE_KCB, 1);
|
||||
if (err_is_fail(err)) return err;
|
||||
// TODO rueegges: does freeing the capability slot work?
|
||||
// err = cap_delete(kcb_ram_cap);
|
||||
// if (err_is_fail(err)) return err_push(err, LIB_ERR_CAP_DELETE);
|
||||
|
||||
// - Get and load the CPU and boot driver binary.
|
||||
struct mem_region * bootdriver_module = multiboot_find_module(bi, "boot_armv8_generic");
|
||||
struct mem_region * bootdriver_module = multiboot_find_module(bi, boot_driver);
|
||||
if (bootdriver_module == NULL) return LIB_ERR_COREBOOT_FIND_MODULE;
|
||||
|
||||
//afeer: toradex board:
|
||||
struct mem_region * cpudriver_module = multiboot_find_module(bi, "cpu_imx8x");
|
||||
//afeer: qemu:
|
||||
// struct mem_region *cpudriver_module = multiboot_find_module(bi, "cpu_a57_qemu");
|
||||
struct mem_region * cpudriver_module = multiboot_find_module(bi, cpu_driver);
|
||||
if (cpudriver_module == NULL) return LIB_ERR_COREBOOT_FIND_MODULE;
|
||||
|
||||
// - Load the ELF binary
|
||||
@ -227,18 +227,61 @@ errval_t coreboot(coreid_t mpid,
|
||||
|
||||
|
||||
// - Allocate a page for the core data struct
|
||||
struct armv8_core_data * core_data = malloc(BASE_PAGE_SIZE);
|
||||
// TODO: free
|
||||
struct capref core_data_frame;
|
||||
err = frame_alloc(&core_data_frame, BASE_PAGE_SIZE, NULL);
|
||||
if(err_is_fail(err)) return err_push(err, LIB_ERR_FRAME_ALLOC);
|
||||
struct frame_identity core_data_frame_id;
|
||||
err = frame_identify(core_data_frame, &core_data_frame_id);
|
||||
if(err_is_fail(err)) return err_push(err, LIB_ERR_FRAME_IDENTIFY);
|
||||
|
||||
// - Allocate stack memory for the new cpu driver (at least 16 pages)
|
||||
char * cpu_driver_stack = paging_malloc(17 * BASE_PAGE_SIZE, NULL, BASE_PAGE_SIZE);
|
||||
// TODO: free
|
||||
struct capref cpu_driver_stack_frame;
|
||||
err = frame_alloc(&cpu_driver_stack_frame, 16 * BASE_PAGE_SIZE, NULL);
|
||||
if(err_is_fail(err)) return err_push(err, LIB_ERR_FRAME_ALLOC);
|
||||
struct frame_identity cpu_driver_stack_frame_id;
|
||||
err = frame_identify(cpu_driver_stack_frame, &cpu_driver_stack_frame_id);
|
||||
if(err_is_fail(err)) return err_push(err, LIB_ERR_FRAME_IDENTIFY);
|
||||
|
||||
// Space to load the init process. This should be at least space for init
|
||||
// plus ARMV8_CORE_DATA_PAGES × BASE_PAGE_SIZE bytes.
|
||||
struct capref init_process_frame;
|
||||
err = frame_alloc(&init_process_frame, init_process_space + ARMV8_CORE_DATA_PAGES * BASE_PAGE_SIZE, NULL);
|
||||
if(err_is_fail(err)) return err_push(err, LIB_ERR_FRAME_ALLOC);
|
||||
struct frame_identity init_process_frame_id;
|
||||
err = frame_identify(init_process_frame, &init_process_frame_id);
|
||||
if(err_is_fail(err)) return err_push(err, LIB_ERR_FRAME_IDENTIFY);
|
||||
|
||||
// - Fill in the core data struct, for a description, see the definition
|
||||
// in include/target/aarch64/barrelfish_kpi/arm_core_data.h
|
||||
core_data->cpu_driver_stack = mem_to_local_phys((lvaddr_t) cpu_driver_stack + 17 * BASE_PAGE_SIZE);
|
||||
core_data->cpu_driver_stack_limit = mem_to_local_phys((lvaddr_t) cpu_driver_stack + BASE_PAGE_SIZE);
|
||||
struct armv8_core_data *core_data;
|
||||
paging_map_frame(get_current_paging_state(), &core_data, PAGE_SIZE, core_data_frame);
|
||||
core_data->boot_magic = ARMV8_BOOTMAGIC_PSCI;
|
||||
|
||||
core_data->cpu_driver_stack = cpu_driver_stack_frame_id.base + 16 * BASE_PAGE_SIZE;
|
||||
core_data->cpu_driver_stack_limit = cpu_driver_stack_frame_id.base;
|
||||
|
||||
core_data->cpu_driver_cmdline = ?;
|
||||
|
||||
core_data->memory.base = init_process_frame_id.base;
|
||||
core_data->memory.length = init_process_frame_id.bytes;
|
||||
|
||||
core_data->urpc_frame.base = urpc_frame_id.base;
|
||||
core_data->urpc_frame.length = urpc_frame_id.bytes;
|
||||
|
||||
core_data->monitor_binary.base = ?;
|
||||
core_data->monitor_binary.length = ?;
|
||||
|
||||
core_data->kcb = ?;
|
||||
|
||||
core_data->src_core_id = disp_get_core_id();
|
||||
core_data->dst_core_id = mpid;
|
||||
core_data->src_arch_id = disp_get_core_id();
|
||||
core_data->dst_arch_id = mpid;
|
||||
|
||||
// find boot entry point
|
||||
genpaddr_t boot_driver_entry = ?;
|
||||
// find cpu driver entry point
|
||||
core_data->cpu_driver_entry = ?;
|
||||
// - Find the CPU driver entry point. Look for the symbol "arch_init". Put
|
||||
// the address in the core data struct.
|
||||
|
||||
@ -254,9 +297,11 @@ errval_t coreboot(coreid_t mpid,
|
||||
// - Call the invoke_monitor_spawn_core with the entry point
|
||||
// of the boot driver and pass the (physical, of course) address of the
|
||||
// boot struct as argument
|
||||
//TODO afeer: insert arguments
|
||||
err = invoke_monitor_spawn_core(1, CPU_ARM8, 0, 0, 0);
|
||||
if (err_is_fail(err)) return err;
|
||||
err = invoke_monitor_spawn_core(mpid, CPU_ARM8, boot_driver_entry, core_data_frame_id.base, 0 /*ignored in aos*/);
|
||||
if (err_is_fail(err)) return err_push(err, MON_ERR_SPAWN_CORE);
|
||||
|
||||
// unmap stuff
|
||||
paging_unmap(get_current_paging_state(), core_data);
|
||||
|
||||
return SYS_ERR_OK;
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#include <grading.h>
|
||||
|
||||
#include "mem_alloc.h"
|
||||
|
||||
#include <aos/coreboot.h>
|
||||
|
||||
|
||||
|
||||
@ -33,9 +33,6 @@ struct bootinfo *bi;
|
||||
coreid_t my_core_id;
|
||||
struct platform_info platform_info;
|
||||
|
||||
|
||||
|
||||
|
||||
static int
|
||||
bsp_main(int argc, char *argv[]) {
|
||||
errval_t err;
|
||||
@ -63,6 +60,31 @@ bsp_main(int argc, char *argv[]) {
|
||||
|
||||
// TODO: Spawn system processes, boot second core etc. here
|
||||
|
||||
// A URPC frame, to hold the cross-core communication channels that you
|
||||
// will implement in Section 7.16.
|
||||
struct capref urpc_frame;
|
||||
err = frame_alloc(&urpc_frame, RPC_URPC_FRAME_SIZE, NULL);
|
||||
if(err_is_fail(err)) return err_push(err, LIB_ERR_FRAME_ALLOC);
|
||||
|
||||
struct frame_identity urpc_frame_id;
|
||||
err = frame_identify(urpc_frame, &urpc_frame_id);
|
||||
if(err_is_fail(err)) return err_push(err, LIB_ERR_CAP_IDENTIFY);
|
||||
// boot second core
|
||||
char *cpu_driver_name;
|
||||
switch (platform_info.platform) {
|
||||
case PI_PLATFORM_QEMU:
|
||||
cpu_driver_name = "cpu_a57_qemu";
|
||||
break;
|
||||
case PI_PLATFORM_IMX8X:
|
||||
cpu_driver_name = "cpu_imx8x";
|
||||
break;
|
||||
default:
|
||||
USER_PANIC("Platform not implemented");
|
||||
}
|
||||
// TODO rueegges: what is the MPID of the second core?
|
||||
err = coreboot(1, "boot_armv8_generic", cpu_driver_name, "init", urpc_frame_id);
|
||||
if (err_is_fail(err)) return err_push(err, MON_ERR_SPAWN_CORE);
|
||||
|
||||
// Grading
|
||||
grading_test_late();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user