2006-07-16 17:35:18 +02:00
|
|
|
OBJS = \
|
2007-08-28 06:20:40 +02:00
|
|
|
bio.o\
|
2006-07-16 17:35:18 +02:00
|
|
|
console.o\
|
2007-08-28 06:20:40 +02:00
|
|
|
exec.o\
|
2006-09-06 20:40:28 +02:00
|
|
|
file.o\
|
2007-08-28 06:20:40 +02:00
|
|
|
fs.o\
|
2006-07-16 17:35:18 +02:00
|
|
|
ide.o\
|
2007-08-28 06:20:40 +02:00
|
|
|
ioapic.o\
|
2006-07-16 17:35:18 +02:00
|
|
|
kalloc.o\
|
2007-08-28 06:20:40 +02:00
|
|
|
kbd.o\
|
2006-07-16 17:35:18 +02:00
|
|
|
lapic.o\
|
|
|
|
main.o\
|
|
|
|
mp.o\
|
|
|
|
picirq.o\
|
|
|
|
pipe.o\
|
|
|
|
proc.o\
|
|
|
|
spinlock.o\
|
|
|
|
string.o\
|
2007-08-28 14:48:33 +02:00
|
|
|
swtch.o\
|
2006-07-16 17:35:18 +02:00
|
|
|
syscall.o\
|
2006-09-06 20:18:43 +02:00
|
|
|
sysfile.o\
|
|
|
|
sysproc.o\
|
2007-08-28 06:41:20 +02:00
|
|
|
timer.o\
|
2006-07-16 17:35:18 +02:00
|
|
|
trapasm.o\
|
|
|
|
trap.o\
|
|
|
|
vectors.o\
|
2006-06-12 17:22:12 +02:00
|
|
|
|
Changes to allow use of native x86 ELF compilers, which on my
Linux 2.4 box using gcc 3.4.6 don't seem to follow the same
conventions as the i386-jos-elf-gcc compilers.
Can run make 'TOOLPREFIX=' or edit the Makefile.
curproc[cpu()] can now be NULL, indicating that no proc is running.
This seemed safer to me than having curproc[0] and curproc[1]
both pointing at proc[0] potentially.
The old implementation of swtch depended on the stack frame layout
used inside swtch being okay to return from on the other stack
(exactly the V6 you are not expected to understand this).
It also could be called in two contexts: at boot time, to schedule
the very first process, and later, on behalf of a process, to sleep
or schedule some other process.
I split this into two functions: scheduler and swtch.
The scheduler is now a separate never-returning function, invoked
by each cpu once set up. The scheduler looks like:
scheduler() {
setjmp(cpu.context);
pick proc to schedule
blah blah blah
longjmp(proc.context)
}
The new swtch is intended to be called only when curproc[cpu()] is not NULL,
that is, only on behalf of a user proc. It does:
swtch() {
if(setjmp(proc.context) == 0)
longjmp(cpu.context)
}
to save the current proc context and then jump over to the scheduler,
running on the cpu stack.
Similarly the system call stubs are now in assembly in usys.S to avoid
needing to know the details of stack frame layout used by the compiler.
Also various changes in the debugging prints.
2006-07-11 03:07:40 +02:00
|
|
|
# Cross-compiling (e.g., on Mac OS X)
|
2007-08-28 21:30:29 +02:00
|
|
|
# TOOLPREFIX = i386-jos-elf-
|
Changes to allow use of native x86 ELF compilers, which on my
Linux 2.4 box using gcc 3.4.6 don't seem to follow the same
conventions as the i386-jos-elf-gcc compilers.
Can run make 'TOOLPREFIX=' or edit the Makefile.
curproc[cpu()] can now be NULL, indicating that no proc is running.
This seemed safer to me than having curproc[0] and curproc[1]
both pointing at proc[0] potentially.
The old implementation of swtch depended on the stack frame layout
used inside swtch being okay to return from on the other stack
(exactly the V6 you are not expected to understand this).
It also could be called in two contexts: at boot time, to schedule
the very first process, and later, on behalf of a process, to sleep
or schedule some other process.
I split this into two functions: scheduler and swtch.
The scheduler is now a separate never-returning function, invoked
by each cpu once set up. The scheduler looks like:
scheduler() {
setjmp(cpu.context);
pick proc to schedule
blah blah blah
longjmp(proc.context)
}
The new swtch is intended to be called only when curproc[cpu()] is not NULL,
that is, only on behalf of a user proc. It does:
swtch() {
if(setjmp(proc.context) == 0)
longjmp(cpu.context)
}
to save the current proc context and then jump over to the scheduler,
running on the cpu stack.
Similarly the system call stubs are now in assembly in usys.S to avoid
needing to know the details of stack frame layout used by the compiler.
Also various changes in the debugging prints.
2006-07-11 03:07:40 +02:00
|
|
|
|
|
|
|
# Using native tools (e.g., on X86 Linux)
|
2007-08-28 21:30:29 +02:00
|
|
|
TOOLPREFIX =
|
Changes to allow use of native x86 ELF compilers, which on my
Linux 2.4 box using gcc 3.4.6 don't seem to follow the same
conventions as the i386-jos-elf-gcc compilers.
Can run make 'TOOLPREFIX=' or edit the Makefile.
curproc[cpu()] can now be NULL, indicating that no proc is running.
This seemed safer to me than having curproc[0] and curproc[1]
both pointing at proc[0] potentially.
The old implementation of swtch depended on the stack frame layout
used inside swtch being okay to return from on the other stack
(exactly the V6 you are not expected to understand this).
It also could be called in two contexts: at boot time, to schedule
the very first process, and later, on behalf of a process, to sleep
or schedule some other process.
I split this into two functions: scheduler and swtch.
The scheduler is now a separate never-returning function, invoked
by each cpu once set up. The scheduler looks like:
scheduler() {
setjmp(cpu.context);
pick proc to schedule
blah blah blah
longjmp(proc.context)
}
The new swtch is intended to be called only when curproc[cpu()] is not NULL,
that is, only on behalf of a user proc. It does:
swtch() {
if(setjmp(proc.context) == 0)
longjmp(cpu.context)
}
to save the current proc context and then jump over to the scheduler,
running on the cpu stack.
Similarly the system call stubs are now in assembly in usys.S to avoid
needing to know the details of stack frame layout used by the compiler.
Also various changes in the debugging prints.
2006-07-11 03:07:40 +02:00
|
|
|
|
|
|
|
CC = $(TOOLPREFIX)gcc
|
2007-08-28 06:20:40 +02:00
|
|
|
AS = $(TOOLPREFIX)gas
|
Changes to allow use of native x86 ELF compilers, which on my
Linux 2.4 box using gcc 3.4.6 don't seem to follow the same
conventions as the i386-jos-elf-gcc compilers.
Can run make 'TOOLPREFIX=' or edit the Makefile.
curproc[cpu()] can now be NULL, indicating that no proc is running.
This seemed safer to me than having curproc[0] and curproc[1]
both pointing at proc[0] potentially.
The old implementation of swtch depended on the stack frame layout
used inside swtch being okay to return from on the other stack
(exactly the V6 you are not expected to understand this).
It also could be called in two contexts: at boot time, to schedule
the very first process, and later, on behalf of a process, to sleep
or schedule some other process.
I split this into two functions: scheduler and swtch.
The scheduler is now a separate never-returning function, invoked
by each cpu once set up. The scheduler looks like:
scheduler() {
setjmp(cpu.context);
pick proc to schedule
blah blah blah
longjmp(proc.context)
}
The new swtch is intended to be called only when curproc[cpu()] is not NULL,
that is, only on behalf of a user proc. It does:
swtch() {
if(setjmp(proc.context) == 0)
longjmp(cpu.context)
}
to save the current proc context and then jump over to the scheduler,
running on the cpu stack.
Similarly the system call stubs are now in assembly in usys.S to avoid
needing to know the details of stack frame layout used by the compiler.
Also various changes in the debugging prints.
2006-07-11 03:07:40 +02:00
|
|
|
LD = $(TOOLPREFIX)ld
|
|
|
|
OBJCOPY = $(TOOLPREFIX)objcopy
|
|
|
|
OBJDUMP = $(TOOLPREFIX)objdump
|
2007-09-18 02:41:34 +02:00
|
|
|
CFLAGS = -fno-builtin -O2 -Wall -MD -ggdb -m32
|
2007-08-28 06:20:40 +02:00
|
|
|
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
|
2007-09-18 02:41:34 +02:00
|
|
|
ASFLAGS = -m32
|
|
|
|
LDFLAGS = -m elf_i386
|
2006-06-12 17:22:12 +02:00
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
xv6.img: bootblock kernel fs.img
|
2006-06-12 17:22:12 +02:00
|
|
|
dd if=/dev/zero of=xv6.img count=10000
|
|
|
|
dd if=bootblock of=xv6.img conv=notrunc
|
|
|
|
dd if=kernel of=xv6.img seek=1 conv=notrunc
|
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
bootblock: bootasm.S bootmain.c
|
2007-09-18 02:41:34 +02:00
|
|
|
$(CC) $(CFLAGS) -O -nostdinc -I. -c bootmain.c
|
|
|
|
$(CC) $(CFLAGS) -nostdinc -I. -c bootasm.S
|
|
|
|
$(LD) $(LDFLAGS) -N -e start -Ttext 0x7C00 -o bootblock.o bootasm.o bootmain.o
|
2006-06-12 17:22:12 +02:00
|
|
|
$(OBJDUMP) -S bootblock.o > bootblock.asm
|
|
|
|
$(OBJCOPY) -S -O binary bootblock.o bootblock
|
|
|
|
./sign.pl bootblock
|
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
bootother: bootother.S
|
2007-09-18 02:41:34 +02:00
|
|
|
$(CC) $(CFLAGS) -nostdinc -I. -c bootother.S
|
|
|
|
$(LD) $(LDFLAGS) -N -e start -Ttext 0x7000 -o bootother.out bootother.o
|
2006-06-22 03:28:57 +02:00
|
|
|
$(OBJCOPY) -S -O binary bootother.out bootother
|
|
|
|
$(OBJDUMP) -S bootother.o > bootother.asm
|
2007-08-28 06:20:40 +02:00
|
|
|
|
|
|
|
initcode: initcode.S
|
2007-09-18 02:41:34 +02:00
|
|
|
$(CC) $(CFLAGS) -nostdinc -I. -c initcode.S
|
|
|
|
$(LD) $(LDFLAGS) -N -e start -Ttext 0 -o initcode.out initcode.o
|
2007-08-21 21:22:08 +02:00
|
|
|
$(OBJCOPY) -S -O binary initcode.out initcode
|
|
|
|
$(OBJDUMP) -S initcode.o > initcode.asm
|
2007-08-28 06:20:40 +02:00
|
|
|
|
|
|
|
kernel: $(OBJS) bootother initcode
|
2007-09-18 02:41:34 +02:00
|
|
|
$(LD) $(LDFLAGS) -Ttext 0x100000 -e main -o kernel $(OBJS) -b binary initcode bootother
|
2006-06-12 17:22:12 +02:00
|
|
|
$(OBJDUMP) -S kernel > kernel.asm
|
2007-08-28 14:48:33 +02:00
|
|
|
$(OBJDUMP) -t kernel | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym
|
2006-06-12 17:22:12 +02:00
|
|
|
|
2006-09-07 16:10:52 +02:00
|
|
|
tags: $(OBJS) bootother.S _init
|
2006-08-28 20:31:33 +02:00
|
|
|
etags *.S *.c
|
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
vectors.S: vectors.pl
|
2006-06-13 17:50:06 +02:00
|
|
|
perl vectors.pl > vectors.S
|
|
|
|
|
2006-08-24 04:44:41 +02:00
|
|
|
ULIB = ulib.o usys.o printf.o umalloc.o
|
Changes to allow use of native x86 ELF compilers, which on my
Linux 2.4 box using gcc 3.4.6 don't seem to follow the same
conventions as the i386-jos-elf-gcc compilers.
Can run make 'TOOLPREFIX=' or edit the Makefile.
curproc[cpu()] can now be NULL, indicating that no proc is running.
This seemed safer to me than having curproc[0] and curproc[1]
both pointing at proc[0] potentially.
The old implementation of swtch depended on the stack frame layout
used inside swtch being okay to return from on the other stack
(exactly the V6 you are not expected to understand this).
It also could be called in two contexts: at boot time, to schedule
the very first process, and later, on behalf of a process, to sleep
or schedule some other process.
I split this into two functions: scheduler and swtch.
The scheduler is now a separate never-returning function, invoked
by each cpu once set up. The scheduler looks like:
scheduler() {
setjmp(cpu.context);
pick proc to schedule
blah blah blah
longjmp(proc.context)
}
The new swtch is intended to be called only when curproc[cpu()] is not NULL,
that is, only on behalf of a user proc. It does:
swtch() {
if(setjmp(proc.context) == 0)
longjmp(cpu.context)
}
to save the current proc context and then jump over to the scheduler,
running on the cpu stack.
Similarly the system call stubs are now in assembly in usys.S to avoid
needing to know the details of stack frame layout used by the compiler.
Also various changes in the debugging prints.
2006-07-11 03:07:40 +02:00
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
_%: %.o $(ULIB)
|
2007-09-18 02:41:34 +02:00
|
|
|
$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o $@ $^
|
2007-08-28 06:20:40 +02:00
|
|
|
$(OBJDUMP) -S $@ > $*.asm
|
2007-08-28 14:48:33 +02:00
|
|
|
$(OBJDUMP) -t $@ | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > $*.sym
|
2007-08-08 10:38:55 +02:00
|
|
|
|
2007-08-24 22:20:23 +02:00
|
|
|
_forktest: forktest.o $(ULIB)
|
|
|
|
# forktest has less library code linked in - needs to be small
|
|
|
|
# in order to be able to max out the proc table.
|
2007-09-18 02:41:34 +02:00
|
|
|
$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o _forktest forktest.o ulib.o usys.o
|
2007-08-24 22:20:23 +02:00
|
|
|
$(OBJDUMP) -S _forktest > forktest.asm
|
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
mkfs: mkfs.c fs.h
|
2007-09-18 02:41:34 +02:00
|
|
|
gcc $(CFLAGS) -Wall -o mkfs mkfs.c
|
2007-08-28 06:20:40 +02:00
|
|
|
|
|
|
|
UPROGS=\
|
|
|
|
_cat\
|
2007-08-28 06:26:34 +02:00
|
|
|
_echo\
|
2007-08-28 06:20:40 +02:00
|
|
|
_forktest\
|
2007-08-28 06:26:34 +02:00
|
|
|
_grep\
|
2007-08-28 06:20:40 +02:00
|
|
|
_init\
|
|
|
|
_kill\
|
|
|
|
_ln\
|
|
|
|
_ls\
|
|
|
|
_mkdir\
|
|
|
|
_rm\
|
|
|
|
_sh\
|
|
|
|
_usertests\
|
|
|
|
_wc\
|
|
|
|
_zombie\
|
|
|
|
|
|
|
|
fs.img: mkfs README $(UPROGS)
|
2007-08-08 10:38:55 +02:00
|
|
|
./mkfs fs.img README $(UPROGS)
|
2006-07-21 15:18:04 +02:00
|
|
|
|
2006-06-15 21:58:01 +02:00
|
|
|
-include *.d
|
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
clean:
|
2007-08-30 20:33:48 +02:00
|
|
|
rm -f *.tex *.dvi *.idx *.aux *.log *.ind *.ilg \
|
2007-08-28 06:20:40 +02:00
|
|
|
*.o *.d *.asm *.sym vectors.S parport.out \
|
2007-08-08 10:38:55 +02:00
|
|
|
bootblock kernel xv6.img fs.img mkfs \
|
|
|
|
$(UPROGS)
|
2006-09-07 22:06:15 +02:00
|
|
|
|
|
|
|
# make a printout
|
2007-08-30 16:12:19 +02:00
|
|
|
FILES = $(shell grep -v '^\#' runoff.list)
|
|
|
|
PRINT = runoff.list $(FILES)
|
2006-09-07 22:06:15 +02:00
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
xv6.pdf: $(PRINT)
|
2006-09-07 22:06:15 +02:00
|
|
|
./runoff
|
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
print: xv6.pdf
|
2006-09-07 22:06:15 +02:00
|
|
|
|
|
|
|
# run in emulators
|
|
|
|
|
|
|
|
bochs : fs.img xv6.img
|
|
|
|
if [ ! -e .bochsrc ]; then ln -s dot-bochsrc .bochsrc; fi
|
|
|
|
bochs -q
|
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
qemu: fs.img xv6.img
|
2006-09-07 22:06:15 +02:00
|
|
|
qemu -parallel stdio -hdb fs.img xv6.img
|
|
|
|
|
2006-09-08 16:41:06 +02:00
|
|
|
# CUT HERE
|
|
|
|
# prepare dist for students
|
|
|
|
# after running make dist, probably want to
|
|
|
|
# rename it to rev0 or rev1 or so on and then
|
|
|
|
# check in that version.
|
2007-08-30 16:12:19 +02:00
|
|
|
|
|
|
|
EXTRA=\
|
|
|
|
mkfs.c ulib.c user.h cat.c echo.c forktest.c grep.c\
|
|
|
|
kill.c ln.c ls.c mkdir.c rm.c usertests.c wc.c zombie.c\
|
|
|
|
printf.c umalloc.c \
|
|
|
|
README dot-bochsrc *.pl toc.* runoff runoff1 runoff.list\
|
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
dist:
|
2006-09-08 16:41:06 +02:00
|
|
|
rm -rf dist
|
|
|
|
mkdir dist
|
2007-08-30 16:12:19 +02:00
|
|
|
for i in $(FILES); \
|
2006-09-08 16:41:06 +02:00
|
|
|
do \
|
|
|
|
grep -v PAGEBREAK $$i >dist/$$i; \
|
|
|
|
done
|
|
|
|
sed '/CUT HERE/,$$d' Makefile >dist/Makefile
|
2007-08-30 16:12:19 +02:00
|
|
|
echo >dist/runoff.spec
|
|
|
|
cp $(EXTRA) dist
|
2006-09-08 16:41:06 +02:00
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
dist-test:
|
2007-08-30 16:12:19 +02:00
|
|
|
rm -rf dist
|
|
|
|
make dist
|
2006-09-08 16:41:06 +02:00
|
|
|
rm -rf dist-test
|
|
|
|
mkdir dist-test
|
|
|
|
cp dist/* dist-test
|
|
|
|
cd dist-test; ../m print
|
|
|
|
cd dist-test; ../m bochs || true
|
|
|
|
cd dist-test; ../m qemu
|
|
|
|
|
2007-08-28 06:20:40 +02:00
|
|
|
# update this rule (change rev1) when it is time to
|
2006-09-08 16:41:06 +02:00
|
|
|
# make a new revision.
|
2007-08-28 06:20:40 +02:00
|
|
|
tar:
|
2006-09-08 16:41:06 +02:00
|
|
|
rm -rf /tmp/xv6
|
|
|
|
mkdir -p /tmp/xv6
|
|
|
|
cp dist/* /tmp/xv6
|
2007-08-28 06:20:40 +02:00
|
|
|
(cd /tmp; tar cf - xv6) | gzip >xv6-rev1.tar.gz
|
2006-09-08 16:41:06 +02:00
|
|
|
|