Skip to content

Commit 8fd6f20

Browse files
author
jason_yao
committed
update
1 parent 5e5377d commit 8fd6f20

File tree

188 files changed

+14924
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+14924
-0
lines changed

data/linux-0.11_qemu_gdb.tar.bz2

8.18 MB
Binary file not shown.

data/linux-0.11_qemu_gdb/.gdbinit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
file tools/system
2+
target remote :1234
75.5 KB
Binary file not shown.

data/linux-0.11_qemu_gdb/Image

129 KB
Binary file not shown.

data/linux-0.11_qemu_gdb/Makefile

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
# indicate the Hardware Image file
2+
HDA_IMG = ../rootfs/hdc-0.11-new.img
3+
4+
# indicate the path of the calltree
5+
CALLTREE=$(shell find tools/ -name "calltree" -perm 755 -type f)
6+
7+
# indicate the path of the bochs
8+
#BOCHS=$(shell find tools/ -name "bochs" -perm 755 -type f)
9+
BOCHS=bochs
10+
11+
#
12+
# if you want the ram-disk device, define this to be the
13+
# size in blocks.
14+
#
15+
RAMDISK = #-DRAMDISK=512
16+
17+
# This is a basic Makefile for setting the general configuration
18+
include Makefile.header
19+
20+
LDFLAGS += -Ttext 0 -e startup_32
21+
CFLAGS += $(RAMDISK) -Iinclude
22+
CPP += -Iinclude
23+
24+
#
25+
# ROOT_DEV specifies the default root-device when making the image.
26+
# This can be either FLOPPY, /dev/xxxx or empty, in which case the
27+
# default of /dev/hd6 is used by 'build'.
28+
#
29+
ROOT_DEV= #FLOPPY
30+
31+
ARCHIVES=kernel/kernel.o mm/mm.o fs/fs.o
32+
DRIVERS =kernel/blk_drv/blk_drv.a kernel/chr_drv/chr_drv.a
33+
MATH =kernel/math/math.a
34+
LIBS =lib/lib.a
35+
36+
.c.s:
37+
@$(CC) $(CFLAGS) -S -o $*.s $<
38+
.s.o:
39+
@$(AS) -o $*.o $<
40+
.c.o:
41+
@$(CC) $(CFLAGS) -c -o $*.o $<
42+
43+
all: Image
44+
45+
Image: boot/bootsect boot/setup tools/system
46+
@cp -f tools/system system.tmp
47+
@strip system.tmp
48+
@objcopy -O binary -R .note -R .comment system.tmp tools/kernel
49+
@tools/build.sh boot/bootsect boot/setup tools/kernel Image $(ROOT_DEV)
50+
@rm system.tmp
51+
@rm tools/kernel -f
52+
@sync
53+
54+
disk: Image
55+
@dd bs=8192 if=Image of=/dev/fd0
56+
57+
boot/head.o: boot/head.s
58+
@make head.o -C boot/
59+
60+
tools/system: boot/head.o init/main.o \
61+
$(ARCHIVES) $(DRIVERS) $(MATH) $(LIBS)
62+
@$(LD) $(LDFLAGS) boot/head.o init/main.o \
63+
$(ARCHIVES) \
64+
$(DRIVERS) \
65+
$(MATH) \
66+
$(LIBS) \
67+
-o tools/system
68+
@nm tools/system | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aU] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)'| sort > System.map
69+
70+
kernel/math/math.a:
71+
@make -C kernel/math
72+
73+
kernel/blk_drv/blk_drv.a:
74+
@make -C kernel/blk_drv
75+
76+
kernel/chr_drv/chr_drv.a:
77+
@make -C kernel/chr_drv
78+
79+
kernel/kernel.o:
80+
@make -C kernel
81+
82+
mm/mm.o:
83+
@make -C mm
84+
85+
fs/fs.o:
86+
@make -C fs
87+
88+
lib/lib.a:
89+
@make -C lib
90+
91+
boot/setup: boot/setup.s
92+
@make setup -C boot
93+
94+
boot/bootsect: boot/bootsect.s
95+
@make bootsect -C boot
96+
97+
tmp.s: boot/bootsect.s tools/system
98+
@(echo -n "SYSSIZE = (";ls -l tools/system | grep system \
99+
| cut -c25-31 | tr '\012' ' '; echo "+ 15 ) / 16") > tmp.s
100+
@cat boot/bootsect.s >> tmp.s
101+
102+
clean:
103+
@rm -f Image System.map tmp_make core boot/bootsect boot/setup
104+
@rm -f init/*.o tools/system boot/*.o typescript* info bochsout.txt
105+
@for i in mm fs kernel lib boot; do make clean -C $$i; done
106+
info:
107+
@make clean
108+
@script -q -c "make all"
109+
@cat typescript | col -bp | grep -E "warning|Error" > info
110+
@cat info
111+
112+
distclean: clean
113+
@rm -f tag cscope* linux-0.11.* $(CALLTREE)
114+
@(find tools/calltree-2.3 -name "*.o" | xargs -i rm -f {})
115+
@make clean -C tools/calltree-2.3
116+
@make clean -C tools/bochs/bochs-2.3.7
117+
118+
backup: clean
119+
@(cd .. ; tar cf - linux | compress16 - > backup.Z)
120+
@sync
121+
122+
dep:
123+
@sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
124+
@(for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done) >> tmp_make
125+
@cp tmp_make Makefile
126+
@for i in fs kernel mm; do make dep -C $$i; done
127+
128+
tag: tags
129+
tags:
130+
@ctags -R
131+
132+
cscope:
133+
@cscope -Rbkq
134+
135+
start:
136+
@qemu -m 16M -boot a -fda Image -hda $(HDA_IMG)
137+
138+
bochs-start:
139+
@$(BOCHS) -q -f tools/bochs/bochsrc/bochsrc-hd.bxrc
140+
141+
debug:
142+
@qemu -m 16M -boot a -fda Image -hda $(HDA_IMG) -s -S -nographic -serial '/dev/ttyS0'
143+
144+
bochs-debug:
145+
@$(BOCHS) -q -f tools/bochs/bochsrc/bochsrc-hd-dbg.bxrc
146+
147+
bochs:
148+
ifeq ($(BOCHS),)
149+
@(cd tools/bochs/bochs-2.3.7; \
150+
./configure --enable-plugins --enable-disasm --enable-gdb-stub;\
151+
make)
152+
endif
153+
154+
bochs-clean:
155+
@make clean -C tools/bochs/bochs-2.3.7
156+
157+
calltree:
158+
ifeq ($(CALLTREE),)
159+
@make -C tools/calltree-2.3
160+
endif
161+
162+
calltree-clean:
163+
@(find tools/calltree-2.3 -name "*.o" \
164+
-o -name "calltree" -type f | xargs -i rm -f {})
165+
166+
cg: callgraph
167+
callgraph:
168+
@calltree -b -np -m init/main.c | tools/tree2dotx > linux-0.11.dot
169+
@dot -Tjpg linux-0.11.dot -o linux-0.11.jpg
170+
171+
help:
172+
@echo "<<<<This is the basic help info of linux-0.11>>>"
173+
@echo ""
174+
@echo "Usage:"
175+
@echo " make --generate a kernel floppy Image with a fs on hda1"
176+
@echo " make start -- start the kernel in qemu"
177+
@echo " make debug -- debug the kernel in qemu & gdb at port 1234"
178+
@echo " make disk -- generate a kernel Image & copy it to floppy"
179+
@echo " make cscope -- genereate the cscope index databases"
180+
@echo " make tags -- generate the tag file"
181+
@echo " make cg -- generate callgraph of the system architecture"
182+
@echo " make clean -- clean the object files"
183+
@echo " make distclean -- only keep the source code files"
184+
@echo ""
185+
@echo "Note!:"
186+
@echo " * You need to install the following basic tools:"
187+
@echo " ubuntu|debian, qemu|bochs, ctags, cscope, calltree, graphviz "
188+
@echo " vim-full, build-essential, hex, dd, gcc 4.3.2..."
189+
@echo " * Becarefull to change the compiling options, which will heavily"
190+
@echo " influence the compiling procedure and running result."
191+
@echo ""
192+
@echo "Author:"
193+
@echo " * 1991, linus write and release the original linux 0.95(linux 0.11)."
194+
@echo " * 2005, jiong.zhao<gohigh@sh163.net> release a new version "
195+
@echo " which can be used in RedHat 9 along with the book 'Explaining "
196+
@echo " Linux-0.11 Completly', and he build a site http://www.oldlinux.org"
197+
@echo " * 2008, falcon<wuzhangjin@gmail.com> release a new version which can be"
198+
@echo " used in ubuntu|debian 32bit|64bit with gcc 4.3.2, and give some new "
199+
@echo " features for experimenting. such as this help info, boot/bootsect.s and"
200+
@echo " boot/setup.s with AT&T rewritting, porting to gcc 4.3.2 :-)"
201+
@echo ""
202+
@echo "<<<Be Happy To Play With It :-)>>>"
203+
204+
### Dependencies:
205+
init/main.o: init/main.c include/unistd.h include/sys/stat.h \
206+
include/sys/types.h include/sys/times.h include/sys/utsname.h \
207+
include/utime.h include/time.h include/linux/tty.h include/termios.h \
208+
include/linux/sched.h include/linux/head.h include/linux/fs.h \
209+
include/linux/mm.h include/signal.h include/asm/system.h \
210+
include/asm/io.h include/stddef.h include/stdarg.h include/fcntl.h
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file is the Makefile Header for every sub Makefile, which designed to
2+
# simplfy the porting and maintaining operation
3+
# author: falcon <wuzhangjin@gmail.com>
4+
# update: 2008-10-29
5+
6+
AS = as --32
7+
LD = ld
8+
LDFLAGS = -m elf_i386 -x
9+
CC = gcc -fno-stack-protector
10+
CFLAGS = -g -m32 -fno-builtin -fomit-frame-pointer -fstrength-reduce #-Wall
11+
12+
CPP = cpp -nostdinc
13+
AR = ar
14+
15+
# we should use -fno-stack-protector with gcc 4.3
16+
gcc_version=$(shell ls -l `which gcc` | tr '-' '\n' | tail -1)

data/linux-0.11_qemu_gdb/README

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
qemu-system-i386 -m 16M -boot a -fda Image -hda rootfs/hdc-0.11-new.img
2+
3+
4+
qemu-system-x86_64 -m 16M -boot a -fda Image -hda rootfs/hdc-0.11-new.img -gdb tcp::1234 -S
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
linux-0.11 development environment(linux-based)
27+
tigercn <moonlight.yang@gmail.com>
28+
update: 2011-07-31
29+
falcon <wuzhangjin@gmail.com>
30+
update: 2008-10-15
31+
32+
NOTE: you can download the whole dev environment from
33+
http://mirror.lzu.edu.cn/software/linux-0.11/linux-0.11-for-gcc4.3.2.tar.gz
34+
Here is just the source code of linux-0.11 for gcc 4.3.2.
35+
36+
1. preparation
37+
38+
* a linux distribution: debian and ubuntu are recommended
39+
* a virtual machine: qemu(recommend) or bochs
40+
* some tools: cscope, ctags, gcc-4.3(or 4.1,4.2,3.4), vim, bash, gdb, dd, qemu, xorg-dev, xserver-xorg-dev...
41+
$ apt-get install qemu cscope exuberant-ctags gcc-4.3 vim-full bash gdb build-essential hex graphviz xorg-dev xserver-xorg-dev vgabios libxpm-dev bochs bochs-x bochsbios bximage
42+
* a linux-0.11 hardware image file: hdc-0.11-new.img, please download it from http://www.oldlinux.org, or http://mirror.lzu.edu.cn/os/oldlinux.org/, after downloading it, you'd put it in linux-0.11/fs/ directory.
43+
44+
and you'd better install tools/calltree, tools/tree2dotx yourself: just copy
45+
them to /usr/bin, of course, you'd compile calltree at first.
46+
47+
2. hack linux-0.11
48+
49+
get help from the main Makefile of linux-0.11 and star to hack it.
50+
51+
$ cd linux-0.11
52+
$ make help // get help
53+
$ make // compile
54+
$ make start // boot it on qemu
55+
$ make debug // debug it via qemu & gdb, you'd start gdb to connect it.
56+
$ make tags // create the tag file from the source code
57+
$ make cscope // create the cscope index database from the source code
58+
59+
NOTE!
60+
61+
there is a calltree in tools/, which can help you to analyze the source code
62+
via printing the calling tree of some indicated functions.
63+
64+
compile
65+
$ cd tools/calltree-2.3
66+
install
67+
$ sudo cp ./calltree/OBJ/i686-linux-cc/calltree /usr/bin
68+
use
69+
$ calltree // just type calltree and get the help
70+
71+
3. debug
72+
73+
start the kernel with qemu, which will listening on port 1234
74+
75+
$ cd linux-0.11
76+
$ make debug
77+
78+
open a new terminal, start gdb and connect the gdbstub in qemu
79+
80+
$ gdb linux-0.11/tools/system
81+
(gdb) break main
82+
(gdb) target remote localhost:1234
83+
(gdb) s // si:assembly instruction, s|n: c statement(s will enter into subfunc)
84+
(gdb) ...
85+
86+
References & Links
87+
88+
[1] http://oss.lzu.edu.cn/blog/article.php?tid_1693.html
89+
[2] http://oss.lzu.edu.cn/modules/newbb/viewtopic.php?topic_id=1403&forum=35

0 commit comments

Comments
 (0)