AFUERAAAA

This commit is contained in:
2025-01-07 15:11:10 +01:00
parent 27569fd5d8
commit b3687d20ee
17 changed files with 2 additions and 670 deletions

View File

@@ -25,8 +25,6 @@ extern void irq13();
extern void irq14();
extern void irq15();
extern void syscall_common_stub();
void *irq_routines[16] =
{
0, 0, 0, 0, 0, 0, 0, 0,
@@ -78,8 +76,6 @@ void irq_install()
idt_set_gate(46, (unsigned)irq14, 0x08, 0x8E);
idt_set_gate(47, (unsigned)irq15, 0x08, 0x8E);
printf("[kernel] installed irq 0-15\n");
idt_set_gate(0x80, (unsigned long)syscall_common_stub, 0x08, 0x8E);
}
void irq_handler(struct regs *r)

View File

@@ -8,14 +8,12 @@
#include "gdt.h"
#include "idt.h"
#include "system.h"
#include "../drivers/ata.h"
#include <stdint.h>
#include "../drivers/framebuffer.h"
#include "kmain.h"
#include "multiboot2.h"
#include "kheap.h"
#include "initrd.h"
#include "../libc/crypto.h"
void kmain(multiboot2_info *mb_info)
{
@@ -112,19 +110,8 @@ void kmain(multiboot2_info *mb_info)
__asm__ __volatile__("sti");
init_alloc();
void* ptr1 = malloc(256);
void* ptr2 = malloc(512);
printf("[debug] malloc test ptr1=0x%x, ptr2=0x%x\n", (unsigned int)ptr1, (unsigned int)ptr2);
free(ptr1); free(ptr2);
void* ptr3 = calloc(1024, 2);
printf("[debug] calloc test ptr3=0x%x\n", (unsigned int)ptr3);
free (ptr3);
// usually the place where i do testing
timer_install();
keyboard_install();
printf("Nothing to do, halting...");
asm("hlt");
}

View File

@@ -210,37 +210,6 @@ irq_common_stub:
add esp, 8
iret
; we'll be placing the syscall_common_stub here.
; push everything, then call syscall_handler (be sure to define it extern)
; then pop back everything and iret
extern syscall_handler
global syscall_common_stub
syscall_common_stub:
pusha
push ds
push es
push fs
push gs
mov eax, ds
push eax ; save ds
mov ax, 0x01 ; kernel segment YES I CHEATED I KNOW THIS SUCKS
mov ds, ax
mov es, ax
call syscall_handler
pop eax
mov ds, eax ; restore ds
pop gs
pop fs
pop es
pop ds
popa
iret
section .bss
align 4

View File

@@ -1,33 +0,0 @@
// System calls
// Author: xamidev
// Licensed under the Unlicense. See the repo below.
// https://github.com/xamidev/blankos
#include "../libc/stdio.h"
void handle_syscall(int syscall_number)
{
switch(syscall_number)
{
case 1:
puts("Here's the syscall 1\n");
break;
default:
printf("[error] Invalid syscall number '%d'!\n", syscall_number);
break;
}
}
void syscall_handler()
{
int syscall_number;
void* arg;
// mov eax, syscall_number
// mov ebx, arg
asm volatile("mov %%eax, %0" : "=r"(syscall_number));
asm volatile("mov %%ebx, %0" : "=r"(arg));
printf("[syscall] syscall_number=%d, arg=%p\n", syscall_number, arg);
handle_syscall(syscall_number);
}

View File

@@ -1,16 +0,0 @@
// System information kernel module
// Author: xamidev
// Licensed under the Unlicense. See the repo below.
// https://github.com/xamidev/blankos
#include "../libc/stdio.h"
#include "../libc/string.h"
void cpuid(int code, unsigned int* a, unsigned int* d)
{
asm volatile("cpuid"
: "=a"(*a), "=d"(*d)
: "a"(code)
: "ecx", "ebx");
}

View File

@@ -1,11 +0,0 @@
// System information kernel module header
// Author: xamidev
// Licensed under the Unlicense. See the repo below.
// https://github.com/xamidev/blankos
#ifndef SYSINFO_H
#define SYSINFO_H
void cpuid(int code, unsigned int* a, unsigned int* d);
#endif