diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/core.h b/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/core.h index d44c18e94..888155a7c 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/core.h +++ b/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/core.h @@ -79,15 +79,6 @@ __attribute__((always_inline)) static inline uint64_t EL0_mode() // Set ARM mode { uint64_t val = 0; - __asm__ __volatile__( - "mrs %0, spsr_el1" - : "=r"(val) - : - :); - val &= ~DIS_INT; - val &= ~SPSR_MODE_MASK; - val |= ARM_MODE_EL0_t; - return val; } diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/boot.S b/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/boot.S index ebba8e85c..198a893e5 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/boot.S +++ b/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/boot.S @@ -40,10 +40,10 @@ _boot_start: mov x5, x2 mul x3, x2, x1 sub x0, x0, x3 + mov sp, x0 mov x2, #ARM_MODE_EL1_h | DIS_INT msr spsr_el1, x2 - mov sp, x0 // bl el2_setup @@ -106,6 +106,7 @@ el2_setup: mrs x0, sctlr_el1 orr x0, x0, #(1 << 0) + bic x0, x0, #(1 << 1) orr x0, x0, #(1 << 2) msr sctlr_el1, x0 diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/config.mk b/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/config.mk index 9c057de45..6dc93ac9c 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/config.mk +++ b/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/config.mk @@ -1,6 +1,6 @@ export CROSS_COMPILE ?= aarch64-none-elf- export DEVICE = -mtune=cortex-a55 -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) -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,-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 := diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/nxp_ls1028.lds b/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/nxp_ls1028.lds index 4c1846f05..66e93e538 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/nxp_ls1028.lds +++ b/Ubiquitous/XiZi_AIoT/hardkernel/arch/arm/armv8-a/cortex-a72/preboot_for_ok1028a-c/nxp_ls1028.lds @@ -114,14 +114,14 @@ SECTIONS } > vir_ddr3 . = ALIGN(0x1000); - PROVIDE(kernel_data_begin = .); - _image_size = . - 0x0000006010000000; + .bss : { + PROVIDE(kernel_data_begin = .); PROVIDE(__bss_start__ = .); *(.bss .bss.* COMMON) + . = ALIGN(0x1000); PROVIDE(__bss_end__ = .); + PROVIDE(kernel_data_end = .); } > vir_ddr3 - . = ALIGN(0x1000); - PROVIDE(kernel_data_end = .); } \ No newline at end of file diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a72/ok1028a-c/clock.c b/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a72/ok1028a-c/clock.c index 1c401bdcc..4c8557aaa 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a72/ok1028a-c/clock.c +++ b/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a72/ok1028a-c/clock.c @@ -22,27 +22,27 @@ static void enable_timer() { - uint32_t c = r_cntv_ctl_el0(); + uint32_t c = r_cntp_ctl_el0(); c |= CNTV_CTL_ENABLE; c &= ~CNTV_CTL_IMASK; - w_cntv_ctl_el0(c); + w_cntp_ctl_el0(c); } static void disable_timer() { - uint32_t c = r_cntv_ctl_el0(); + uint32_t c = r_cntp_ctl_el0(); c |= CNTV_CTL_IMASK; c &= ~CNTV_CTL_ENABLE; - w_cntv_ctl_el0(c); + w_cntp_ctl_el0(c); } static void reload_timer() { - // interval 100ms - static uint32_t ms = 10; + // interval 1ms + static uint32_t ms = 1; uint32_t interval = ms * 1000; uint32_t interval_clk = interval * (r_cntfrq_el0() / 1000000); - w_cntv_tval_el0(interval_clk); + w_cntp_tval_el0(interval_clk); } void _sys_clock_init() @@ -54,7 +54,7 @@ void _sys_clock_init() static uint32_t _get_clock_int() { - return 27; + return 30; } static uint64_t _get_tick() diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a72/ok1028a-c/include/generic_timer.h b/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a72/ok1028a-c/include/generic_timer.h index c01e54c6c..a5d4ce6b1 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a72/ok1028a-c/include/generic_timer.h +++ b/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a72/ok1028a-c/include/generic_timer.h @@ -15,28 +15,28 @@ #include // armv8 generic timer -static inline uint32_t r_cntv_ctl_el0() +static inline uint32_t r_cntp_ctl_el0() { uint32_t x; - __asm__ volatile("mrs %0, cntv_ctl_el0" : "=r"(x)); + __asm__ volatile("mrs %0, cntp_ctl_el0" : "=r"(x)); return x; } -static inline void w_cntv_ctl_el0(uint32_t x) +static inline void w_cntp_ctl_el0(uint32_t x) { - __asm__ volatile("msr cntv_ctl_el0, %0" : : "r"(x)); + __asm__ volatile("msr cntp_ctl_el0, %0" : : "r"(x)); } -static inline uint32_t r_cntv_tval_el0() +static inline uint32_t r_cntp_tval_el0() { uint32_t x; - __asm__ volatile("mrs %0, cntv_tval_el0" : "=r"(x)); + __asm__ volatile("mrs %0, cntp_tval_el0" : "=r"(x)); return x; } -static inline void w_cntv_tval_el0(uint32_t x) +static inline void w_cntp_tval_el0(uint32_t x) { - __asm__ volatile("msr cntv_tval_el0, %0" : : "r"(x)); + __asm__ volatile("msr cntp_tval_el0, %0" : : "r"(x)); } static inline uint64_t r_cntvct_el0() diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/error_debug.c b/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/error_debug.c index 8cfe5c074..53b2f0eb0 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/error_debug.c +++ b/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/error_debug.c @@ -39,12 +39,14 @@ Modification: 2. Modify iabort and dabort handler(in dabort_handler() and iabort_handler()) *************************************************/ #include +#include + +#include "exception_registers.h" #include "assert.h" #include "core.h" #include "log.h" #include "multicores.h" -#include "spinlock.h" #include "task.h" #include "trap_common.h" @@ -91,6 +93,7 @@ void dabort_reason(struct trapframe* r) uint32_t fault_status, fault_address; __asm__ __volatile__("mrs %0, esr_el1" : "=r"(fault_status)); __asm__ __volatile__("mrs %0, far_el1" : "=r"(fault_address)); + w_esr_el1(0); LOG("program counter: 0x%016lx caused\n", r->pc); LOG("data abort at 0x%016lx, status 0x%016lx\n", fault_address, fault_status); if ((fault_status & 0x3f) == 0x21) // Alignment failure @@ -133,6 +136,7 @@ void iabort_reason(struct trapframe* r) __asm__ __volatile__("mrs %0, far_el1" : "=r"(fault_address)); LOG("program counter: 0x%016lx caused\n", r->pc); LOG("data abort at 0x%016lx, status 0x%016lx\n", fault_address, fault_status); + w_esr_el1(0); if ((fault_status & 0x3f) == 0x21) // Alignment failure KPrintf("reason: alignment\n"); else if ((fault_status & 0x3f) == 0x4) // Translation fault, level 0 diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/ok1028a-c/trap.c b/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/ok1028a-c/trap.c index bba1caf15..194dc6f93 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/ok1028a-c/trap.c +++ b/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/ok1028a-c/trap.c @@ -28,13 +28,16 @@ Modification: *************************************************/ #include +#include "exception_registers.h" + #include "assert.h" #include "core.h" -#include "exception_registers.h" #include "multicores.h" #include "syscall.h" #include "task.h" +#include "mmu.h" + extern void dabort_handler(struct trapframe* r); extern void iabort_handler(struct trapframe* r); @@ -73,7 +76,6 @@ void syscall_arch_handler(struct trapframe* tf) uint64_t esr = r_esr_el1(); uint64_t ec = (esr >> 0x1A) & 0x3F; - w_esr_el1(0); switch (ec) { case 0B010101: software_irq_dispatch(tf); @@ -87,11 +89,30 @@ void syscall_arch_handler(struct trapframe* tf) iabort_handler(tf); break; default: { - ERROR("USYSCALL: unexpected ec: %016lx\n", esr); + ERROR("USYSCALL: unexpected\n"); + ERROR(" esr: %016lx\n", esr); ERROR(" elr = %016lx far = %016lx\n", r_elr_el1(), r_far_el1()); + w_esr_el1(0); + extern void dump_tf(struct trapframe * tf); + dump_tf(tf); + + uint32_t sctlr = 0; + SCTLR_R(sctlr); + DEBUG("SCTLR: %x\n", sctlr); + uint32_t spsr = 0; + __asm__ volatile("mrs %0, spsr_el1" : "=r"(spsr)::"memory"); + DEBUG("SPSR: %x\n", spsr); + uint64_t tcr = 0; + __asm__ volatile("mrs %0, tcr_el1" : "=r"(tcr)::"memory"); + DEBUG("TCR: %x\n", tcr); + uint64_t mair = 0; + __asm__ volatile("mrs %0, mair_el1" : "=r"(mair)::"memory"); + DEBUG("MAIR: %x\n", mair); + // kill error task xizi_enter_kernel(); assert(cur_cpu()->task != NULL); + ERROR("Error Task: %s\n", cur_cpu()->task->name); sys_exit(cur_cpu()->task); context_switch(&cur_cpu()->task->thread_context.context, cur_cpu()->scheduler); panic("dabort end should never be reashed.\n"); diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/trampoline.S b/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/trampoline.S index c365de082..00941a0e9 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/trampoline.S +++ b/Ubiquitous/XiZi_AIoT/hardkernel/intr/arm/armv8-a/cortex-a72/trampoline.S @@ -143,13 +143,13 @@ Modification: .balign 0x800 alltraps: // Current EL with sp0 - b . + b badtrap .balign 0x80 - b . + b badtrap .balign 0x80 - b . + b badtrap .balign 0x80 - b . + b badtrap // Current EL with spx .balign 0x80 @@ -157,9 +157,9 @@ alltraps: .balign 0x80 b el1irq .balign 0x80 - b . + b badtrap .balign 0x80 - b . + b badtrap // Lower EL using aarch64 .balign 0x80 @@ -167,19 +167,27 @@ alltraps: .balign 0x80 b el0irq .balign 0x80 - b . + b badtrap .balign 0x80 - b . + b badtrap // Lower EL using aarch32 .balign 0x80 - b . + b badtrap .balign 0x80 - b . + b badtrap .balign 0x80 - b . + b badtrap .balign 0x80 - b . + b badtrap + +badtrap: + msr daifset, #0xf + savereg + + mov x0, sp + bl kernel_intr_handler + b . el1sync: msr daifset, #0xf diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/bootmmu.c b/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/bootmmu.c index f0818d815..4101d2c32 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/bootmmu.c +++ b/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/bootmmu.c @@ -33,8 +33,6 @@ Modification: #include "pagetable.h" #include "registers.h" -#include "ns16550.h" - #include #include @@ -69,15 +67,6 @@ uint64_t boot_kern_l3pgdir[NUM_LEVEL3_PDE] __attribute__((aligned(0x1000))) = { uint64_t boot_dev_l4pgdirs[NUM_LEVEL3_PDE][NUM_LEVEL4_PTE] __attribute__((aligned(0x1000))) = { 0 }; uint64_t boot_kern_l4pgdirs[NUM_LEVEL3_PDE][NUM_LEVEL4_PTE] __attribute__((aligned(0x1000))) = { 0 }; -static inline int cpu_id() -{ - int x = -1; - __asm__ volatile("mrs %0, mpidr_el1" : "=r"(x)); - return x & 0x3; -} - -extern int debug_printf_(const char* format, ...); - static void build_boot_pgdir() { static bool built = false; @@ -86,9 +75,7 @@ static void build_boot_pgdir() // dev mem boot_l2pgdir[(dev_phy_mem_base >> LEVEL2_PDE_SHIFT) & IDX_MASK] = (uint64_t)boot_dev_l3pgdir | L2_TYPE_TAB | L2_PTE_VALID; - // boot_l2pgdir[(dev_phy_mem_base >> LEVEL2_PDE_SHIFT) & IDX_MASK] = (uint64_t)0xEFFF1000ULL | L2_TYPE_TAB | L2_PTE_VALID; boot_l2pgdir[(MMIO_P2V_WO(dev_phy_mem_base) >> LEVEL2_PDE_SHIFT) & IDX_MASK] = (uint64_t)boot_dev_l3pgdir | L2_TYPE_TAB | L2_PTE_VALID; - // boot_l2pgdir[(MMIO_P2V_WO(dev_phy_mem_base) >> LEVEL2_PDE_SHIFT) & IDX_MASK] = (uint64_t)0xEFFF1000ULL | L2_TYPE_TAB | L2_PTE_VALID; uint64_t cur_mem_paddr = ALIGNDOWN((uint64_t)DEV_PHYMEM_BASE, LEVEL2_PDE_SIZE); for (size_t i = 0; i < NUM_LEVEL3_PDE; i++) { @@ -134,28 +121,22 @@ static void build_boot_pgdir() } } -extern void el2_setup(void); +#include "log.h" static void load_boot_pgdir() { - // debug_printf_("Loading TTBR0 %x.\r\n", boot_l2pgdir); TTBR0_W((uintptr_t)boot_l2pgdir); - // TTBR0_W((uintptr_t)0xEFFF0000); - // TTBR1_W(0); + TTBR1_W(0); #define TCR_TRUE_VALUE (0x0000000080813519ULL) uint64_t tcr = 0; - TCR_W(TCR_TRUE_VALUE); TCR_R(tcr); - uint64_t mair = 0; - MAIR_R(mair); - // MAIR_W((MT_DEVICE_nGnRnE << (8 * AI_DEVICE_nGnRnE_IDX)) | (MT_NORMAL_NC << (8 * AI_NORMAL_NC_IDX))); - // debug_printf_("TCR: %016lx(0x%016lx)\r\n", tcr, TCR_VALUE); - // debug_printf_("MAIR: %016lx\r\n", mair); + tcr &= (uint64_t)~0xFF; + tcr |= 0x19; + TCR_W(tcr); // Enable paging using read/modify/write - // debug_printf_("Loading SCTLR.\r\n"); // uint32_t val = 0; // SCTLR_R(val); // debug_printf_("Old SCTLR: %016lx\r\n", val); @@ -177,8 +158,6 @@ static void load_boot_pgdir() DSB(); CLEARTLB(0); ISB(); - - // debug_printf_("Alive after TLB.\r\n"); } static inline unsigned int current_el(void) @@ -192,27 +171,12 @@ extern void main(void); static bool _bss_inited = false; void bootmain() { - // debug_printf_("building pgdir.\r\n"); build_boot_pgdir(); - // debug_printf_("l2[0]: %p\r\n", boot_l2pgdir[0]); - // debug_printf_("l2[1]: %p\r\n", boot_l2pgdir[1]); - // debug_printf_("l2[2]: %p\r\n", boot_l2pgdir[2]); - // debug_printf_("l2[3]: %p\r\n", boot_l2pgdir[3]); - // debug_printf_("loading pgdir, current el: %d\r\n", current_el()); load_boot_pgdir(); - // debug_printf_("loading pgdir, current el: %d\r\n", current_el()); - // debug_printf_("test upper address: %x\r\n", *(uintptr_t*)P2V(boot_l2pgdir)); - // el2_setup(); - // unsigned int el = current_el(); - // debug_printf_("loading pgdir, current el: %d\r\n", el); - // debug_printf_("Fix stack.\r\n"); __asm__ __volatile__("add sp, sp, %0" ::"r"(KERN_OFFSET)); - // debug_printf_("Alive after fix stack.\r\n"); if (!_bss_inited) { - // debug_printf_("Clear bss.\r\n"); memset(&kernel_data_begin, 0x00, (size_t)((uint64_t)kernel_data_end - (uint64_t)kernel_data_begin)); _bss_inited = true; } - // debug_printf_("Going main.\r\n"); main(); } \ No newline at end of file diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/mmu.c b/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/mmu.c index 9b2656f1f..6067c4dc9 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/mmu.c +++ b/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/mmu.c @@ -35,8 +35,6 @@ Modification: #include "mmu_common.h" #include "trap_common.h" -#include "log.h" - // extern struct MmuCommonDone mmu_common_done; static struct MmuDriverRightGroup right_group; diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/ok1028a-c/memlayout.h b/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/ok1028a-c/memlayout.h index 74601b7de..7e2f07e78 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/ok1028a-c/memlayout.h +++ b/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/ok1028a-c/memlayout.h @@ -61,14 +61,14 @@ Modification: #define MAX_NR_FREE_PAGES ((PHY_MEM_STOP - PHY_MEM_BASE) >> LEVEL4_PTE_SHIFT) /* Deivce memory layout */ -#define DEV_PHYMEM_BASE (0x00000000C0000000ULL) -#define DEV_VRTMEM_BASE (0x00000040C0000000ULL) -#define DEV_MEM_SIZE (0x0000000040000000ULL) +#define DEV_PHYMEM_BASE (0x00000000F0000000ULL) +#define DEV_VRTMEM_BASE (0x00000040F0000000ULL) +#define DEV_MEM_SIZE (0x0000000010000000ULL) /* User memory layout */ #define USER_STACK_SIZE PAGE_SIZE #define USER_MEM_BASE (0x0000000000000000ULL) -#define USER_MEM_TOP DEV_VRTMEM_BASE +#define USER_MEM_TOP (0x0000004000000000ULL) #define USER_IPC_SPACE_BASE (0x0000003000000000ULL) #define USER_IPC_USE_ALLOCATOR_WATERMARK (0x0000003000010000ULL) #define USER_IPC_SPACE_TOP (USER_IPC_SPACE_BASE + 0x10000000ULL) diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/pagetable_attr.c b/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/pagetable_attr.c index 8a20c7777..8085ad036 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/pagetable_attr.c +++ b/Ubiquitous/XiZi_AIoT/hardkernel/mmu/arm/armv8-a/cortex-a72/pagetable_attr.c @@ -53,20 +53,19 @@ Modification: void GetUsrPteAttr(uintptr_t* attr) { // *attr = ARMV8_PTE_AP_U | ARMV8_PTE_AP_RW | ARMV8_PTE_AF | ARMV8_PTE_NORMAL | ARMV8_PTE_VALID; - *attr = 0x753; + *attr = 0x713 | ARMV8_PTE_AP_U; } void GetUsrDevPteAttr(uintptr_t* attr) { // *attr = ARMV8_PTE_AP_U | ARMV8_PTE_AP_RW | ARMV8_PTE_AF | ARMV8_PTE_DEVICE | ARMV8_PTE_XN | ARMV8_PTE_VALID; - *attr = 0x443; + *attr = 0x403 | ARMV8_PTE_AP_U; } void GetDevPteAttr(uintptr_t* attr) { // *attr = ARMV8_PTE_AP_K | ARMV8_PTE_AP_RW | ARMV8_PTE_AF | ARMV8_PTE_DEVICE | ARMV8_PTE_XN | ARMV8_PTE_VALID; *attr = 0x403ULL; - // *attr = 0x711; } void GetKernPteAttr(uintptr_t* attr) diff --git a/Ubiquitous/XiZi_AIoT/services/app/Makefile b/Ubiquitous/XiZi_AIoT/services/app/Makefile index cfb49eb45..91c37ce47 100644 --- a/Ubiquitous/XiZi_AIoT/services/app/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/app/Makefile @@ -13,7 +13,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie board_specs = stub.o endif diff --git a/Ubiquitous/XiZi_AIoT/services/app/init.c b/Ubiquitous/XiZi_AIoT/services/app/init.c index dbedd4795..08a76a846 100755 --- a/Ubiquitous/XiZi_AIoT/services/app/init.c +++ b/Ubiquitous/XiZi_AIoT/services/app/init.c @@ -20,8 +20,9 @@ int main(int argc, char* argv[]) { struct Session session; printf("init: connecting MemFS\n"); - while (connect_session(&session, "MemFS", 8092) < 0) - ; + while (connect_session(&session, "MemFS", 8092) < 0) { + yield(SYS_TASK_YIELD_NO_REASON); + } printf("init: connect MemFS success\n"); int fd; diff --git a/Ubiquitous/XiZi_AIoT/services/boards/imx6q-sabrelite/Makefile b/Ubiquitous/XiZi_AIoT/services/boards/imx6q-sabrelite/Makefile index 7b5aca8bc..de4607b80 100644 --- a/Ubiquitous/XiZi_AIoT/services/boards/imx6q-sabrelite/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/boards/imx6q-sabrelite/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/boards/ok1028a-c/Makefile b/Ubiquitous/XiZi_AIoT/services/boards/ok1028a-c/Makefile index 0b703bb7f..a19a1b17c 100644 --- a/Ubiquitous/XiZi_AIoT/services/boards/ok1028a-c/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/boards/ok1028a-c/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/boards/zynq7000-zc702/Makefile b/Ubiquitous/XiZi_AIoT/services/boards/zynq7000-zc702/Makefile index a25053e3f..f9459341c 100644 --- a/Ubiquitous/XiZi_AIoT/services/boards/zynq7000-zc702/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/boards/zynq7000-zc702/Makefile @@ -12,7 +12,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/clock/Makefile b/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/clock/Makefile index 9d97d6194..10a27ebb5 100644 --- a/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/clock/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/clock/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc ld = ${toolchain}g++ diff --git a/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/gpio/Makefile b/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/gpio/Makefile index 69480b3be..915704cf5 100644 --- a/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/gpio/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/gpio/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/lib/Makefile b/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/lib/Makefile index 512525d57..824b9248a 100644 --- a/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/lib/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/drivers/imx6q-sabrelite/lib/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/fs/fs_server/Makefile b/Ubiquitous/XiZi_AIoT/services/fs/fs_server/Makefile index 6f54fa6d5..a8f2d97ac 100644 --- a/Ubiquitous/XiZi_AIoT/services/fs/fs_server/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/fs/fs_server/Makefile @@ -12,7 +12,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/fs/fs_server/fs_server.c b/Ubiquitous/XiZi_AIoT/services/fs/fs_server/fs_server.c index 3bfc42b89..ae460ce13 100644 --- a/Ubiquitous/XiZi_AIoT/services/fs/fs_server/fs_server.c +++ b/Ubiquitous/XiZi_AIoT/services/fs/fs_server/fs_server.c @@ -349,6 +349,7 @@ IPC_SERVER_REGISTER_INTERFACES(IpcFsServer, 10, int main(int argc, char* argv[]) { + printf("MemFS Start\n"); sys_state_info info; get_memblock_info(&info); diff --git a/Ubiquitous/XiZi_AIoT/services/fs/fs_server/include/block_io.h b/Ubiquitous/XiZi_AIoT/services/fs/fs_server/include/block_io.h index f457436fd..2fe14d8af 100644 --- a/Ubiquitous/XiZi_AIoT/services/fs/fs_server/include/block_io.h +++ b/Ubiquitous/XiZi_AIoT/services/fs/fs_server/include/block_io.h @@ -18,7 +18,7 @@ // Block size #define BLOCK_SIZE 512 -#define NR_BIT_BLOCKS 2 +#define NR_BIT_BLOCKS 8 // bits size #define BITS 8 diff --git a/Ubiquitous/XiZi_AIoT/services/fs/libfs/Makefile b/Ubiquitous/XiZi_AIoT/services/fs/libfs/Makefile index 0696ebdff..123e72dd9 100644 --- a/Ubiquitous/XiZi_AIoT/services/fs/libfs/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/fs/libfs/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/lib/ipc/Makefile b/Ubiquitous/XiZi_AIoT/services/lib/ipc/Makefile index 8e6246cc4..0cf93c758 100644 --- a/Ubiquitous/XiZi_AIoT/services/lib/ipc/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/lib/ipc/Makefile @@ -12,7 +12,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/lib/memory/Makefile b/Ubiquitous/XiZi_AIoT/services/lib/memory/Makefile index 87ae1f39d..3ae15289a 100644 --- a/Ubiquitous/XiZi_AIoT/services/lib/memory/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/lib/memory/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/lib/serial/Makefile b/Ubiquitous/XiZi_AIoT/services/lib/serial/Makefile index f08e492a2..54142a8af 100644 --- a/Ubiquitous/XiZi_AIoT/services/lib/serial/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/lib/serial/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/lib/usyscall/Makefile b/Ubiquitous/XiZi_AIoT/services/lib/usyscall/Makefile index bbb8c8411..b8b268c23 100644 --- a/Ubiquitous/XiZi_AIoT/services/lib/usyscall/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/lib/usyscall/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/semaphore/Makefile b/Ubiquitous/XiZi_AIoT/services/semaphore/Makefile index 2da75e146..9f24141b1 100644 --- a/Ubiquitous/XiZi_AIoT/services/semaphore/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/semaphore/Makefile @@ -12,7 +12,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/shell/letter-shell/Makefile b/Ubiquitous/XiZi_AIoT/services/shell/letter-shell/Makefile index ee7c40d34..39506097a 100644 --- a/Ubiquitous/XiZi_AIoT/services/shell/letter-shell/Makefile +++ b/Ubiquitous/XiZi_AIoT/services/shell/letter-shell/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(BOARD), ok1028a-c) toolchain ?= aarch64-none-elf- user_ldflags = -N -Ttext 0 -cflags = -Wall -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie +cflags = -Wall -O0 -g -std=c11 -mtune=cortex-a55 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie endif cc = ${toolchain}gcc diff --git a/Ubiquitous/XiZi_AIoT/services/tools/mkfs/mkfs.h b/Ubiquitous/XiZi_AIoT/services/tools/mkfs/mkfs.h index b7d299bb9..e44e96798 100755 --- a/Ubiquitous/XiZi_AIoT/services/tools/mkfs/mkfs.h +++ b/Ubiquitous/XiZi_AIoT/services/tools/mkfs/mkfs.h @@ -49,7 +49,7 @@ Modification: #define ROOT_INUM 1 // root inode number #define BLOCK_SIZE 512 // block size #define NR_BIT_PER_BYTE 8 -#define NR_BIT_BLOCKS 2 +#define NR_BIT_BLOCKS 8 #define nr_blocks_total (BLOCK_SIZE * NR_BIT_PER_BYTE * NR_BIT_BLOCKS) // total number of blocks (including used blocks and free blocks) #define nr_inodes 200 // total number of inodes diff --git a/Ubiquitous/XiZi_AIoT/softkernel/main.c b/Ubiquitous/XiZi_AIoT/softkernel/main.c index dd61c4666..f06bc4a15 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/main.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/main.c @@ -89,7 +89,6 @@ int main(void) char* fs_server_task_param[2] = { "/app/fs_server", 0 }; sys_spawn((char*)_binary_default_fs_start, "memfs", fs_server_task_param); } - /* start scheduler */ struct SchedulerRightGroup scheduler_rights; assert(AchieveResourceTag(&scheduler_rights.mmu_driver_tag, &hardkernel_tag, "mmu-ac-resource")); diff --git a/Ubiquitous/XiZi_AIoT/softkernel/memory/pagetable.c b/Ubiquitous/XiZi_AIoT/softkernel/memory/pagetable.c index e90d906a5..74759524c 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/memory/pagetable.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/memory/pagetable.c @@ -61,12 +61,12 @@ static bool _map_pages(uintptr_t* pgdir, uintptr_t vaddr, uintptr_t paddr, int l while (true) { uintptr_t* pte = NULL; if ((pte = _page_walk(pgdir, vaddr, true)) == NULL) { - ERROR("pte not found for vaddr %x.\n", vaddr); + ERROR("pte not found for vaddr %p.\n", vaddr); return false; } if (UNLIKELY(*pte != 0)) { - ERROR("remapping: vaddr: %x | paddr: %x | pte: %x |\n", vaddr, paddr, *pte); + ERROR("remapping: vaddr: %p | paddr: %p | pte: %p |\n", vaddr, paddr, *pte); return false; } @@ -93,12 +93,12 @@ static bool _unmap_pages(uintptr_t* pgdir, uintptr_t vaddr, int len) while (true) { uintptr_t* pte = NULL; if ((pte = _page_walk(pgdir, vaddr, false)) == NULL) { - ERROR("pte not found for vaddr %x.\n", vaddr); + ERROR("pte not found for vaddr %p.\n", vaddr); return false; } if (*pte == 0) { - ERROR("unmap a unmapped page, vaddr: %x, pte: %x\n", vaddr, *pte); + ERROR("unmap a unmapped page, vaddr: %p, pte: %p\n", vaddr, *pte); return false; } diff --git a/Ubiquitous/XiZi_AIoT/softkernel/trap/clock_irq_handler.c b/Ubiquitous/XiZi_AIoT/softkernel/trap/clock_irq_handler.c index d7a66169c..2fdbdf67f 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/trap/clock_irq_handler.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/trap/clock_irq_handler.c @@ -34,8 +34,6 @@ Modification: #include "multicores.h" #include "task.h" -#include "log.h" - static struct TraceTag clock_driver_tag; static struct XiziClockDriver* p_clock_driver = NULL;