| 102 | } |
| 103 | |
| 104 | void __OSThreadInit() |
| 105 | { |
| 106 | OSThread* thread = &DefaultThread; |
| 107 | int prio; |
| 108 | |
| 109 | thread->state = OS_THREAD_STATE_RUNNING; |
| 110 | thread->attr = OS_THREAD_ATTR_DETACH; |
| 111 | thread->priority = thread->base = 16; |
| 112 | thread->suspend = 0; |
| 113 | thread->val = (void*)-1; |
| 114 | thread->mutex = NULL; |
| 115 | OSInitThreadQueue(&thread->queueJoin); |
| 116 | OSInitMutexQueue(&thread->queueMutex); |
| 117 | |
| 118 | __OSFPUContext = &thread->context; |
| 119 | |
| 120 | OSClearContext(&thread->context); |
| 121 | OSSetCurrentContext(&thread->context); |
| 122 | thread->stackBase = (void*)_stack_addr; |
| 123 | thread->stackEnd = (void*)_stack_end; |
| 124 | *(thread->stackEnd) = OS_THREAD_STACK_MAGIC; |
| 125 | |
| 126 | OSSetCurrentThread(thread); |
| 127 | OSClearStack(0); |
| 128 | |
| 129 | RunQueueBits = 0; |
| 130 | RunQueueHint = FALSE; |
| 131 | for (prio = OS_PRIORITY_MIN; prio <= OS_PRIORITY_MAX; ++prio) |
| 132 | { |
| 133 | OSInitThreadQueue(&RunQueue[prio]); |
| 134 | } |
| 135 | |
| 136 | OSInitThreadQueue(&__OSActiveThreadQueue); |
| 137 | AddTail(&__OSActiveThreadQueue, thread, linkActive); |
| 138 | OSClearContext(&IdleContext); |
| 139 | Reschedule = 0; |
| 140 | } |
| 141 | |
| 142 | void OSInitThreadQueue(OSThreadQueue* queue) |
| 143 | { |
no test coverage detected