diff --git a/core/hw/board/raspberrypi2/board_mem.c b/core/hw/board/raspberrypi2/board_mem.c index af10acd..12b9ae6 100755 --- a/core/hw/board/raspberrypi2/board_mem.c +++ b/core/hw/board/raspberrypi2/board_mem.c @@ -73,9 +73,9 @@ memory_layout_entry memory_padr_layout[] = { MLT_IO_RW_REG, MLF_READABLE | MLF_WRITEABLE}, //Quad-Core processor control (0x40000000 to 0x400000FF) - //Nota bene: All other peripherals are mapped from 3F to FA, this will be + //N.B.: All other peripherals are mapped from 3F to FA, while this will be //mapped to FB. Crude methods which simply assume peripherals to be in the - //range FA will fail here. + //range FA-FB will fail for these registers. {ADDR_TO_PAGE(0x40000000), ADDR_TO_PAGE(0x40000000 + 0x1000), MLT_IO_RW_REG, MLF_READABLE | MLF_WRITEABLE}, diff --git a/core/hw/cpu/arm/armv7a/boot.S b/core/hw/cpu/arm/armv7a/boot.S index 67f0722..2dc48b3 100755 --- a/core/hw/cpu/arm/armv7a/boot.S +++ b/core/hw/cpu/arm/armv7a/boot.S @@ -54,7 +54,8 @@ adr_undef: .word impl_undef impl_reset: /* Start in supervisor mode, disable interrupts. */ msr CPSR_c, #ARM_MODE_SUPERVISOR | ARM_INTERRUPT_MASK - /* Stack pointer starts at the physical address of the hyper stack top. */ + /* Stack pointer starts at the physical address of the hyper stack top. + * In this file, we always boot the primary core. */ ldr sp, =(__hyper_stack_top__ + HAL_OFFSET) //TODO: TEST: diff --git a/core/hw/cpu/arm/armv7a/cpu_init.c b/core/hw/cpu/arm/armv7a/cpu_init.c index 4e93c8c..01e8603 100755 --- a/core/hw/cpu/arm/armv7a/cpu_init.c +++ b/core/hw/cpu/arm/armv7a/cpu_init.c @@ -5,10 +5,10 @@ extern uint32_t __hyper_pt_start__[]; // Symbols address is the value (linker script) -/* forward refrence */ +/* Forward reference */ static return_value default_catcher(uint32_t r0, uint32_t r1, uint32_t r2); -/* callback functions */ +/* Callback functions */ cpu_callback family_callback_inst_abort = default_catcher; cpu_callback family_callback_data_abort = default_catcher; @@ -44,8 +44,8 @@ void cpu_break_to_debugger() /* - * default exception catcher so we dont crash into NULL - * due to very early exceptions + * Default exception catcher so we dont crash into NULL due to very early + * exceptions. */ static return_value default_catcher(uint32_t r0, uint32_t r1, uint32_t r2) { @@ -80,7 +80,7 @@ static return_value default_catcher(uint32_t r0, uint32_t r1, uint32_t r2) void cpu_init() { - /* Invalidate and enable cache*/ + /* Invalidate and enable cache */ //mem_cache_invalidate(TRUE,TRUE,TRUE); //instr, data, writeback //mem_cache_set_enable(TRUE); CacheDataCleanInvalidateAll(); @@ -92,9 +92,9 @@ void cpu_init() uint32_t pt = (uint32_t)GET_PHYS(__hyper_pt_start__); uint32_t ttb_flags = ( pt | TTB_IRGN_WB | TTB_RGN_OC_WB); COP_WRITE(COP_SYSTEM,COP_SYSTEM_TRANSLATION_TABLE1,ttb_flags); - /*The following is Linux specific configuration on armV7, - *These configuration are used to identify what kind of memory - *the address space is by looking at the page attributes */ + /* The following is Linux specific configuration on armV7, + * These configuration are used to identify what kind of memory + * the address space is by looking at the page attributes */ /* * Memory region attributes with SCTLR.TRE=1 @@ -141,7 +141,7 @@ void cpu_init() COP_READ(COP_SYSTEM,COP_SYSTEM_CONTROL, mmu_config); mmu_config &= (~clear); mmu_config |= set; - /*Setting alignment fault with beagleboard crashes it*/ + /* Setting alignment fault with beagleboard crashes it */ //mmu_config |= CR_A; // Set Alignment fault checking COP_WRITE(COP_SYSTEM, COP_SYSTEM_CONTROL, mmu_config); //mem_cache_set_enable(TRUE); diff --git a/core/hw/cpu/arm/armv7a/cpu_mem.c b/core/hw/cpu/arm/armv7a/cpu_mem.c index 2df6932..19f1fad 100755 --- a/core/hw/cpu/arm/armv7a/cpu_mem.c +++ b/core/hw/cpu/arm/armv7a/cpu_mem.c @@ -35,7 +35,7 @@ void mem_mmu_tlb_invalidate_one(BOOL inst, BOOL data, uint32_t virtual_addr) * CACHES */ -/* XXX: this can be simplified alot! /AV */ +/* XXX: this can be simplified a lot! /AV */ static inline signed int log_2_n_round_up(uint32_t n) { signed int log2n = -1; @@ -138,12 +138,12 @@ void mem_cache_set_enable(BOOL enable) void mem_cache_invalidate(BOOL inst_inv, BOOL data_inv, BOOL data_writeback) { uint32_t tmp = 1; - /* first, handle the data cache */ + /* First, handle the data cache. */ if(data_inv) { mem_icache_invalidate(data_writeback); } - /* now, the instruction cache */ + /* Then, the instruction cache. */ if(inst_inv) { COP_WRITE(COP_SYSTEM, COP_ICACHE_INVALIDATE_ALL, tmp); } diff --git a/core/hypervisor/dmmu.c b/core/hypervisor/dmmu.c index f171359..3fe1699 100644 --- a/core/hypervisor/dmmu.c +++ b/core/hypervisor/dmmu.c @@ -71,7 +71,7 @@ void dmmu_init() uint32_t i; dmmu_entry_t * bft = (dmmu_entry_t *) DMMU_BFT_BASE_VA; - /* clear all entries in the table */ + /* Clear all entries in the table. */ for(i = 0; i < DMMU_BFT_COUNT ; i++) { bft[i].all = 0; } @@ -274,7 +274,7 @@ int dmmu_create_L1_pt(addr_t l1_base_pa_add) return ERR_MMU_OUT_OF_CACHEABLE_RANGE; #endif - /* 16KB aligned ? */ + /* 16 KiB aligned ? */ if (l1_base_pa_add != (l1_base_pa_add & 0xFFFFC000)) return ERR_MMU_L1_BASE_IS_NOT_16KB_ALIGNED; @@ -371,7 +371,7 @@ int dmmu_unmap_L1_pt(addr_t l1_base_pa_add) if (!guest_pa_range_checker(l1_base_pa_add, 4*PAGE_SIZE)) return ERR_MMU_OUT_OF_RANGE_PA; - /* 16KB aligned ? */ + /* 16 KiB aligned ? */ if (l1_base_pa_add != (l1_base_pa_add & 0xFFFFC000)) return ERR_MMU_L1_BASE_IS_NOT_16KB_ALIGNED; diff --git a/core/hypervisor/dmmu.h b/core/hypervisor/dmmu.h index 02c0492..d17ad8b 100644 --- a/core/hypervisor/dmmu.h +++ b/core/hypervisor/dmmu.h @@ -5,7 +5,7 @@ // Disabling aggressive flushing //#define AGGRESSIVE_FLUSHING_HANDLERS -/* bft base and size definition */ +/* BFT base and size definition */ #define DMMU_BFT_BASE_PY (MB + HAL_PHYS_START) #define DMMU_BFT_BASE_VA (DMMU_BFT_BASE_PY - HAL_OFFSET) @@ -20,12 +20,12 @@ #define PG_ADDR_LOWER_BOUND curr_vm->config->firmware->pstart + 0x6800000 #define PG_ADDR_UPPER_BOUND curr_vm->config->firmware->pstart + 0x6A00000 -/* bft entry type */ +/* BFT entry type */ enum dmmu_entry_type { DMMU_TYPE_DATA, DMMU_TYPE_L1PT, DMMU_TYPE_L2PT, DMMU_TYPE_INVALID }; -/* a single bft table */ +/* A single BFT table */ typedef union dmmu_entry { uint32_t all; __PACKED struct { @@ -170,11 +170,11 @@ void mmu_bft_region_set(addr_t start, size_t size, uint32_t refc, uint32_t typ); -/* in translate.c */ +/* In translate.c */ int mmu_lookup_guest(addr_t vadr, addr_t *padr, int user_write); int mmu_lookup_hv(addr_t vadr, addr_t *padr, int hv_write); -/*Function prototypes*/ +/* Function prototypes */ int dmmu_switch_mm(addr_t l1_base_pa_add); int dmmu_create_L1_pt(addr_t l1_base_pa_add); diff --git a/core/hypervisor/hyper.h b/core/hypervisor/hyper.h index 5957e81..e3e1369 100755 --- a/core/hypervisor/hyper.h +++ b/core/hypervisor/hyper.h @@ -14,7 +14,7 @@ typedef void(*pabort_handler_fn)(void); -/*Data structures +/* Data structures * * */ @@ -25,14 +25,14 @@ typedef struct guest_info_ { uint32_t phys_offset; addr_t vmalloc_end; uint32_t guest_size; -}guest_info; +} guest_info; typedef struct boot_info_ { guest_info guest; uint32_t cpu_id; uint32_t cpu_mmf; uint32_t cpu_cr; -}boot_info; +} boot_info; /* Virtual machine data structures */ diff --git a/core/hypervisor/init.c b/core/hypervisor/init.c index 4fc96b2..4ec3ed0 100755 --- a/core/hypervisor/init.c +++ b/core/hypervisor/init.c @@ -100,7 +100,7 @@ void memory_commit() void memory_init() { - /*Setup heap pointer*/ + /* Setup heap pointer. */ core_mem_init(); uint32_t j; //TODO: Note: Removed unused variable va_offset here. @@ -176,7 +176,7 @@ void guests_init() // dump_mmu(flpt_va); // DEBUG - /* show guest information */ + /* Show guest information */ printf("We have %d guests in physical memory area %x %x\n", guests_db.count, guests_db.pstart, guests_db.pend); @@ -340,7 +340,7 @@ void guests_init() // Init the context with the physical addresses do{ - /*Init default values*/ + /* Init default values */ for(i = 0; i < HC_NGUESTMODES;i++){ curr_vm->mode_states[i].mode_config = (curr_vm->config->guest_modes[i]); curr_vm->mode_states[i].rpc_for = MODE_NONE; @@ -369,39 +369,41 @@ void guests_init() void start_guest() { - - /*Change guest mode to KERNEL before going into guest*/ + /* Change guest mode to KERNEL before going into guest. */ change_guest_mode(HC_GM_KERNEL); - /*Starting Guest*/ + /* Start guest! */ start(); - } -//Contains a function call to an assembly function which is an infinite loop. +//Contains a function call to an assembly label above an infinite loop. void debug_temp(){ debug_inf_loop(); } void start_() { + /* Flush and enable the cache, among other things. Defined in + * core/hw/cpu/family/model/cpu_init.c. */ cpu_init(); - /* Set up pagetable rules. */ + /* Set up pagetable rules - defined further up in this file. */ memory_init(); - /* Initialize hardware. */ + /* Initialize hardware - defined in core/hw/soc/platform and + * core/hw/board/platform, respectively. */ soc_init(); board_init(); - /* Set up exception handlers and starting timer. */ + /* Set up exception handlers and starting timer - defined further up in this + * file. */ setup_handlers(); - /* DMMU initialization. */ + /* DMMU initialization - defined in dmmu.c. */ dmmu_init(); /* Initialize hypervisor guest modes and data structures - * according to config file in guest*/ + * according to config file in guest - defined further up in this file. */ guests_init(); printf("Hypervisor initialized.\n Entering Guest...\n"); diff --git a/core/hypervisor/init_slave.c b/core/hypervisor/init_slave.c index 299bf45..93eb79e 100644 --- a/core/hypervisor/init_slave.c +++ b/core/hypervisor/init_slave.c @@ -9,26 +9,34 @@ //to do what you want. void slave_start_(){ - //TODO: Which of these needs to be done? - //cpu_init(); - - /* Set up pagetable rules. */ - //memory_init(); - - /* Initialize hardware. */ - //soc_init(); - //board_init(); - - /* Set up exception handlers and starting timer. */ - //setup_handlers(); - - /* DMMU initialization. */ - //dmmu_init(); - - /* Initialize hypervisor guest modes and data structures - * according to config file in guest*/ - //guests_init(); - - //Move along, main core... - //start_guest(); + /* Flush and enable the cache, among other things. Defined in + * core/hw/cpu/family/model/cpu_init.c. */ + cpu_init(); //TODO: I think this needs to be done a second time. + + /* Set up pagetable rules - defined in init.c. */ + //memory_init(); //TODO: This sets up the heap and the memory layout... + + /* Initialize peripherals - defined in core/hw/soc/platform and + * core/hw/board/platform, respectively. */ + //soc_init(); //TODO: I'm 99% this does not need to be done a second time. + //board_init(); //TODO: This does nothing, but what could be found in here + // should probably only be called once. + + /* Set up exception handlers and starting timer - defined in init.c. */ + //setup_handlers(); //TODO: This does not do anything core-specific, as far + // as I'm aware... + + /* DMMU initialization - defined in dmmu.c. */ + //dmmu_init(); //TODO: This needs to be done once per core if every core + // requires a separate BFT - but that will require some + // modification... + + /* Initialize hypervisor guest modes and data structures according to config + * file in guest - defined in init.c. */ + //guests_init(); //TODO: This appears hard-coded to load only one guest and/ + // or the trusted guest, and takes no arguments. + // Currently, everything related to choosing guests + // is done by pre-processor macros. + + //start_guest(); //TODO: Simply swaps to kernel mode and starts guest. }