diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2014-08-08 06:33:51 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2014-08-16 05:15:37 -0400 |
commit | 6ed00870abd566d7267d2436c2693f5a281cda2f (patch) | |
tree | 6011c73e302254fc73f61a1b8b1f295ded1f5d56 /firmware/export/system.h | |
parent | eb63d8b4a2a7cbe4e98216b48a75391718fcebd7 (diff) | |
download | rockbox-6ed00870abd566d7267d2436c2693f5a281cda2f.tar.gz rockbox-6ed00870abd566d7267d2436c2693f5a281cda2f.zip |
Base scheduler queues off linked lists and do cleanup/consolidation
Abstracts threading from itself a bit, changes the way its queues are
handled and does type hiding for that as well.
Do alot here due to already required major brain surgery.
Threads may now be on a run queue and a wait queue simultaneously so
that the expired timer only has to wake the thread but not remove it
from the wait queue which simplifies the implicit wake handling.
List formats change for wait queues-- doubly-linked, not circular.
Timeout queue is now singly-linked. The run queue is still circular
as before.
Adds a better thread slot allocator that may keep the slot marked as
used regardless of the thread state. Assists in dumping special tasks
that switch_thread was tasked to perform (blocking tasks).
Deletes alot of code yet surprisingly, gets larger than expected.
Well, I'm not not minding that for the time being-- omlettes and break
a few eggs and all that.
Change-Id: I0834d7bb16b2aecb2f63b58886eeda6ae4f29d59
Diffstat (limited to 'firmware/export/system.h')
-rw-r--r-- | firmware/export/system.h | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h index 0a13ec2208..5064fcd91d 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h | |||
@@ -118,15 +118,17 @@ int get_cpu_boost_counter(void); | |||
118 | #define ALIGN_UP(n, a) ALIGN_DOWN((n)+((a)-1),a) | 118 | #define ALIGN_UP(n, a) ALIGN_DOWN((n)+((a)-1),a) |
119 | 119 | ||
120 | /* align start and end of buffer to nearest integer multiple of a */ | 120 | /* align start and end of buffer to nearest integer multiple of a */ |
121 | #define ALIGN_BUFFER(ptr,len,align) \ | 121 | #define ALIGN_BUFFER(ptr, size, align) \ |
122 | {\ | 122 | ({ \ |
123 | uintptr_t tmp_ptr1 = (uintptr_t)ptr; \ | 123 | size_t __sz = (size); \ |
124 | uintptr_t tmp_ptr2 = tmp_ptr1 + len;\ | 124 | size_t __ali = (align); \ |
125 | tmp_ptr1 = ALIGN_UP(tmp_ptr1,align); \ | 125 | uintptr_t __a1 = (uintptr_t)(ptr); \ |
126 | tmp_ptr2 = ALIGN_DOWN(tmp_ptr2,align); \ | 126 | uintptr_t __a2 = __a1 + __sz; \ |
127 | len = tmp_ptr2 - tmp_ptr1; \ | 127 | __a1 = ALIGN_UP(__a1, __ali); \ |
128 | ptr = (typeof(ptr))tmp_ptr1; \ | 128 | __a2 = ALIGN_DOWN(__a2, __ali); \ |
129 | } | 129 | (ptr) = (typeof (ptr))__a1; \ |
130 | (size) = __a2 > __a1 ? __a2 - __a1 : 0; \ | ||
131 | }) | ||
130 | 132 | ||
131 | #define PTR_ADD(ptr, x) ((typeof(ptr))((char*)(ptr) + (x))) | 133 | #define PTR_ADD(ptr, x) ((typeof(ptr))((char*)(ptr) + (x))) |
132 | #define PTR_SUB(ptr, x) ((typeof(ptr))((char*)(ptr) - (x))) | 134 | #define PTR_SUB(ptr, x) ((typeof(ptr))((char*)(ptr) - (x))) |
@@ -150,11 +152,16 @@ int get_cpu_boost_counter(void); | |||
150 | #endif | 152 | #endif |
151 | 153 | ||
152 | /* Get the byte offset of a type's member */ | 154 | /* Get the byte offset of a type's member */ |
153 | #define OFFSETOF(type, membername) ((off_t)&((type *)0)->membername) | 155 | #ifndef offsetof |
156 | #define offsetof(type, member) __builtin_offsetof(type, member) | ||
157 | #endif | ||
154 | 158 | ||
155 | /* Get the type pointer from one of its members */ | 159 | /* Get the containing item of *ptr in type */ |
156 | #define TYPE_FROM_MEMBER(type, memberptr, membername) \ | 160 | #ifndef container_of |
157 | ((type *)((intptr_t)(memberptr) - OFFSETOF(type, membername))) | 161 | #define container_of(ptr, type, member) ({ \ |
162 | const typeof (((type *)0)->member) *__mptr = (ptr); \ | ||
163 | (type *)((void *)(__mptr) - offsetof(type, member)); }) | ||
164 | #endif | ||
158 | 165 | ||
159 | /* returns index of first set bit or 32 if no bits are set */ | 166 | /* returns index of first set bit or 32 if no bits are set */ |
160 | #if defined(CPU_ARM) && ARM_ARCH >= 5 && !defined(__thumb__) | 167 | #if defined(CPU_ARM) && ARM_ARCH >= 5 && !defined(__thumb__) |
@@ -324,6 +331,11 @@ static inline uint32_t swaw32_hw(uint32_t value) | |||
324 | * for all ARM CPUs. */ | 331 | * for all ARM CPUs. */ |
325 | #ifdef CPU_ARM | 332 | #ifdef CPU_ARM |
326 | #define HAVE_CPU_CACHE_ALIGN | 333 | #define HAVE_CPU_CACHE_ALIGN |
334 | #define MIN_STACK_ALIGN 8 | ||
335 | #endif | ||
336 | |||
337 | #ifndef MIN_STACK_ALIGN | ||
338 | #define MIN_STACK_ALIGN (sizeof (uintptr_t)) | ||
327 | #endif | 339 | #endif |
328 | 340 | ||
329 | /* Calculate CACHEALIGN_SIZE from CACHEALIGN_BITS */ | 341 | /* Calculate CACHEALIGN_SIZE from CACHEALIGN_BITS */ |