Skip to content

Commit 5a98315

Browse files
author
Wang Jian
committed
init
0 parents  commit 5a98315

Some content is hidden

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

121 files changed

+21695
-0
lines changed

bxs/tornado.deb.bxrc

Lines changed: 1118 additions & 0 deletions
Large diffs are not rendered by default.

bxs/tornado.gdb.bxrc

Lines changed: 1118 additions & 0 deletions
Large diffs are not rendered by default.

src/Makefile

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
###############################################################################
2+
# Common
3+
###############################################################################
4+
5+
#=========================================================#
6+
#
7+
#=========================================================#
8+
INCLUDE = ./include
9+
10+
AS = as
11+
ASFLAGS = -g --32
12+
13+
LD = ld
14+
LDFLAGS = -m elf_i386
15+
16+
17+
CC = gcc34
18+
CFLAGS = -g -m32 -O -Wall \
19+
-fno-builtin -nostdinc -I$(INCLUDE) \
20+
-finline-functions #-fomit-frame-pointer
21+
22+
CPP = gcc34 -E
23+
CPPFLAGS= -g -nostdinc -I$(INCLUDE)
24+
25+
AR = ar
26+
RM = rm -fr
27+
28+
###############################################################################
29+
# MAKELEVEL == 0
30+
ifeq (0, $(MAKELEVEL))
31+
###############################################################################
32+
SRCDIR = $(shell pwd)
33+
TPLDIR = $(SRCDIR)/template
34+
OBJDIR = $(SRCDIR)/../obj
35+
BXSDIR = $(SRCDIR)/../bxs
36+
37+
export PATH += :$(SRCDIR)/bin
38+
39+
RAMDISK =#-DRAMDISK=512
40+
ROOT_DEV=#FLOPPY
41+
SWAP_DEV=
42+
43+
#=========================================================#
44+
#
45+
#=========================================================#
46+
47+
BOOT = boot/boot.a
48+
MODS = \
49+
init/init.a \
50+
mm/mm.o \
51+
kernel/kernel.o \
52+
fs/fs.o \
53+
fs/minix/minix.o \
54+
kernel/chr_drv/chr_drv.a \
55+
kernel/blk_drv/blk_drv.a \
56+
kernel/math/math.a \
57+
lib/lib.a
58+
59+
all : kernel.img
60+
61+
backup : clean
62+
cd ../../ && tar -cjf linux.tar.gz linux
63+
64+
kernel.img : compile
65+
rm -f $(BXSDIR)/kernel.img
66+
@$(AR) -p $(addprefix $(OBJDIR)/, $(BOOT)) bootsect.o > $(OBJDIR)/bootsect.o
67+
$(LD) $(LDFLAGS) -Ttext 0 -o bootsect $(OBJDIR)/bootsect.o ; rm -fr $(OBJDIR)/bootsect.o
68+
@objcopy -R .pdr -R .comment -R .note -O binary -S bootsect
69+
@$(AR) -p $(addprefix $(OBJDIR)/, $(BOOT)) setup.o > $(OBJDIR)/setup.o
70+
$(LD) $(LDFLAGS) -Ttext 0 -o setup $(OBJDIR)/setup.o ; rm -fr $(OBJDIR)/setup.o
71+
@objcopy -R .pdr -R .comment -R .note -O binary -S setup
72+
$(LD) $(LDFLAGS) -Ttext 0 -o $(OBJDIR)/system.o $(addprefix $(OBJDIR)/, $(MODS))
73+
@objcopy -R .pdr -R .comment -R .note -O binary $(OBJDIR)/system.o system
74+
build bootsect setup system kernel.img $(ROOT_DEV)
75+
@rm -f bootsect setup system $(OBJDIR)/head.o
76+
@mv kernel.img $(BXSDIR)/ && echo "Create kernel.img"
77+
78+
compile :
79+
@for module in $(BOOT) $(MODS); do \
80+
$(MAKE) all -e TARGET=$$(basename $$module) -C $$(dirname $$module) -f $(TPLDIR)/compile.mak || exit 1; \
81+
done
82+
83+
#in case timestamp disturbed
84+
clean :
85+
@for module in $(BOOT) $(MODS); do \
86+
$(MAKE) clean -e TARGET=$$(basename $$module) -C $$(dirname $$module) -f $(TPLDIR)/compile.mak || exit 1; \
87+
done
88+
rm -fr $(BXSDIR)/kernel.img $(OBJDIR)/system.o
89+
90+
#in case file deleted
91+
cleanall :
92+
rm -fr $(OBJDIR) $(BXSDIR)/kernel.img
93+
94+
###############################################################################
95+
# MAKELEVEL > 0
96+
# LDFLAGS :
97+
# SRCS :
98+
# CUR_DIR :
99+
else
100+
###############################################################################
101+
#=========================================================#
102+
#
103+
#=========================================================#
104+
OBJM = $(PATHM)/$(TARGET)
105+
OBJS = $(addprefix $(PATHM)/, \
106+
$(patsubst %.s, %.o, $(filter %.s, $(SRCS))) \
107+
$(patsubst %.S, %.o, $(filter %.S, $(SRCS))) \
108+
$(patsubst %.c, %.o, $(filter %.c, $(SRCS))) \
109+
)
110+
DEPS = $(addprefix $(PATHM)/, \
111+
$(patsubst %.c, %.d, $(filter %.c, $(SRCS))) \
112+
$(patsubst %.S, %.d, $(filter %.S, $(SRCS))) \
113+
)
114+
115+
#=========================================================#
116+
#
117+
#=========================================================#
118+
$(OBJDIR)/%.o : %.c
119+
$(CC) $(CFLAGS) -c -o $@ $<
120+
121+
$(OBJDIR)/%.o : %.s
122+
$(AS) $(ASFLAGS) -o $@ $<
123+
124+
$(OBJDIR)/%.o : %.S
125+
$(CPP) $(CPPFLAGS) -o $(<:.S=.s) $<
126+
$(AS) $(ASFLAGS) -o $@ $(<:.S=.s)
127+
$(RM) $(<:.S=.s)
128+
129+
$(OBJDIR)/%.d : %.c
130+
$(CPP) $(CPPFLAGS) -MT '$@ $(@:.d=.o)' -MM $< > $@
131+
132+
$(OBJDIR)/%.d : %.S
133+
$(CPP) $(CPPFLAGS) -MT '$@ $(@:.d=.o)' -MM $< > $@
134+
135+
#=========================================================#
136+
#
137+
#=========================================================#
138+
all : makedir $(OBJM) ;
139+
140+
makedir :
141+
@test ! -d "$(PATHM)" && mkdir -p $(PATHM)
142+
143+
$(OBJM) : $(OBJS)
144+
ifeq (.a, $(suffix $(OBJM)))
145+
$(AR) rcs $(OBJM) $(OBJS)
146+
else ifeq (.o, $(suffix $(OBJM)))
147+
$(LD) $(LDFLAGS) -r -o $(OBJM) $(OBJS)
148+
endif
149+
150+
ifneq ($(MAKECMDGOALS),clean)
151+
-include $(DEPS)
152+
endif
153+
154+
clean:
155+
rm -fr $(OBJM) $(OBJS) $(DEPS)
156+
157+
###############################################################################
158+
# MAKELEVEL end
159+
endif
160+
###############################################################################
161+
162+
163+

