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>
35 lines
581 B
ArmAsm
35 lines
581 B
ArmAsm
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
#define genrw(reg) \
|
|
.global reg##_read; \
|
|
reg##_read: \
|
|
movq %##reg, %rax; \
|
|
ret; \
|
|
.global reg##_write; \
|
|
reg##_write: \
|
|
movq %rdi, %##reg; \
|
|
ret;
|
|
|
|
#define genrww(reg) \
|
|
.global reg##_read; \
|
|
reg##_read: \
|
|
movw %##reg, %ax; \
|
|
ret; \
|
|
.global reg##_write; \
|
|
reg##_write: \
|
|
movw %di, %##reg; \
|
|
ret;
|
|
|
|
genrw(rsp)
|
|
genrw(rbp)
|
|
genrw(cr3)
|
|
genrww(ds)
|
|
|
|
.global load_stack_and_park
|
|
load_stack_and_park:
|
|
movq %rdi, %rsp
|
|
movq %rsi, %rbp
|
|
|
|
__load_stack_and_park_no_escape:
|
|
call yield
|
|
jmp __load_stack_and_park_no_escape
|