Get super basic ring3 task switching working

* It looks like UEFI enables SSE, so we need to tell clang -mno-sse for
  now to not use XMM* until we're ready to save them.
* SYSCALL is working from ring3 tasks, calling console printf!
This commit is contained in:
Justin C. Miller
2018-05-21 01:00:34 -07:00
parent e6f819ed90
commit 2597e2002b
4 changed files with 19 additions and 57 deletions

View File

@@ -113,7 +113,6 @@ print_stacktrace(int skip = 0)
addr_t
isr_handler(addr_t return_rsp, cpu_state regs)
{
log::debug(logs::task, "Starting RSP %016lx", return_rsp);
console *cons = console::get();
switch (static_cast<isr>(regs.interrupt & 0xff)) {
@@ -284,10 +283,8 @@ isr_handler(addr_t return_rsp, cpu_state regs)
print_stacktrace(2);
while(1) asm("hlt");
}
*reinterpret_cast<uint32_t *>(0xffffff80fee000b0) = 0;
log::debug(logs::task, "Returning RSP %016lx", return_rsp);
return return_rsp;
}

View File

@@ -80,19 +80,10 @@ gdt_load:
pop rax
%endmacro
%macro load_kernel_segments 0
mov ax, 0x10 ; load the kernel data segment
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
%endmacro
extern isr_handler
global isr_handler_prelude
isr_handler_prelude:
push_all_and_segments
;load_kernel_segments
mov rdi, rsp
call isr_handler
@@ -108,7 +99,6 @@ extern irq_handler
global irq_handler_prelude
irq_handler_prelude:
push_all_and_segments
load_kernel_segments
call irq_handler
@@ -205,45 +195,18 @@ global taskA
taskA:
push rbp
mov rbp, rsp
push 0x123456789abcdef0
push 0x0fedcba987654321
mov rax, 0xaaaaaaaaaaaaaaaa
.loop:
syscall
jmp .loop
global taskB
taskB:
push rbp
mov rbp, rsp
mov rax, 0xbbbbbbbbbbbbbbbb
.loop:
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
syscall
nop
nop
nop
nop
nop
nop
jmp .loop

View File

@@ -18,11 +18,7 @@ char taskBstack3[stack_size];
uint64_t taskAcount = 0;
extern "C" void taskA();
void taskB()
{
while (1);
}
extern "C" void taskB();
scheduler::scheduler(lapic *apic) :
@@ -68,6 +64,8 @@ create_process(uint16_t pid, void *stack0, void *stack3, void (*rip)())
void
scheduler::start()
{
log::info(logs::task, "Starting scheduler.");
m_apic->enable_timer(isr::isrTimer, 128, quantum, false);
m_processes.append({0, 0}); // The kernel idle task

View File

@@ -29,7 +29,11 @@ def build(bld):
return node.path_from(node.ctx.launch_node())
def run(self):
from subprocess import check_output
args = self.env.objdump + ["--source", "-D", self.inputs[0].abspath()]
args = self.env.objdump + [
"--source",
"-D",
"-M", "intel",
self.inputs[0].abspath()]
with file(self.outputs[0].abspath(), 'w') as output:
output.write(check_output(args))