Skip to content

Commit

Permalink
Merged in masayuki2009/nuttx.nuttx/fix_fe310_signal (pull request #1099)
Browse files Browse the repository at this point in the history
Fix fe310 signal handling

* arch: fe310: Disable all interrupts in mie at __start

* arch: fe310: Fix up_irq_enable() to set external interrupt only

* arch: fe310: Fix up_schedule_sigaction() to save REG_INT_CTX

* boards: hifive1-revb: Adjust stack size to reduce runtime memory

Approved-by: Gregory Nutt <gnutt@nuttx.org>
  • Loading branch information
masayuki2009 authored and gregory-nutt committed Dec 20, 2019
1 parent d80d6b8 commit 15f2889
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions arch/risc-v/src/fe310/fe310_head.S
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ __start:
lui sp, %hi(FE310_IDLESTACK_TOP)
addi sp, sp, %lo(FE310_IDLESTACK_TOP)

/* Disable all interrupts (i.e. timer, external) in mie */

csrw mie, zero

/* Initialize the Machine Trap Vector */

lui t0, %hi(__trap_vec)
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/fe310/fe310_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ irqstate_t up_irq_enable(void)

/* TODO: should move to up_enable_irq() */

asm volatile("csrw mie, %0" : /* no output */ : "r"(MIE_MEIE));
asm volatile ("csrrs %0, mie, %1": "=r" (oldstat) : "r"(MIE_MEIE));
#endif

/* Read mstatus & set machine interrupt enable (MIE) in mstatus */
Expand Down
1 change: 1 addition & 0 deletions arch/risc-v/src/fe310/up_schedulesigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)

tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_epc = g_current_regs[REG_EPC];
tcb->xcp.saved_int_ctx = g_current_regs[REG_INT_CTX];

/* Then set up to vector to the trampoline with interrupts
* disabled
Expand Down
5 changes: 3 additions & 2 deletions boards/risc-v/fe310/hifive1-revb/configs/nsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ CONFIG_DISABLE_MQUEUE=y
CONFIG_EXAMPLES_BUTTONS=y
CONFIG_EXAMPLES_BUTTONS_NAMES=y
CONFIG_EXAMPLES_BUTTONS_QTD=1
CONFIG_EXAMPLES_BUTTONS_STACKSIZE=1572
CONFIG_EXAMPLES_BUTTONS_STACKSIZE=1024
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_HELLO_STACKSIZE=1024
CONFIG_FS_PROCFS=y
CONFIG_FS_WRITABLE=y
CONFIG_IDLETHREAD_STACKSIZE=1536
Expand Down Expand Up @@ -76,9 +77,9 @@ CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=12
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_GETPRIME_STACKSIZE=2048
CONFIG_UART0_RXBUFSIZE=8
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_UART0_TXBUFSIZE=32
CONFIG_USERMAIN_STACKSIZE=1536
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WDOG_INTRESERVE=0

0 comments on commit 15f2889

Please sign in to comment.