Skip to content

Commit 990f731

Browse files
committed
fix mips64 some bug
1 parent 0f26ffa commit 990f731

File tree

16 files changed

+138
-81
lines changed

16 files changed

+138
-81
lines changed

bsp/ls2kdev/.config

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ CONFIG_RT_USING_IDLE_HOOK=y
2121
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
2222
CONFIG_IDLE_THREAD_STACK_SIZE=2048
2323
CONFIG_RT_USING_TIMER_SOFT=y
24-
CONFIG_RT_TIMER_THREAD_PRIO=4
24+
CONFIG_RT_TIMER_THREAD_PRIO=20
2525
CONFIG_RT_TIMER_THREAD_STACK_SIZE=2048
2626
CONFIG_RT_DEBUG=y
2727
# CONFIG_RT_DEBUG_COLOR is not set
28-
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
28+
CONFIG_RT_DEBUG_INIT_CONFIG=y
29+
CONFIG_RT_DEBUG_INIT=1
2930
# CONFIG_RT_DEBUG_THREAD_CONFIG is not set
3031
# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
3132
# CONFIG_RT_DEBUG_IPC_CONFIG is not set
@@ -106,18 +107,7 @@ CONFIG_FINSH_ARG_MAX=10
106107
#
107108
# Device virtual file system
108109
#
109-
CONFIG_RT_USING_DFS=y
110-
CONFIG_DFS_USING_WORKDIR=y
111-
CONFIG_DFS_FILESYSTEMS_MAX=2
112-
CONFIG_DFS_FILESYSTEM_TYPES_MAX=2
113-
CONFIG_DFS_FD_MAX=16
114-
# CONFIG_RT_USING_DFS_MNTTABLE is not set
115-
# CONFIG_RT_USING_DFS_ELMFAT is not set
116-
CONFIG_RT_USING_DFS_DEVFS=y
117-
# CONFIG_RT_USING_DFS_ROMFS is not set
118-
# CONFIG_RT_USING_DFS_RAMFS is not set
119-
# CONFIG_RT_USING_DFS_UFFS is not set
120-
# CONFIG_RT_USING_DFS_JFFS2 is not set
110+
# CONFIG_RT_USING_DFS is not set
121111

122112
#
123113
# Device Drivers
@@ -161,10 +151,6 @@ CONFIG_RT_USING_PIN=y
161151
#
162152
CONFIG_RT_USING_LIBC=y
163153
# CONFIG_RT_USING_PTHREADS is not set
164-
CONFIG_RT_USING_POSIX=y
165-
# CONFIG_RT_USING_POSIX_MMAP is not set
166-
# CONFIG_RT_USING_POSIX_TERMIOS is not set
167-
# CONFIG_RT_USING_POSIX_AIO is not set
168154
# CONFIG_RT_USING_MODULE is not set
169155

170156
#

bsp/ls2kdev/drivers/board.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ void rt_hw_board_init(void)
7070
/* init hardware interrupt */
7171
rt_hw_interrupt_init();
7272

73-
#ifdef RT_USING_FPU
73+
#ifdef RT_USING_FPU
7474
/* init hardware fpu */
7575
rt_hw_fpu_init();
76-
#endif
76+
#endif
7777

7878
#ifdef RT_USING_SERIAL
7979
/* init hardware UART device */
@@ -88,8 +88,7 @@ void rt_hw_board_init(void)
8888

8989
/* init operating system timer */
9090
rt_hw_timer_init();
91-
92-
91+
9392
#ifdef RT_USING_COMPONENTS_INIT
9493
rt_components_board_init();
9594
#endif

bsp/ls2kdev/drivers/board.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
extern unsigned char __bss_end;
1717

1818
#define CPU_HZ (100 * 1000 * 1000)
19-
#define RT_HW_HEAP_BEGIN (void*)&__bss_end
19+
#define RT_HW_HEAP_BEGIN KSEG1BASE//(void*)&__bss_end
2020
#define RT_HW_HEAP_END (void*)(RT_HW_HEAP_BEGIN + 64 * 1024 * 1024)
2121

