From 730e065e0bba1394750b3172bb7e2f1c0fd42c73 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Tue, 24 Oct 2023 19:22:27 +0200 Subject: Kernel: Add basic PCI and very basic rtl8139 support --- cpu/idt.c | 2 ++ cpu/io.h | 15 +++++++++------ cpu/io.s | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) (limited to 'cpu') diff --git a/cpu/idt.c b/cpu/idt.c index 832162c..60ab441 100644 --- a/cpu/idt.c +++ b/cpu/idt.c @@ -108,6 +108,7 @@ __attribute__((interrupt)) void general_protection_fault(registers_t *regs) { __attribute__((interrupt)) void double_fault(registers_t *regs) { (void)regs; klog("DOUBLE FAULT, THIS IS REALLY BAD", LOG_ERROR); + asm("cli"); asm("hlt"); for (;;) ; @@ -258,6 +259,7 @@ void idt_init(void) { // IRQ_set_mask(0xc); IRQ_set_mask(0xe); IRQ_clear_mask(2); + IRQ_set_mask(0xB); idtr.interrupt_table = (struct IDT_Descriptor **)&IDT_Entry; idtr.size = (sizeof(struct IDT_Descriptor) * IDT_MAX_ENTRY) - 1; diff --git a/cpu/io.h b/cpu/io.h index 9c33b66..5e28e86 100644 --- a/cpu/io.h +++ b/cpu/io.h @@ -1,11 +1,14 @@ #include -__attribute__((no_caller_saved_registers)) extern void outsw(uint16_t, - uint32_t); -__attribute__((no_caller_saved_registers)) extern void outb(uint16_t, uint16_t); -__attribute__((no_caller_saved_registers)) extern uint16_t inb(uint16_t); -__attribute__((no_caller_saved_registers)) extern void -rep_outsw(uint16_t count, uint16_t port, volatile void *addy); +extern void outsw(uint16_t, uint32_t); +extern void outb(uint16_t, uint8_t); +extern void outw(uint16_t, uint16_t); +extern void outl(uint16_t, uint32_t); + +extern uint32_t inl(uint16_t); +extern uint16_t inb(uint16_t); + +extern void rep_outsw(uint16_t count, uint16_t port, volatile void *addy); __attribute__((no_caller_saved_registers)) extern void rep_insw(uint16_t count, uint16_t port, volatile void *addy); extern void jump_usermode(void (*address)(), uint32_t stack_pointer); diff --git a/cpu/io.s b/cpu/io.s index fe370a5..3c409de 100644 --- a/cpu/io.s +++ b/cpu/io.s @@ -1,7 +1,10 @@ .intel_syntax noprefix .global outsw .global outb +.global outw +.global outl .global inb +.global inl .global rep_outsw .global rep_insw .global flush_tss @@ -20,12 +23,29 @@ outsw: pop ebp ret +outl: + mov eax, [esp + 8] + mov dx, [esp + 4] + out dx, eax + ret + outb: mov al, [esp + 8] mov dx, [esp + 4] out dx, al ret +outw: + mov eax, [esp + 8] + mov dx, [esp + 4] + out dx, eax + ret + +inl: + mov dx, [esp + 4] + in eax, dx + ret + inb: mov dx, [esp + 4] in al, dx -- cgit v1.2.3