Support armv8.(TODO: fix clock)
This commit is contained in:
+3
-131
@@ -11,125 +11,6 @@
|
||||
.global _boot_start
|
||||
.global primary_cpu_init
|
||||
|
||||
//_entry:
|
||||
// mrs x1, mpidr_el1
|
||||
// and x1, x1, #0x3
|
||||
// cbz x1, entry // primary
|
||||
# b entryothers // secondary
|
||||
|
||||
//entry:
|
||||
// clear .bss
|
||||
// adrp x1, __bss_start__
|
||||
// ldr w2, =bss_size
|
||||
// 1:
|
||||
// // cbz w2, 2f
|
||||
// str xzr, [x1], #8
|
||||
// sub w2, w2, #1
|
||||
// b 1b
|
||||
// 2:
|
||||
// // set up entry pagetable
|
||||
// //
|
||||
// // Phase 1.
|
||||
// // map the kernel code identically.
|
||||
// // map [0x40000000,PA(end)) to [0x40000000,PA(end))
|
||||
// // memory type is normal
|
||||
// //
|
||||
// // Phase 2.
|
||||
// // map the kernel code.
|
||||
// // map [0xffffff8040000000,VA(end)) to [0x40000000,PA(end))
|
||||
// // memory type is normal.
|
||||
|
||||
// // Phase 1
|
||||
// // map [0x40000000,PA(end)) to [0x40000000,PA(end))
|
||||
// adrp x0, l2entrypgt
|
||||
|
||||
// mov x1, #0x00000000
|
||||
// ldr x2, =V2P_WO(end)-1
|
||||
|
||||
// lsr x3, x1, #PXSHIFT(2)
|
||||
// and x3, x3, #PXMASK // PX(2, x1)
|
||||
// lsr x4, x2, #PXSHIFT(2)
|
||||
// and x4, x4, #PXMASK // PX(2, x2)
|
||||
// mov x5, #(PTE_AF | PTE_INDX(AI_NORMAL_NC_IDX) | PTE_VALID) // entry attr
|
||||
// orr x6, x1, x5 // block entry
|
||||
// l2epgt_loop:
|
||||
// str x6, [x0, x3, lsl #3] // l2entrypgt[l2idx] = block entry
|
||||
// add x3, x3, #1 // next index
|
||||
// add x6, x6, #0x200000 // next block, block size is 2MB
|
||||
// cmp x3, x4
|
||||
// b.ls l2epgt_loop // if start va idx <= end va idx
|
||||
|
||||
// adrp x0, l1entrypgt
|
||||
|
||||
// lsr x3, x1, #PXSHIFT(1)
|
||||
// and x3, x3, #PXMASK // start va level1 index
|
||||
|
||||
// mov x4, #(PTE_TABLE | PTE_VALID) // entry attr
|
||||
// adrp x5, l2entrypgt
|
||||
// orr x6, x4, x5 // table entry
|
||||
|
||||
// str x6, [x0, x3, lsl #3] // l1entrypgt[l1idx] = table entry
|
||||
|
||||
// // Phase 2
|
||||
// // map [0xffffff8040000000,VA(end)) to [0x40000000,PA(end))
|
||||
// adrp x0, l2kpgt
|
||||
|
||||
// mov x1, #0x00000000 // start pa
|
||||
// ldr x2, =V2P_WO(end)-1 // end pa
|
||||
// mov x3, #KERN_MEM_BASE
|
||||
// add x4, x1, x3 // start va
|
||||
// add x5, x2, x3 // end va
|
||||
|
||||
// lsr x6, x4, #PXSHIFT(2)
|
||||
// and x6, x6, #PXMASK // x6 = PX(2,x4)
|
||||
// lsr x7, x5, #PXSHIFT(2)
|
||||
// and x7, x7, #PXMASK // x7 = PX(2,x5)
|
||||
// mov x8, #(PTE_AF | PTE_INDX(AI_NORMAL_NC_IDX) | PTE_VALID) // entry attr
|
||||
// orr x9, x1, x8 // block entry
|
||||
// l2kpgt_loop:
|
||||
// str x9, [x0, x6, lsl #3] // l2entrypgt[l2idx] = block entry
|
||||
// add x6, x6, #1 // next index
|
||||
// add x9, x9, #0x200000 // next block, block size is 2MB
|
||||
// cmp x6, x7
|
||||
// b.ls l2kpgt_loop // if start va idx <= end va idx
|
||||
|
||||
// adrp x0, l1kpgt
|
||||
|
||||
// lsr x5, x4, #PXSHIFT(1)
|
||||
// and x5, x5, #PXMASK // x5 = PX(1,x4)
|
||||
|
||||
// mov x6, #(PTE_TABLE | PTE_VALID) // entry attr
|
||||
// adrp x7, l2kpgt
|
||||
// orr x8, x6, x7 // table entry
|
||||
|
||||
// str x8, [x0, x5, lsl #3] // l1kpgt[l1idx] = table entry
|
||||
|
||||
// entryothers: // secondary CPU starts here
|
||||
// // load pagetable
|
||||
// adrp x0, l1entrypgt
|
||||
// adrp x1, l1kpgt
|
||||
// msr ttbr0_el1, x0
|
||||
// msr ttbr1_el1, x1
|
||||
|
||||
// // setup tcr
|
||||
// ldr x0, =(TCR_T0SZ(25)|TCR_T1SZ(25)|TCR_TG0(0)|TCR_TG1(2)|TCR_IPS(0))
|
||||
// msr tcr_el1, x0
|
||||
|
||||
// // setup mair
|
||||
// ldr x1, =((MT_DEVICE_nGnRnE<<(8*AI_DEVICE_nGnRnE_IDX)) | (MT_NORMAL_NC<<(8*AI_NORMAL_NC_IDX)))
|
||||
// msr mair_el1, x1
|
||||
|
||||
// ISB
|
||||
|
||||
// ldr x1, =_start // x1 = VA(_start)
|
||||
|
||||
// // enable paging
|
||||
// mrs x0, sctlr_el1
|
||||
// orr x0, x0, #1
|
||||
// msr sctlr_el1, x0
|
||||
|
||||
// br x1 // jump to higher address (0xffffff8000000000~)
|
||||
|
||||
_boot_start:
|
||||
// set up a stack for C.
|
||||
// stack0 is declared in start.c,
|
||||
@@ -138,7 +19,8 @@ _boot_start:
|
||||
// cpuid = mpidr_el1 & 0xff
|
||||
// save r0 for cores 1-3, r0 arg field passed by ROM
|
||||
// r0 is a function pointer for secondary cpus
|
||||
mov x4, x0
|
||||
|
||||
// mov x4, x0
|
||||
|
||||
mrs x0, spsr_el1 /* Enter EL1 (Exception Level 1) */
|
||||
bic x0, x0, #0x1f
|
||||
@@ -153,11 +35,6 @@ _boot_start:
|
||||
MSR CPACR_EL1, X1
|
||||
ISB
|
||||
|
||||
/* Clear A bit of SCTLR */
|
||||
MRS x0, SCTLR_EL1
|
||||
BIC x0, x0, #0x2
|
||||
MSR SCTLR_EL1, x0
|
||||
|
||||
// clear some registers
|
||||
msr elr_el1, XZR
|
||||
|
||||
@@ -171,7 +48,7 @@ _boot_start:
|
||||
mul x3, x2, x1
|
||||
sub x0, x0, x3
|
||||
|
||||
MOV X2, #ARM_MODE_EL1_h | DIS_INT
|
||||
MOV X2, #ARM_MODE_EL1_h | DIS_INT
|
||||
MSR SPSR_EL1, X2
|
||||
mov sp, x0
|
||||
SUB x0, x0,x1
|
||||
@@ -199,11 +76,6 @@ primary_cpu_init:
|
||||
mov x1, #0 // argv
|
||||
mov x2, #0 // env
|
||||
|
||||
// jump to main()
|
||||
//b main
|
||||
|
||||
//b . // spin
|
||||
|
||||
bl bootmain
|
||||
|
||||
.end
|
||||
|
||||
+1
-5
@@ -1,11 +1,7 @@
|
||||
export CROSS_COMPILE ?= aarch64-none-elf-
|
||||
# export DEVICE = -march=armv8-a -mtune=cortex-a72 -ffreestanding -fno-common -nostdlib
|
||||
export DEVICE = -mtune=cortex-a72 -ffreestanding -fno-common -fno-stack-protector -fno-pie -no-pie
|
||||
# export CFLAGS := $(DEVICE) -Wall -Werror -O0 -g -fno-omit-frame-pointer -fPIC
|
||||
export CFLAGS := $(DEVICE) -O0 -g -fno-omit-frame-pointer -fPIC
|
||||
export CFLAGS := $(DEVICE) -Wall -Werror -O0 -g -fno-omit-frame-pointer -fPIC
|
||||
# export AFLAGS := -c $(DEVICE) -x assembler-with-cpp -D__ASSEMBLY__ -gdwarf-2
|
||||
# export LFLAGS := $(DEVICE) -Wl,-Map=XiZi-imx6q-sabrelite.map,-cref,-u,_boot_start -T $(KERNEL_ROOT)/hardkernel/arch/arm/armv7-a/cortex-a9/preboot_for_imx6q-sabrelite/nxp_imx6q_sabrelite.lds
|
||||
# export LFLAGS := $(DEVICE) -mcmodel=large -Wl,-Map=XiZi-ok1028a-c.map,-cref,-u,_start -T $(KERNEL_ROOT)/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/nxp_ls1028.lds -Wl,--start-group,-lgcc,-lc,--end-group
|
||||
export LFLAGS := $(DEVICE) -Wl,-T -Wl,$(KERNEL_ROOT)/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/nxp_ls1028.lds -Wl,--start-group,-lgcc,-lc,--end-group
|
||||
export CXXFLAGS :=
|
||||
|
||||
|
||||
+11
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef INC_SYSREGS_H_
|
||||
#define INC_SYSREGS_H_
|
||||
|
||||
|
||||
Reference in New Issue
Block a user