fix sys.c

This commit is contained in:
NIIBE Yutaka
2013-06-06 15:16:11 +09:00
parent 0b46ccbae1
commit bbd9404fa5
4 changed files with 20 additions and 12 deletions

View File

@@ -540,11 +540,14 @@ nvic_system_reset (void)
{
SCB->AIRCR = (0x05FA0000 | (SCB->AIRCR & 0x70) | SYSRESETREQ);
asm volatile ("dsb");
for (;;);
}
static void __attribute__ ((naked))
reset (void)
{
extern const unsigned long *FT0, *FT1, *FT2;
asm volatile ("cpsid i\n\t" /* Mask all interrupts. */
"mov.w r0, #0xed00\n\t" /* r0 = SCR */
"movt r0, #0xe000\n\t"
@@ -559,13 +562,16 @@ reset (void)
"ldr r0, [r1]\n\t" /* Reset handler. */
"bx r0\n"
: /* no output */ : /* no input */ : "memory");
/* Never reach here. */
/* Artificial entry to refer FT0, FT1, and FT2. */
asm volatile (""
: : "r" (&FT0), "r" (&FT1), "r" (&FT2));
}
typedef void (*handler)(void);
extern uint8_t __ram_end__;
extern const unsigned long *FT0, *FT1, *FT2;
handler vector[] __attribute__ ((section(".vectors"))) = {
(handler)&__ram_end__,
reset,
@@ -582,9 +588,7 @@ handler vector[] __attribute__ ((section(".vectors"))) = {
nvic_system_reset,
clock_init,
gpio_init,
(handler)&FT0,
(handler)&FT1,
(handler)&FT2,
NULL,
};
const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {

View File

@@ -1,7 +1,7 @@
extern const uint8_t sys_version[8];
typedef void (*handler)(void);
extern handler vector[18];
extern handler vector[16];
static inline const uint8_t *
unique_device_id (void)

View File

@@ -540,11 +540,14 @@ nvic_system_reset (void)
{
SCB->AIRCR = (0x05FA0000 | (SCB->AIRCR & 0x70) | SYSRESETREQ);
asm volatile ("dsb");
for (;;);
}
static void __attribute__ ((naked))
reset (void)
{
extern const unsigned long *FT0, *FT1, *FT2;
asm volatile ("cpsid i\n\t" /* Mask all interrupts. */
"mov.w r0, #0xed00\n\t" /* r0 = SCR */
"movt r0, #0xe000\n\t"
@@ -559,13 +562,16 @@ reset (void)
"ldr r0, [r1]\n\t" /* Reset handler. */
"bx r0\n"
: /* no output */ : /* no input */ : "memory");
/* Never reach here. */
/* Artificial entry to refer FT0, FT1, and FT2. */
asm volatile (""
: : "r" (&FT0), "r" (&FT1), "r" (&FT2));
}
typedef void (*handler)(void);
extern uint8_t __ram_end__;
extern const unsigned long *FT0, *FT1, *FT2;
handler vector[] __attribute__ ((section(".vectors"))) = {
(handler)&__ram_end__,
reset,
@@ -582,9 +588,7 @@ handler vector[] __attribute__ ((section(".vectors"))) = {
nvic_system_reset,
clock_init,
gpio_init,
(handler)&FT0,
(handler)&FT1,
(handler)&FT2,
NULL,
};
const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {

View File

@@ -1,7 +1,7 @@
extern const uint8_t sys_version[8];
typedef void (*handler)(void);
extern handler vector[18];
extern handler vector[16];
static inline const uint8_t *
unique_device_id (void)