5 all: kernel.bin loader.bin
7 include ../../Make.config
9 include ../../tests/Make.tests
11 # Compiler and assembler options.
12 kernel.bin: CPPFLAGS += -I$(SRCDIR)/lib/kernel
15 threads_SRC = threads/start.S # Startup code.
16 threads_SRC += threads/init.c # Main program.
17 threads_SRC += threads/thread.c # Thread management core.
18 threads_SRC += threads/switch.S # Thread switch routine.
19 threads_SRC += threads/interrupt.c # Interrupt core.
20 threads_SRC += threads/intr-stubs.S # Interrupt stubs.
21 threads_SRC += threads/synch.c # Synchronization.
22 threads_SRC += threads/palloc.c # Page allocator.
23 threads_SRC += threads/malloc.c # Subpage allocator.
26 devices_SRC = devices/pit.c # Programmable interrupt timer chip.
27 devices_SRC += devices/timer.c # Periodic timer device.
28 devices_SRC += devices/kbd.c # Keyboard device.
29 devices_SRC += devices/vga.c # Video device.
30 devices_SRC += devices/serial.c # Serial port device.
31 devices_SRC += devices/block.c # Block device abstraction layer.
32 devices_SRC += devices/partition.c # Partition block device.
33 devices_SRC += devices/ide.c # IDE disk block device.
34 devices_SRC += devices/input.c # Serial and keyboard input.
35 devices_SRC += devices/intq.c # Interrupt queue.
36 devices_SRC += devices/rtc.c # Real-time clock.
37 devices_SRC += devices/shutdown.c # Reboot and power off.
38 devices_SRC += devices/speaker.c # PC speaker.
39 devices_SRC += devices/pci.c # PCI bus.
40 devices_SRC += devices/usb.c # USB layer.
41 devices_SRC += devices/usb_uhci.c # UHCI device.
42 devices_SRC += devices/usb_ehci.c # EHCI device.
43 devices_SRC += devices/usb_storage.c # USB mass storage class driver.
44 devices_SRC += devices/usb_hub.c # USB hub class driver.
46 # Library code shared between kernel and user programs.
47 lib_SRC = lib/debug.c # Debug helpers.
48 lib_SRC += lib/random.c # Pseudo-random numbers.
49 lib_SRC += lib/stdio.c # I/O library.
50 lib_SRC += lib/stdlib.c # Utility functions.
51 lib_SRC += lib/string.c # String functions.
52 lib_SRC += lib/arithmetic.c # 64-bit arithmetic for GCC.
53 lib_SRC += lib/ustar.c # Unix standard tar format utilities.
55 # Kernel-specific library code.
56 lib/kernel_SRC = lib/kernel/debug.c # Debug helpers.
57 lib/kernel_SRC += lib/kernel/list.c # Doubly-linked lists.
58 lib/kernel_SRC += lib/kernel/bitmap.c # Bitmaps.
59 lib/kernel_SRC += lib/kernel/hash.c # Hash tables.
60 lib/kernel_SRC += lib/kernel/console.c # printf(), putchar().
63 userprog_SRC = userprog/process.c # Process loading.
64 userprog_SRC += userprog/pagedir.c # Page directories.
65 userprog_SRC += userprog/exception.c # User exception handler.
66 userprog_SRC += userprog/syscall.c # System call handler.
67 userprog_SRC += userprog/gdt.c # GDT initialization.
68 userprog_SRC += userprog/tss.c # TSS management.
70 # No virtual memory code yet.
71 #vm_SRC = vm/file.c # Some file.
74 filesys_SRC = filesys/filesys.c # Filesystem core.
75 filesys_SRC += filesys/free-map.c # Free sector bitmap.
76 filesys_SRC += filesys/file.c # Files.
77 filesys_SRC += filesys/directory.c # Directories.
78 filesys_SRC += filesys/inode.c # File headers.
79 filesys_SRC += filesys/fsutil.c # Utilities.
81 SOURCES = $(foreach dir,$(KERNEL_SUBDIRS),$($(dir)_SRC))
82 OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES)))
83 DEPENDS = $(patsubst %.o,%.d,$(OBJECTS))
85 threads/kernel.lds.s: CPPFLAGS += -P
86 threads/kernel.lds.s: threads/kernel.lds.S threads/loader.h
88 kernel.o: threads/kernel.lds.s $(OBJECTS)
89 $(LD) -T $< -o $@ $(OBJECTS)
92 $(OBJCOPY) -R .note -R .comment -S $< $@
94 threads/loader.o: threads/loader.S
95 $(CC) -c $< -o $@ $(ASFLAGS) $(CPPFLAGS) $(DEFINES)
97 loader.bin: threads/loader.o
98 $(LD) -N -e 0 -Ttext 0x7c00 --oformat binary -o $@ $<
104 rm -f $(OBJECTS) $(DEPENDS)
105 rm -f threads/loader.o threads/kernel.lds.s threads/loader.d
107 rm -f kernel.o kernel.lds.s
108 rm -f kernel.bin loader.bin
109 rm -f bochsout.txt bochsrc.txt
112 Makefile: $(SRCDIR)/Makefile.build