LM32: Correct some assembly language interrupt handling issues. Now the basic port seems functional.
This commit is contained in:
parent
89c3c20052
commit
fe2b755791
@ -38,13 +38,43 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
#include <arch/irq.h>
|
#include <arch/irq.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
/* Linker memory organization ***********************************************/
|
||||||
|
/* Data memory is organized as follows:
|
||||||
|
*
|
||||||
|
* 1) Initialized data (.data):
|
||||||
|
* Start: _sdata
|
||||||
|
* End(+1): _edata
|
||||||
|
* 2) Uninitialized data (.bss):
|
||||||
|
* Start: _sbss
|
||||||
|
* End(+1): _ebss
|
||||||
|
*
|
||||||
|
* The following are placed outside of the "normal" memory segments -- mostly
|
||||||
|
* so that they do not have to be cleared on power up.
|
||||||
|
*
|
||||||
|
* 3) Idle thread stack:
|
||||||
|
* Start: _ebss
|
||||||
|
* End(+1): _ebss+CONFIG_IDLETHREAD_STACKSIZE
|
||||||
|
* 4) Heap:
|
||||||
|
* Start: _ebss+CONFIG_IDLETHREAD_STACKSIZE
|
||||||
|
* End(+1): to the end of memory
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LM32_STACK_BASE _ebss
|
||||||
|
#define LM32_STACK_TOP _ebss+CONFIG_IDLETHREAD_STACKSIZE
|
||||||
|
#define LM32_HEAP_BASE LM32_STACK_TOP
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Exception handlers - Must be 32 bytes long.
|
* Exception handlers - Must be 32 bytes long.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.section .text, "ax", @progbits
|
.section .text, "ax", @progbits
|
||||||
|
.global g_idle_topstack
|
||||||
.global __start
|
.global __start
|
||||||
|
|
||||||
__start:
|
__start:
|
||||||
@ -131,24 +161,24 @@ _syscall_handler:
|
|||||||
_do_reset:
|
_do_reset:
|
||||||
/* Setup stack and global pointer */
|
/* Setup stack and global pointer */
|
||||||
|
|
||||||
mvhi sp, hi(_fstack)
|
mvhi sp, hi(LM32_STACK_TOP)
|
||||||
ori sp, sp, lo(_fstack)
|
ori sp, sp, lo(LM32_STACK_TOP)
|
||||||
|
|
||||||
/* Clear BSS */
|
/* Clear BSS */
|
||||||
|
|
||||||
mvhi r1, hi(_sbss)
|
mvhi r1, hi(_sbss)
|
||||||
ori r1, r1, lo(_sbss)
|
ori r1, r1, lo(_sbss)
|
||||||
mvhi r3, hi(_ebss)
|
mvhi r3, hi(_ebss)
|
||||||
ori r3, r3, lo(_ebss)
|
ori r3, r3, lo(_ebss)
|
||||||
|
|
||||||
.clearBSS:
|
.clearBSS:
|
||||||
be r1, r3, .callMain
|
be r1, r3, .callMain
|
||||||
sw (r1+0), r0
|
sw (r1+0), r0
|
||||||
addi r1, r1, 4
|
addi r1, r1, 4
|
||||||
bi .clearBSS
|
bi .clearBSS
|
||||||
|
|
||||||
.callMain:
|
.callMain:
|
||||||
bi os_start
|
bi os_start
|
||||||
|
|
||||||
.save_all:
|
.save_all:
|
||||||
addi sp, sp, -136
|
addi sp, sp, -136
|
||||||
@ -181,7 +211,11 @@ _do_reset:
|
|||||||
|
|
||||||
sw (sp+REG_GP), r26
|
sw (sp+REG_GP), r26
|
||||||
sw (sp+REG_FP), r27
|
sw (sp+REG_FP), r27
|
||||||
sw (sp+REG_SP), r28
|
|
||||||
|
/* Save SP before we add 136 */
|
||||||
|
|
||||||
|
addi r1, sp, 136
|
||||||
|
sw (sp+REG_SP), r1
|
||||||
|
|
||||||
/* reg RA done later */
|
/* reg RA done later */
|
||||||
|
|
||||||
@ -239,7 +273,7 @@ _do_reset:
|
|||||||
lw r1, (r1+REG_INT_CTX)
|
lw r1, (r1+REG_INT_CTX)
|
||||||
wcsr IE, r1
|
wcsr IE, r1
|
||||||
lw r1, (r1+REG_X1)
|
lw r1, (r1+REG_X1)
|
||||||
addi sp, sp, 136
|
|
||||||
eret
|
eret
|
||||||
|
|
||||||
/* This global variable is unsigned long g_idle_topstack and is
|
/* This global variable is unsigned long g_idle_topstack and is
|
||||||
@ -249,10 +283,9 @@ _do_reset:
|
|||||||
|
|
||||||
.data
|
.data
|
||||||
.align 4
|
.align 4
|
||||||
.globl g_idle_topstack
|
|
||||||
.type g_idle_topstack, object
|
.type g_idle_topstack, object
|
||||||
|
|
||||||
g_idle_topstack:
|
g_idle_topstack:
|
||||||
.long _ebss+CONFIG_IDLETHREAD_STACKSIZE
|
.long _LM32_STACK_TOP
|
||||||
.size g_idle_topstack, .-g_idle_topstack
|
.size g_idle_topstack, .-g_idle_topstack
|
||||||
.end
|
.end
|
||||||
|
Loading…
Reference in New Issue
Block a user