summaryrefslogtreecommitdiff
path: root/arch/x86/machine/tcb.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-06-13 23:26:38 +0200
committerRichard Braun <rbraun@sceen.net>2017-06-14 01:09:02 +0200
commit3350443b4a800a16f4663e0573903633ad82225f (patch)
treec1a7a23d0c7920fbbc3776d302e33197b3dd3af4 /arch/x86/machine/tcb.h
parent72ed0dc2f153e7cf1d6e96f86a773bbe490e9e1c (diff)
x86: improve TCB load and context switch
Diffstat (limited to 'arch/x86/machine/tcb.h')
-rw-r--r--arch/x86/machine/tcb.h21
1 files changed, 9 insertions, 12 deletions
diff --git a/arch/x86/machine/tcb.h b/arch/x86/machine/tcb.h
index 914ec9d..0f67b76 100644
--- a/arch/x86/machine/tcb.h
+++ b/arch/x86/machine/tcb.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2014 Richard Braun.
+ * Copyright (c) 2012-2017 Richard Braun.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
#define _X86_TCB_H
#include <assert.h>
+#include <stdint.h>
#include <kern/macros.h>
#include <machine/cpu.h>
@@ -30,25 +31,19 @@
* Thread control block.
*/
struct tcb {
- unsigned long bp;
- unsigned long sp;
- unsigned long ip;
+ uintptr_t bp;
+ uintptr_t sp;
};
/*
* Initialize a TCB.
*
* Prepare the given stack for execution. The context is defined so that it
- * will call fn() with interrupts disabled when loaded.
+ * will call thread_main(fn, arg) with interrupts disabled when loaded.
*
* In addition, initialize any thread-local machine-specific data.
*/
-int tcb_init(struct tcb *tcb, void *stack, void (*fn)(void));
-
-/*
- * Low level context switch function.
- */
-void tcb_context_switch(struct tcb *prev, struct tcb *next);
+int tcb_init(struct tcb *tcb, void *stack, void (*fn)(void *), void *arg);
static inline struct tcb *
tcb_current(void)
@@ -79,6 +74,8 @@ void __noreturn tcb_load(struct tcb *tcb);
static inline void
tcb_switch(struct tcb *prev, struct tcb *next)
{
+ void tcb_context_switch(struct tcb *prev, struct tcb *next);
+
assert(!cpu_intr_enabled());
tcb_set_current(next);
@@ -88,7 +85,7 @@ tcb_switch(struct tcb *prev, struct tcb *next)
/*
* Dump the stack trace of a TCB.
*
- * The thread associated to the TCB should not be running.
+ * The thread associated to the TCB must not be running.
*/
void tcb_trace(const struct tcb *tcb);