fix bug in context_gcc.s and start_gcc.s:

save mie into stack
msh  running normaly
This commit is contained in:
zhangjun 2017-07-31 10:59:59 +08:00
parent d9c0bdc70e
commit a5305c05df
5 changed files with 22 additions and 10 deletions

View File

@ -17,7 +17,6 @@ static void usart_init(int buard)
static void usart_handler(int vector, void *param)
{
rt_hw_serial_isr((struct rt_serial_device*)param, RT_SERIAL_EVENT_RX_IND);
UART0_REG(UART_REG_IP) = 0;
return;
}
static rt_err_t usart_configure(struct rt_serial_device *serial,

View File

@ -11,7 +11,7 @@ struct rt_irq_desc irq_desc[MAX_HANDLERS];
rt_uint32_t rt_interrupt_from_thread;
rt_uint32_t rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
plic_instance_t g_plic;
volatile plic_instance_t g_plic;
/**
* This function will mask a interrupt.
* @param vector the interrupt number

View File

@ -106,9 +106,11 @@ rt_hw_context_switch:
STORE x26, 26*REGBYTES(sp)
STORE x27, 27*REGBYTES(sp)
STORE x28, 28*REGBYTES(sp)
STORE x1, 31*REGBYTES(sp)
STORE x10, 29*REGBYTES(sp)
STORE x1, 30*REGBYTES(sp)
STORE x1, 31*REGBYTES(sp)
csrr x10, mie
STORE x10, 0*REGBYTES(sp)
/*
*Remain in M-mode after mret
*enable interrupt in M-mode
@ -147,6 +149,8 @@ rt_hw_context_switch:
LOAD x28, 28*REGBYTES(sp)
LOAD x10, 31*REGBYTES(sp)
csrw mepc,x10
LOAD x10, 0*REGBYTES(sp)
csrw mie, x10
LOAD x10, 29*REGBYTES(sp)
LOAD x1, 30*REGBYTES(sp)

View File

@ -86,7 +86,8 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
*(--stk) = 0xffffffff; /* t6 */
*(--stk) = 0xffffffff; /* tp */
*(--stk) = 0xffffffff; /* gp */
*(--stk) = 0x880; /* mie */
// *(--stk) = (rt_uint32_t)parameter; /* r0 : argument */
/* return task's current stack address */
return (rt_uint8_t *)--stk;
return (rt_uint8_t *)stk;
}

View File

@ -176,8 +176,17 @@ trap_entry:
STORE x1, 30*REGBYTES(sp)
csrr x10, mepc
STORE x10, 31*REGBYTES(sp)
csrr x10, mie
STORE x10, 0*REGBYTES(sp)
/*
*Remain in M-mode after mret
*enable interrupt in M-mode
*/
li t0, MSTATUS_MPP
csrrs t0, mstatus, t0
call rt_interrupt_enter
csrr a0, mcause
lui a5, 0x80000
@ -189,17 +198,13 @@ trap_entry:
bne a5, a4, 1f
call rt_hw_trap_irq
1:
/*Machine software interrupt*/
/*Machine timer interrupt*/
li a4, 7
bne a5, a4, 2f
call rt_systick_handler
2:
call rt_interrupt_leave
# Remain in M-mode after mret
li t0, 136
csrrs t0, mstatus, t0
la a0, rt_thread_switch_interrupt_flag
lw a1, (a0)
bnez a1, rt_hw_context_switch_interrupt_do
@ -235,9 +240,10 @@ trap_entry:
LOAD x28, 28*REGBYTES(sp)
LOAD x10, 31*REGBYTES(sp)
csrw mepc,x10
LOAD x10, 0*REGBYTES(sp)
csrw mie, x10
LOAD x10, 29*REGBYTES(sp)
LOAD x1, 30*REGBYTES(sp)
addi sp, sp, 32*REGBYTES
mret
@ -282,6 +288,8 @@ rt_hw_context_switch_interrupt_do:
LOAD x28, 28*REGBYTES(sp)
LOAD x10, 31*REGBYTES(sp)
csrw mepc,x10
LOAD x10, 0*REGBYTES(sp)
csrw mie, x10
LOAD x10, 29*REGBYTES(sp)
LOAD x1, 30*REGBYTES(sp)