usr: implement user process switching
This is a rather large commit, so the gist of it is this: User context switching is now functional, after a change to the TSS, and a few minor details in the scheduler and loader. ELF parsing is rather primitive, but basically functional, as long as it only loads code. The interrupt 0x80 is for syscalls, and will switch from user mode to kernel mode. It is currently the only interrupt that can be called from user mode This adds the syscall functionality, which currently uses a red-black tree to store the function pointers, although when the table is more flushed out, it will probably be replaced with an array The pager now correctly marks the parent nodes with attributes as it allocates them. Without doing this, the page table entries will never be reached in lower privilege modes, causing page faults Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
parent
d60da85470
commit
37518aea81
19 changed files with 262 additions and 69 deletions
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
typedef uint32_t ino_t;
|
||||
typedef uint8_t ftype_t;
|
||||
typedef size_t off_t;
|
||||
|
||||
struct vnode {
|
||||
char name[256];
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@
|
|||
#define GDT_ACCESS_CODE_RING3 0b11111010
|
||||
|
||||
#define GDT_SEGMENT_CODE_RING0 0x28
|
||||
#define GDT_SEGMENT_DATA_RING0 0x30
|
||||
|
||||
#define GDT_SEGMENT_CODE_RING3 0x38
|
||||
#define GDT_SEGMENT_DATA_RING3 0x40
|
||||
|
||||
#ifndef __ASM__
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#define GATE_INTR 0x8E
|
||||
#define GATE_TRAP 0x8F
|
||||
|
||||
#define GATE_INTR_DPL3 0xEE
|
||||
|
||||
#define IDT_GATE_SIZE 16
|
||||
#define IDT_NUM_VECTORS 256
|
||||
#define IDT_SIZE (IDT_GATE_SIZE * IDT_NUM_VECTORS)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
genrw(rsp);
|
||||
genrw(rbp);
|
||||
genrw(cr3);
|
||||
genrw(ds);
|
||||
|
||||
#undef genrw
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ struct proc {
|
|||
struct procregs *proc_current_regs();
|
||||
struct proc *proc_create();
|
||||
struct proc *proc_get(pid_t pid);
|
||||
pid_t getpid();
|
||||
void proc_term(pid_t pid);
|
||||
struct proc *proc_find(pid_t pid);
|
||||
void proc_set_current(pid_t pid);
|
||||
void proc_init(unsigned num_cpus);
|
||||
|
||||
#endif /* _PROC_H_ */
|
||||
|
|
|
|||
Loading…
Reference in a new issue