src/bin/build

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# build.sh
3+
4+
bootsect=$1
5+
setup=$2
6+
system=$3
7+
image=$4
8+
root_dev=$5
9+
10+
# Set the sys_size limit
11+
SYS_SIZE=$((0x3000*16))
12+
13+
# set default root device
14+
if [ -z "$root_dev" ]
15+
then
16+
ROOT_MAJOR=3
17+
ROOT_MINOR=1
18+
else
19+
ROOT_MAJOR=${root_dev:0:2}
20+
ROOT_MINOR=${root_dev:2:3}
21+
fi
22+
23+
# Write bootsect (512 bytes, one sector)
24+
test ! -f "$bootsect" && echo "no bootsect" && exit -1
25+
dd if=$bootsect bs=512 count=1 of=$image 1>/dev/null 2>/dev/null
26+
27+
# Write setup(4 * 512bytes, four sectors)
28+
test ! -f "$setup" && echo "no setup" && exit -1
29+
dd if=$setup seek=1 bs=512 count=4 of=$image 1>/dev/null 2>/dev/null
30+
31+
# Write system(< SYS_SIZE)
32+
test ! -f "$system" && echo "no system" && exit -1
33+
system_size=`wc -c $system | cut -d" " -f1`
34+
test $system_size -gt $SYS_SIZE && echo "system limit exceeded" && exit -1
35+
dd if=$system seek=5 bs=512 count=$((2888-1-4)) of=$image 1>/dev/null 2>/dev/null
36+
37+
# Set default device
38+
echo -ne "\x$ROOT_MINOR\x$ROOT_MAJOR" \
39+
| dd ibs=1 obs=1 count=2 seek=508 of=$image conv=notrunc 1>/dev/null 2>/dev/null

0 commit comments

Comments
 (0)