diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | src/kernel/acpi/acpi.c | 4 | ||||
-rw-r--r-- | src/kernel/cmos/rtc.c | 2 | ||||
-rw-r--r-- | src/kernel/fs/ata_pio.c | 4 | ||||
-rw-r--r-- | src/kernel/fs/install.c | 5 | ||||
-rw-r--r-- | src/kernel/io/io.c | 17 | ||||
-rw-r--r-- | src/kernel/io/io.h | 4 | ||||
-rw-r--r-- | src/kernel/kernel.c | 6 | ||||
-rw-r--r-- | src/kernel/memory/alloc.c | 6 | ||||
-rw-r--r-- | src/kernel/system.c | 8 | ||||
-rw-r--r-- | src/kernel/tasks/task.c | 11 | ||||
-rw-r--r-- | src/userspace/main.c | 2 | ||||
-rw-r--r-- | src/userspace/syscall.c | 2 |
13 files changed, 49 insertions, 27 deletions
@@ -1,9 +1,10 @@ -.idea Melvix.iml CMakeLists.txt +.idea/ +.clangd/ build/ cmake-build-debug/ cross/ cross64/ -iso/
\ No newline at end of file +iso/ diff --git a/src/kernel/acpi/acpi.c b/src/kernel/acpi/acpi.c index 0122450..e6e5b91 100644 --- a/src/kernel/acpi/acpi.c +++ b/src/kernel/acpi/acpi.c @@ -178,7 +178,7 @@ int acpi_install() void acpi_poweroff() { - asm ("cli"); + cli(); if (SCI_EN == 0) { warn("ACPI shutdown is not supported\n"); return; @@ -197,7 +197,7 @@ void acpi_poweroff() void reboot() { - asm ("cli"); + cli(); uint8_t good = 0x02; while (good & 0x02) good = inb(0x64); diff --git a/src/kernel/cmos/rtc.c b/src/kernel/cmos/rtc.c index 9f4e7c2..4a9c998 100644 --- a/src/kernel/cmos/rtc.c +++ b/src/kernel/cmos/rtc.c @@ -87,4 +87,4 @@ void write_time() { read_rtc(); printf("Current time: %d:%d:%d %d/%d/%d\n", hour, minute, second, month, day, year); -}
\ No newline at end of file +} diff --git a/src/kernel/fs/ata_pio.c b/src/kernel/fs/ata_pio.c index b6dcdcc..ef9a23e 100644 --- a/src/kernel/fs/ata_pio.c +++ b/src/kernel/fs/ata_pio.c @@ -81,7 +81,7 @@ uint8_t *ata_read28(struct ata_interface *interface, uint32_t sector) uint8_t ata_write28(struct ata_interface *interface, uint32_t sector, const uint8_t *contents) { if (sector > 0x0FFFFFFF) return 1; - asm ("cli"); + cli(); outb(interface->device_port, (uint8_t) ((interface->master ? 0xE0 : 0xF0) | ((sector & 0x0F000000) >> 24))); @@ -122,4 +122,4 @@ uint8_t ata_clear28(struct ata_interface *interface, uint32_t sector) { uint8_t empty_sector[512] = {0}; return ata_write28(interface, sector, empty_sector); -}
\ No newline at end of file +} diff --git a/src/kernel/fs/install.c b/src/kernel/fs/install.c index 84d74fd..0c3d824 100644 --- a/src/kernel/fs/install.c +++ b/src/kernel/fs/install.c @@ -1,5 +1,6 @@ #include <kernel/graphics/vesa.h> #include <kernel/fs/ata_pio.h> +#include <kernel/io/io.h> #include <kernel/fs/marfs/marfs.h> #include <kernel/fs/iso9660/iso9660.h> #include <kernel/fs/atapi_pio.h> @@ -12,7 +13,7 @@ void install_melvix() { info("You're booting from a CD, Melvix will only run after an installation"); - asm ("cli"); + cli(); struct ata_interface *primary_master = new_ata(1, 0x1F0); if (marfs_init(primary_master) != 0) { panic("No HDD found!"); @@ -90,4 +91,4 @@ void install_melvix() // timer_wait(200); acpi_poweroff(); halt_loop(); -}
\ No newline at end of file +} diff --git a/src/kernel/io/io.c b/src/kernel/io/io.c index 858f968..c4dad52 100644 --- a/src/kernel/io/io.c +++ b/src/kernel/io/io.c @@ -22,6 +22,21 @@ uint32_t inl(uint16_t port) return value; } +void cli() +{ + asm volatile ("cli"); +} + +void sti() +{ + asm volatile ("sti"); +} + +void hlt() +{ + asm volatile ("hlt"); +} + void outb(uint16_t port, uint8_t data) { asm ("outb %0, %1"::"a" (data), "Nd"(port)); @@ -58,4 +73,4 @@ void serial_put(char ch) { while (is_transmit_empty() == 0); outb(0x3f8, (uint8_t) ch); -}
\ No newline at end of file +} diff --git a/src/kernel/io/io.h b/src/kernel/io/io.h index b62e90f..7d09dcb 100644 --- a/src/kernel/io/io.h +++ b/src/kernel/io/io.h @@ -24,6 +24,10 @@ uint16_t inw(uint16_t port); */ uint32_t inl(uint16_t port); +void cli(); +void sti(); +void hlt(); + /** * Send data to the specified hardware port * @param port The hardware port diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index ec98a88..9ce1e14 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -34,13 +34,13 @@ void kernel_main(uint32_t initial_stack) set_optimal_resolution(); // Install drivers - asm ("cli"); + cli(); timer_install(); mouse_install(); keyboard_install(); pci_remap(); network_install(); - asm ("sti"); + sti(); // tasking_install(); @@ -67,4 +67,4 @@ void kernel_main(uint32_t initial_stack) panic("This should NOT happen!"); // asm ("div %0" :: "r"(0)); // Exception testing x/0 -}
\ No newline at end of file +} diff --git a/src/kernel/memory/alloc.c b/src/kernel/memory/alloc.c index cffcace..faeb4bf 100644 --- a/src/kernel/memory/alloc.c +++ b/src/kernel/memory/alloc.c @@ -5,13 +5,13 @@ int liballoc_lock() { - // asm ("cli"); + // cli(); return 0; } int liballoc_unlock() { - // asm ("sti"); + // sti(); return 0; } @@ -454,4 +454,4 @@ void *PREFIX(realloc)(void *p, size_t size) PREFIX(free)(p); return ptr; -}
\ No newline at end of file +} diff --git a/src/kernel/system.c b/src/kernel/system.c index 368dee5..e4f59a2 100644 --- a/src/kernel/system.c +++ b/src/kernel/system.c @@ -103,7 +103,7 @@ const char *random_message[10] = { void panic(char *msg) { - asm ("cli"); + cli(); vesa_set_color(vesa_dark_red); kernel_time(); serial_printf("PNC: %s - System halted!", msg); @@ -121,9 +121,9 @@ void assert(int x) void halt_loop() { - asm ("cli"); + cli(); loop: - asm ("hlt"); + hlt(); goto loop; } @@ -132,4 +132,4 @@ void v86(uint8_t code, regs16_t *regs) paging_disable(); int32(code, regs); paging_enable(); -}
\ No newline at end of file +} diff --git a/src/kernel/tasks/task.c b/src/kernel/tasks/task.c index 2c30346..572651e 100644 --- a/src/kernel/tasks/task.c +++ b/src/kernel/tasks/task.c @@ -2,6 +2,7 @@ #include <kernel/tasks/task.h> #include <kernel/memory/alloc.h> #include <kernel/lib/lib.h> +#include <kernel/io/io.h> #include <kernel/gdt/gdt.h> #include <kernel/system.h> @@ -14,7 +15,7 @@ uint32_t next_pid = 1; void tasking_install() { - asm ("cli"); + cli(); move_stack((void *) 0xE0000000, 0x2000); current_task = ready_queue = (task_t *) kmalloc(sizeof(task_t)); @@ -27,7 +28,7 @@ void tasking_install() current_task->kernel_stack = kmalloc(KERNEL_STACK_SIZE); vga_log("Installed Tasking"); - asm ("sti"); + sti(); } void move_stack(void *new_stack_start, uint32_t size) @@ -102,7 +103,7 @@ void switch_task() int fork() { - asm ("cli"); + cli(); task_t *parent_task = (task_t *) current_task; @@ -129,7 +130,7 @@ int fork() new_task->esp = esp; new_task->ebp = ebp; new_task->eip = eip; - asm volatile ("sti"); + sti(); return new_task->id; } else { @@ -166,4 +167,4 @@ void exec(uint32_t binary) " : : "r" (binary)); // syscall_write("test"); -}
\ No newline at end of file +} diff --git a/src/userspace/main.c b/src/userspace/main.c index da9ee5b..875423d 100644 --- a/src/userspace/main.c +++ b/src/userspace/main.c @@ -16,4 +16,4 @@ void main() char test[] = "banane"; syscall_write(test); syscall_halt(); -}
\ No newline at end of file +} diff --git a/src/userspace/syscall.c b/src/userspace/syscall.c index 9462b10..c147703 100644 --- a/src/userspace/syscall.c +++ b/src/userspace/syscall.c @@ -17,4 +17,4 @@ DEFN_SYSCALL0(get_pointers, 5); DEFN_SYSCALL1(alloc, 6, uint32_t); -DEFN_SYSCALL1(free, 7, uint32_t);
\ No newline at end of file +DEFN_SYSCALL1(free, 7, uint32_t); |