diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-04-22 23:41:29 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-04-22 23:41:29 +0000 |
commit | 8ded7ca323baddf20575f9884f81694d328fe807 (patch) | |
tree | 3766ff02ab27ea6a7ce218a4646a70ae5ae5a729 /firmware/thread.c | |
parent | c7e811bffe0f37139cd07248522c407fd3901024 (diff) | |
download | rockbox-8ded7ca323baddf20575f9884f81694d328fe807.tar.gz rockbox-8ded7ca323baddf20575f9884f81694d328fe807.zip |
The indent police strikes again!
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@181 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/thread.c')
-rw-r--r-- | firmware/thread.c | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/firmware/thread.c b/firmware/thread.c index f9fe1ccf17..97e2d2173e 100644 --- a/firmware/thread.c +++ b/firmware/thread.c | |||
@@ -20,22 +20,22 @@ | |||
20 | 20 | ||
21 | typedef union | 21 | typedef union |
22 | { | 22 | { |
23 | struct regs_t | 23 | struct regs_t |
24 | { | 24 | { |
25 | unsigned int r[7]; /* Registers r8 thru r14 */ | 25 | unsigned int r[7]; /* Registers r8 thru r14 */ |
26 | void *sp; /* Stack pointer (r15) */ | 26 | void *sp; /* Stack pointer (r15) */ |
27 | unsigned int sr; /* Status register */ | 27 | unsigned int sr; /* Status register */ |
28 | void* gbr; /* Global base register */ | 28 | void* gbr; /* Global base register */ |
29 | void* pr; /* Procedure register */ | 29 | void* pr; /* Procedure register */ |
30 | } regs; | 30 | } regs; |
31 | unsigned int mem[32]; | 31 | unsigned int mem[32]; |
32 | } ctx_t; | 32 | } ctx_t; |
33 | 33 | ||
34 | typedef struct | 34 | typedef struct |
35 | { | 35 | { |
36 | int created; | 36 | int created; |
37 | int current; | 37 | int current; |
38 | ctx_t ctx[MAXTHREADS] __attribute__ ((aligned (32))); | 38 | ctx_t ctx[MAXTHREADS] __attribute__ ((aligned (32))); |
39 | } thread_t; | 39 | } thread_t; |
40 | 40 | ||
41 | static thread_t threads = {1, 0}; | 41 | static thread_t threads = {1, 0}; |
@@ -46,20 +46,20 @@ static thread_t threads = {1, 0}; | |||
46 | */ | 46 | */ |
47 | static inline void stctx(void* addr) | 47 | static inline void stctx(void* addr) |
48 | { | 48 | { |
49 | asm volatile ("mov.l r8, @(0, %0)\n\t" | 49 | asm volatile ("mov.l r8, @(0, %0)\n\t" |
50 | "mov.l r9, @(4, %0)\n\t" | 50 | "mov.l r9, @(4, %0)\n\t" |
51 | "mov.l r10, @(8, %0)\n\t" | 51 | "mov.l r10, @(8, %0)\n\t" |
52 | "mov.l r11, @(12, %0)\n\t" | 52 | "mov.l r11, @(12, %0)\n\t" |
53 | "mov.l r12, @(16, %0)\n\t" | 53 | "mov.l r12, @(16, %0)\n\t" |
54 | "mov.l r13, @(20, %0)\n\t" | 54 | "mov.l r13, @(20, %0)\n\t" |
55 | "mov.l r14, @(24, %0)\n\t" | 55 | "mov.l r14, @(24, %0)\n\t" |
56 | "mov.l r15, @(28, %0)\n\t" | 56 | "mov.l r15, @(28, %0)\n\t" |
57 | "stc sr, r0\n\t" | 57 | "stc sr, r0\n\t" |
58 | "mov.l r0, @(32, %0)\n\t" | 58 | "mov.l r0, @(32, %0)\n\t" |
59 | "stc gbr, r0\n\t" | 59 | "stc gbr, r0\n\t" |
60 | "mov.l r0, @(36, %0)\n\t" | 60 | "mov.l r0, @(36, %0)\n\t" |
61 | "sts pr, r0\n\t" | 61 | "sts pr, r0\n\t" |
62 | "mov.l r0, @(40, %0)" :: "r" (addr)); | 62 | "mov.l r0, @(40, %0)" :: "r" (addr)); |
63 | } | 63 | } |
64 | 64 | ||
65 | /*--------------------------------------------------------------------------- | 65 | /*--------------------------------------------------------------------------- |
@@ -68,21 +68,21 @@ static inline void stctx(void* addr) | |||
68 | */ | 68 | */ |
69 | static inline void ldctx(void* addr) | 69 | static inline void ldctx(void* addr) |
70 | { | 70 | { |
71 | asm volatile ("mov.l @(0, %0), r8\n\t" | 71 | asm volatile ("mov.l @(0, %0), r8\n\t" |
72 | "mov.l @(4, %0), r9\n\t" | 72 | "mov.l @(4, %0), r9\n\t" |
73 | "mov.l @(8, %0), r10\n\t" | 73 | "mov.l @(8, %0), r10\n\t" |
74 | "mov.l @(12, %0), r11\n\t" | 74 | "mov.l @(12, %0), r11\n\t" |
75 | "mov.l @(16, %0), r12\n\t" | 75 | "mov.l @(16, %0), r12\n\t" |
76 | "mov.l @(20, %0), r13\n\t" | 76 | "mov.l @(20, %0), r13\n\t" |
77 | "mov.l @(24, %0), r14\n\t" | 77 | "mov.l @(24, %0), r14\n\t" |
78 | "mov.l @(28, %0), r15\n\t" | 78 | "mov.l @(28, %0), r15\n\t" |
79 | "mov.l @(32, %0), r0\n\t" | 79 | "mov.l @(32, %0), r0\n\t" |
80 | "ldc r0, sr\n\t" | 80 | "ldc r0, sr\n\t" |
81 | "mov.l @(36, %0), r0\n\t" | 81 | "mov.l @(36, %0), r0\n\t" |
82 | "ldc r0, gbr\n\t" | 82 | "ldc r0, gbr\n\t" |
83 | "mov.l @(40, %0), r0\n\t" | 83 | "mov.l @(40, %0), r0\n\t" |
84 | "lds r0, pr\n\t" | 84 | "lds r0, pr\n\t" |
85 | "mov.l r0, @(0, r15)" :: "r" (addr)); | 85 | "mov.l r0, @(0, r15)" :: "r" (addr)); |
86 | } | 86 | } |
87 | 87 | ||
88 | /*--------------------------------------------------------------------------- | 88 | /*--------------------------------------------------------------------------- |
@@ -92,16 +92,16 @@ static inline void ldctx(void* addr) | |||
92 | void | 92 | void |
93 | switch_thread(void) | 93 | switch_thread(void) |
94 | { | 94 | { |
95 | int ct; | 95 | int ct; |
96 | int nt; | 96 | int nt; |
97 | thread_t* t = &threads; | 97 | thread_t* t = &threads; |
98 | 98 | ||
99 | nt = ct = t->current; | 99 | nt = ct = t->current; |
100 | if (++nt >= t->created) | 100 | if (++nt >= t->created) |
101 | nt = 0; | 101 | nt = 0; |
102 | t->current = nt; | 102 | t->current = nt; |
103 | stctx(&t->ctx[ct]); | 103 | stctx(&t->ctx[ct]); |
104 | ldctx(&t->ctx[nt]); | 104 | ldctx(&t->ctx[nt]); |
105 | } | 105 | } |
106 | 106 | ||
107 | /*--------------------------------------------------------------------------- | 107 | /*--------------------------------------------------------------------------- |
@@ -112,16 +112,16 @@ switch_thread(void) | |||
112 | */ | 112 | */ |
113 | int create_thread(void* fp, void* sp, int stk_size) | 113 | int create_thread(void* fp, void* sp, int stk_size) |
114 | { | 114 | { |
115 | thread_t* t = &threads; | 115 | thread_t* t = &threads; |
116 | 116 | ||
117 | if (t->created >= MAXTHREADS) | 117 | if (t->created >= MAXTHREADS) |
118 | return -1; | 118 | return -1; |
119 | else | 119 | else |
120 | { | 120 | { |
121 | ctx_t* ctxp = &t->ctx[t->created++]; | 121 | ctx_t* ctxp = &t->ctx[t->created++]; |
122 | stctx(ctxp); | 122 | stctx(ctxp); |
123 | ctxp->regs.sp = (void*)(((unsigned int)sp + stk_size) & ~31); | 123 | ctxp->regs.sp = (void*)(((unsigned int)sp + stk_size) & ~31); |
124 | ctxp->regs.pr = fp; | 124 | ctxp->regs.pr = fp; |
125 | } | 125 | } |
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |