From b66f20ae24dbf1895a2ed71b01fe1e24c2d69e37 Mon Sep 17 00:00:00 2001 From: Sparchatus Date: Mon, 25 Apr 2022 14:44:45 +0000 Subject: [PATCH] Fix coreboot cache flushing. --- lib/aos/coreboot.c | 9 +++++++-- usr/init/main.c | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/aos/coreboot.c b/lib/aos/coreboot.c index c9d502d..f493232 100644 --- a/lib/aos/coreboot.c +++ b/lib/aos/coreboot.c @@ -217,7 +217,7 @@ errval_t coreboot(coreid_t mpid, // - Get and load the CPU and boot driver binary. struct mem_region * bootdriver_module = multiboot_find_module(bi, boot_driver); - if (bootdriver_module == NULL) return LIB_ERR_COREBOOT_FIND_MODULE; + if (bootdriver_module == NULL) return LIB_ERR_COREBOOT_FIND_MODULE; struct mem_region * cpudriver_module = multiboot_find_module(bi, cpu_driver); if (cpudriver_module == NULL) return LIB_ERR_COREBOOT_FIND_MODULE; @@ -375,13 +375,18 @@ errval_t coreboot(coreid_t mpid, // find cpu driver entry point core_data->cpu_driver_entry = reloc_cpudriver_entry + ARMv8_KERNEL_OFFSET; + debug_printf("[coreboot] Flush the cache\n"); + // - Flush the cache. //memory barrier __asm volatile ( "dmb sy\n" ); //clean and invalidate cache - cpu_idcache_wbinv_range(0, VADDR_SIZE); + // cpu_idcache_wbinv_range(0, VADDR_SIZE); + cpu_idcache_wbinv_range((genvaddr_t)remote_bootdriver_elf_addr, remote_bootdriver_elf_frame_id.bytes); + cpu_idcache_wbinv_range((genvaddr_t)remote_cpudriver_elf_addr, remote_cpudriver_elf_frame_id.bytes); + cpu_idcache_wbinv_range((genvaddr_t)core_data, PAGE_SIZE); // - Call the invoke_monitor_spawn_core with the entry point // of the boot driver and pass the (physical, of course) address of the diff --git a/usr/init/main.c b/usr/init/main.c index 25415f8..8903453 100644 --- a/usr/init/main.c +++ b/usr/init/main.c @@ -81,9 +81,13 @@ bsp_main(int argc, char *argv[]) { default: USER_PANIC("Platform not implemented"); } - // TODO rueegges: what is the MPID of the second core? + // TODO rueegges: can we get the mpid in a better way? 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); + // err = coreboot(2, "boot_armv8_generic", cpu_driver_name, "init", urpc_frame_id); + // if (err_is_fail(err)) return err_push(err, MON_ERR_SPAWN_CORE); + // err = coreboot(3, "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();