diff --git a/kernel/common/Makefile b/kernel/common/Makefile index f8ae7f19..1f54d828 100644 --- a/kernel/common/Makefile +++ b/kernel/common/Makefile @@ -1,7 +1,7 @@ CFLAGS += -I . -kernel_common_subdirs:=libELF math +kernel_common_subdirs:= math ECHO: @echo "$@" @@ -10,38 +10,5 @@ $(kernel_common_subdirs): ECHO $(MAKE) -C $@ all CFLAGS="$(CFLAGS)" ASFLAGS="$(ASFLAGS)" PIC="$(PIC)" -all: glib.o printk.o cpu.o bitree.o kfifo.o wait_queue.o mutex.o wait.o unistd.o string.o semaphore.o $(kernel_common_subdirs) +all: $(kernel_common_subdirs) - -glib.o: glib.c - gcc $(CFLAGS) -c glib.c -o glib.o - -printk.o: printk.c - gcc $(CFLAGS) -c printk.c -o printk.o - -cpu.o: cpu.c - gcc $(CFLAGS) -c cpu.c -o cpu.o - -bitree.o: bitree.c - gcc $(CFLAGS) -c bitree.c -o bitree.o - -kfifo.o: kfifo.c - gcc $(CFLAGS) -c kfifo.c -o kfifo.o - -wait_queue.o: wait_queue.c - gcc $(CFLAGS) -c wait_queue.c -o wait_queue.o - -mutex.o: mutex.c - gcc $(CFLAGS) -c mutex.c -o mutex.o - -wait.o: sys/wait.c - gcc $(CFLAGS) -c sys/wait.c -o sys/wait.o - -unistd.o: unistd.c - gcc $(CFLAGS) -c unistd.c -o unistd.o - -string.o: string.c - gcc $(CFLAGS) -c string.c -o string.o - -semaphore.o: semaphore.c - gcc $(CFLAGS) -c semaphore.c -o semaphore.o \ No newline at end of file diff --git a/kernel/common/libELF/elf.h b/kernel/common/elf.h similarity index 100% rename from kernel/common/libELF/elf.h rename to kernel/common/elf.h diff --git a/kernel/lib/Makefile b/kernel/lib/Makefile index 9db1a09d..58ff5c35 100644 --- a/kernel/lib/Makefile +++ b/kernel/lib/Makefile @@ -1,7 +1,7 @@ CFLAGS += -I . -kernel_lib_subdirs:= libUI +kernel_lib_subdirs:= libUI sys libELF kernel_lib_objs:= $(shell find ./*.c) diff --git a/kernel/common/bitree.c b/kernel/lib/bitree.c similarity index 99% rename from kernel/common/bitree.c rename to kernel/lib/bitree.c index 02c5d4f4..c81f7146 100644 --- a/kernel/common/bitree.c +++ b/kernel/lib/bitree.c @@ -1,4 +1,4 @@ -#include "bitree.h" +#include #include #include #include diff --git a/kernel/common/cpu.c b/kernel/lib/cpu.c similarity index 98% rename from kernel/common/cpu.c rename to kernel/lib/cpu.c index 4596a844..2eaffa44 100644 --- a/kernel/common/cpu.c +++ b/kernel/lib/cpu.c @@ -1,6 +1,6 @@ -#include "cpu.h" -#include "kprint.h" -#include "printk.h" +#include +#include +#include // #pragma GCC optimize("O0") // cpu支持的最大cpuid指令的基础主功能号 uint Cpu_cpuid_max_Basic_mop; diff --git a/kernel/common/glib.c b/kernel/lib/glib.c similarity index 96% rename from kernel/common/glib.c rename to kernel/lib/glib.c index c921e7e5..75839ce1 100644 --- a/kernel/common/glib.c +++ b/kernel/lib/glib.c @@ -1,5 +1,5 @@ -#include "glib.h" -#include "string.h" +#include +#include /** * @brief 这个函数让蜂鸣器发声,目前仅用于真机调试。未来将移除,请勿依赖此函数。 diff --git a/kernel/common/kfifo.c b/kernel/lib/kfifo.c similarity index 100% rename from kernel/common/kfifo.c rename to kernel/lib/kfifo.c diff --git a/kernel/common/libELF/Makefile b/kernel/lib/libELF/Makefile similarity index 100% rename from kernel/common/libELF/Makefile rename to kernel/lib/libELF/Makefile diff --git a/kernel/common/libELF/elf.c b/kernel/lib/libELF/elf.c similarity index 100% rename from kernel/common/libELF/elf.c rename to kernel/lib/libELF/elf.c diff --git a/kernel/common/mutex.c b/kernel/lib/mutex.c similarity index 100% rename from kernel/common/mutex.c rename to kernel/lib/mutex.c diff --git a/kernel/common/printk.c b/kernel/lib/printk.c similarity index 99% rename from kernel/common/printk.c rename to kernel/lib/printk.c index 7b56831f..95894b35 100644 --- a/kernel/common/printk.c +++ b/kernel/lib/printk.c @@ -1,14 +1,14 @@ // // Created by longjin on 2022/1/22. // -#include "printk.h" -#include "kprint.h" +#include +#include #include #include #include -#include "math.h" +#include #include static spinlock_t __printk_lock = {1}; diff --git a/kernel/common/semaphore.c b/kernel/lib/semaphore.c similarity index 97% rename from kernel/common/semaphore.c rename to kernel/lib/semaphore.c index 1f2edceb..88e5a0b0 100644 --- a/kernel/common/semaphore.c +++ b/kernel/lib/semaphore.c @@ -1,4 +1,4 @@ -#include "semaphore.h" +#include #include #include diff --git a/kernel/common/string.c b/kernel/lib/string.c similarity index 98% rename from kernel/common/string.c rename to kernel/lib/string.c index bbb59ed7..830d8f85 100644 --- a/kernel/common/string.c +++ b/kernel/lib/string.c @@ -1,5 +1,5 @@ -#include "string.h" -#include "glib.h" +#include +#include /** * @brief 拷贝整个字符串 diff --git a/kernel/lib/sys/Makefile b/kernel/lib/sys/Makefile new file mode 100644 index 00000000..4213d9a7 --- /dev/null +++ b/kernel/lib/sys/Makefile @@ -0,0 +1,17 @@ + +CFLAGS += -I . + +kernel_lib_sys_objs:= $(shell find ./*.c) + +ECHO: + @echo "$@" + +$(kernel_lib_sys_objs): ECHO + $(MAKE) -C $@ all CFLAGS="$(CFLAGS)" ASFLAGS="$(ASFLAGS)" PIC="$(PIC)" + +$(kernel_lib_sys_objs): ECHO + gcc $(CFLAGS) -c $@ -o $@.o + +all: $(kernel_lib_sys_objs) $(kernel_lib_sys_objs) + @echo $(kernel_lib_sys_objs) + diff --git a/kernel/common/sys/wait.c b/kernel/lib/sys/wait.c similarity index 100% rename from kernel/common/sys/wait.c rename to kernel/lib/sys/wait.c diff --git a/kernel/common/unistd.c b/kernel/lib/unistd.c similarity index 100% rename from kernel/common/unistd.c rename to kernel/lib/unistd.c diff --git a/kernel/common/wait_queue.c b/kernel/lib/wait_queue.c similarity index 98% rename from kernel/common/wait_queue.c rename to kernel/lib/wait_queue.c index ec7387ac..e6250096 100644 --- a/kernel/common/wait_queue.c +++ b/kernel/lib/wait_queue.c @@ -1,4 +1,4 @@ -#include "wait_queue.h" +#include #include #include #include diff --git a/kernel/process/process.c b/kernel/process/process.c index c748507a..d9eecae8 100644 --- a/kernel/process/process.c +++ b/kernel/process/process.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include