My Kernel v0.1.0
process.h
Go to the documentation of this file.
1#ifndef KERNEL_ARCH_I686_PROCESS_H
2#define KERNEL_ARCH_I686_PROCESS_H
3
14#include <kernel/types.h>
15
20typedef struct x86_thread {
21
22 u32 cr3;
23
32 u32 esp0;
33
39
40 u32 esp;
41
43
44static inline void
45arch_thread_set_stack_pointer(thread_context_t *ctx, void *stack)
46{
47 ctx->esp = (u32)stack;
48}
49
50static inline void *arch_thread_get_stack_pointer(thread_context_t *ctx)
51{
52 return (void *)ctx->esp;
53}
54
55static inline void
56arch_thread_set_kernel_stack_top(thread_context_t *ctx, void *top)
57{
58 ctx->esp0 = (u32)top;
59}
60
61static inline void *
62arch_thread_get_kernel_stack_top(const thread_context_t *ctx)
63{
64 return (void *)ctx->esp0;
65}
66
67static inline void
68arch_thread_set_user_stack_top(thread_context_t *ctx, void *top)
69{
70 ctx->esp_user = (u32)top;
71}
72
73static inline void *arch_thread_get_user_stack_top(const thread_context_t *ctx)
74{
75 return (void *)ctx->esp_user;
76}
77
78#endif /* KERNEL_ARCH_I686_PROCESS_H */
u32 esp0
Address of the top of the thread's kernel stack.
Definition: process.h:32
u32 esp_user
Address of the top of the user stack This is only valid for user threads.
Definition: process.h:38
u32 cr3
Physical address of the process's page directory.
Definition: process.h:22
u32 esp
The current stack pointer of the thread.
Definition: process.h:40
Contains all the system-level information about a task.
Definition: process.h:20