aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2013-06-08 22:05:19 -0400
committerKevin O'Connor <kevin@koconnor.net>2013-06-08 22:05:19 -0400
commit3cf301fd8c12785e90d654c711eacd18b752e505 (patch)
tree39aaf6c40b15cfda3ac0c51383eaf942da237b1e /src
parente097a75ef0de08ad6d8660c41efe10c1133f1865 (diff)
downloadseabios-hppa-3cf301fd8c12785e90d654c711eacd18b752e505.zip
seabios-hppa-3cf301fd8c12785e90d654c711eacd18b752e505.tar.gz
seabios-hppa-3cf301fd8c12785e90d654c711eacd18b752e505.tar.bz2
Minor - relocate code in stacks.c to keep low-level thread code together.
Just code movement - no actual code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/stacks.c109
1 files changed, 57 insertions, 52 deletions
diff --git a/src/stacks.c b/src/stacks.c
index 7423939..bf9db06 100644
--- a/src/stacks.c
+++ b/src/stacks.c
@@ -279,58 +279,6 @@ switch_next(struct thread_info *cur)
: "ebx", "edx", "esi", "edi", "cc", "memory");
}
-// Low-level irq enable.
-void VISIBLE16
-check_irqs(void)
-{
- asm volatile("sti ; nop ; rep ; nop ; cli ; cld" : : :"memory");
-}
-
-// Briefly permit irqs to occur.
-void
-yield(void)
-{
- if (MODESEGMENT) {
- stack_hop_back(0, 0, check_irqs);
- return;
- }
- extern void _cfunc16_check_irqs(void);
- if (!CONFIG_THREADS) {
- call16big(0, _cfunc16_check_irqs);
- return;
- }
- struct thread_info *cur = getCurThread();
- if (cur == &MainThread)
- // Permit irqs to fire
- call16big(0, _cfunc16_check_irqs);
-
- // Switch to the next thread
- switch_next(cur);
-}
-
-void VISIBLE16
-wait_irq(void)
-{
- asm volatile("sti ; hlt ; cli ; cld": : :"memory");
-}
-
-// Wait for next irq to occur.
-void
-yield_toirq(void)
-{
- if (MODESEGMENT) {
- stack_hop_back(0, 0, wait_irq);
- return;
- }
- if (CONFIG_THREADS && MainThread.next != &MainThread) {
- // Threads still active - do a yield instead.
- yield();
- return;
- }
- extern void _cfunc16_wait_irq(void);
- call16big(0, _cfunc16_wait_irq);
-}
-
// Last thing called from a thread (called on "next" stack).
static void
__end_thread(struct thread_info *old)
@@ -388,6 +336,63 @@ fail:
func(data);
}
+
+/****************************************************************
+ * Thread helpers
+ ****************************************************************/
+
+// Low-level irq enable.
+void VISIBLE16
+check_irqs(void)
+{
+ asm volatile("sti ; nop ; rep ; nop ; cli ; cld" : : :"memory");
+}
+
+// Briefly permit irqs to occur.
+void
+yield(void)
+{
+ if (MODESEGMENT) {
+ stack_hop_back(0, 0, check_irqs);
+ return;
+ }
+ extern void _cfunc16_check_irqs(void);
+ if (!CONFIG_THREADS) {
+ call16big(0, _cfunc16_check_irqs);
+ return;
+ }
+ struct thread_info *cur = getCurThread();
+ if (cur == &MainThread)
+ // Permit irqs to fire
+ call16big(0, _cfunc16_check_irqs);
+
+ // Switch to the next thread
+ switch_next(cur);
+}
+
+void VISIBLE16
+wait_irq(void)
+{
+ asm volatile("sti ; hlt ; cli ; cld": : :"memory");
+}
+
+// Wait for next irq to occur.
+void
+yield_toirq(void)
+{
+ if (MODESEGMENT) {
+ stack_hop_back(0, 0, wait_irq);
+ return;
+ }
+ if (CONFIG_THREADS && MainThread.next != &MainThread) {
+ // Threads still active - do a yield instead.
+ yield();
+ return;
+ }
+ extern void _cfunc16_wait_irq(void);
+ call16big(0, _cfunc16_wait_irq);
+}
+
// Wait for all threads (other than the main thread) to complete.
void
wait_threads(void)