diff --git a/.clangd b/.clangd index 7427527..ae70c97 100644 --- a/.clangd +++ b/.clangd @@ -13,3 +13,6 @@ CompileFlags: - "-nostdlib" - "-I" - "/home/oliste/repos/nub-os/src/stdlib" + +Style: + AngledHeaders: "src/stdlib/.*" diff --git a/src/arch/mmap.h b/src/arch/mmap.h index 93f6958..8bcc65e 100644 --- a/src/arch/mmap.h +++ b/src/arch/mmap.h @@ -1,17 +1,18 @@ #pragma once -#include "stdint.h" +#include +#include typedef struct { uint64_t base_address; - uint64_t length; + size_t length; } memory_region_t; typedef struct { - uint64_t num_regions; memory_region_t* regions; + size_t num_regions; } memory_map_t; extern memory_map_t memory_map; \ No newline at end of file diff --git a/src/arch/x86_64/interrupts.c b/src/arch/x86_64/interrupts.c index 6d28858..f699efc 100644 --- a/src/arch/x86_64/interrupts.c +++ b/src/arch/x86_64/interrupts.c @@ -1,7 +1,7 @@ #include "interrupts.h" #include "../arch.h" -#include "stdio.h" #include "util.h" +#include #define PIC1_COMMAND 0x20 #define PIC1_DATA 0x21 diff --git a/src/arch/x86_64/interrupts.h b/src/arch/x86_64/interrupts.h index f5886d9..5cfbd2d 100644 --- a/src/arch/x86_64/interrupts.h +++ b/src/arch/x86_64/interrupts.h @@ -1,7 +1,7 @@ #pragma once -#include "stdbool.h" -#include "stdint.h" +#include +#include typedef struct { diff --git a/src/arch/x86_64/keyboard.c b/src/arch/x86_64/keyboard.c index bc17da1..8bd5d88 100644 --- a/src/arch/x86_64/keyboard.c +++ b/src/arch/x86_64/keyboard.c @@ -1,7 +1,7 @@ // #include "keyboard.h" // #include "interrupts.h" // #include "util.h" -// #include "stddef.h" +// #include // #define SCANCODE_LEFT_SHIFT 42 // #define SCANCODE_RIGHT_SHIFT 54 diff --git a/src/arch/x86_64/keyboard.h b/src/arch/x86_64/keyboard.h index dc7d058..eac0d16 100644 --- a/src/arch/x86_64/keyboard.h +++ b/src/arch/x86_64/keyboard.h @@ -1,7 +1,7 @@ // #pragma once -// #include "stdbool.h" -// #include "stdint.h" +// #include +// #include // typedef struct // { diff --git a/src/arch/x86_64/mmap.c b/src/arch/x86_64/mmap.c index 5c7885d..f2e701d 100644 --- a/src/arch/x86_64/mmap.c +++ b/src/arch/x86_64/mmap.c @@ -1,7 +1,7 @@ #include "mmap.h" #include "../mmap.h" -#include "stddef.h" -#include "stdio.h" +#include +#include #define USABLE_REGION_SIZE 32 diff --git a/src/arch/x86_64/util.h b/src/arch/x86_64/util.h index 6cf15fb..a843e64 100644 --- a/src/arch/x86_64/util.h +++ b/src/arch/x86_64/util.h @@ -1,6 +1,6 @@ #pragma once -#include "stdint.h" +#include enum { diff --git a/src/arch/x86_64/vga.c b/src/arch/x86_64/vga.c index 3f00227..580276c 100644 --- a/src/arch/x86_64/vga.c +++ b/src/arch/x86_64/vga.c @@ -1,5 +1,5 @@ #include "vga.h" -#include "stddef.h" +#include #define ROWS 25 #define COLUMNS 80 diff --git a/src/arch/x86_64/vga.h b/src/arch/x86_64/vga.h index 918c6c3..da55117 100644 --- a/src/arch/x86_64/vga.h +++ b/src/arch/x86_64/vga.h @@ -1,6 +1,6 @@ #pragma once -#include "stdint.h" +#include #define VGA_BLACK 0 #define VGA_BLUE 1 diff --git a/src/arch/x86_64/x86_64.c b/src/arch/x86_64/x86_64.c index ead4bdd..36b6fbd 100644 --- a/src/arch/x86_64/x86_64.c +++ b/src/arch/x86_64/x86_64.c @@ -3,10 +3,9 @@ #include "interrupts.h" #include "mmap.h" #include "multiboot.h" -#include "stddef.h" -#include "stdio.h" #include "util.h" #include "vga.h" +#include void entry(multiboot_info_t* mbd) { @@ -14,7 +13,7 @@ void entry(multiboot_info_t* mbd) map_memory(mbd); remap_pic(); enable_interrupts(); - kmain(); + main(); } void arch_callback() diff --git a/src/kernel.c b/src/kernel.c index 1dd0faa..23e6ab3 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -1,8 +1,8 @@ #include "kernel.h" #include "pmm.h" -#include "stdio.h" +#include -void kmain() +void main() { init_pmm(); printf("Welcome to nub OS :)\n"); diff --git a/src/kernel.h b/src/kernel.h index e80bba2..f7a8c31 100644 --- a/src/kernel.h +++ b/src/kernel.h @@ -1,3 +1,3 @@ #pragma once -void kmain(); \ No newline at end of file +void main(); \ No newline at end of file diff --git a/src/pmm.c b/src/pmm.c index 7bd4572..0e20b3f 100644 --- a/src/pmm.c +++ b/src/pmm.c @@ -1,8 +1,8 @@ #include "pmm.h" #include "arch/mmap.h" -#include "mem.h" -#include "stddef.h" -#include "stdio.h" +#include +#include +#include #define BITMAP_SIZE 32768 // Supports up to 1GB of RAM #define USABLE_REGION_SIZE 32 diff --git a/src/pmm.h b/src/pmm.h index 49d133e..421f758 100644 --- a/src/pmm.h +++ b/src/pmm.h @@ -1,6 +1,6 @@ #pragma once -#include "stdint.h" +#include #define PAGE_SIZE 4096 diff --git a/src/stdlib/mem.c b/src/stdlib/mem.c deleted file mode 100644 index 4151265..0000000 --- a/src/stdlib/mem.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "mem.h" -#include "stdint.h" - -void memset(void* destination, uint8_t value, size_t length) -{ - for (size_t i = 0; i < length; i++) - { - ((uint8_t*)destination)[i] = value; - } -} \ No newline at end of file diff --git a/src/stdlib/mem.h b/src/stdlib/mem.h deleted file mode 100644 index c6ecbb1..0000000 --- a/src/stdlib/mem.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include "stddef.h" -#include "stdint.h" - -void memset(void* destination, uint8_t value, size_t length); \ No newline at end of file diff --git a/src/stdlib/stdio.c b/src/stdlib/stdio.c index 8fdbfb4..06717c0 100644 --- a/src/stdlib/stdio.c +++ b/src/stdlib/stdio.c @@ -1,9 +1,9 @@ -#include "stdio.h" #include "../arch/arch.h" -#include "stdarg.h" -#include "stdbool.h" -#include "stddef.h" -#include "string.h" +#include +#include +#include +#include +#include void printf(const char* fmt, ...) { diff --git a/src/stdlib/string.c b/src/stdlib/string.c index 9a9c1a4..dfba224 100644 --- a/src/stdlib/string.c +++ b/src/stdlib/string.c @@ -1,4 +1,12 @@ -#include "string.h" +#include + +void memset(void* destination, uint8_t value, size_t length) +{ + for (size_t i = 0; i < length; i++) + { + ((uint8_t*)destination)[i] = value; + } +} int strcmp(const char* a, const char* b) { diff --git a/src/stdlib/string.h b/src/stdlib/string.h index 68706e2..3e50283 100644 --- a/src/stdlib/string.h +++ b/src/stdlib/string.h @@ -1,8 +1,9 @@ #pragma once -#include "stddef.h" -#include "stdint.h" +#include +#include +void memset(void* destination, uint8_t value, size_t length); int strcmp(const char* a, const char* b); void reverse(char* str, size_t length); void uitoa64(uint64_t value, char* buffer);