From a10509f1e532bb44a7b9941b360dfb92abe722c0 Mon Sep 17 00:00:00 2001 From: Michael Shaw Date: Tue, 30 Jan 2024 22:00:20 -0500 Subject: [PATCH] lib: move lib headers into `lib` directory --- dev/apic.c | 1 - dev/serial.c | 2 -- fs/vfs.c | 2 +- include/fs/vfs.h | 2 +- include/kernel/common.h | 10 +++++----- include/{ => lib}/assert.h | 0 include/{ => lib}/errno.h | 0 include/{ => lib}/math.h | 0 include/{ => lib}/stdio.h | 0 include/{ => lib}/string.h | 0 init/acpi.c | 3 --- init/cmd.c | 2 -- init/gdt.c | 2 -- init/irq.c | 1 - init/main.c | 2 -- lib/errno.c | 2 +- lib/math.c | 2 +- lib/stack.c | 3 +++ lib/string.c | 2 +- sched/load.c | 1 - 20 files changed, 13 insertions(+), 24 deletions(-) rename include/{ => lib}/assert.h (100%) rename include/{ => lib}/errno.h (100%) rename include/{ => lib}/math.h (100%) rename include/{ => lib}/stdio.h (100%) rename include/{ => lib}/string.h (100%) create mode 100644 lib/stack.c diff --git a/dev/apic.c b/dev/apic.c index bce2f9c..f88a92a 100644 --- a/dev/apic.c +++ b/dev/apic.c @@ -4,7 +4,6 @@ #include #include -#include static uintptr_t ioapic_addr = 0xFEC00000; static uintptr_t lapic_addr = 0; diff --git a/dev/serial.c b/dev/serial.c index 1829af5..41f7fad 100644 --- a/dev/serial.c +++ b/dev/serial.c @@ -6,8 +6,6 @@ #include #include -#include - int serial_init() { outb(COM1 | 1, 0x00); diff --git a/fs/vfs.c b/fs/vfs.c index dceccd6..231ff77 100644 --- a/fs/vfs.c +++ b/fs/vfs.c @@ -107,7 +107,7 @@ struct file *vfs_open(const char *pathname, int *err) file->vnode = cur_vnode; file->type = cur_vnode->flags & VFS_VTYPE_MASK; file->size = vnode->size; - file->inode_num = vnode->ino_num; + file->ino_num = vnode->ino_num; return file; diff --git a/include/fs/vfs.h b/include/fs/vfs.h index ac73d27..bea6c68 100644 --- a/include/fs/vfs.h +++ b/include/fs/vfs.h @@ -96,7 +96,7 @@ typedef struct _DIR { struct file { struct vnode *vnode; - ino_t inode_num; /* inode number */ + ino_t ino_num; /* inode number */ uint32_t type; /* type of the file */ uint64_t size; /* size of the file */ }; diff --git a/include/kernel/common.h b/include/kernel/common.h index ae0f52a..092e87d 100644 --- a/include/kernel/common.h +++ b/include/kernel/common.h @@ -7,11 +7,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include diff --git a/include/assert.h b/include/lib/assert.h similarity index 100% rename from include/assert.h rename to include/lib/assert.h diff --git a/include/errno.h b/include/lib/errno.h similarity index 100% rename from include/errno.h rename to include/lib/errno.h diff --git a/include/math.h b/include/lib/math.h similarity index 100% rename from include/math.h rename to include/lib/math.h diff --git a/include/stdio.h b/include/lib/stdio.h similarity index 100% rename from include/stdio.h rename to include/lib/stdio.h diff --git a/include/string.h b/include/lib/string.h similarity index 100% rename from include/string.h rename to include/lib/string.h diff --git a/init/acpi.c b/init/acpi.c index ecf64c0..5834312 100644 --- a/init/acpi.c +++ b/init/acpi.c @@ -5,9 +5,6 @@ #include -#include -#include - struct limine_rsdp_request rsdp_req = { .id = LIMINE_RSDP_REQUEST, .revision = 0 }; static struct rsdp *rsdp = NULL; diff --git a/init/cmd.c b/init/cmd.c index 4a4add8..0c3c649 100644 --- a/init/cmd.c +++ b/init/cmd.c @@ -7,8 +7,6 @@ #include -#include - int kcmd_help(int argc, char **argv); int kcmd_ls(int argc, char **argv); int kcmd_clear(int argc, char **argv); diff --git a/init/gdt.c b/init/gdt.c index 0ab05ac..23af7bc 100644 --- a/init/gdt.c +++ b/init/gdt.c @@ -3,8 +3,6 @@ #include #include -#include - void gdt_load(); static int gdt_index = 0; diff --git a/init/irq.c b/init/irq.c index 977481d..2864339 100644 --- a/init/irq.c +++ b/init/irq.c @@ -5,7 +5,6 @@ #include #include #include -#include #define exception(_i) _exception_##_i #define exception_decl(_j) void exception(_j)() diff --git a/init/main.c b/init/main.c index f72a054..fa0021c 100644 --- a/init/main.c +++ b/init/main.c @@ -18,8 +18,6 @@ #include -#include - #define LIMINE_INTERNAL_MODULE_REQUIRED (1 << 0) #include diff --git a/lib/errno.c b/lib/errno.c index d589476..37ecd1e 100644 --- a/lib/errno.c +++ b/lib/errno.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -#include #include +#include static const char *errno_str[] = { [0] = "Success", diff --git a/lib/math.c b/lib/math.c index fc683b9..a036f0a 100644 --- a/lib/math.c +++ b/lib/math.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include -#include +#include size_t npow2(size_t n) { diff --git a/lib/stack.c b/lib/stack.c new file mode 100644 index 0000000..7fd8944 --- /dev/null +++ b/lib/stack.c @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include + diff --git a/lib/string.c b/lib/string.c index c0fbed0..ed52648 100644 --- a/lib/string.c +++ b/lib/string.c @@ -2,7 +2,7 @@ #include #include -#include +#include void *memcpy(void *dest, const void *src, size_t num) { diff --git a/sched/load.c b/sched/load.c index ca5a48d..f7fa9f8 100644 --- a/sched/load.c +++ b/sched/load.c @@ -6,7 +6,6 @@ #include #include -#include static const char elf_magic[] = { 0x7F, 'E', 'L', 'F' };