working on getting a unified stack setup for user and kernel tasks
This commit is contained in:
@@ -129,10 +129,9 @@ void load_root_program(const char* path) {
|
||||
*(--u_esp) = 0; // argc = 0
|
||||
|
||||
create_task(e_hdr->e_entry, (uint32_t)cr3, 1, (uint32_t)u_esp);
|
||||
|
||||
load_pd((void*)kernel_cr3);
|
||||
flush_tlb();
|
||||
|
||||
kprintf("task created for origin program %s\n", path);
|
||||
}
|
||||
|
||||
void kmain(uint32_t magic, multiboot_info* mbi) {
|
||||
@@ -168,10 +167,10 @@ void kmain(uint32_t magic, multiboot_info* mbi) {
|
||||
mount(vfs_root, initrd_root);
|
||||
kprintf("initrd read, mounted @ /\n");
|
||||
|
||||
disable_interrupts();
|
||||
init_scheduler();
|
||||
enable_interrupts();
|
||||
|
||||
kprintf("loading origin program\n");
|
||||
load_root_program("/origin.elf");
|
||||
yield();
|
||||
}
|
||||
|
||||
@@ -138,6 +138,8 @@ int create_task(uint32_t entry_point, uint32_t cr3, int user, uint32_t u_esp) {
|
||||
*(--esp) = 0x23;
|
||||
} else {
|
||||
// IRET values for Ring 0
|
||||
*(--esp) = 0x23; // User Data Segment (SS) with RPL 3 (0x20 | 3)
|
||||
*(--esp) = kstack_top; // User Stack Pointer (ESP) - location mapped in user space
|
||||
*(--esp) = 0x0202; // EFLAGS
|
||||
*(--esp) = 0x08; // Kernel Code Segment (CS)
|
||||
*(--esp) = entry_point; // EIP
|
||||
@@ -153,6 +155,12 @@ int create_task(uint32_t entry_point, uint32_t cr3, int user, uint32_t u_esp) {
|
||||
*(--esp) = 0; // ESI
|
||||
*(--esp) = 0; // EDI
|
||||
|
||||
if (user) {
|
||||
*(--esp) = 0x23; // User Data Segment
|
||||
} else {
|
||||
*(--esp) = 0x10; // Kernel Data Segment
|
||||
}
|
||||
|
||||
process->esp = (uint32_t)esp;
|
||||
if (!reuse) {
|
||||
total_processes++;
|
||||
|
||||
Reference in New Issue
Block a user