Skip to content

Commit

Permalink
* convert to coding conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegHahm committed Mar 31, 2013
1 parent 349bec1 commit ad0b7a8
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 171 deletions.
69 changes: 39 additions & 30 deletions cpu/arm_common/arm_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,59 +25,68 @@
#include "sched.h"
#include "kernel_intern.h"

void thread_yield() {
#define STACK_MARKER (0x77777777)
#define REGISTER_CNT (12)

void thread_yield(void)
{
asm("svc 0\n");
}

//----------------------------------------------------------------------------
// Processor specific routine - here for ARM7
// sizeof(void*) = sizeof(int)
//----------------------------------------------------------------------------
char * thread_stack_init(void * task_func, void * stack_start, int stack_size)
/*----------------------------------------------------------------------------
* Processor specific routine - here for ARM7
* sizeof(void*) = sizeof(int)
*--------------------------------------------------------------------------*/
char *thread_stack_init(void *task_func, void *stack_start, int stack_size)
{
unsigned int * stk;
stk = (unsigned int *) (stack_start + stack_size);
unsigned int *stk;
stk = (unsigned int *) (stack_start + stack_size);
stk--;

*stk = 0x77777777;
stk--;
*stk = STACK_MARKER;

*stk = (unsigned int)sched_task_exit; // LR
/* set the return address (LR) */
stk--;
*stk = (unsigned int) sched_task_exit;

stk--;
*stk = (unsigned int) (stack_start + stack_size) - 4; // SP
/* set the stack pointer (SP) */
stk--;
*stk = (unsigned int) (stack_start + stack_size) - 4;

for (int i = 12; i>= 0 ; i--) { // build base stack
stk--;
*stk = i;
}
/* build base stack */
for (int i = REGISTER_CNT; i>= 0 ; i--) {
stk--;
*stk = i;
}

stk--;
*stk = ((unsigned int) task_func); // Entry Point
stk--;
*stk = (unsigned int) NEW_TASK_CPSR; // spsr
/* set the entry point */
stk--;
*stk = ((unsigned int) task_func);
/* set the saved program status register */
stk--;
*stk = (unsigned int) NEW_TASK_CPSR;

return (char*)stk;
return (char*) stk;
}

void thread_print_stack () {
register void * stack = 0;
void thread_print_stack(void)
{
register void *stack = 0;
asm( "mov %0, sp" : "=r" (stack));

register unsigned int * s = (unsigned int*) stack;
printf("task: %X SP: %X\n", (unsigned int)active_thread, (unsigned int)stack);
register unsigned int *s = (unsigned int*) stack;
printf("task: %X SP: %X\n", (unsigned int) active_thread, (unsigned int) stack);
register int i = 0;
s += 5;
while (*s != 0x77777777) {
printf("STACK (%u) addr=%X = %X \n",i,(unsigned int) s, (unsigned int)*s);
while (*s != STACK_MARKER) {
printf("STACK (%u) addr=%X = %X \n", i, (unsigned int) s, (unsigned int) *s);
s++;
i++;
}
printf("STACK (%u)= %X \n",i,*s);
}

__attribute__((naked,noreturn)) void
arm_reset(void)
__attribute__((naked,noreturn)) void arm_reset(void)
{
dINT();
WDTC = 0x00FFF;
Expand Down
Loading

0 comments on commit ad0b7a8

Please sign in to comment.