Browse Source

将common文件夹下的c文件移动到lib文件夹下

fslongjin 2 years ago
parent
commit
1872d9bd4a

+ 2 - 35
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

+ 0 - 0
kernel/common/libELF/elf.h → kernel/common/elf.h


+ 1 - 1
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)
 

+ 1 - 1
kernel/common/bitree.c → kernel/lib/bitree.c

@@ -1,4 +1,4 @@
-#include "bitree.h"
+#include <common/bitree.h>
 #include <mm/slab.h>
 #include <common/errno.h>
 #include <common/kfifo.h>

+ 3 - 3
kernel/common/cpu.c → kernel/lib/cpu.c

@@ -1,6 +1,6 @@
-#include "cpu.h"
-#include "kprint.h"
-#include "printk.h"
+#include <common/cpu.h>
+#include <common/kprint.h>
+#include <common/printk.h>
 // #pragma GCC optimize("O0")
 // cpu支持的最大cpuid指令的基础主功能号
 uint Cpu_cpuid_max_Basic_mop;

+ 2 - 2
kernel/common/glib.c → kernel/lib/glib.c

@@ -1,5 +1,5 @@
-#include "glib.h"
-#include "string.h"
+#include <common/glib.h>
+#include <common/string.h>
 
 /**
  * @brief 这个函数让蜂鸣器发声,目前仅用于真机调试。未来将移除,请勿依赖此函数。

+ 0 - 0
kernel/common/kfifo.c → kernel/lib/kfifo.c


+ 0 - 0
kernel/common/libELF/Makefile → kernel/lib/libELF/Makefile


+ 0 - 0
kernel/common/libELF/elf.c → kernel/lib/libELF/elf.c


+ 0 - 0
kernel/common/mutex.c → kernel/lib/mutex.c


+ 3 - 3
kernel/common/printk.c → kernel/lib/printk.c

@@ -1,14 +1,14 @@
 //
 // Created by longjin on 2022/1/22.
 //
-#include "printk.h"
-#include "kprint.h"
+#include <common/printk.h>
+#include <common/kprint.h>
 
 #include <mm/mm.h>
 #include <common/spinlock.h>
 #include <lib/libUI/textui.h>
 
-#include "math.h"
+#include <common/math.h>
 #include <common/string.h>
 
 static spinlock_t __printk_lock = {1};

+ 1 - 1
kernel/common/semaphore.c → kernel/lib/semaphore.c

@@ -1,4 +1,4 @@
-#include "semaphore.h"
+#include <common/semaphore.h>
 #include <sched/sched.h>
 #include <process/process.h>
 

+ 2 - 2
kernel/common/string.c → kernel/lib/string.c

@@ -1,5 +1,5 @@
-#include "string.h"
-#include "glib.h"
+#include <common/string.h>
+#include <common/glib.h>
 
 /**
  * @brief 拷贝整个字符串

+ 17 - 0
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 [email protected]
+
+all: $(kernel_lib_sys_objs) $(kernel_lib_sys_objs)
+	@echo $(kernel_lib_sys_objs)
+

+ 0 - 0
kernel/common/sys/wait.c → kernel/lib/sys/wait.c


+ 0 - 0
kernel/common/unistd.c → kernel/lib/unistd.c


+ 1 - 1
kernel/common/wait_queue.c → kernel/lib/wait_queue.c

@@ -1,4 +1,4 @@
-#include "wait_queue.h"
+#include <common/wait_queue.h>
 #include <sched/sched.h>
 #include <process/process.h>
 #include <mm/slab.h>

+ 1 - 1
kernel/process/process.c

@@ -5,7 +5,7 @@
 #include <common/stdio.h>
 #include <common/string.h>
 #include <common/compiler.h>
-#include <common/libELF/elf.h>
+#include <common/elf.h>
 #include <common/time.h>
 #include <common/sys/wait.h>
 #include <driver/video/video.h>