synchronize with external depot
-add relocation code to initial asm setup -print the top of the stack on a crash -turn off debug spew when threads exit -make sure the critical section routines are fully inlined -remove warning in dpc code
This commit is contained in:
committed by
Travis Geiselbrecht
parent
f54ab82112
commit
887061fc2e
@@ -51,6 +51,30 @@ reset:
|
||||
.word 0xe1600070
|
||||
#endif
|
||||
|
||||
/* see if we need to relocate */
|
||||
mov r0, pc
|
||||
sub r0, r0, #(.Laddr - _start)
|
||||
.Laddr:
|
||||
ldr r1, =_start
|
||||
cmp r0, r1
|
||||
beq .Lstack_setup
|
||||
|
||||
/* we need to relocate ourselves to the proper spot */
|
||||
ldr r2, =__data_end
|
||||
|
||||
.Lrelocate_loop:
|
||||
ldr r3, [r0], #4
|
||||
str r3, [r1], #4
|
||||
cmp r1, r2
|
||||
bne .Lrelocate_loop
|
||||
|
||||
/* we're relocated, jump to the right address */
|
||||
ldr r0, =.Lstack_setup
|
||||
bx r0
|
||||
|
||||
.ltorg
|
||||
|
||||
.Lstack_setup:
|
||||
/* set up the stack for irq, fiq, abort, undefined, system/user, and lastly supervisor mode */
|
||||
mrs r0, cpsr
|
||||
bic r0, r0, #0x1f
|
||||
@@ -86,23 +110,23 @@ reset:
|
||||
ldr r2, =__data_end
|
||||
|
||||
cmp r0, r1
|
||||
beq __do_bss
|
||||
beq .L__do_bss
|
||||
|
||||
__copy_loop:
|
||||
.L__copy_loop:
|
||||
cmp r1, r2
|
||||
ldrlt r3, [r0], #4
|
||||
strlt r3, [r1], #4
|
||||
blt __copy_loop
|
||||
blt .L__copy_loop
|
||||
|
||||
__do_bss:
|
||||
.L__do_bss:
|
||||
/* clear out the bss */
|
||||
ldr r0, =__bss_start
|
||||
ldr r1, =_end
|
||||
mov r2, #0
|
||||
__bss_loop:
|
||||
.L__bss_loop:
|
||||
cmp r0, r1
|
||||
strlt r2, [r0], #4
|
||||
blt __bss_loop
|
||||
blt .L__bss_loop
|
||||
|
||||
bl kmain
|
||||
b .
|
||||
|
||||
@@ -40,14 +40,31 @@ static void dump_fault_frame(struct arm_fault_frame *frame)
|
||||
dprintf("%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_SVC) ? '*' : ' ', "svc", regs.svc_r13, regs.svc_r14);
|
||||
dprintf("%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_UND) ? '*' : ' ', "und", regs.und_r13, regs.und_r14);
|
||||
dprintf("%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_SYS) ? '*' : ' ', "sys", regs.sys_r13, regs.sys_r14);
|
||||
|
||||
// dump the bottom of the current stack
|
||||
addr_t stack;
|
||||
switch (frame->spsr & MODE_MASK) {
|
||||
case MODE_FIQ: stack = regs.fiq_r13; break;
|
||||
case MODE_IRQ: stack = regs.irq_r13; break;
|
||||
case MODE_SVC: stack = regs.svc_r13; break;
|
||||
case MODE_UND: stack = regs.und_r13; break;
|
||||
case MODE_SYS: stack = regs.sys_r13; break;
|
||||
default:
|
||||
stack = 0;
|
||||
}
|
||||
|
||||
if (stack != 0) {
|
||||
dprintf("bottom of stack at 0x%08x:\n", (unsigned int)stack);
|
||||
hexdump((void *)stack, 128);
|
||||
}
|
||||
}
|
||||
|
||||
static void exception_die(struct arm_fault_frame *frame, int pc_off, const char *msg)
|
||||
{
|
||||
inc_critical_section();
|
||||
frame->pc += pc_off;
|
||||
dump_fault_frame(frame);
|
||||
dprintf(msg);
|
||||
dump_fault_frame(frame);
|
||||
debug_halt();
|
||||
for(;;);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ SECTIONS
|
||||
|
||||
.rodata : {
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(4);
|
||||
__commands_start = .;
|
||||
KEEP (*(.commands))
|
||||
__commands_end = .;
|
||||
|
||||
@@ -56,7 +56,7 @@ static void initial_thread_func(void)
|
||||
|
||||
ret = current_thread->entry(current_thread->arg);
|
||||
|
||||
dprintf("initial_thread_func: thread %p exiting with %d\n", current_thread, ret);
|
||||
// dprintf("initial_thread_func: thread %p exiting with %d\n", current_thread, ret);
|
||||
|
||||
thread_exit(ret);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ typedef struct thread {
|
||||
enum thread_state state;
|
||||
int saved_critical_section_count;
|
||||
int remaining_quantum;
|
||||
|
||||
|
||||
/* if blocked, a pointer to the wait queue */
|
||||
struct wait_queue *blocking_wait_queue;
|
||||
status_t wait_queue_block_ret;
|
||||
@@ -117,21 +117,21 @@ extern thread_t *idle_thread;
|
||||
/* critical sections */
|
||||
extern int critical_section_count;
|
||||
|
||||
static inline void enter_critical_section(void)
|
||||
static inline __ALWAYS_INLINE void enter_critical_section(void)
|
||||
{
|
||||
critical_section_count++;
|
||||
if (critical_section_count == 1)
|
||||
arch_disable_ints();
|
||||
}
|
||||
|
||||
static inline void exit_critical_section(void)
|
||||
static inline __ALWAYS_INLINE void exit_critical_section(void)
|
||||
{
|
||||
critical_section_count--;
|
||||
if (critical_section_count == 0)
|
||||
arch_enable_ints();
|
||||
}
|
||||
|
||||
static inline bool in_critical_section(void)
|
||||
static inline __ALWAYS_INLINE bool in_critical_section(void)
|
||||
{
|
||||
return critical_section_count > 0;
|
||||
}
|
||||
|
||||
@@ -81,6 +81,8 @@ static int dpc_thread_routine(void *arg)
|
||||
free(dpc);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ void timer_set_oneshot(timer_t *timer, time_t delay, timer_callback callback, vo
|
||||
{
|
||||
time_t now;
|
||||
|
||||
// TRACEF("delay %d, callback %p, arg %p\n", delay, callback, arg);
|
||||
|
||||
DEBUG_ASSERT(timer->magic == TIMER_MAGIC);
|
||||
|
||||
if (list_in_list(&timer->node)) {
|
||||
@@ -70,6 +72,8 @@ void timer_set_oneshot(timer_t *timer, time_t delay, timer_callback callback, vo
|
||||
timer->callback = callback;
|
||||
timer->arg = arg;
|
||||
|
||||
// TRACEF("scheduled time %u\n", timer->scheduled_time);
|
||||
|
||||
enter_critical_section();
|
||||
|
||||
insert_timer_in_queue(timer);
|
||||
@@ -115,6 +119,7 @@ static enum handler_return timer_tick(void *arg, time_t now)
|
||||
thread_stats.timers++;
|
||||
#endif
|
||||
|
||||
// TRACEF("firing callback %p, arg %p\n", timer->callback, timer->arg);
|
||||
if (timer->callback(timer, now, timer->arg) == INT_RESCHEDULE)
|
||||
ret = INT_RESCHEDULE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user