From 89d1308e41fd141e548d9b67bee9b4283afe0532 Mon Sep 17 00:00:00 2001 From: os_lab_user Date: Wed, 11 Feb 2015 00:11:06 +0800 Subject: [PATCH] update lab1_result 1. Now can edit/analysis/debug in eclipse 2. add .cproject .project in .gitignore 3. fix some warnning using gcc-4.8 --- .gitignore | 2 ++ labcodes_answer/lab1_result/Makefile | 7 +++++-- labcodes_answer/lab1_result/boot/bootmain.c | 5 ++--- labcodes_answer/lab1_result/kern/init/init.c | 6 +++--- labcodes_answer/lab1_result/tools/gdbinit | 4 +++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 9565562..4ccad4e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ cscope.* ncscope.* tags *swp +.cproject +.project diff --git a/labcodes_answer/lab1_result/Makefile b/labcodes_answer/lab1_result/Makefile index 62701cb..e770c79 100644 --- a/labcodes_answer/lab1_result/Makefile +++ b/labcodes_answer/lab1_result/Makefile @@ -152,6 +152,7 @@ $(bootblock): $(call toobj,$(bootfiles)) | $(call totarget,sign) @echo + ld $@ $(V)$(LD) $(LDFLAGS) -N -e start -Ttext 0x7C00 $^ -o $(call toobj,bootblock) @$(OBJDUMP) -S $(call objfile,bootblock) > $(call asmfile,bootblock) + @$(OBJDUMP) -t $(call objfile,bootblock) | $(SED) '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > $(call symfile,bootblock) @$(OBJCOPY) -S -O binary $(call objfile,bootblock) $(call outfile,bootblock) @$(call totarget,sign) $(call outfile,bootblock) $(bootblock) @@ -193,7 +194,7 @@ endif # files for grade script TARGETS: $(TARGETS) - +all: $(TARGETS) .DEFAULT_GOAL := TARGETS .PHONY: qemu qemu-nox debug debug-nox @@ -214,10 +215,12 @@ qemu: $(UCOREIMG) qemu-nox: $(UCOREIMG) $(V)$(QEMU) -serial mon:stdio -hda $< -nographic TERMINAL :=gnome-terminal +gdb: $(UCOREIMG) + $(V)$(QEMU) -S -s -parallel stdio -hda $< -serial null & debug: $(UCOREIMG) $(V)$(QEMU) -S -s -parallel stdio -hda $< -serial null & $(V)sleep 2 - $(V)$(TERMINAL) -e "gdb -q -x tools/gdbinit" + $(V)$(TERMINAL) --full-screen -e "gdb -tui -q -x tools/gdbinit" debug-nox: $(UCOREIMG) $(V)$(QEMU) -S -s -serial mon:stdio -hda $< -nographic & diff --git a/labcodes_answer/lab1_result/boot/bootmain.c b/labcodes_answer/lab1_result/boot/bootmain.c index 4b55eb7..cb63508 100644 --- a/labcodes_answer/lab1_result/boot/bootmain.c +++ b/labcodes_answer/lab1_result/boot/bootmain.c @@ -29,9 +29,8 @@ * * * bootmain() in this file takes over, reads in the kernel and jumps to it. * */ - -#define SECTSIZE 512 -#define ELFHDR ((struct elfhdr *)0x10000) // scratch space +unsigned int SECTSIZE = 512 ; +struct elfhdr * ELFHDR = ((struct elfhdr *)0x10000) ; // scratch space /* waitdisk - wait for disk ready */ static void diff --git a/labcodes_answer/lab1_result/kern/init/init.c b/labcodes_answer/lab1_result/kern/init/init.c index 5e13746..2cd8120 100644 --- a/labcodes_answer/lab1_result/kern/init/init.c +++ b/labcodes_answer/lab1_result/kern/init/init.c @@ -9,12 +9,12 @@ #include #include #include -int kern_init(void) __attribute__((noreturn)); +void kern_init(void) __attribute__((noreturn)); void grade_backtrace(void); static void lab1_switch_test(void); -int -kern_init(void) { +void +kern_init(void){ extern char edata[], end[]; memset(edata, 0, end - edata); diff --git a/labcodes_answer/lab1_result/tools/gdbinit b/labcodes_answer/lab1_result/tools/gdbinit index abf6161..bbeb8aa 100644 --- a/labcodes_answer/lab1_result/tools/gdbinit +++ b/labcodes_answer/lab1_result/tools/gdbinit @@ -1,4 +1,6 @@ file bin/kernel +file obj/bootblock.o target remote :1234 +break bootmain break kern_init -continue \ No newline at end of file +continue