From 03d32c476b113e42f989c46af9c0c1c6d257eaa3 Mon Sep 17 00:00:00 2001 From: hinus Date: Mon, 16 Aug 2021 08:42:57 +0800 Subject: [PATCH] Title: debug level Issue: https://gitee.com/hinus/linux_kernel_011/issues/I45O6U Description: Define 4 debug levels in makefile. --- Makefile | 2 +- kernel/Makefile | 5 +++-- kernel/sys_call.S | 6 +++++- tools/build.c | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index cefc423..469eec4 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ linux.img : tools/build bootsect setup kernel/system tools/build : tools/build.c gcc -o $@ $< -kernel/system : kernel/head.S kernel/*.c mm/*.c kernel/blk_drv/*.c fs/*.c +kernel/system : kernel/*.S kernel/*.c mm/*.c kernel/blk_drv/*.c fs/*.c cd kernel; make system; cd .. bootsect : bootsect.o diff --git a/kernel/Makefile b/kernel/Makefile index 0f25438..8311094 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,6 @@ GCC := gcc -CCFLAG := -I../include -nostdinc -ffreestanding -Wall -fomit-frame-pointer -fno-pic -fno-stack-protector -c -m32 +USE_DEBUG := +CCFLAG := -I../include -nostdinc -ffreestanding -Wall -fomit-frame-pointer -fno-pic -fno-stack-protector -c -m32 $(USE_DEBUG) LDFLAG := -Ttext 0x0 -s --oformat binary -m elf_i386 INCDIR := ../include OBJS := head.o main.o sys_call.o asm.o sched.o printk.o vsprintf.o mktime.o \ @@ -14,7 +15,7 @@ head.o : head.S $(GCC) -m32 -traditional -c -o $@ $< sys_call.o : sys_call.S - $(GCC) -m32 -traditional -c -o $@ $< + $(GCC) $(USE_DEBUG) -m32 -traditional -c -o $@ $< asm.o : asm.S $(GCC) -m32 -traditional -c -o $@ $< diff --git a/kernel/sys_call.S b/kernel/sys_call.S index 541cbc7..c7506ba 100644 --- a/kernel/sys_call.S +++ b/kernel/sys_call.S @@ -56,11 +56,15 @@ system_call: movl $0x17, %edx movw %dx, %fs +#ifdef DEBUG +#if DEBUG > 1 pushl %eax pushl $show_ind - //call printk + call printk popl %eax popl %eax +#endif +#endif call *sys_call_table(, %eax, 4) pushl %eax diff --git a/tools/build.c b/tools/build.c index df7cf9d..6cf7bd3 100644 --- a/tools/build.c +++ b/tools/build.c @@ -12,8 +12,8 @@ #define SYS_SIZE 0x2000 -#define DEFAULT_MAJOR_ROOT 2 -#define DEFAULT_MINOR_ROOT 29 +#define DEFAULT_MAJOR_ROOT 3 +#define DEFAULT_MINOR_ROOT 1 #define SETUP_SECTS 4 -- Gitee