From 990f731b776055390db854f9cc980799e39247e8 Mon Sep 17 00:00:00 2001 From: bigmagic Date: Mon, 6 Apr 2020 15:46:28 +0800 Subject: fix mips64 some bug --- libcpu/mips/common/stackframe.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libcpu/mips/common/stackframe.h') diff --git a/libcpu/mips/common/stackframe.h b/libcpu/mips/common/stackframe.h index 77d55f6934..b5a038d1f6 100644 --- a/libcpu/mips/common/stackframe.h +++ b/libcpu/mips/common/stackframe.h @@ -159,11 +159,11 @@ .endm .macro RESTORE_TEMP - LONG_L $24, PT_LO(sp) + lw $24, PT_LO(sp) LONG_L $8, PT_R8(sp) LONG_L $9, PT_R9(sp) mtlo $24 - LONG_L $24, PT_HI(sp) + lw $24, PT_HI(sp) LONG_L $10, PT_R10(sp) LONG_L $11, PT_R11(sp) mthi $24 -- cgit v1.3.1 From c024e2e485c813aa1c70e079f61fe50a80d8215c Mon Sep 17 00:00:00 2001 From: bigmagic Date: Tue, 7 Apr 2020 11:26:30 +0800 Subject: add ls2k bsp config --- bsp/ls2kdev/.config | 9 +++------ bsp/ls2kdev/applications/main.c | 2 +- bsp/ls2kdev/rtconfig.h | 7 +------ libcpu/mips/common/exception.c | 6 +++--- libcpu/mips/common/stackframe.h | 4 ++-- 5 files changed, 10 insertions(+), 18 deletions(-) (limited to 'libcpu/mips/common/stackframe.h') diff --git a/bsp/ls2kdev/.config b/bsp/ls2kdev/.config index 20cf03b625..d8a97b46b0 100644 --- a/bsp/ls2kdev/.config +++ b/bsp/ls2kdev/.config @@ -20,13 +20,10 @@ CONFIG_RT_USING_HOOK=y CONFIG_RT_USING_IDLE_HOOK=y CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=2048 -CONFIG_RT_USING_TIMER_SOFT=y -CONFIG_RT_TIMER_THREAD_PRIO=20 -CONFIG_RT_TIMER_THREAD_STACK_SIZE=2048 +# CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y # CONFIG_RT_DEBUG_COLOR is not set -CONFIG_RT_DEBUG_INIT_CONFIG=y -CONFIG_RT_DEBUG_INIT=1 +# CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set # CONFIG_RT_DEBUG_IPC_CONFIG is not set @@ -65,7 +62,7 @@ CONFIG_RT_USING_DEVICE=y # CONFIG_RT_USING_DEVICE_OPS is not set # CONFIG_RT_USING_INTERRUPT_INFO is not set CONFIG_RT_USING_CONSOLE=y -CONFIG_RT_CONSOLEBUF_SIZE=128 +CONFIG_RT_CONSOLEBUF_SIZE=256 CONFIG_RT_CONSOLE_DEVICE_NAME="uart" CONFIG_RT_VER_NUM=0x40003 # CONFIG_RT_USING_CPU_FFS is not set diff --git a/bsp/ls2kdev/applications/main.c b/bsp/ls2kdev/applications/main.c index 54691f0f89..bd975f4825 100644 --- a/bsp/ls2kdev/applications/main.c +++ b/bsp/ls2kdev/applications/main.c @@ -12,6 +12,6 @@ int main(int argc, char** argv) { - rt_kprintf("ls2k1000:hello rtthread!\n"); + rt_kprintf("Hi, this is RT-Thread!!\n"); return 0; } diff --git a/bsp/ls2kdev/rtconfig.h b/bsp/ls2kdev/rtconfig.h index 80f068c5c0..aaeed71df5 100644 --- a/bsp/ls2kdev/rtconfig.h +++ b/bsp/ls2kdev/rtconfig.h @@ -16,12 +16,7 @@ #define RT_USING_IDLE_HOOK #define RT_IDLE_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 2048 -#define RT_USING_TIMER_SOFT -#define RT_TIMER_THREAD_PRIO 20 -#define RT_TIMER_THREAD_STACK_SIZE 2048 #define RT_DEBUG -#define RT_DEBUG_INIT_CONFIG -#define RT_DEBUG_INIT 1 /* Inter-Thread communication */ @@ -41,7 +36,7 @@ #define RT_USING_DEVICE #define RT_USING_CONSOLE -#define RT_CONSOLEBUF_SIZE 128 +#define RT_CONSOLEBUF_SIZE 256 #define RT_CONSOLE_DEVICE_NAME "uart" #define RT_VER_NUM 0x40003 #define ARCH_MIPS64 diff --git a/libcpu/mips/common/exception.c b/libcpu/mips/common/exception.c index 11192955cf..cd7d97e6c0 100644 --- a/libcpu/mips/common/exception.c +++ b/libcpu/mips/common/exception.c @@ -117,14 +117,14 @@ int rt_hw_exception_init(void) void rt_general_exc_dispatch(struct pt_regs *regs) { - rt_ubase_t cause, exccode; + rt_ubase_t exccode = 0; - exccode = (cause & CAUSEF_EXCCODE) >> CAUSEB_EXCCODE; if (exccode == 0) { rt_ubase_t status, pending; status = read_c0_status(); - pending = (cause & CAUSEF_IP) & (status & ST0_IM); + + pending = (CAUSEF_IP) & (status & ST0_IM); if (pending & CAUSEF_IP0) rt_do_mips_cpu_irq(0); if (pending & CAUSEF_IP1) diff --git a/libcpu/mips/common/stackframe.h b/libcpu/mips/common/stackframe.h index b5a038d1f6..258f9a994f 100644 --- a/libcpu/mips/common/stackframe.h +++ b/libcpu/mips/common/stackframe.h @@ -60,11 +60,11 @@ mfhi v1 LONG_S $8, PT_R8(sp) LONG_S $9, PT_R9(sp) - LONG_S v1, PT_HI(sp) + sw v1, PT_HI(sp) mflo v1 LONG_S $10, PT_R10(sp) LONG_S $11, PT_R11(sp) - LONG_S v1, PT_LO(sp) + sw v1, PT_LO(sp) LONG_S $12, PT_R12(sp) LONG_S $13, PT_R13(sp) LONG_S $14, PT_R14(sp) -- cgit v1.3.1 From 3d0bdf4bb65bcb676b120ae273c8c28e7f52b911 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 25 Aug 2020 11:52:07 +0800 Subject: MIPS:improvement FPU support --- libcpu/mips/common/stackframe.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libcpu/mips/common/stackframe.h') diff --git a/libcpu/mips/common/stackframe.h b/libcpu/mips/common/stackframe.h index 258f9a994f..4f1157aebf 100644 --- a/libcpu/mips/common/stackframe.h +++ b/libcpu/mips/common/stackframe.h @@ -22,7 +22,9 @@ #ifdef RT_USING_FPU /* Ensure CU1 (FPU) is enabled */ MFC0 v1, CP0_STATUS - ori v1, ST0_CU1 + lui t1, %hi(ST0_CU1) + addiu t1, t1, %lo(ST0_CU1) + or v1, v1, t1 MTC0 v1, CP0_STATUS SSNOP cfc1 v1, fcr31 @@ -125,11 +127,13 @@ #ifdef RT_USING_FPU /* Ensure CU1 (FPU) is enabled */ MFC0 v1, CP0_STATUS - ori v1, ST0_CU1 + lui t1, %hi(ST0_CU1) + addiu t1, t1, %lo(ST0_CU1) + or v1, v1, t1 MTC0 v1, CP0_STATUS SSNOP LONG_L v1, PT_FPU_FCSR31(sp) - ctc1 v1, fcsr31 + ctc1 v1, fcr31 l.d $f0, PT_FPU_R0(sp) l.d $f2, PT_FPU_R2(sp) l.d $f4, PT_FPU_R4(sp) -- cgit v1.3.1 From bd95f3a94f53d1fd379e659ea9a56789d9fe471d Mon Sep 17 00:00:00 2001 From: bigmagic Date: Wed, 26 Aug 2020 12:03:01 +0800 Subject: fix mips stackframe and exception --- libcpu/Kconfig | 4 ++++ libcpu/mips/common/context_gcc.S | 21 +++++++++++---------- libcpu/mips/common/exception_gcc.S | 8 +++++++- libcpu/mips/common/stackframe.h | 2 ++ 4 files changed, 24 insertions(+), 11 deletions(-) (limited to 'libcpu/mips/common/stackframe.h') diff --git a/libcpu/Kconfig b/libcpu/Kconfig index e355664de2..ae2767dec9 100644 --- a/libcpu/Kconfig +++ b/libcpu/Kconfig @@ -82,6 +82,10 @@ config ARCH_MIPS config ARCH_MIPS64 bool + select ARCH_CPU_64BIT + +config ARCH_CPU_64BIT + bool config ARCH_MIPS_XBURST bool diff --git a/libcpu/mips/common/context_gcc.S b/libcpu/mips/common/context_gcc.S index cdcdede39a..3fdbe374c9 100644 --- a/libcpu/mips/common/context_gcc.S +++ b/libcpu/mips/common/context_gcc.S @@ -1,11 +1,12 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2020, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2019-12-04 Jiaxun Yang Initial version + * 2020-07-26 lizhirui Fixed some problems */ #ifndef __ASSEMBLY__ @@ -56,12 +57,12 @@ rt_hw_context_switch_interrupt: bnez t1, _reswitch nop li t1, 0x01 /* set rt_thread_switch_interrupt_flag to 1 */ - sw t1, 0(t0) + LONG_S t1, 0(t0) PTR_LA t0, rt_interrupt_from_thread /* set rt_interrupt_from_thread */ - sw a0, 0(t0) + LONG_S a0, 0(t0) _reswitch: PTR_LA t0, rt_interrupt_to_thread /* set rt_interrupt_to_thread */ - sw a1, 0(t0) + LONG_S a1, 0(t0) jr ra nop @@ -97,24 +98,24 @@ mips_irq_handle: * rt_hw_context_switch_interrupt_do and do not return */ PTR_LA k0, rt_thread_switch_interrupt_flag - lw k1, 0(k0) + LONG_L k1, 0(k0) beqz k1, spurious_interrupt nop - sw zero, 0(k0) /* clear flag */ + LONG_S zero, 0(k0) /* clear flag */ nop /* * switch to the new thread */ PTR_LA k0, rt_interrupt_from_thread - lw k1, 0(k0) + LONG_L k1, 0(k0) nop - sw sp, 0(k1) /* store sp in preempted task TCB */ + LONG_S sp, 0(k1) /* store sp in preempted task TCB */ PTR_LA k0, rt_interrupt_to_thread - lw k1, 0(k0) + LONG_L k1, 0(k0) nop - lw sp, 0(k1) /* get new task stack pointer */ + LONG_L sp, 0(k1) /* get new task stack pointer */ j spurious_interrupt nop diff --git a/libcpu/mips/common/exception_gcc.S b/libcpu/mips/common/exception_gcc.S index 9664438ac1..c685928a84 100644 --- a/libcpu/mips/common/exception_gcc.S +++ b/libcpu/mips/common/exception_gcc.S @@ -1,11 +1,12 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2020, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2019-12-04 Jiaxun Yang Initial version + * 2020-07-26 lizhirui Add xtlb exception entry */ #ifndef __ASSEMBLY__ #define __ASSEMBLY__ @@ -26,6 +27,11 @@ tlb_refill_exception: b _general_exception_handler nop + /* 0x080 - XTLB refill handler */ + .org ebase_start + 0x080 + b _general_exception_handler + nop + /* 0x100 - Cache error handler */ .org ebase_start + 0x100 j cache_error_handler diff --git a/libcpu/mips/common/stackframe.h b/libcpu/mips/common/stackframe.h index 4f1157aebf..bb92a18c9c 100644 --- a/libcpu/mips/common/stackframe.h +++ b/libcpu/mips/common/stackframe.h @@ -206,6 +206,8 @@ li v1, ~(ST0_CU1 | ST0_FR | ST0_IM) and v0, v1 or v0, a0 + li v1, (ST0_KX | ST0_SX | ST0_UX) + or v0, v1 mtc0 v0, CP0_STATUS LONG_L v1, PT_EPC(sp) MTC0 v1, CP0_EPC -- cgit v1.3.1