fixing pf, again
This commit is contained in:
parent
4309b666a4
commit
f27e0a240c
11 changed files with 35 additions and 12 deletions
|
@ -139,6 +139,7 @@ void kmain(void) {
|
||||||
log("kmain - %s\n", f->path);
|
log("kmain - %s\n", f->path);
|
||||||
|
|
||||||
program_t *prog = elf_load((char*)f->address);
|
program_t *prog = elf_load((char*)f->address);
|
||||||
|
|
||||||
sched_create("Init", prog->entry, prog->pm, SCHED_USER_PROCESS);
|
sched_create("Init", prog->entry, prog->pm, SCHED_USER_PROCESS);
|
||||||
|
|
||||||
log("kernel - Soaplin initialized sucessfully.\n");
|
log("kernel - Soaplin initialized sucessfully.\n");
|
||||||
|
|
|
@ -149,12 +149,11 @@ void vmm_load_pagemap(pagemap_t *pm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t *__vmm_get_next_lvl(uint64_t *level, uint64_t entry, uint64_t flags) {
|
static uint64_t *__vmm_get_next_lvl(uint64_t *level, uint64_t entry, uint64_t flags) {
|
||||||
|
(void)flags;
|
||||||
if (!(level[entry] & 1)){
|
if (!(level[entry] & 1)){
|
||||||
uint64_t *pml = HIGHER_HALF(pmm_request_page());
|
uint64_t *pml = HIGHER_HALF(pmm_request_page());
|
||||||
memset(pml, 0, PMM_PAGE_SIZE);
|
memset(pml, 0, PMM_PAGE_SIZE);
|
||||||
level[entry] = ((uint64_t)PHYSICAL(pml) & 0x000FFFFFFFFFF000ULL) | flags;
|
level[entry] = ((uint64_t)PHYSICAL(pml) & 0x000FFFFFFFFFF000ULL) | 0b111;
|
||||||
} else {
|
|
||||||
level[entry] |= (flags & ~VMM_NX) & 0xFF;
|
|
||||||
}
|
}
|
||||||
return HIGHER_HALF(PTE_GET_ADDR(level[entry]));
|
return HIGHER_HALF(PTE_GET_ADDR(level[entry]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,8 @@ void schedule(registers_t *regs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(&curr_proc->regs, regs, sizeof(registers_t));
|
||||||
|
|
||||||
if (curr_proc->type == SCHED_DIED) {
|
if (curr_proc->type == SCHED_DIED) {
|
||||||
sched_process *prev_proc = proc_list;
|
sched_process *prev_proc = proc_list;
|
||||||
while (prev_proc->next != curr_proc) {
|
while (prev_proc->next != curr_proc) {
|
||||||
|
@ -136,9 +138,9 @@ void schedule(registers_t *regs)
|
||||||
|
|
||||||
// R.I.P. process
|
// R.I.P. process
|
||||||
pmm_free_page(curr_proc);
|
pmm_free_page(curr_proc);
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&curr_proc->regs, regs, sizeof(registers_t));
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
curr_proc = curr_proc->next;
|
curr_proc = curr_proc->next;
|
||||||
if (curr_proc == NULL)
|
if (curr_proc == NULL)
|
||||||
|
|
|
@ -2,10 +2,15 @@
|
||||||
#include "sys/gfx/flanterm/flanterm.h"
|
#include "sys/gfx/flanterm/flanterm.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/printf.h>
|
#include <sys/printf.h>
|
||||||
|
#include <lib/spinlock.h>
|
||||||
|
|
||||||
extern struct flanterm_context *ft_ctx;
|
extern struct flanterm_context *ft_ctx;
|
||||||
|
|
||||||
|
static spinlock_t log_lock = {0};
|
||||||
|
|
||||||
void log(char *format, ...) {
|
void log(char *format, ...) {
|
||||||
|
//spinlock_acquire(&log_lock);
|
||||||
|
|
||||||
// TODO: replace this call with a call to printf() when the RTC is implemented.
|
// TODO: replace this call with a call to printf() when the RTC is implemented.
|
||||||
char *date = "1970-01-01 00:00:00 | ";
|
char *date = "1970-01-01 00:00:00 | ";
|
||||||
int i2 = 0; for (i2; date[i2] != 0; i2++);;
|
int i2 = 0; for (i2; date[i2] != 0; i2++);;
|
||||||
|
@ -35,4 +40,6 @@ void log(char *format, ...) {
|
||||||
|
|
||||||
outb(0xE9, buf[i]);
|
outb(0xE9, buf[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//spinlock_release(&log_lock);
|
||||||
}
|
}
|
|
@ -27,7 +27,7 @@ void syscall_handle(registers_t *regs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
regs->rax = syscall_table[regs->rax](regs->rsp, regs->rbp, regs->r12, regs->r13, regs->r14, regs->r15);
|
regs->rax = syscall_table[regs->rax](regs->rdi, regs->rsi, regs->rdx, regs->rcx, regs->r8, regs->r9);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,10 +39,14 @@ void syscall_register(int id, syscall handler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
syscall_table[id] = handler;
|
syscall_table[id] = handler;
|
||||||
log("syscall - System call %d has been set to %p", handler);
|
log("syscall - System call %d has been set to %p", id, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void syscall_exit(int exit_code);
|
||||||
|
|
||||||
void syscall_init() {
|
void syscall_init() {
|
||||||
for (int i = 0; i < 1024; i++)
|
for (int i = 0; i < 1024; i++)
|
||||||
syscall_table[i] = (syscall)__syscall_undefined;
|
syscall_table[i] = (syscall)__syscall_undefined;
|
||||||
|
|
||||||
|
syscall_register(0, (syscall)syscall_exit);
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
/// A function that defines a system call.
|
/// A function that defines a system call.
|
||||||
/// NOTE: Arguments are defined as uint64_t, but you can simply put your own type, and then cast your function to syscall.
|
/// NOTE: Arguments are defined as uint64_t, but you can simply put your own type, and then cast your function to syscall.
|
||||||
typedef uint64_t(*syscall)(uint64_t rsp, uint64_t rbp, uint64_t r12, uint64_t r13, uint64_t r14, uint64_t r15);
|
typedef uint64_t(*syscall)(uint64_t rdi, uint64_t rsi, uint64_t rdx, uint64_t rcx, uint64_t r8, uint64_t r9);
|
||||||
|
|
||||||
/// Registers a system call.
|
/// Registers a system call.
|
||||||
/// NOTE: an existing system call cannot be replaced by another.
|
/// NOTE: an existing system call cannot be replaced by another.
|
||||||
|
|
6
kernel/src/sys/syscalls/syscalls_proc.c
Normal file
6
kernel/src/sys/syscalls/syscalls_proc.c
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include <sched/sched.h>
|
||||||
|
|
||||||
|
int syscall_exit(int exit_code) {
|
||||||
|
//sched_exit(exit_code);
|
||||||
|
return 0;
|
||||||
|
}
|
Binary file not shown.
|
@ -4,7 +4,11 @@ section .text
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
int 0x80
|
int 0x80
|
||||||
; tell the kernel to exit the process.
|
|
||||||
mov rax, 10
|
|
||||||
int 0x80
|
int 0x80
|
||||||
ret
|
int 0x80
|
||||||
|
int 0x80
|
||||||
|
int 0x80
|
||||||
|
int 0x80
|
||||||
|
int 0x80
|
||||||
|
.hey:
|
||||||
|
jmp .hey
|
BIN
testing/test.o
BIN
testing/test.o
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue