[arch] have each arch define ARCH_HAS_MMU
This lets some code decide whether or not there's any mmu present to use. Also kernel VM will complain if it isn't set as an extra safety.
This commit is contained in:
@@ -26,7 +26,9 @@
|
||||
#include <platform.h>
|
||||
#include <target.h>
|
||||
#include <kernel/thread.h>
|
||||
#if WITH_KERNEL_VM
|
||||
#include <kernel/vm.h>
|
||||
#endif
|
||||
|
||||
#define LOCAL_TRACE 0
|
||||
|
||||
@@ -68,7 +70,7 @@ void arch_early_init(void) {
|
||||
*REG32(scu_base) |= (1<<0); /* enable SCU */
|
||||
#endif
|
||||
|
||||
#if ARM_WITH_MMU
|
||||
#if ARCH_HAS_MMU
|
||||
arm_mmu_early_init();
|
||||
|
||||
platform_init_mmu_mappings();
|
||||
@@ -137,7 +139,7 @@ void arch_init(void) {
|
||||
|
||||
//spinlock_test();
|
||||
|
||||
#if ARM_WITH_MMU
|
||||
#if ARCH_HAS_MMU
|
||||
/* finish initializing the mmu */
|
||||
arm_mmu_init();
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
#if ARCH_HAS_MMU
|
||||
|
||||
#include <lk/debug.h>
|
||||
#include <lk/trace.h>
|
||||
#include <stdlib.h>
|
||||
@@ -23,8 +25,6 @@
|
||||
#define LOCAL_TRACE 0
|
||||
#define TRACE_CONTEXT_SWITCH 0
|
||||
|
||||
#if ARM_WITH_MMU
|
||||
|
||||
#define IS_SECTION_ALIGNED(x) IS_ALIGNED(x, SECTION_SIZE)
|
||||
#define IS_SUPERSECTION_ALIGNED(x) IS_ALIGNED(x, SUPERSECTION_SIZE)
|
||||
|
||||
@@ -724,4 +724,4 @@ status_t arch_mmu_destroy_aspace(arch_aspace_t *aspace) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
#endif // ARM_WITH_MMU
|
||||
#endif // ARCH_HAS_MMU
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
#include <lk/asm.h>
|
||||
#include <arch/arm/cores.h>
|
||||
#include <arch/arm/mmu.h>
|
||||
|
||||
#if WITH_KERNEL_VM
|
||||
#include <kernel/vm.h>
|
||||
#endif
|
||||
|
||||
.section ".text.boot"
|
||||
.globl _start
|
||||
@@ -106,7 +109,7 @@ arm_reset:
|
||||
.Lrelocate_done:
|
||||
#endif // !WITH_NO_PHYS_RELOCATION
|
||||
|
||||
#if ARM_WITH_MMU
|
||||
#if ARCH_HAS_MMU
|
||||
.Lsetup_mmu:
|
||||
|
||||
/* set up the mmu according to mmu_initial_mappings */
|
||||
@@ -212,7 +215,7 @@ arm_reset:
|
||||
|
||||
/* set up the mmu */
|
||||
bl .Lmmu_setup
|
||||
#endif // ARM_WITH_MMU
|
||||
#endif // ARCH_HAS_MMU
|
||||
|
||||
/* at this point we're running at our final location in virtual memory (if enabled) */
|
||||
.Lstack_setup:
|
||||
|
||||
@@ -98,7 +98,7 @@ endif
|
||||
ifeq ($(ARM_CPU),cortex-a7)
|
||||
GLOBAL_DEFINES += \
|
||||
ARM_WITH_CP15=1 \
|
||||
ARM_WITH_MMU=1 \
|
||||
ARCH_HAS_MMU=1 \
|
||||
ARM_ISA_ARMv7=1 \
|
||||
ARM_ISA_ARMv7A=1 \
|
||||
ARM_WITH_VFP=1 \
|
||||
@@ -112,7 +112,7 @@ endif
|
||||
ifeq ($(ARM_CPU),cortex-a15)
|
||||
GLOBAL_DEFINES += \
|
||||
ARM_WITH_CP15=1 \
|
||||
ARM_WITH_MMU=1 \
|
||||
ARCH_HAS_MMU=1 \
|
||||
ARM_ISA_ARMv7=1 \
|
||||
ARM_ISA_ARMv7A=1 \
|
||||
ARM_WITH_THUMB=1 \
|
||||
@@ -129,7 +129,7 @@ endif
|
||||
ifeq ($(ARM_CPU),cortex-a8)
|
||||
GLOBAL_DEFINES += \
|
||||
ARM_WITH_CP15=1 \
|
||||
ARM_WITH_MMU=1 \
|
||||
ARCH_HAS_MMU=1 \
|
||||
ARM_ISA_ARMv7=1 \
|
||||
ARM_ISA_ARMv7A=1 \
|
||||
ARM_WITH_VFP=1 \
|
||||
@@ -143,7 +143,7 @@ endif
|
||||
ifeq ($(ARM_CPU),cortex-a9)
|
||||
GLOBAL_DEFINES += \
|
||||
ARM_WITH_CP15=1 \
|
||||
ARM_WITH_MMU=1 \
|
||||
ARCH_HAS_MMU=1 \
|
||||
ARM_ISA_ARMv7=1 \
|
||||
ARM_ISA_ARMv7A=1 \
|
||||
ARM_WITH_THUMB=1 \
|
||||
@@ -155,7 +155,7 @@ ifeq ($(ARM_CPU),cortex-a9-neon)
|
||||
GLOBAL_DEFINES += \
|
||||
ARM_CPU_CORTEX_A9=1 \
|
||||
ARM_WITH_CP15=1 \
|
||||
ARM_WITH_MMU=1 \
|
||||
ARCH_HAS_MMU=1 \
|
||||
ARM_ISA_ARMv7=1 \
|
||||
ARM_ISA_ARMv7A=1 \
|
||||
ARM_WITH_VFP=1 \
|
||||
@@ -168,7 +168,7 @@ endif
|
||||
ifeq ($(ARM_CPU),arm1136j-s)
|
||||
GLOBAL_DEFINES += \
|
||||
ARM_WITH_CP15=1 \
|
||||
ARM_WITH_MMU=1 \
|
||||
ARCH_HAS_MMU=1 \
|
||||
ARM_ISA_ARMv6=1 \
|
||||
ARM_WITH_THUMB=1 \
|
||||
ARM_WITH_CACHE=1 \
|
||||
@@ -178,7 +178,7 @@ endif
|
||||
ifeq ($(ARM_CPU),arm1176jzf-s)
|
||||
GLOBAL_DEFINES += \
|
||||
ARM_WITH_CP15=1 \
|
||||
ARM_WITH_MMU=1 \
|
||||
ARCH_HAS_MMU=1 \
|
||||
ARM_ISA_ARMv6=1 \
|
||||
ARM_WITH_VFP=1 \
|
||||
ARM_WITH_THUMB=1 \
|
||||
|
||||
@@ -65,7 +65,8 @@ GLOBAL_DEFINES += \
|
||||
KERNEL_ASPACE_BASE=$(KERNEL_ASPACE_BASE) \
|
||||
KERNEL_ASPACE_SIZE=$(KERNEL_ASPACE_SIZE) \
|
||||
USER_ASPACE_BASE=$(USER_ASPACE_BASE) \
|
||||
USER_ASPACE_SIZE=$(USER_ASPACE_SIZE)
|
||||
USER_ASPACE_SIZE=$(USER_ASPACE_SIZE) \
|
||||
ARCH_HAS_MMU=1
|
||||
|
||||
KERNEL_BASE ?= $(KERNEL_ASPACE_BASE)
|
||||
KERNEL_LOAD_OFFSET ?= 0
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if ARCH_HAS_MMU
|
||||
|
||||
#include <arch.h>
|
||||
#include <sys/types.h>
|
||||
#include <lk/compiler.h>
|
||||
@@ -55,3 +57,5 @@ void arch_disable_mmu(void);
|
||||
|
||||
__END_CDECLS
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -41,6 +41,12 @@ GLOBAL_DEFINES += \
|
||||
MEMBASE=$(MEMBASE) \
|
||||
MEMSIZE=$(MEMSIZE)
|
||||
|
||||
# we have an mmu
|
||||
WITH_KERNEL_VM=1
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
ARCH_HAS_MMU=1
|
||||
|
||||
# potentially generated files that should be cleaned out with clean make rule
|
||||
GENERATED += \
|
||||
$(BUILDDIR)/linker.ld
|
||||
|
||||
@@ -59,7 +59,6 @@ void arch_early_init(void) {
|
||||
|
||||
#if RISCV_S_MODE
|
||||
sbi_early_init();
|
||||
|
||||
#endif
|
||||
#if RISCV_MMU
|
||||
riscv_early_mmu_init();
|
||||
|
||||
@@ -89,6 +89,7 @@ endif
|
||||
ifeq ($(WITH_KERNEL_VM),1)
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
ARCH_HAS_MMU=1 \
|
||||
KERNEL_ASPACE_BASE=$(KERNEL_ASPACE_BASE) \
|
||||
KERNEL_ASPACE_SIZE=$(KERNEL_ASPACE_SIZE) \
|
||||
USER_ASPACE_BASE=$(USER_ASPACE_BASE) \
|
||||
|
||||
@@ -38,7 +38,8 @@ GLOBAL_DEFINES += \
|
||||
KERNEL_LOAD_OFFSET=$(KERNEL_LOAD_OFFSET) \
|
||||
KERNEL_ASPACE_BASE=$(KERNEL_ASPACE_BASE) \
|
||||
KERNEL_ASPACE_SIZE=$(KERNEL_ASPACE_SIZE) \
|
||||
SMP_MAX_CPUS=1
|
||||
SMP_MAX_CPUS=1 \
|
||||
ARCH_HAS_MMU=1
|
||||
|
||||
MODULE_SRCS += \
|
||||
$(SUBARCH_DIR)/start.S \
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
#define MMU_INITIAL_MAPPING_FLAG_DEVICE (0x4)
|
||||
#define MMU_INITIAL_MAPPING_FLAG_DYNAMIC (0x8) /* entry has to be patched up by platform_reset */
|
||||
|
||||
#if !ARCH_HAS_MMU
|
||||
#error ARCH needs to declare mmu support
|
||||
#endif
|
||||
|
||||
#ifndef ASSEMBLY
|
||||
|
||||
#include <arch.h>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
#include <lk/reg.h>
|
||||
#include <kernel/thread.h>
|
||||
#include <kernel/vm.h>
|
||||
#include <dev/uart.h>
|
||||
#include <dev/timer/or1k_ticktimer.h>
|
||||
#include <platform.h>
|
||||
@@ -17,6 +16,9 @@
|
||||
#include <platform/or1ksim.h>
|
||||
#include <sys/types.h>
|
||||
#include <target/debugconfig.h>
|
||||
#if WITH_KERNEL_VM
|
||||
#include <kernel/vm.h>
|
||||
#endif
|
||||
|
||||
struct mmu_initial_mapping mmu_initial_mappings[] = {
|
||||
/* 32 MB of RAM space */
|
||||
|
||||
@@ -16,9 +16,6 @@ MODULE_SRCS += \
|
||||
MEMBASE ?= 0x00000000
|
||||
MEMSIZE ?= 0x02000000
|
||||
|
||||
# we have an mmu
|
||||
WITH_KERNEL_VM=1
|
||||
|
||||
KERNEL_BASE = 0xc0000000
|
||||
|
||||
include make/module.mk
|
||||
|
||||
Reference in New Issue
Block a user