From f6580e9ad405b519dbe85027691bf3c66074b0a4 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 5 Sep 2004 21:55:24 +0000 Subject: [PATCH] Redo makefiles. Adjust all #include lines appropriately. --- src/Makefile.build | 93 ++++++++++++++++++++++++++++++++++++++ src/Makefile.inc | 87 ----------------------------------- src/Makefile.kernel | 15 ++++++ src/devices/16550a.h | 2 +- src/devices/disk.c | 10 ++-- src/devices/kbd.c | 8 ++-- src/devices/serial.c | 4 +- src/devices/timer.c | 6 +-- src/devices/vga.c | 6 +-- src/filesys/Makefile | 5 +- src/filesys/Makefile.vars | 2 + src/filesys/directory.c | 4 +- src/filesys/directory.h | 2 +- src/filesys/file.c | 6 +-- src/filesys/file.h | 2 +- src/filesys/filehdr.c | 8 ++-- src/filesys/filehdr.h | 2 +- src/filesys/filesys.c | 10 ++-- src/filesys/fsutil.c | 10 ++-- src/lib/bitmap.c | 4 +- src/lib/debug.c | 2 +- src/lib/hash.c | 3 +- src/lib/lib.c | 8 ++-- src/threads/Makefile | 5 +- src/threads/Makefile.vars | 2 + src/threads/init.c | 28 ++++++------ src/threads/interrupt.c | 6 +-- src/threads/intr-stubs.pl | 2 +- src/threads/malloc.c | 8 ++-- src/threads/malloc.h | 2 +- src/threads/mmu.h | 2 +- src/threads/paging.c | 2 +- src/threads/palloc.c | 6 +-- src/threads/synch.c | 2 +- src/threads/synch.h | 2 +- src/threads/thread.c | 8 ++-- src/threads/thread.h | 6 +-- src/userprog/Makefile | 5 +- src/userprog/Makefile.vars | 2 + src/userprog/addrspace.c | 18 ++++---- src/userprog/exception.c | 6 +-- src/userprog/gdt.c | 6 +-- src/userprog/gdt.h | 2 +- src/userprog/syscall.c | 6 +-- src/userprog/tss.c | 6 +-- 45 files changed, 228 insertions(+), 203 deletions(-) create mode 100644 src/Makefile.build delete mode 100644 src/Makefile.inc create mode 100644 src/Makefile.kernel create mode 100644 src/filesys/Makefile.vars create mode 100644 src/threads/Makefile.vars create mode 100644 src/userprog/Makefile.vars diff --git a/src/Makefile.build b/src/Makefile.build new file mode 100644 index 0000000..0a25309 --- /dev/null +++ b/src/Makefile.build @@ -0,0 +1,93 @@ +# -*- makefile -*- + +include ../Makefile.vars + +SHELL = /bin/sh + +CC = gcc + +SRC_ROOT = ../.. +VPATH = $(SRC_ROOT) + +WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes +INCLUDES = -I$(SRC_ROOT) +CFLAGS = -g -O3 -MMD -msoft-float $(INCLUDES) $(WARNINGS) $(DEFINES) +ASFLAGS = -Wa,--gstabs $(INCLUDES) $(DEFINES) + +# Core kernel. +threads_SRC = threads/init.c # Main program. +threads_SRC += threads/thread.c # Thread management core. +threads_SRC += threads/switch.S # Thread switch routine. +threads_SRC += threads/interrupt.c # Interrupt core. +threads_SRC += threads/intr-stubs.S # Interrupt stubs. +threads_SRC += threads/synch.c # Synchronization. +threads_SRC += threads/paging.c # Page tables. +threads_SRC += threads/palloc.c # Page allocator. +threads_SRC += threads/malloc.c # Subpage allocator. +threads_SRC += threads/start.S # Startup code. + +# Device driver code. +devices_SRC = devices/timer.c # Timer device. +devices_SRC += devices/kbd.c # Keyboard device. +devices_SRC += devices/vga.c # Video device. +devices_SRC += devices/serial.c # Serial port device. +devices_SRC += devices/disk.c # IDE disk device. + +# Library code. +lib_SRC = lib/debug.c # Debug helpers. +lib_SRC += lib/lib.c # Standard C library. +lib_SRC += lib/random.c # Pseudo-random numbers. +lib_SRC += lib/list.c # Doubly-linked lists. +lib_SRC += lib/bitmap.c # Bitmaps. +lib_SRC += lib/hash.c # Hash tables. + +# Filesystem code. +filesys_SRC = filesys/filesys.c # Filesystem core. +filesys_SRC += filesys/file.c # Files. +filesys_SRC += filesys/directory.c # Directories. +filesys_SRC += filesys/filehdr.c # File headers (inodes). +filesys_SRC += filesys/fsutil.c # Utilities. + +# User process code. +userprog_SRC = userprog/addrspace.c # Address spaces. +userprog_SRC += userprog/exception.c # User exception handler. +userprog_SRC += userprog/syscall.c # System call handler. +userprog_SRC += userprog/gdt.c # GDT initialization. +userprog_SRC += userprog/tss.c # TSS management. + +SOURCES = $(foreach dir,$(SUBDIRS),$($(dir)_SRC)) +OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES))) +DEPENDS = $(patsubst %.o,%.d,$(OBJECTS)) + +all: os.dsk + +threads/intr-stubs.S: threads/intr-stubs.pl threads/loader.h + $< > $@ + +threads/kernel.lds.s: CPPFLAGS += -P -C +threads/kernel.lds.s: threads/kernel.lds.S threads/loader.h + +kernel.o: threads/kernel.lds.s $(OBJECTS) + ld -T $< -o $@ $(OBJECTS) `$(CC) -print-libgcc-file-name` + +kernel.bin: kernel.o + objcopy -O binary -R .note -R .comment -S $< $@.tmp + $(SRC_ROOT)/pad 4096 < $@.tmp > $@ + rm $@.tmp + +threads/loader.o: threads/loader.S threads/loader.h kernel.bin + gcc -c $< -o $@ -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'` + +loader.bin: threads/loader.o + ld -N -e start -Ttext 0x7c00 --oformat binary -o $@ $< + +os.dsk: loader.bin kernel.bin + cat $^ > $@ + +clean: + rm -f $(OBJECTS) $(DEPENDS) + rm -f threads/intr-stubs.S threads/loader.o + rm -f kernel.o kernel.lds.s + rm -f kernel.bin loader.bin + +-include $(DEPENDS) diff --git a/src/Makefile.inc b/src/Makefile.inc deleted file mode 100644 index df6b010..0000000 --- a/src/Makefile.inc +++ /dev/null @@ -1,87 +0,0 @@ -# -*- makefile -*- - -SHELL = /bin/sh - -CC = gcc - -VPATH := $(TOP_SRCDIR)/threads -VPATH := $(VPATH):$(TOP_SRCDIR)/devices -VPATH := $(VPATH):$(TOP_SRCDIR)/lib -VPATH := $(VPATH):$(TOP_SRCDIR)/filesys -VPATH := $(VPATH):$(TOP_SRCDIR)/userprog - -WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes -CFLAGS = -g -O3 -MMD -msoft-float $(WARNINGS) $(INCLUDES) $(DEFINES) -ASFLAGS = -Wa,--gstabs $(INCLUDES) $(DEFINES) - -# Core kernel. -THREADS_SRC = init.c # Main program. -THREADS_SRC += thread.c # Thread management core. -THREADS_SRC += switch.S # Thread switch routine. -THREADS_SRC += interrupt.c # Interrupt core. -THREADS_SRC += intr-stubs.S # Interrupt stubs. -THREADS_SRC += synch.c # Synchronization. -THREADS_SRC += paging.c # Page tables. -THREADS_SRC += palloc.c # Page allocator. -THREADS_SRC += malloc.c # Subpage allocator. -THREADS_SRC += start.S # Startup code. - -# Device driver code. -DEVICES_SRC = timer.c # Timer device. -DEVICES_SRC += kbd.c # Keyboard device. -DEVICES_SRC += vga.c # Video device. -DEVICES_SRC += serial.c # Serial port device. -DEVICES_SRC += disk.c # IDE disk device. - -# Library code. -LIB_SRC = debug.c # Debug helpers. -LIB_SRC += lib.c # Standard C library. -LIB_SRC += random.c # Pseudo-random numbers. -LIB_SRC += list.c # Doubly-linked lists. -LIB_SRC += bitmap.c # Bitmaps. -LIB_SRC += hash.c # Hash tables. - -# Filesystem code. -FILESYS_SRC = filesys.c # Filesystem core. -FILESYS_SRC += file.c # Files. -FILESYS_SRC += directory.c # Directories. -FILESYS_SRC += filehdr.c # File headers (inodes). -FILESYS_SRC += fsutil.c # Utilities. - -# User process code. -USERPROG_SRC = addrspace.c # Address spaces. -USERPROG_SRC += exception.c # User exception handler. -USERPROG_SRC += syscall.c # System call handler. -USERPROG_SRC += gdt.c # GDT initialization. -USERPROG_SRC += tss.c # TSS management. - -# Objects. -OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES))) - -all: diskimage.bin - -intr-stubs.S: $(TOP_SRCDIR)/threads/intr-stubs.pl $(TOP_SRCDIR)/threads/loader.h - $< > $@ - -kernel.lds.s: CPPFLAGS += -P -C -kernel.lds.s: $(TOP_SRCDIR)/threads/kernel.lds.S $(TOP_SRCDIR)/threads/loader.h - -kernel.o: $(OBJECTS) kernel.lds.s - ld -T kernel.lds.s -o $@ $(OBJECTS) `$(CC) -print-libgcc-file-name` - -kernel.bin: kernel.o - objcopy -O binary -R .note -R .comment -S $< $@.tmp - $(TOP_SRCDIR)/pad 4096 < $@.tmp > $@ - -loader.bin: loader.S loader.h kernel.bin - gcc -c $< -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'` - ld -N -e start -Ttext 0x7c00 --oformat binary -o $@ loader.o - -diskimage.bin: loader.bin kernel.bin - cat loader.bin kernel.bin > diskimage.bin - -clean: - rm -f *.o *.d *.bin - rm -f kernel.bin.data kernel.bin.pad intr-stubs.S kernel.lds.s - --include *.d diff --git a/src/Makefile.kernel b/src/Makefile.kernel new file mode 100644 index 0000000..9337203 --- /dev/null +++ b/src/Makefile.kernel @@ -0,0 +1,15 @@ +include Makefile.vars +BUILD_SUBDIRS = $(addprefix build/, $(SUBDIRS)) + +all: build build/Makefile $(BUILD_SUBDIRS) + $(MAKE) -C build + +$(BUILD_SUBDIRS): + mkdir $@ +build: + mkdir $@ +build/Makefile: ../Makefile.build + cp $< $@ + +clean: + rm -rf build diff --git a/src/devices/16550a.h b/src/devices/16550a.h index bfe9484..9a1e37d 100644 --- a/src/devices/16550a.h +++ b/src/devices/16550a.h @@ -3,7 +3,7 @@ #include #include -#include "debug.h" +#include "lib/debug.h" /* Register definitions for the 16550A UART used in PCs. This is a full definition of all the registers and their bits. We diff --git a/src/devices/disk.c b/src/devices/disk.c index dc0c181..9e4b9f5 100644 --- a/src/devices/disk.c +++ b/src/devices/disk.c @@ -1,11 +1,11 @@ #include "disk.h" #include -#include "debug.h" -#include "io.h" -#include "interrupt.h" -#include "lib.h" -#include "synch.h" #include "timer.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "threads/io.h" +#include "threads/interrupt.h" +#include "threads/synch.h" /* ATA command block port addresses. */ #define reg_data(CHANNEL) ((CHANNEL)->reg_base + 0) /* Data. */ diff --git a/src/devices/kbd.c b/src/devices/kbd.c index 0bd2d99..867c64a 100644 --- a/src/devices/kbd.c +++ b/src/devices/kbd.c @@ -1,8 +1,8 @@ #include "kbd.h" -#include "debug.h" -#include "interrupt.h" -#include "io.h" -#include "lib.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "threads/interrupt.h" +#include "threads/io.h" static void irq21_keyboard (struct intr_frame *args UNUSED) diff --git a/src/devices/serial.c b/src/devices/serial.c index e5b2fb7..eeac40a 100644 --- a/src/devices/serial.c +++ b/src/devices/serial.c @@ -1,8 +1,8 @@ #include "serial.h" #include "16550a.h" -#include "debug.h" -#include "io.h" #include "timer.h" +#include "lib/debug.h" +#include "threads/io.h" static void set_serial (int bps, int bits, enum parity_type parity, int stop); diff --git a/src/devices/timer.c b/src/devices/timer.c index d23bed3..85bc3ee 100644 --- a/src/devices/timer.c +++ b/src/devices/timer.c @@ -1,7 +1,7 @@ #include "timer.h" -#include "debug.h" -#include "interrupt.h" -#include "io.h" +#include "lib/debug.h" +#include "threads/interrupt.h" +#include "threads/io.h" #if TIMER_FREQ < 19 #error 8254 timer requires TIMER_FREQ >= 19 diff --git a/src/devices/vga.c b/src/devices/vga.c index fdddd91..fcdc689 100644 --- a/src/devices/vga.c +++ b/src/devices/vga.c @@ -1,9 +1,9 @@ #include "vga.h" #include #include -#include "io.h" -#include "lib.h" -#include "mmu.h" +#include "lib/lib.h" +#include "threads/io.h" +#include "threads/mmu.h" /* VGA text screen support. See [FREEVGA] for more information. */ diff --git a/src/filesys/Makefile b/src/filesys/Makefile index 495615d..bc2307b 100644 --- a/src/filesys/Makefile +++ b/src/filesys/Makefile @@ -1,3 +1,2 @@ -all: -%: - $(MAKE) -C build $@ +include Makefile.vars +include ../Makefile.kernel diff --git a/src/filesys/Makefile.vars b/src/filesys/Makefile.vars new file mode 100644 index 0000000..db29a74 --- /dev/null +++ b/src/filesys/Makefile.vars @@ -0,0 +1,2 @@ +DEFINES = -DUSERPROG -DFILESYS +SUBDIRS = threads devices lib userprog filesys diff --git a/src/filesys/directory.c b/src/filesys/directory.c index 1384d8d..32911b8 100644 --- a/src/filesys/directory.c +++ b/src/filesys/directory.c @@ -1,8 +1,8 @@ #include "directory.h" #include "file.h" #include "fsutil.h" -#include "lib.h" -#include "malloc.h" +#include "lib/lib.h" +#include "threads/malloc.h" /* Initializes D as a directory that holds ENTRY_CNT entries. */ bool diff --git a/src/filesys/directory.h b/src/filesys/directory.h index f5f5ebd..a3364ae 100644 --- a/src/filesys/directory.h +++ b/src/filesys/directory.h @@ -3,7 +3,7 @@ #include #include -#include "disk.h" +#include "devices/disk.h" /* Maximum length of a filename. This is the traditional UNIX maximum. diff --git a/src/filesys/file.c b/src/filesys/file.c index 323470e..a40c073 100644 --- a/src/filesys/file.c +++ b/src/filesys/file.c @@ -1,10 +1,10 @@ #include "file.h" -#include "debug.h" -#include "lib.h" -#include "malloc.h" #include "directory.h" #include "filehdr.h" #include "filesys.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "threads/malloc.h" bool file_open (struct file *file, disk_sector_t hdr_sector) diff --git a/src/filesys/file.h b/src/filesys/file.h index c3cde12..afa1990 100644 --- a/src/filesys/file.h +++ b/src/filesys/file.h @@ -4,7 +4,7 @@ #include #include #include -#include "disk.h" +#include "devices/disk.h" #include "off_t.h" struct file diff --git a/src/filesys/filehdr.c b/src/filesys/filehdr.c index d7d2cc2..eafe211 100644 --- a/src/filesys/filehdr.c +++ b/src/filesys/filehdr.c @@ -1,9 +1,9 @@ #include "filehdr.h" -#include "bitmap.h" -#include "debug.h" -#include "malloc.h" #include "filesys.h" -#include "lib.h" +#include "lib/bitmap.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "threads/malloc.h" /* Allocates sectors from bitmap B for the content of a file whose size is LENGTH bytes, and returns a new `struct filehdr' diff --git a/src/filesys/filehdr.h b/src/filesys/filehdr.h index 235a1e6..cb28416 100644 --- a/src/filesys/filehdr.h +++ b/src/filesys/filehdr.h @@ -3,8 +3,8 @@ #include #include -#include "disk.h" #include "off_t.h" +#include "devices/disk.h" /* Number of direct sector pointers in a file header. */ #define DIRECT_CNT ((DISK_SECTOR_SIZE - sizeof (off_t) * 2) \ diff --git a/src/filesys/filesys.c b/src/filesys/filesys.c index 57dab76..77284ad 100644 --- a/src/filesys/filesys.c +++ b/src/filesys/filesys.c @@ -27,13 +27,13 @@ */ #include "filesys.h" -#include "bitmap.h" -#include "debug.h" -#include "directory.h" -#include "disk.h" #include "file.h" #include "filehdr.h" -#include "lib.h" +#include "directory.h" +#include "devices/disk.h" +#include "lib/bitmap.h" +#include "lib/debug.h" +#include "lib/lib.h" /* Filesystem. diff --git a/src/filesys/fsutil.c b/src/filesys/fsutil.c index 67dab6f..6598785 100644 --- a/src/filesys/fsutil.c +++ b/src/filesys/fsutil.c @@ -1,11 +1,11 @@ #include "fsutil.h" #include -#include "debug.h" -#include "filesys.h" #include "file.h" -#include "lib.h" -#include "mmu.h" -#include "palloc.h" +#include "filesys.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "threads/mmu.h" +#include "threads/palloc.h" /* Filename and file size to use for copy operations, as "filename:size". */ diff --git a/src/lib/bitmap.c b/src/lib/bitmap.c index 8357d2e..eb18a49 100644 --- a/src/lib/bitmap.c +++ b/src/lib/bitmap.c @@ -3,9 +3,9 @@ #include #include "debug.h" #include "lib.h" -#include "malloc.h" +#include "threads/malloc.h" #ifdef FILESYS -#include "file.h" +#include "filesys/file.h" #endif /* Number of bits in an element. */ diff --git a/src/lib/debug.c b/src/lib/debug.c index 534fc02..babf229 100644 --- a/src/lib/debug.c +++ b/src/lib/debug.c @@ -1,7 +1,7 @@ #include "debug.h" #include -#include "interrupt.h" #include "lib.h" +#include "threads/interrupt.h" #define MAX_CLASSES 16 static bool all_enabled; diff --git a/src/lib/hash.c b/src/lib/hash.c index 665fd09..a6b18a9 100644 --- a/src/lib/hash.c +++ b/src/lib/hash.c @@ -1,5 +1,6 @@ #include "hash.h" -#include "malloc.h" +#include "debug.h" +#include "threads/malloc.h" static struct list *find_bucket (struct hash *, hash_elem *); static struct list_elem *find_elem (struct hash *, struct list *, hash_elem *); diff --git a/src/lib/lib.c b/src/lib/lib.c index 8fe5161..91fb318 100644 --- a/src/lib/lib.c +++ b/src/lib/lib.c @@ -1,12 +1,12 @@ +#include "lib.h" #include #include #include #include #include "debug.h" -#include "interrupt.h" -#include "lib.h" -#include "serial.h" -#include "vga.h" +#include "devices/serial.h" +#include "devices/vga.h" +#include "threads/interrupt.h" static void vprintf_core (const char *format, va_list args, diff --git a/src/threads/Makefile b/src/threads/Makefile index 495615d..bc2307b 100644 --- a/src/threads/Makefile +++ b/src/threads/Makefile @@ -1,3 +1,2 @@ -all: -%: - $(MAKE) -C build $@ +include Makefile.vars +include ../Makefile.kernel diff --git a/src/threads/Makefile.vars b/src/threads/Makefile.vars new file mode 100644 index 0000000..1ec24db --- /dev/null +++ b/src/threads/Makefile.vars @@ -0,0 +1,2 @@ +DEFINES = +SUBDIRS = threads devices lib diff --git a/src/threads/init.c b/src/threads/init.c index 57f3cbe..57d5301 100644 --- a/src/threads/init.c +++ b/src/threads/init.c @@ -2,31 +2,31 @@ #include #include #include -#include "debug.h" #include "interrupt.h" #include "io.h" -#include "kbd.h" -#include "lib.h" #include "loader.h" #include "malloc.h" #include "mmu.h" #include "paging.h" #include "palloc.h" -#include "random.h" -#include "serial.h" #include "thread.h" -#include "timer.h" -#include "vga.h" +#include "devices/kbd.h" +#include "devices/serial.h" +#include "devices/timer.h" +#include "devices/vga.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "lib/random.h" #ifdef USERPROG -#include "exception.h" -#include "syscall.h" -#include "gdt.h" -#include "tss.h" +#include "userprog/exception.h" +#include "userprog/gdt.h" +#include "userprog/syscall.h" +#include "userprog/tss.h" #endif #ifdef FILESYS -#include "filesys.h" -#include "disk.h" -#include "fsutil.h" +#include "devices/disk.h" +#include "filesys/filesys.h" +#include "filesys/fsutil.h" #endif /* Amount of physical memory, in 4 kB pages. */ diff --git a/src/threads/interrupt.c b/src/threads/interrupt.c index eb10cd6..4c7ec9e 100644 --- a/src/threads/interrupt.c +++ b/src/threads/interrupt.c @@ -2,12 +2,12 @@ #include #include #include "intr-stubs.h" -#include "debug.h" #include "io.h" -#include "lib.h" #include "mmu.h" #include "thread.h" -#include "timer.h" +#include "devices/timer.h" +#include "lib/debug.h" +#include "lib/lib.h" /* Number of x86 interrupts. */ #define INTR_CNT 256 diff --git a/src/threads/intr-stubs.pl b/src/threads/intr-stubs.pl index a52f379..c333260 100755 --- a/src/threads/intr-stubs.pl +++ b/src/threads/intr-stubs.pl @@ -1,7 +1,7 @@ #! /usr/bin/perl print <<'EOF'; -#include "loader.h" +#include "threads/loader.h" .data .globl intr_stubs diff --git a/src/threads/malloc.c b/src/threads/malloc.c index 7af1156..28f2324 100644 --- a/src/threads/malloc.c +++ b/src/threads/malloc.c @@ -1,11 +1,11 @@ #include "malloc.h" #include -#include "debug.h" -#include "lib.h" -#include "list.h" -#include "synch.h" #include "mmu.h" #include "palloc.h" +#include "synch.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "lib/list.h" /* A simple implementation of malloc(). diff --git a/src/threads/malloc.h b/src/threads/malloc.h index 1fb531f..4a3bee7 100644 --- a/src/threads/malloc.h +++ b/src/threads/malloc.h @@ -1,7 +1,7 @@ #ifndef HEADER_MALLOC_H #define HEADER_MALLOC_H -#include "debug.h" +#include "lib/debug.h" #include void malloc_init (void); diff --git a/src/threads/mmu.h b/src/threads/mmu.h index 4a32b73..7e68b29 100644 --- a/src/threads/mmu.h +++ b/src/threads/mmu.h @@ -3,7 +3,7 @@ #ifndef __ASSEMBLER__ #include -#include "debug.h" +#include "lib/debug.h" #endif #include "loader.h" diff --git a/src/threads/paging.c b/src/threads/paging.c index a86969b..ca5f4b4 100644 --- a/src/threads/paging.c +++ b/src/threads/paging.c @@ -2,9 +2,9 @@ #include #include #include "init.h" -#include "lib.h" #include "mmu.h" #include "palloc.h" +#include "lib/lib.h" static uint32_t *base_page_dir; diff --git a/src/threads/palloc.c b/src/threads/palloc.c index 2b07ad7..e3cfafb 100644 --- a/src/threads/palloc.c +++ b/src/threads/palloc.c @@ -1,13 +1,13 @@ #include "palloc.h" #include #include -#include "debug.h" #include "init.h" #include "loader.h" -#include "lib.h" -#include "list.h" #include "mmu.h" #include "synch.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "lib/list.h" /* Page allocator. Hands out memory in page-size chunks. See malloc.h for an allocator that hands out smaller diff --git a/src/threads/synch.c b/src/threads/synch.c index d7601da..7993543 100644 --- a/src/threads/synch.c +++ b/src/threads/synch.c @@ -28,8 +28,8 @@ #include "synch.h" #include "interrupt.h" -#include "lib.h" #include "thread.h" +#include "lib/lib.h" /* Initializes semaphore SEMA to VALUE and names it NAME (for debugging purposes only). A semaphore is a nonnegative diff --git a/src/threads/synch.h b/src/threads/synch.h index d21ecff..c74ba68 100644 --- a/src/threads/synch.h +++ b/src/threads/synch.h @@ -2,7 +2,7 @@ #define HEADER_SYNCH_H 1 #include -#include "list.h" +#include "lib/list.h" /* A counting semaphore. */ struct semaphore diff --git a/src/threads/thread.c b/src/threads/thread.c index 61351b5..f24f1fe 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -1,15 +1,15 @@ #include "thread.h" #include -#include "debug.h" #include "interrupt.h" #include "intr-stubs.h" -#include "lib.h" #include "mmu.h" #include "palloc.h" -#include "random.h" #include "switch.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "lib/random.h" #ifdef USERPROG -#include "gdt.h" +#include "userprog/gdt.h" #endif /* Value for struct thread's `magic' member. diff --git a/src/threads/thread.h b/src/threads/thread.h index 421751b..27c1f04 100644 --- a/src/threads/thread.h +++ b/src/threads/thread.h @@ -2,11 +2,11 @@ #define HEADER_THREAD_H 1 #include -#include "debug.h" -#include "list.h" +#include "lib/debug.h" +#include "lib/list.h" #ifdef USERPROG -#include "addrspace.h" +#include "userprog/addrspace.h" #endif /* States in a thread's life cycle. */ diff --git a/src/userprog/Makefile b/src/userprog/Makefile index 495615d..bc2307b 100644 --- a/src/userprog/Makefile +++ b/src/userprog/Makefile @@ -1,3 +1,2 @@ -all: -%: - $(MAKE) -C build $@ +include Makefile.vars +include ../Makefile.kernel diff --git a/src/userprog/Makefile.vars b/src/userprog/Makefile.vars new file mode 100644 index 0000000..db29a74 --- /dev/null +++ b/src/userprog/Makefile.vars @@ -0,0 +1,2 @@ +DEFINES = -DUSERPROG -DFILESYS +SUBDIRS = threads devices lib userprog filesys diff --git a/src/userprog/addrspace.c b/src/userprog/addrspace.c index 2574c31..bb2dc60 100644 --- a/src/userprog/addrspace.c +++ b/src/userprog/addrspace.c @@ -1,15 +1,15 @@ #include "addrspace.h" #include -#include "debug.h" -#include "file.h" -#include "filesys.h" -#include "init.h" -#include "lib.h" -#include "mmu.h" -#include "paging.h" -#include "palloc.h" -#include "thread.h" #include "tss.h" +#include "filesys/file.h" +#include "filesys/filesys.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "threads/init.h" +#include "threads/mmu.h" +#include "threads/paging.h" +#include "threads/palloc.h" +#include "threads/thread.h" /* We load ELF binaries. The following definitions are taken from the ELF specification, [ELF1], more-or-less verbatim. */ diff --git a/src/userprog/exception.c b/src/userprog/exception.c index 6383a4b..0d5461a 100644 --- a/src/userprog/exception.c +++ b/src/userprog/exception.c @@ -1,9 +1,9 @@ #include "exception.h" #include -#include "lib.h" #include "gdt.h" -#include "interrupt.h" -#include "thread.h" +#include "lib/lib.h" +#include "threads/interrupt.h" +#include "threads/thread.h" static void kill (struct intr_frame *); static void page_fault (struct intr_frame *); diff --git a/src/userprog/gdt.c b/src/userprog/gdt.c index c122849..4e338f7 100644 --- a/src/userprog/gdt.c +++ b/src/userprog/gdt.c @@ -1,8 +1,8 @@ #include "gdt.h" -#include "debug.h" -#include "mmu.h" -#include "palloc.h" #include "tss.h" +#include "lib/debug.h" +#include "threads/mmu.h" +#include "threads/palloc.h" /* The Global Descriptor Table (GDT). diff --git a/src/userprog/gdt.h b/src/userprog/gdt.h index ae89681..599e40e 100644 --- a/src/userprog/gdt.h +++ b/src/userprog/gdt.h @@ -1,7 +1,7 @@ #ifndef HEADER_GDT_H #define HEADER_GDT_H 1 -#include "loader.h" +#include "threads/loader.h" /* Segment selectors. More selectors are defined by the loader in loader.h. */ diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 6084726..e6dfe94 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -1,7 +1,7 @@ #include "syscall.h" -#include "lib.h" -#include "interrupt.h" -#include "thread.h" +#include "lib/lib.h" +#include "threads/interrupt.h" +#include "threads/thread.h" static void syscall_handler (struct intr_frame *); diff --git a/src/userprog/tss.c b/src/userprog/tss.c index 4b32d85..69113e4 100644 --- a/src/userprog/tss.c +++ b/src/userprog/tss.c @@ -1,9 +1,9 @@ #include "tss.h" #include -#include "debug.h" #include "gdt.h" -#include "mmu.h" -#include "palloc.h" +#include "lib/debug.h" +#include "threads/mmu.h" +#include "threads/palloc.h" /* The Task-State Segment (TSS). -- 2.30.2