X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm%2Fao_arch.h;h=bbd1b3b1f33e50a90bed62d4178fd689789f77d6;hb=03dc80d15a2f8fe9d7340351226dadd8bc3cfdb9;hp=dd9579f1093252b303cfff84506ebb68d5734b6b;hpb=51aef5d4fc29986353ad887f4a67ed2fe35f8c8e;p=fw%2Faltos diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h index dd9579f1..bbd1b3b1 100644 --- a/src/stm/ao_arch.h +++ b/src/stm/ao_arch.h @@ -42,7 +42,9 @@ #define __interrupt(n) #define __at(n) -#define ao_arch_reboot() /* XXX */ +#define CORTEX_M3_AIRCR ((uint32_t *) 0xe000ed0c) + +#define ao_arch_reboot() (*((uint32_t *) 0xe000ed0c) = 0x05fa0004) #define ao_arch_nop() asm("nop") @@ -72,12 +74,6 @@ extern const uint16_t ao_serial_number; uint32_t a = (uint32_t) start; \ int i; \ \ - /* APSR */ \ - ARM_PUSH32(sp, 0); \ - \ - /* PRIMASK with interrupts enabled */ \ - ARM_PUSH32(sp, 0); \ - \ /* Return address (goes into LR) */ \ ARM_PUSH32(sp, a); \ \ @@ -86,23 +82,29 @@ extern const uint16_t ao_serial_number; while (i--) \ ARM_PUSH32(sp, 0); \ \ + /* APSR */ \ + ARM_PUSH32(sp, 0); \ + \ + /* PRIMASK with interrupts enabled */ \ + ARM_PUSH32(sp, 0); \ + \ task->sp = sp; \ } while (0); #define ao_arch_save_regs() do { \ - uint32_t apsr; \ - uint32_t primask; \ + /* Save general registers */ \ + asm("push {r0-r12,lr}\n"); \ \ /* Save APSR */ \ - asm("mrs %0,apsr" : "=&r" (apsr)); \ - asm("push {%0}" : : "r" (apsr)); \ + asm("mrs r0,apsr"); \ + asm("push {r0}"); \ \ /* Save PRIMASK */ \ - asm("mrs %0,primask" : "=&r" (primask)); \ - asm("push {%0}" : : "r" (primask)); \ + asm("mrs r0,primask"); \ + asm("push {r0}"); \ \ - /* Save general registers */ \ - asm("push {r0-r12,lr}\n"); \ + /* Enable interrupts */ \ + sei(); \ } while (0) #define ao_arch_save_stack() do { \ @@ -121,23 +123,21 @@ extern const uint16_t ao_serial_number; #define ao_arch_restore_stack() do { \ uint32_t sp; \ - uint32_t primask; \ - uint32_t apsr; \ sp = (uint32_t) ao_cur_task->sp; \ \ /* Switch stacks */ \ asm("mov sp, %0" : : "r" (sp) ); \ \ - /* Restore general registers */ \ - asm("pop {r0-r12,lr}\n"); \ - \ /* Restore PRIMASK */ \ - asm("pop {%0}" : "=&r" (primask) ); \ - asm("msr primask,%0" : : "r" (primask) ); \ + asm("pop {r0}"); \ + asm("msr primask,r0"); \ \ /* Restore APSR */ \ - asm("pop {%0}" : "=&r" (apsr) ); \ - asm("msr apsr,%0" : : "r" (apsr) ); \ + asm("pop {r0}"); \ + asm("msr apsr,r0"); \ + \ + /* Restore general registers */ \ + asm("pop {r0-r12,lr}\n"); \ \ /* Return to calling function */ \ asm("bx lr"); \ @@ -179,8 +179,6 @@ void ao_lcd_font_init(void); void ao_lcd_font_string(char *s); -#define USE_SERIAL_STDIN (USE_SERIAL_1_STDIN + USE_SERIAL_2_STDIN + USE_SERIAL_3_STDIN) - char ao_serial1_getchar(void);