2222
void rt_hw_board_init(void);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ GROUP(-lgcc -lc)
1414
ENTRY(_start)
1515
SECTIONS
1616
{
17-
. = 0x80200000 ;
17+
. = 0xffffffff82000000 ;
1818
.text :
1919
{
2020
__ebase_entry = .;

bsp/ls2kdev/rtconfig.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
#define RT_IDLE_HOOK_LIST_SIZE 4
1818
#define IDLE_THREAD_STACK_SIZE 2048
1919
#define RT_USING_TIMER_SOFT
20-
#define RT_TIMER_THREAD_PRIO 4
20+
#define RT_TIMER_THREAD_PRIO 20
2121
#define RT_TIMER_THREAD_STACK_SIZE 2048
2222
#define RT_DEBUG
23+
#define RT_DEBUG_INIT_CONFIG
24+
#define RT_DEBUG_INIT 1
2325

2426
/* Inter-Thread communication */
2527

@@ -71,12 +73,6 @@
7173

7274
/* Device virtual file system */
7375

74-
#define RT_USING_DFS
75-
#define DFS_USING_WORKDIR
76-
#define DFS_FILESYSTEMS_MAX 2
77-
#define DFS_FILESYSTEM_TYPES_MAX 2
78-
#define DFS_FD_MAX 16
79-
#define RT_USING_DFS_DEVFS
8076

8177
/* Device Drivers */
8278

@@ -93,7 +89,6 @@
9389
/* POSIX layer and C standard library */
9490

9591
#define RT_USING_LIBC
96-
#define RT_USING_POSIX
9792

9893
/* Network */
9994

bsp/ls2kdev/rtconfig.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
OBJCPY = PREFIX + 'objcopy'
4141
READELF = PREFIX + 'readelf'
4242

43-
DEVICE = ' -march=mips64r2 -mabi=64 -msoft-float'
44-
CFLAGS = DEVICE + ' -EL -G0 -mno-abicalls -fno-pic -fno-builtin -fno-exceptions -ffunction-sections -fomit-frame-pointer'
45-
AFLAGS = ' -c' + DEVICE + ' -EL -fno-pic -fno-builtin -mno-abicalls -x assembler-with-cpp'
46-
LFLAGS = DEVICE + ' -nostartfiles -EL -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T mipssim_ram.lds'
43+
DEVICE = ' -march=mips64r2 -mabi=64 -msoft-float -EL'
44+
CFLAGS = DEVICE + ' -G0 -mno-abicalls -fno-pic -fno-builtin -fno-exceptions -ffunction-sections -fomit-frame-pointer'
45+
AFLAGS = ' -c' + DEVICE + ' -fno-pic -fno-builtin -mno-abicalls -x assembler-with-cpp'
46+
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T ls2k_ram.lds'
4747
CXXFLAGS = CFLAGS
4848

4949
CPATH = ''

libcpu/mips/common/asm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,11 @@ symbol = value
261261
#define LONG_SRAV srav
262262

263263
#define LONG .word
264+
#ifdef ARCH_MIPS64
265+
#define LONGSIZE 8
266+
#else
264267
#define LONGSIZE 4
268+
#endif
265269
#define LONGMASK 3
266270
#define LONGLOG 2
267271

libcpu/mips/common/context_gcc.S

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
*/
2626
.globl rt_hw_context_switch
2727
rt_hw_context_switch:
28-
mtc0 ra, CP0_EPC
28+
MTC0 ra, CP0_EPC
2929
SAVE_ALL
3030

31-
sw sp, 0(a0) /* store sp in preempted tasks TCB */
32-
lw sp, 0(a1) /* get new task stack pointer */
31+
REG_S sp, 0(a0) /* store sp in preempted tasks TCB */
32+
REG_L sp, 0(a1) /* get new task stack pointer */
3333

3434
RESTORE_ALL_AND_RET
3535

@@ -39,7 +39,7 @@ rt_hw_context_switch:
3939
*/
4040
.globl rt_hw_context_switch_to
4141
rt_hw_context_switch_to:
42-
lw sp, 0(a0) /* get new task stack pointer */
42+
REG_L sp, 0(a0) /* get new task stack pointer */
4343
RESTORE_ALL_AND_RET
4444

4545
/*
@@ -50,17 +50,17 @@ rt_hw_context_switch_to:
5050
.globl rt_interrupt_to_thread
5151
.globl rt_hw_context_switch_interrupt
5252
rt_hw_context_switch_interrupt:
53-
la t0, rt_thread_switch_interrupt_flag
54-
lw t1, 0(t0)
53+
PTR_LA t0, rt_thread_switch_interrupt_flag
54+
REG_L t1, 0(t0)
5555
nop
5656
bnez t1, _reswitch
5757
nop
5858
li t1, 0x01 /* set rt_thread_switch_interrupt_flag to 1 */
5959
sw t1, 0(t0)
60-
la t0, rt_interrupt_from_thread /* set rt_interrupt_from_thread */
60+
PTR_LA t0, rt_interrupt_from_thread /* set rt_interrupt_from_thread */
6161
sw a0, 0(t0)
6262
_reswitch:
63-
la t0, rt_interrupt_to_thread /* set rt_interrupt_to_thread */
63+
PTR_LA t0, rt_interrupt_to_thread /* set rt_interrupt_to_thread */
6464
sw a1, 0(t0)
6565
jr ra
6666
nop
@@ -78,7 +78,7 @@ mips_irq_handle:
7878
/* let k0 keep the current context sp */
7979
move k0, sp
8080
/* switch to kernel stack */
81-
la sp, _system_stack
81+
PTR_LA sp, _system_stack
8282

8383
jal rt_interrupt_enter
8484
nop
@@ -96,7 +96,7 @@ mips_irq_handle:
9696
* if rt_thread_switch_interrupt_flag set, jump to
9797
* rt_hw_context_switch_interrupt_do and do not return
9898
*/
99-
la k0, rt_thread_switch_interrupt_flag
99+
PTR_LA k0, rt_thread_switch_interrupt_flag
100100
lw k1, 0(k0)
101101
beqz k1, spurious_interrupt
102102
nop
@@ -106,12 +106,12 @@ mips_irq_handle:
106106
/*
107107
* switch to the new thread
108108
*/
109-
la k0, rt_interrupt_from_thread
109+
PTR_LA k0, rt_interrupt_from_thread
110110
lw k1, 0(k0)
111111
nop
112112
sw sp, 0(k1) /* store sp in preempted task TCB */
113113

114-
la k0, rt_interrupt_to_thread
114+
PTR_LA k0, rt_interrupt_to_thread
115115
lw k1, 0(k0)
116116
nop
117117
lw sp, 0(k1) /* get new task stack pointer */

libcpu/mips/common/entry_gcc.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ _start:
3131
PTR_LA ra, _rtthread_entry
3232

3333
/* disable interrupt */
34-
mtc0 zero, CP0_CAUSE
35-
mtc0 zero, CP0_STATUS # Set CPU to disable interrupt.
34+
MTC0 zero, CP0_CAUSE
35+
MTC0 zero, CP0_STATUS # Set CPU to disable interrupt.
3636
ehb
3737

3838
#ifdef ARCH_MIPS64

libcpu/mips/common/exception.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
/*@{*/
2121

22-
extern rt_uint32_t __ebase_entry;
23-
rt_uint32_t rt_interrupt_from_thread;
24-
rt_uint32_t rt_interrupt_to_thread;
25-
rt_uint32_t rt_thread_switch_interrupt_flag;
22+
extern rt_ubase_t __ebase_entry;
23+
rt_ubase_t rt_interrupt_from_thread;
24+
rt_ubase_t rt_interrupt_to_thread;
25+
rt_ubase_t rt_thread_switch_interrupt_flag;
2626

2727
rt_base_t rt_hw_interrupt_disable(void)
2828
{
@@ -101,7 +101,10 @@ static void install_default_exception_handler(void)
101101

102102
int rt_hw_exception_init(void)
103103
{
104-
rt_uint32_t ebase = (rt_uint32_t)&__ebase_entry;
104+
rt_ubase_t ebase = (rt_ubase_t)&__ebase_entry;
105+
#ifdef ARCH_MIPS64
106+
ebase |= 0xffffffff00000000;
107+
#endif
105108
write_c0_ebase(ebase);
106109
clear_c0_status(ST0_BEV | ST0_ERL | ST0_EXL);
107110
clear_c0_status(ST0_IM | ST0_IE);
@@ -114,12 +117,12 @@ int rt_hw_exception_init(void)
114117

115118
void rt_general_exc_dispatch(struct pt_regs *regs)
116119
{
117-
rt_uint32_t cause, exccode;
120+
rt_ubase_t cause, exccode;
118121

119122
exccode = (cause & CAUSEF_EXCCODE) >> CAUSEB_EXCCODE;
120123

121124
if (exccode == 0) {
122-
rt_uint32_t status, pending;
125+
rt_ubase_t status, pending;
123126
status = read_c0_status();
124127
pending = (cause & CAUSEF_IP) & (status & ST0_IM);
125128
if (pending & CAUSEF_IP0)

0 commit comments

Comments
 (0)