sched: add kernel-mode context switching
This commit is contained in:
@@ -36,32 +36,32 @@ struct irq_hook {
|
||||
};
|
||||
|
||||
struct cpu_context {
|
||||
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
|
||||
uint64_t rdi, rsi, rbp, unused_rsp, rbx, rdx, rcx, rax;
|
||||
uint64_t int_no, err_no;
|
||||
uint64_t rip, cs, rflags, rsp, ss;
|
||||
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
|
||||
uint64_t rdi, rsi, rbp, unused_rsp, rbx, rdx, rcx, rax;
|
||||
uint64_t int_no, err_no;
|
||||
uint64_t rip, cs, rflags, rsp, ss;
|
||||
} __packed;
|
||||
|
||||
struct idt_entry {
|
||||
uint16_t base_low;
|
||||
uint16_t selector;
|
||||
uint8_t always0;
|
||||
uint8_t type : 4;
|
||||
uint8_t zero : 1;
|
||||
uint8_t dpl : 2;
|
||||
uint8_t present : 1;
|
||||
uint16_t base_middle;
|
||||
uint32_t base_high;
|
||||
uint32_t reserved;
|
||||
uint16_t base_low;
|
||||
uint16_t selector;
|
||||
uint8_t always0;
|
||||
uint8_t type : 4;
|
||||
uint8_t zero : 1;
|
||||
uint8_t dpl : 2;
|
||||
uint8_t present : 1;
|
||||
uint16_t base_middle;
|
||||
uint32_t base_high;
|
||||
uint32_t reserved;
|
||||
} __packed;
|
||||
|
||||
struct idt {
|
||||
struct idt_entry i_entries[NR_IDT_ENTRIES];
|
||||
struct idt_entry i_entries[NR_IDT_ENTRIES];
|
||||
};
|
||||
|
||||
struct idt_ptr {
|
||||
uint16_t i_limit;
|
||||
uintptr_t i_base;
|
||||
uint16_t i_limit;
|
||||
uintptr_t i_base;
|
||||
} __packed;
|
||||
|
||||
typedef void (*int_hook)(struct cpu_context *);
|
||||
|
||||
10
arch/x86_64/include/socks/machine/thread.h
Normal file
10
arch/x86_64/include/socks/machine/thread.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef SOCKS_X86_64_THREAD_H_
|
||||
#define SOCKS_X86_64_THREAD_H_
|
||||
|
||||
#include <socks/sched.h>
|
||||
|
||||
extern void switch_to(struct thread *from, struct thread *to);
|
||||
extern void prepare_stack(uintptr_t ip, uintptr_t *sp);
|
||||
extern void user_jump(uintptr_t ip, uintptr_t sp);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user