From 798b1dc391f424868f5f4bac8937c191ed4716b8 Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Mon, 30 Jan 2023 00:05:53 +0000 Subject: headers moved around --- api/lib/elf.h | 15 +++++++++++++++ api/lib/kstdio.h | 18 ++++++++++++++++++ api/lib/kstring.h | 14 ++++++++++++++ api/lib/sophialib.h | 14 ++++++++++++++ kc/boot/kc_main.c | 4 ++-- kc/core/cpu/cpu.c | 3 ++- kc/core/cpu/exceptions.h | 2 +- kc/core/kc_main.c | 2 +- kc/core/kprint.h | 5 ----- kc/core/kstdio.c | 6 +++--- kc/core/memory.h | 2 +- kc/core/memory/memory.c | 2 +- kc/core/memory/page_early.c | 3 ++- kc/core/panic.c | 3 ++- kc/core/pic8259.c | 3 ++- kc/core/pit8253.c | 3 ++- kc/core/task.c | 4 +++- kc/core/vm_tree.c | 4 ++-- lib/elf.h | 15 --------------- lib/elf64.c | 3 ++- lib/kprintf.c | 2 +- lib/kstdio.h | 18 ------------------ lib/sophialib.h | 14 -------------- lib/string.c | 2 +- loader/main_efi.c | 5 +++-- 25 files changed, 92 insertions(+), 74 deletions(-) create mode 100644 api/lib/elf.h create mode 100644 api/lib/kstdio.h create mode 100644 api/lib/kstring.h create mode 100644 api/lib/sophialib.h delete mode 100644 kc/core/kprint.h delete mode 100644 lib/elf.h delete mode 100644 lib/kstdio.h delete mode 100644 lib/sophialib.h diff --git a/api/lib/elf.h b/api/lib/elf.h new file mode 100644 index 0000000..05d25bc --- /dev/null +++ b/api/lib/elf.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#include +#include + +#ifdef __x86_64__ +# define elf_validate elf64_validate +# define elf_size elf64_size +#endif + +bool elf64_validate(Elf64_Ehdr *ehdr, unsigned type, unsigned machine); +size_t elf64_size(Elf64_Ehdr *ehdr, Elf64_Phdr *phdr); + diff --git a/api/lib/kstdio.h b/api/lib/kstdio.h new file mode 100644 index 0000000..80e47cc --- /dev/null +++ b/api/lib/kstdio.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +#include + +typedef struct FILE FILE; + +extern FILE *kstdout; +extern FILE *kstderr; + +extern int kfputc(int c, FILE *f); + +int kvfprintf(FILE *f, const char *restrict format, va_list arguments); +int kfprintf(FILE *f, const char *restrict format, ...); +int kvprintf(const char *restrict format, va_list arguments); +int kprintf(const char *restrict format, ...); + diff --git a/api/lib/kstring.h b/api/lib/kstring.h new file mode 100644 index 0000000..c28e17c --- /dev/null +++ b/api/lib/kstring.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +void *memcpy(void *dest, const void *src, size_t size); +void *memmove(void *dest, const void *src, size_t size); +void *memset(void *dest, int val, size_t size); +int memcmp(const void *str1, const void *str2, size_t count); +size_t strlen(const char *s); +unsigned long long strtoull( + const char *restrict begin, + char **restrict end, + int base); + diff --git a/api/lib/sophialib.h b/api/lib/sophialib.h new file mode 100644 index 0000000..c28e17c --- /dev/null +++ b/api/lib/sophialib.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +void *memcpy(void *dest, const void *src, size_t size); +void *memmove(void *dest, const void *src, size_t size); +void *memset(void *dest, int val, size_t size); +int memcmp(const void *str1, const void *str2, size_t count); +size_t strlen(const char *s); +unsigned long long strtoull( + const char *restrict begin, + char **restrict end, + int base); + diff --git a/kc/boot/kc_main.c b/kc/boot/kc_main.c index ca4ba8b..4d8cef9 100644 --- a/kc/boot/kc_main.c +++ b/kc/boot/kc_main.c @@ -7,11 +7,11 @@ #include #include #include -#include #include -#include "../lib/elf.h" +#include +#include #define KERNEL_IMAGE_BASE 0xffffffff80000000 #define OBJECT_SPACE_SIZE 131072 diff --git a/kc/core/cpu/cpu.c b/kc/core/cpu/cpu.c index f0e7844..a979336 100644 --- a/kc/core/cpu/cpu.c +++ b/kc/core/cpu/cpu.c @@ -1,6 +1,5 @@ #include "cpu.h" #include "exceptions.h" -#include "kprint.h" #include "panic.h" #include "msr.h" #include "task.h" @@ -10,6 +9,8 @@ #include #include +#include + #define GDT_ENTRIES 16 #define IDT_ENTRIES 256 diff --git a/kc/core/cpu/exceptions.h b/kc/core/cpu/exceptions.h index 8f7add2..7babb65 100644 --- a/kc/core/cpu/exceptions.h +++ b/kc/core/cpu/exceptions.h @@ -21,7 +21,7 @@ #ifndef __ASSEMBLER__ -#include "kprint.h" +#include struct isr_context_param_regs { diff --git a/kc/core/kc_main.c b/kc/core/kc_main.c index 02b6302..443a6aa 100644 --- a/kc/core/kc_main.c +++ b/kc/core/kc_main.c @@ -1,6 +1,5 @@ #include "cpu.h" #include "serial.h" -#include "kprint.h" #include "memory.h" #include "panic.h" #include "task.h" @@ -9,6 +8,7 @@ #include "cpu/irq.h" #include +#include #include #include diff --git a/kc/core/kprint.h b/kc/core/kprint.h deleted file mode 100644 index d023799..0000000 --- a/kc/core/kprint.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - - diff --git a/kc/core/kstdio.c b/kc/core/kstdio.c index fdb52b7..1d0bfa9 100644 --- a/kc/core/kstdio.c +++ b/kc/core/kstdio.c @@ -1,11 +1,11 @@ -#include "kprint.h" #include "serial.h" -#include - #include #include +#include +#include + FILE *kstdout; int kfputc(int c, FILE *f) diff --git a/kc/core/memory.h b/kc/core/memory.h index a587d56..1303a99 100644 --- a/kc/core/memory.h +++ b/kc/core/memory.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include diff --git a/kc/core/memory/memory.c b/kc/core/memory/memory.c index df48271..06c2942 100644 --- a/kc/core/memory/memory.c +++ b/kc/core/memory/memory.c @@ -11,7 +11,6 @@ #include "page_stack.h" #include "memory.h" -#include "kprint.h" #include "panic.h" #include "vm_object.h" #include "cpu/mmu.h" @@ -21,6 +20,7 @@ #include #include +#include #define align_next(x, a) (x + a - 1) & ~(a - 1) diff --git a/kc/core/memory/page_early.c b/kc/core/memory/page_early.c index 7f1d0eb..933f01b 100644 --- a/kc/core/memory/page_early.c +++ b/kc/core/memory/page_early.c @@ -1,7 +1,8 @@ #include "page_early.h" -#include "kprint.h" #include "panic.h" +#include + static struct page_early_state { struct memory_range *first; diff --git a/kc/core/panic.c b/kc/core/panic.c index 2f46a6a..7844487 100644 --- a/kc/core/panic.c +++ b/kc/core/panic.c @@ -1,5 +1,6 @@ #include "panic.h" -#include "kprint.h" + +#include #include diff --git a/kc/core/pic8259.c b/kc/core/pic8259.c index 2c85e4d..bbcffc8 100644 --- a/kc/core/pic8259.c +++ b/kc/core/pic8259.c @@ -1,10 +1,11 @@ #include "pic8259.h" #include "cpu.h" #include "port.h" -#include "kprint.h" #include +#include + #define ICW1_ICW4 0x1 #define ICW1_SINGLE 0x2 #define ICW1_INTERVAL4 0x4 diff --git a/kc/core/pit8253.c b/kc/core/pit8253.c index 5653eb9..360808f 100644 --- a/kc/core/pit8253.c +++ b/kc/core/pit8253.c @@ -1,11 +1,12 @@ #include "pit8253.h" #include "pic8259.h" #include "port.h" -#include "kprint.h" #include "memory.h" #include +#include + #define PIT8253_DATA0 0x40 #define PIT8253_CMD 0x43 diff --git a/kc/core/task.c b/kc/core/task.c index 5e55073..df0c03e 100644 --- a/kc/core/task.c +++ b/kc/core/task.c @@ -3,7 +3,6 @@ #include "memory.h" #include "panic.h" #include "cpu.h" -#include "kprint.h" #include "cpu/irq.h" #include "cpu/mmu.h" #include "pit8253.h" @@ -11,6 +10,9 @@ #include #include +#include +#include + static const size_t INTERRUPT_STACK_SIZE = 4096; static const size_t THREAD_SIZE = 16834; diff --git a/kc/core/vm_tree.c b/kc/core/vm_tree.c index 88a4be1..dd3667e 100644 --- a/kc/core/vm_tree.c +++ b/kc/core/vm_tree.c @@ -30,9 +30,9 @@ #include "vm_tree.h" #include "panic.h" -#include "kprint.h" -#include +#include +#include #define assert(expr) diff --git a/lib/elf.h b/lib/elf.h deleted file mode 100644 index 05d25bc..0000000 --- a/lib/elf.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -#include -#include - -#ifdef __x86_64__ -# define elf_validate elf64_validate -# define elf_size elf64_size -#endif - -bool elf64_validate(Elf64_Ehdr *ehdr, unsigned type, unsigned machine); -size_t elf64_size(Elf64_Ehdr *ehdr, Elf64_Phdr *phdr); - diff --git a/lib/elf64.c b/lib/elf64.c index 2dee395..bae408a 100644 --- a/lib/elf64.c +++ b/lib/elf64.c @@ -1,4 +1,5 @@ -#include "elf.h" +#include +#include bool elf64_validate(Elf64_Ehdr *ehdr, unsigned type, unsigned machine) { diff --git a/lib/kprintf.c b/lib/kprintf.c index 18ae42c..3d803f6 100644 --- a/lib/kprintf.c +++ b/lib/kprintf.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/lib/kstdio.h b/lib/kstdio.h deleted file mode 100644 index d3615f1..0000000 --- a/lib/kstdio.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include - -#include - -typedef struct FILE FILE; - -extern FILE *kstdout; -extern FILE *kstderr; - -extern int kfputc(int c, FILE *f); - -int kvfprintf(FILE *f, const char *restrict format, va_list arguments); -int kfprintf(FILE *f, const char *restrict format, ...); -int kvprintf(const char *restrict format, va_list arguments); -int kprintf(const char *restrict format, ...); - diff --git a/lib/sophialib.h b/lib/sophialib.h deleted file mode 100644 index c28e17c..0000000 --- a/lib/sophialib.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -void *memcpy(void *dest, const void *src, size_t size); -void *memmove(void *dest, const void *src, size_t size); -void *memset(void *dest, int val, size_t size); -int memcmp(const void *str1, const void *str2, size_t count); -size_t strlen(const char *s); -unsigned long long strtoull( - const char *restrict begin, - char **restrict end, - int base); - diff --git a/lib/string.c b/lib/string.c index 3d3f4a1..5d4efb7 100644 --- a/lib/string.c +++ b/lib/string.c @@ -1,4 +1,4 @@ -#include +#include size_t strlen(const char *s) { diff --git a/loader/main_efi.c b/loader/main_efi.c index 131c7e4..e49fad6 100644 --- a/loader/main_efi.c +++ b/loader/main_efi.c @@ -5,8 +5,9 @@ #include #include -#include "elf.h" -#include "kstdio.h" +#include +#include +#include FILE *kstdout; FILE *kstderr; -- cgit v1.3.1-1-g115d