-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d88b64f
Showing
87 changed files
with
9,160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
############################################################### | ||
# bochsrc file for pragmalinux disk image. | ||
# | ||
# This file is provided both as .bochsrc and bochsrc so | ||
# that it works on win32 and unix. | ||
############################################################### | ||
|
||
# how much memory the emulated machine will have | ||
megs: 32 | ||
|
||
# filename of ROM images | ||
romimage: file=$BXSHARE/BIOS-bochs-latest | ||
#, address=0xf0000 | ||
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest | ||
|
||
# Use the parallel port as an alternate console, | ||
# so that we can run Bochs without the GUI. | ||
parport1: enabled=1, file="/dev/stdout" | ||
#parport1: enabled=1, file="/dev/null" | ||
|
||
# uncommenting one of the following lines can be used to specify your | ||
# preferred display. (defaults to x11 for bochs-bin and to term for | ||
# bochs-term) | ||
|
||
#display_library: x | ||
|
||
# nogui can still be useful because you can see the output on the | ||
# parport1 from above | ||
#display_library: nogui | ||
|
||
# if using "term", you probably want to change the parport output to | ||
# go to a file or /dev/null | ||
#display_library: term | ||
|
||
# disk images | ||
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 | ||
ata0-master: type=disk, mode=flat, path="./obj/kern/kernel.img", cylinders=25, heads=16, spt=25 | ||
|
||
# choose the boot disk. | ||
boot: c | ||
|
||
# where do we send log messages? | ||
log: bochs.log | ||
#log: /dev/stdout | ||
|
||
# disable the mouse | ||
mouse: enabled=0 | ||
|
||
#debug: action=ignore | ||
info: action=ignore | ||
error: action=report | ||
panic: action=ask | ||
|
||
# this changes how often the screen is refreshed. Lowering it will | ||
# make your screen update more often, which will slow down emulation, | ||
# but will make the display respond faster. It can also be useful if | ||
# you machine is panicing and the most recent screen changes are not | ||
# displayed before it panics. | ||
|
||
vga_update_interval: 100000 | ||
|
||
# changing ips can lead to dramatically different performance. It | ||
# also affects how quickly time passes in the emulated machine. | ||
# Setting it too low can cause clock interrupts to happen too rapidly. | ||
# Setting it too high will make the whole machine feel sluggish. | ||
# (Note: with using clock sync=realtime, the ips parameter is not | ||
# really used, although it is still used for vga updates) | ||
# ips: 2000000 | ||
|
||
# This means that time in the emulated machine is the same as | ||
# realtime. This can be scary because running the same simulation | ||
# twice in a row can lead to different results (because they started | ||
# at different times, for instance). If you want to use non-real | ||
# time, then use sync=none. | ||
clock: sync=realtime, time0=local | ||
# clock: sync=none, time0=946681200 # jan 1, 2000 | ||
|
||
keyboard_serial_delay: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bochs.log | ||
obj/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
JOS CODING STANDARDS | ||
|
||
It's easier on everyone if all authors working on a shared | ||
code base are consistent in the way they write their programs. | ||
We have the following conventions in our code: | ||
|
||
* No space after the name of a function in a call | ||
For example, printf("hello") not printf ("hello"). | ||
|
||
* One space after keywords "if", "for", "while", "switch". | ||
For example, if (x) not if(x). | ||
|
||
* Space before braces. | ||
For example, if (x) { not if (x){. | ||
|
||
* Function names are all lower-case separated by underscores. | ||
|
||
* Beginning-of-line indentation via tabs, not spaces. | ||
|
||
* Preprocessor macros are always UPPERCASE. | ||
There are a few grandfathered exceptions: assert, panic, | ||
static_assert, offsetof. | ||
|
||
* Pointer types have spaces: (uint16_t *) not (uint16_t*). | ||
|
||
* Multi-word names are lower_case_with_underscores. | ||
|
||
* Comments in imported code are usually C /* ... */ comments. | ||
Comments in new code are C++ style //. | ||
|
||
* In a function definition, the function name starts a new line. | ||
Then you can grep -n '^foo' */*.c to find the definition of foo. | ||
|
||
* Functions that take no arguments are declared f(void) not f(). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
# | ||
# This makefile system follows the structuring conventions | ||
# recommended by Peter Miller in his excellent paper: | ||
# | ||
# Recursive Make Considered Harmful | ||
# http://aegis.sourceforge.net/auug97.pdf | ||
# | ||
OBJDIR := obj | ||
|
||
ifdef LAB | ||
SETTINGLAB := true | ||
else | ||
-include conf/lab.mk | ||
endif | ||
|
||
-include conf/env.mk | ||
|
||
ifndef SOL | ||
SOL := 0 | ||
endif | ||
ifndef LABADJUST | ||
LABADJUST := 0 | ||
endif | ||
|
||
ifndef LABSETUP | ||
LABSETUP := ./ | ||
endif | ||
|
||
|
||
TOP = . | ||
|
||
# Cross-compiler jos toolchain | ||
# | ||
# This Makefile will automatically use the cross-compiler toolchain | ||
# installed as 'i386-jos-elf-*', if one exists. If the host tools ('gcc', | ||
# 'objdump', and so forth) compile for a 32-bit x86 ELF target, that will | ||
# be detected as well. If you have the right compiler toolchain installed | ||
# using a different name, set GCCPREFIX explicitly in conf/env.mk | ||
|
||
# try to infer the correct GCCPREFIX | ||
ifndef GCCPREFIX | ||
GCCPREFIX := $(shell if i386-jos-elf-objdump -i 2>&1 | grep '^elf32-i386$$' >/dev/null 2>&1; \ | ||
then echo 'i386-jos-elf-'; \ | ||
elif objdump -i 2>&1 | grep 'elf32-i386' >/dev/null 2>&1; \ | ||
then echo ''; \ | ||
else echo "***" 1>&2; \ | ||
echo "*** Error: Couldn't find an i386-*-elf version of GCC/binutils." 1>&2; \ | ||
echo "*** Is the directory with i386-jos-elf-gcc in your PATH?" 1>&2; \ | ||
echo "*** If your i386-*-elf toolchain is installed with a command" 1>&2; \ | ||
echo "*** prefix other than 'i386-jos-elf-', set your GCCPREFIX" 1>&2; \ | ||
echo "*** environment variable to that prefix and run 'make' again." 1>&2; \ | ||
echo "*** To turn off this error, run 'gmake GCCPREFIX= ...'." 1>&2; \ | ||
echo "***" 1>&2; exit 1; fi) | ||
endif | ||
|
||
# try to infer the correct QEMU | ||
ifndef QEMU | ||
QEMU := $(shell if which qemu > /dev/null; \ | ||
then echo qemu; exit; \ | ||
else \ | ||
qemu=/Applications/Q.app/Contents/MacOS/i386-softmmu.app/Contents/MacOS/i386-softmmu; \ | ||
if test -x $$qemu; then echo $$qemu; exit; fi; fi; \ | ||
echo "***" 1>&2; \ | ||
echo "*** Error: Couldn't find a working QEMU executable." 1>&2; \ | ||
echo "*** Is the directory containing the qemu binary in your PATH" 1>&2; \ | ||
echo "*** or have you tried setting the QEMU variable in conf/env.mk?" 1>&2; \ | ||
echo "***" 1>&2; exit 1) | ||
endif | ||
|
||
# try to generate a unique GDB port | ||
GDBPORT := $(shell expr `id -u` % 5000 + 25000) | ||
|
||
CC := $(GCCPREFIX)gcc -pipe | ||
AS := $(GCCPREFIX)as | ||
AR := $(GCCPREFIX)ar | ||
LD := $(GCCPREFIX)ld | ||
OBJCOPY := $(GCCPREFIX)objcopy | ||
OBJDUMP := $(GCCPREFIX)objdump | ||
NM := $(GCCPREFIX)nm | ||
|
||
# Native commands | ||
NCC := gcc $(CC_VER) -pipe | ||
TAR := gtar | ||
PERL := perl | ||
|
||
# Compiler flags | ||
# -fno-builtin is required to avoid refs to undefined functions in the kernel. | ||
CFLAGS := $(CFLAGS) $(DEFS) $(LABDEFS) -fno-builtin -I$(TOP) -MD | ||
CFLAGS += -Wall -Wno-format -Wno-unused -Werror -gstabs -m32 | ||
|
||
# Add -fno-stack-protector if the option exists. | ||
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) | ||
|
||
# Common linker flags | ||
LDFLAGS := -m elf_i386 | ||
|
||
# Linker flags for JOS user programs | ||
ULDFLAGS := -T user/user.ld | ||
|
||
GCC_LIB := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) | ||
|
||
# Lists that the */Makefrag makefile fragments will add to | ||
OBJDIRS := | ||
|
||
# Make sure that 'all' is the first target | ||
all: | ||
|
||
# Eliminate default suffix rules | ||
.SUFFIXES: | ||
|
||
# Delete target files if there is an error (or make is interrupted) | ||
.DELETE_ON_ERROR: | ||
|
||
# make it so that no intermediate .o files are ever deleted | ||
.PRECIOUS: %.o $(OBJDIR)/boot/%.o $(OBJDIR)/kern/%.o \ | ||
$(OBJDIR)/lib/%.o $(OBJDIR)/fs/%.o $(OBJDIR)/user/%.o | ||
|
||
KERN_CFLAGS := $(CFLAGS) -DJOS_KERNEL -gstabs | ||
USER_CFLAGS := $(CFLAGS) -DJOS_USER -gstabs | ||
|
||
|
||
|
||
|
||
# Include Makefrags for subdirectories | ||
include boot/Makefrag | ||
include kern/Makefrag | ||
include lib/Makefrag | ||
include user/Makefrag | ||
|
||
|
||
IMAGES = $(OBJDIR)/kern/kernel.img | ||
QEMUOPTS = -hda $(OBJDIR)/kern/kernel.img -serial mon:stdio | ||
|
||
.gdbinit: .gdbinit.tmpl | ||
sed "s/localhost:1234/localhost:$(GDBPORT)/" < $^ > $@ | ||
|
||
qemu: $(IMAGES) | ||
$(QEMU) $(QEMUOPTS) | ||
|
||
qemu-nox: $(IMAGES) | ||
echo "*** Use Ctrl-a x to exit" | ||
$(QEMU) -nographic $(QEMUOPTS) | ||
|
||
qemu-gdb: $(IMAGES) .gdbinit | ||
@echo "*** Now run 'gdb'." 1>&2 | ||
$(QEMU) $(QEMUOPTS) -s -S -p $(GDBPORT) | ||
|
||
qemu-gdb-nox: $(IMAGES) .gdbinit | ||
@echo "*** Now run 'gdb'." 1>&2 | ||
$(QEMU) -nographic $(QEMUOPTS) -s -S -p $(GDBPORT) | ||
|
||
which-qemu: | ||
@echo $(QEMU) | ||
|
||
# For deleting the build | ||
clean: | ||
rm -rf $(OBJDIR) | ||
|
||
realclean: clean | ||
rm -rf lab$(LAB).tar.gz jos.out | ||
|
||
distclean: realclean | ||
rm -rf conf/gcc.mk | ||
|
||
grade: $(LABSETUP)grade-lab$(LAB).sh | ||
$(V)$(MAKE) clean >/dev/null 2>/dev/null | ||
$(MAKE) all | ||
sh $(LABSETUP)grade-lab$(LAB).sh | ||
|
||
handin: tarball | ||
@echo Please visit http://pdos.csail.mit.edu/cgi-bin/828handin | ||
@echo and upload lab$(LAB)-handin.tar.gz. Thanks! | ||
|
||
tarball: realclean | ||
tar cf - `find . -type f | grep -v '^\.*$$' | grep -v '/CVS/' | grep -v '/\.svn/' | grep -v '/\.git/' | grep -v 'lab[0-9].*\.tar\.gz'` | gzip > lab$(LAB)-handin.tar.gz | ||
|
||
# For test runs | ||
run-%: | ||
$(V)rm -f $(OBJDIR)/kern/init.o $(IMAGES) | ||
$(V)$(MAKE) "DEFS=-DTEST=_binary_obj_user_$*_start -DTESTSIZE=_binary_obj_user_$*_size" $(IMAGES) | ||
echo "*** Use Ctrl-a x to exit" | ||
$(QEMU) -nographic $(QEMUOPTS) | ||
|
||
xrun-%: | ||
$(V)rm -f $(OBJDIR)/kern/init.o $(IMAGES) | ||
$(V)$(MAKE) "DEFS=-DTEST=_binary_obj_user_$*_start -DTESTSIZE=_binary_obj_user_$*_size" $(IMAGES) | ||
$(QEMU) $(QEMUOPTS) | ||
|
||
# This magic automatically generates makefile dependencies | ||
# for header files included from C source files we compile, | ||
# and keeps those dependencies up-to-date every time we recompile. | ||
# See 'mergedep.pl' for more information. | ||
$(OBJDIR)/.deps: $(foreach dir, $(OBJDIRS), $(wildcard $(OBJDIR)/$(dir)/*.d)) | ||
@mkdir -p $(@D) | ||
@$(PERL) mergedep.pl $@ $^ | ||
|
||
-include $(OBJDIR)/.deps | ||
|
||
always: | ||
@: | ||
|
||
.PHONY: all always \ | ||
handin tarball clean realclean clean-labsetup distclean grade labsetup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Makefile fragment for the JOS kernel. | ||
# This is NOT a complete makefile; | ||
# you must run GNU make in the top-level directory | ||
# where the GNUmakefile is located. | ||
# | ||
|
||
OBJDIRS += boot | ||
|
||
BOOT_OBJS := $(OBJDIR)/boot/boot.o $(OBJDIR)/boot/main.o | ||
|
||
$(OBJDIR)/boot/%.o: boot/%.c | ||
@echo + cc -Os $< | ||
@mkdir -p $(@D) | ||
$(V)$(CC) -nostdinc $(KERN_CFLAGS) -Os -c -o $@ $< | ||
|
||
$(OBJDIR)/boot/%.o: boot/%.S | ||
@echo + as $< | ||
@mkdir -p $(@D) | ||
$(V)$(CC) -nostdinc $(KERN_CFLAGS) -c -o $@ $< | ||
|
||
$(OBJDIR)/boot/main.o: boot/main.c | ||
@echo + cc -Os $< | ||
$(V)$(CC) -nostdinc $(KERN_CFLAGS) -Os -c -o $(OBJDIR)/boot/main.o boot/main.c | ||
|
||
$(OBJDIR)/boot/boot: $(BOOT_OBJS) | ||
@echo + ld boot/boot | ||
$(V)$(LD) $(LDFLAGS) -N -e start -Ttext 0x7C00 -o [email protected] $^ | ||
$(V)$(OBJDUMP) -S [email protected] >[email protected] | ||
$(V)$(OBJCOPY) -S -O binary -j .text [email protected] $@ | ||
$(V)perl boot/sign.pl $(OBJDIR)/boot/boot |
Oops, something went wrong.