Index: code/build.freebsd/Makefile =================================================================== RCS file: code/build.freebsd/Makefile diff -N code/build.freebsd/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ code/build.freebsd/Makefile 12 Nov 2004 20:08:15 -0000 1.4 @@ -0,0 +1,370 @@ +# Copyright (c) 1992-1996 The Regents of the University of California. +# All rights reserved. See copyright.h for copyright notice and limitation +# of liability and disclaimer of warranty provisions. +# +# This is a GNU Makefile. It must be used with the GNU make program. +# At UW, the GNU make program is /software/gnu/bin/make. +# In many other places it is known as "gmake". +# You may wish to include /software/gnu/bin/ early in your command +# search path, so that you will be using GNU make when you type "make". +# +# About this Makefile: +# -------------------- +# +# This Makefile is used to build the Nachos system, which includes +# the MIPS machine simulation and a simple operating system. +# +# There is a separate Makefile, in the "test" directory, that is +# used to build the Nachos test programs (which run on the +# simulated machine). +# +# There are several "build" directories, one for each type +# of machine in the MFCF computing environment +# (build.solaris, build.sunos, and build.ultrix), as well +# as a build directory for Linux (build.linux) and a generic +# build directory (build.other) for those who wish to try +# building Nachos on other platforms. +# +# This Makefile appears to be located in all of the build directories. +# If you edit it in one directory, the copies in all of the other +# directories appear to change as well. This is the desired behaviour, +# since this file is machine independent. (The file actually lives +# in build.solaris, with symbolic links from the other build directories.) +# +# The platform-dependent parts of make's instructions are located +# in the file Makefile.dep. +# There is a different Makefile.dep in each build directory. +# +# If you are in the MFCF environment, you should not have to edit +# the Makefile.dep files by hand. Any changes to the make instructions +# can be made in this file (see the instructions below) - they will +# apply no matter where you build Nachos. +# If you are not in the MFCF environment, e.g., if you are trying +# to build Nachos on Linux at home, you will probably need +# to edit Makefile.dep (in the appropriate build directory) to +# customize the make procedure to your environment. +# +# How to build Nachos for the first time: +# --------------------------------------- +# +# (1) Make sure than you are in the build directory for the +# type of machine you are logged in to (the "host" machine): +# +# host type examples build directory +# ----------- ----------- ---------------- +# +# sparc/SunOS cayley,napier, build.sunos +# (SunOS 4.1.3) descartes +# +# sparc/Solaris picard.math, build.solaris +# (SunOS 5.x) hermite.math, +# markov.math, +# hypatia.math, +# hume.math +# +# mips/ULTRIX cantor.math build.ultrix +# (ULTRIX 4.2) noether.math +# +# If you are not sure what type of machine you are on, +# try the command "uname -a". +# +# (2) Type "make depend" +# - this computes file dependencies and records them +# at the end of the file Makefile.dep in +# your build directory. Have a look... +# +# (3) Type "make nachos" (or just "make"). +# - make echos the commands it is executing, so that +# you can observe its progress. When the +# build is finished, you should have an +# executable "nachos" in the build directory. +# +# (4) There is no 4th step. You are done. Try running "./nachos -u". +# +# +# How to Re-build Nachos after you have changed the code: +#-------------------------------------------------------- +# +# - The Nachos source code is located in the code subdirectories: +# threads, userprog, filesys, network, and lib. You may +# change the files in any of these directories, and you can +# add new files and/or remove files. The "machine" subdirectory +# contains the hardware simulation (which is also part of +# Nachos. You may look at it, but +# you may not change it, except as noted in machine/machine.h +# - When you want to re-make Nachos, always do it in the +# "build" directory that is appropriate for the machine +# type that you are running on. +# DO NOT TRY TO MAKE NACHOS IN THE SOURCE CODE DIRECTORIES. +# +# - IF all you have done is changed C++ code in existing files +# (since the last time you made Nachos in this build directory), +# THEN all you need to do to re-make Nachos is to type +# +# "make nachos" +# +# in the build directory. +# +# - IF you have done any of the following since the last build in +# this directory: +# added new .cc files or new .h files +# added or deleted #include's from existing files +# THEN +# you must do +# "make depend" +# followed by +# "make nachos" +# +# in the build directory. +# +# Note that is is always safe to do "make depend" followed by +# "make nachos", so if you are not sure what changes you have +# made, do "make depend". +# +# - IF you have added new files (.cc or .h) since the last build, +# you should edit this Makefile before running "make depend" +# and "make nachos". + +# For new .h files, simply update the appropriate "_H" list below. +# For example, if you create a file called +# "bigfile.h" in the filesys subdirectory, you should add +# "../filesys/bigfile.h" to FILESYS_H, which is defined below + +# For new .cc files, update the appropriate "_C" and "_O" lists. +# For example, if you create a file called "filetable.cc" in +# the directory "userprog", you should add +# "../userprog/filetable.cc" to USERPROG_C, +# and you should add "filetable.o" to USERPROG_O. +# Note that the entry in the "_C" list includes the subdirectory +# name, while the entry on the "_O" list does not. +# +# Some Important Notes: +# --------------------- +# +# * You can clean up all of the .o and other files left behind +# by make by typeing "make clean" in the build directory. +# * You can clean up .o and other files, as well as the nachos +# executable, DISK, core, SOCKET, and other files by typing +# make "distclean" +# +# These are good ways to save space, but the next build that +# you do after cleaning will take longer than usual, since +# much of the stuff you cleaned will need to be rebuilt. +# +# * When you build Nachos on an ULTRIX machine (in build.ultrix), +# you will get lots of warning messages like this: +# +# openfile.o: does not have gp tables for all it's sectons +# +# from the loader. Ignore them. Or better yet, figure out +# how to make them go away. +# +# The Most Important Note: +# ----------------------- +# +# * If "make" is behaving strangely and you cannot figure out +# why, you should REBUILD the program FROM SCRATCH. +# Yes, it is slow. +# But, there are lots of little things that can go wrong, especially +# with all of these different types of machines available. +# Rebuilding from scratch at least gives you a known starting +# place. To rebuild from scratch, go to the appropriate +# build directory and do: +# +# make distclean +# make depend +# make nachos +# +################################################################ +# READ THIS: CONFIGURING NACHOS +# +# Change DEFINES (below) to +# DEFINES = -DUSE_TLB -DFILESYS_STUB +# if you want the simulated machine to use its TLB +# +# If you want to use the real Nachos file system (based on +# the simulated disk), rather than the stub, remove +# the -DFILESYS_STUB from DEFINES. +# +# There is a a fix to the MIPS simulator to enable it to properly +# handle unaligned data access. This fix is enabled by the addition +# of "-DSIM_FIX" to the DEFINES. This should be enabled by default +# and eventually will not require the symbol definition +################################################################ +DEFINES = -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT + + +##################################################################### +# +# You might want to play with the CFLAGS, but if you use -O it may +# break the thread system. You might want to use -fno-inline if +# you need to call some inline functions from the debugger. + +#CFLAGS = -ftemplate-depth-100 -Wno-deprecated -g -Wall -fwritable-strings $(INCPATH) $(DEFINES) $(HOSTCFLAGS) -DCHANGED +CFLAGS = -ftemplate-depth-100 -Wno-deprecated -g -fwritable-strings $(INCPATH) $(DEFINES) $(HOSTCFLAGS) -DCHANGED +LDFLAGS = + +##################################################################### +CPP=/lib/cpp +CC = g++ +LD = g++ +AS = as +RM = /bin/rm + +INCPATH = -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib + +PROGRAM = nachos + +# +# Edit these lists as if you add files to the source directories. +# See the instructions at the top of the file for more information. +# + +LIB_H = ../lib/bitmap.h\ + ../lib/copyright.h\ + ../lib/debug.h\ + ../lib/hash.h\ + ../lib/libtest.h\ + ../lib/list.h\ + ../lib/sysdep.h\ + ../lib/tut.h\ + ../lib/tut_reporter.h\ + ../lib/utility.h + +LIB_C = ../lib/bitmap.cc\ + ../lib/debug.cc\ + ../lib/hash.cc\ + ../lib/libtest.cc\ + ../lib/list.cc\ + ../lib/sysdep.cc + +LIB_O = bitmap.o debug.o libtest.o sysdep.o + + +MACHINE_H = ../machine/callback.h\ + ../machine/interrupt.h\ + ../machine/stats.h\ + ../machine/timer.h\ + ../machine/console.h\ + ../machine/machine.h\ + ../machine/mipssim.h\ + ../machine/translate.h\ + ../machine/network.h\ + ../machine/disk.h + +MACHINE_C = ../machine/interrupt.cc\ + ../machine/stats.cc\ + ../machine/timer.cc\ + ../machine/console.cc\ + ../machine/machine.cc\ + ../machine/mipssim.cc\ + ../machine/translate.cc\ + ../machine/network.cc\ + ../machine/disk.cc + +MACHINE_O = interrupt.o stats.o timer.o console.o machine.o mipssim.o\ + translate.o network.o disk.o + +THREAD_H = ../threads/alarm.h\ + ../threads/kernel.h\ + ../threads/main.h\ + ../threads/scheduler.h\ + ../threads/switch.h\ + ../threads/synch.h\ + ../threads/synchlist.h\ + ../threads/thread.h + +THREAD_C = ../threads/alarm.cc\ + ../threads/kernel.cc\ + ../threads/main.cc\ + ../threads/scheduler.cc\ + ../threads/synch.cc\ + ../threads/synchlist.cc\ + ../threads/thread.cc + +THREAD_O = alarm.o kernel.o main.o scheduler.o synch.o thread.o + +USERPROG_H = ../userprog/addrspace.h\ + ../userprog/syscall.h\ + ../userprog/synchconsole.h\ + ../userprog/noff.h + +USERPROG_C = ../userprog/addrspace.cc\ + ../userprog/exception.cc\ + ../userprog/synchconsole.cc + +USERPROG_O = addrspace.o exception.o synchconsole.o + +FILESYS_H =../filesys/directory.h \ + ../filesys/filehdr.h\ + ../filesys/filesys.h \ + ../filesys/openfile.h\ + ../filesys/pbitmap.h\ + ../filesys/synchdisk.h + +FILESYS_C =../filesys/directory.cc\ + ../filesys/filehdr.cc\ + ../filesys/filesys.cc\ + ../filesys/pbitmap.cc\ + ../filesys/openfile.cc\ + ../filesys/synchdisk.cc\ + +FILESYS_O =directory.o filehdr.o filesys.o pbitmap.o openfile.o synchdisk.o + +NETWORK_H = ../network/post.h + +NETWORK_C = ../network/post.cc + +NETWORK_O = post.o + +################################################################## +# You probably don't want to change anything below this point in +# the file unless you are comfortable with GNU make and know what +# you are doing... +################################################################## + +THREAD_S = ../threads/switch.s + +HFILES = $(LIB_H) $(MACHINE_H) $(THREAD_H) $(USERPROG_H) $(FILESYS_H) $(NETWORK_H) +CFILES = $(LIB_C) $(MACHINE_C) $(THREAD_C) $(USERPROG_C) $(FILESYS_C) $(NETWORK_C) + +C_OFILES = $(LIB_O) $(MACHINE_O) $(THREAD_O) $(USERPROG_O) $(FILESYS_O) $(NETWORK_O) + +S_OFILES = switch.o +OFILES = $(C_OFILES) $(S_OFILES) + +$(PROGRAM): $(OFILES) + $(LD) $(OFILES) $(LDFLAGS) -o $(PROGRAM) + +$(C_OFILES): %.o: + $(CC) $(CFLAGS) -c $< + +switch.o: ../threads/switch.s + cat ../threads/switch.s > swtch.S + $(CPP) $(CPP_AS_FLAGS) -E -P $(INCPATH) $(HOSTCFLAGS) -I../threads swtch.S > swtch.s + $(AS) -o switch.o swtch.s + +depend: $(CFILES) $(HFILES) + $(CC) $(INCPATH) $(DEFINES) $(HOSTCFLAGS) -DCHANGED -M $(CFILES) > makedep + @echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep + @echo '$$r makedep' >>eddep + @echo 'w' >>eddep + @echo 'q' >>eddep + ed - Makefile.dep < eddep + rm eddep makedep + @echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile.dep + @echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.dep + @echo '# see make depend above' >> Makefile.dep + +clean: + $(RM) -f $(OFILES) + $(RM) -f swtch.s + $(RM) -f swtch.S + +distclean: clean + $(RM) -f $(PROGRAM) + $(RM) -f DISK_? + $(RM) -f core + $(RM) -f SOCKET_? + +include Makefile.dep Index: code/build.freebsd/Makefile.dep =================================================================== RCS file: code/build.freebsd/Makefile.dep diff -N code/build.freebsd/Makefile.dep --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ code/build.freebsd/Makefile.dep 15 Nov 2004 20:27:37 -0000 1.7 @@ -0,0 +1,21 @@ +################################################################## +# Machine Dependencies - this file is included automatically +# into the main Makefile +# +# This file contains definitions below for x86 running Linux +# It has *not* been tested! +################################################################## + +HOSTCFLAGS = -Dx86 -DBSD +CC = g++ +CPP = gcc +LD = g++ + +#----------------------------------------------------------------- +# Do not put anything below this point - it will be destroyed by +# "make depend" +# +# DO NOT DELETE THIS LINE -- make depend uses it +# DEPENDENCIES MUST END AT END OF FILE +# IF YOU PUT STUFF HERE IT WILL GO AWAY +# see make depend above Index: code/build.freebsd_amd64/Makefile =================================================================== RCS file: code/build.freebsd_amd64/Makefile diff -N code/build.freebsd_amd64/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ code/build.freebsd_amd64/Makefile 15 Nov 2004 11:16:37 -0000 1.1 @@ -0,0 +1,370 @@ +# Copyright (c) 1992-1996 The Regents of the University of California. +# All rights reserved. See copyright.h for copyright notice and limitation +# of liability and disclaimer of warranty provisions. +# +# This is a GNU Makefile. It must be used with the GNU make program. +# At UW, the GNU make program is /software/gnu/bin/make. +# In many other places it is known as "gmake". +# You may wish to include /software/gnu/bin/ early in your command +# search path, so that you will be using GNU make when you type "make". +# +# About this Makefile: +# -------------------- +# +# This Makefile is used to build the Nachos system, which includes +# the MIPS machine simulation and a simple operating system. +# +# There is a separate Makefile, in the "test" directory, that is +# used to build the Nachos test programs (which run on the +# simulated machine). +# +# There are several "build" directories, one for each type +# of machine in the MFCF computing environment +# (build.solaris, build.sunos, and build.ultrix), as well +# as a build directory for Linux (build.linux) and a generic +# build directory (build.other) for those who wish to try +# building Nachos on other platforms. +# +# This Makefile appears to be located in all of the build directories. +# If you edit it in one directory, the copies in all of the other +# directories appear to change as well. This is the desired behaviour, +# since this file is machine independent. (The file actually lives +# in build.solaris, with symbolic links from the other build directories.) +# +# The platform-dependent parts of make's instructions are located +# in the file Makefile.dep. +# There is a different Makefile.dep in each build directory. +# +# If you are in the MFCF environment, you should not have to edit +# the Makefile.dep files by hand. Any changes to the make instructions +# can be made in this file (see the instructions below) - they will +# apply no matter where you build Nachos. +# If you are not in the MFCF environment, e.g., if you are trying +# to build Nachos on Linux at home, you will probably need +# to edit Makefile.dep (in the appropriate build directory) to +# customize the make procedure to your environment. +# +# How to build Nachos for the first time: +# --------------------------------------- +# +# (1) Make sure than you are in the build directory for the +# type of machine you are logged in to (the "host" machine): +# +# host type examples build directory +# ----------- ----------- ---------------- +# +# sparc/SunOS cayley,napier, build.sunos +# (SunOS 4.1.3) descartes +# +# sparc/Solaris picard.math, build.solaris +# (SunOS 5.x) hermite.math, +# markov.math, +# hypatia.math, +# hume.math +# +# mips/ULTRIX cantor.math build.ultrix +# (ULTRIX 4.2) noether.math +# +# If you are not sure what type of machine you are on, +# try the command "uname -a". +# +# (2) Type "make depend" +# - this computes file dependencies and records them +# at the end of the file Makefile.dep in +# your build directory. Have a look... +# +# (3) Type "make nachos" (or just "make"). +# - make echos the commands it is executing, so that +# you can observe its progress. When the +# build is finished, you should have an +# executable "nachos" in the build directory. +# +# (4) There is no 4th step. You are done. Try running "./nachos -u". +# +# +# How to Re-build Nachos after you have changed the code: +#-------------------------------------------------------- +# +# - The Nachos source code is located in the code subdirectories: +# threads, userprog, filesys, network, and lib. You may +# change the files in any of these directories, and you can +# add new files and/or remove files. The "machine" subdirectory +# contains the hardware simulation (which is also part of +# Nachos. You may look at it, but +# you may not change it, except as noted in machine/machine.h +# - When you want to re-make Nachos, always do it in the +# "build" directory that is appropriate for the machine +# type that you are running on. +# DO NOT TRY TO MAKE NACHOS IN THE SOURCE CODE DIRECTORIES. +# +# - IF all you have done is changed C++ code in existing files +# (since the last time you made Nachos in this build directory), +# THEN all you need to do to re-make Nachos is to type +# +# "make nachos" +# +# in the build directory. +# +# - IF you have done any of the following since the last build in +# this directory: +# added new .cc files or new .h files +# added or deleted #include's from existing files +# THEN +# you must do +# "make depend" +# followed by +# "make nachos" +# +# in the build directory. +# +# Note that is is always safe to do "make depend" followed by +# "make nachos", so if you are not sure what changes you have +# made, do "make depend". +# +# - IF you have added new files (.cc or .h) since the last build, +# you should edit this Makefile before running "make depend" +# and "make nachos". + +# For new .h files, simply update the appropriate "_H" list below. +# For example, if you create a file called +# "bigfile.h" in the filesys subdirectory, you should add +# "../filesys/bigfile.h" to FILESYS_H, which is defined below + +# For new .cc files, update the appropriate "_C" and "_O" lists. +# For example, if you create a file called "filetable.cc" in +# the directory "userprog", you should add +# "../userprog/filetable.cc" to USERPROG_C, +# and you should add "filetable.o" to USERPROG_O. +# Note that the entry in the "_C" list includes the subdirectory +# name, while the entry on the "_O" list does not. +# +# Some Important Notes: +# --------------------- +# +# * You can clean up all of the .o and other files left behind +# by make by typeing "make clean" in the build directory. +# * You can clean up .o and other files, as well as the nachos +# executable, DISK, core, SOCKET, and other files by typing +# make "distclean" +# +# These are good ways to save space, but the next build that +# you do after cleaning will take longer than usual, since +# much of the stuff you cleaned will need to be rebuilt. +# +# * When you build Nachos on an ULTRIX machine (in build.ultrix), +# you will get lots of warning messages like this: +# +# openfile.o: does not have gp tables for all it's sectons +# +# from the loader. Ignore them. Or better yet, figure out +# how to make them go away. +# +# The Most Important Note: +# ----------------------- +# +# * If "make" is behaving strangely and you cannot figure out +# why, you should REBUILD the program FROM SCRATCH. +# Yes, it is slow. +# But, there are lots of little things that can go wrong, especially +# with all of these different types of machines available. +# Rebuilding from scratch at least gives you a known starting +# place. To rebuild from scratch, go to the appropriate +# build directory and do: +# +# make distclean +# make depend +# make nachos +# +################################################################ +# READ THIS: CONFIGURING NACHOS +# +# Change DEFINES (below) to +# DEFINES = -DUSE_TLB -DFILESYS_STUB +# if you want the simulated machine to use its TLB +# +# If you want to use the real Nachos file system (based on +# the simulated disk), rather than the stub, remove +# the -DFILESYS_STUB from DEFINES. +# +# There is a a fix to the MIPS simulator to enable it to properly +# handle unaligned data access. This fix is enabled by the addition +# of "-DSIM_FIX" to the DEFINES. This should be enabled by default +# and eventually will not require the symbol definition +################################################################ +DEFINES = -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT + + +##################################################################### +# +# You might want to play with the CFLAGS, but if you use -O it may +# break the thread system. You might want to use -fno-inline if +# you need to call some inline functions from the debugger. + +#CFLAGS = -ftemplate-depth-100 -Wno-deprecated -g -Wall -fwritable-strings $(INCPATH) $(DEFINES) $(HOSTCFLAGS) -DCHANGED +CFLAGS = -ftemplate-depth-100 -Wno-deprecated -g -fwritable-strings $(INCPATH) $(DEFINES) $(HOSTCFLAGS) -DCHANGED +LDFLAGS = + +##################################################################### +CPP=/lib/cpp +CC = g++ +LD = g++ +AS = as +RM = /bin/rm + +INCPATH = -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib + +PROGRAM = nachos + +# +# Edit these lists as if you add files to the source directories. +# See the instructions at the top of the file for more information. +# + +LIB_H = ../lib/bitmap.h\ + ../lib/copyright.h\ + ../lib/debug.h\ + ../lib/hash.h\ + ../lib/libtest.h\ + ../lib/list.h\ + ../lib/sysdep.h\ + ../lib/tut.h\ + ../lib/tut_reporter.h\ + ../lib/utility.h + +LIB_C = ../lib/bitmap.cc\ + ../lib/debug.cc\ + ../lib/hash.cc\ + ../lib/libtest.cc\ + ../lib/list.cc\ + ../lib/sysdep.cc + +LIB_O = bitmap.o debug.o libtest.o sysdep.o + + +MACHINE_H = ../machine/callback.h\ + ../machine/interrupt.h\ + ../machine/stats.h\ + ../machine/timer.h\ + ../machine/console.h\ + ../machine/machine.h\ + ../machine/mipssim.h\ + ../machine/translate.h\ + ../machine/network.h\ + ../machine/disk.h + +MACHINE_C = ../machine/interrupt.cc\ + ../machine/stats.cc\ + ../machine/timer.cc\ + ../machine/console.cc\ + ../machine/machine.cc\ + ../machine/mipssim.cc\ + ../machine/translate.cc\ + ../machine/network.cc\ + ../machine/disk.cc + +MACHINE_O = interrupt.o stats.o timer.o console.o machine.o mipssim.o\ + translate.o network.o disk.o + +THREAD_H = ../threads/alarm.h\ + ../threads/kernel.h\ + ../threads/main.h\ + ../threads/scheduler.h\ + ../threads/switch.h\ + ../threads/synch.h\ + ../threads/synchlist.h\ + ../threads/thread.h + +THREAD_C = ../threads/alarm.cc\ + ../threads/kernel.cc\ + ../threads/main.cc\ + ../threads/scheduler.cc\ + ../threads/synch.cc\ + ../threads/synchlist.cc\ + ../threads/thread.cc + +THREAD_O = alarm.o kernel.o main.o scheduler.o synch.o thread.o + +USERPROG_H = ../userprog/addrspace.h\ + ../userprog/syscall.h\ + ../userprog/synchconsole.h\ + ../userprog/noff.h + +USERPROG_C = ../userprog/addrspace.cc\ + ../userprog/exception.cc\ + ../userprog/synchconsole.cc + +USERPROG_O = addrspace.o exception.o synchconsole.o + +FILESYS_H =../filesys/directory.h \ + ../filesys/filehdr.h\ + ../filesys/filesys.h \ + ../filesys/openfile.h\ + ../filesys/pbitmap.h\ + ../filesys/synchdisk.h + +FILESYS_C =../filesys/directory.cc\ + ../filesys/filehdr.cc\ + ../filesys/filesys.cc\ + ../filesys/pbitmap.cc\ + ../filesys/openfile.cc\ + ../filesys/synchdisk.cc\ + +FILESYS_O =directory.o filehdr.o filesys.o pbitmap.o openfile.o synchdisk.o + +NETWORK_H = ../network/post.h + +NETWORK_C = ../network/post.cc + +NETWORK_O = post.o + +################################################################## +# You probably don't want to change anything below this point in +# the file unless you are comfortable with GNU make and know what +# you are doing... +################################################################## + +THREAD_S = ../threads/switch.s + +HFILES = $(LIB_H) $(MACHINE_H) $(THREAD_H) $(USERPROG_H) $(FILESYS_H) $(NETWORK_H) +CFILES = $(LIB_C) $(MACHINE_C) $(THREAD_C) $(USERPROG_C) $(FILESYS_C) $(NETWORK_C) + +C_OFILES = $(LIB_O) $(MACHINE_O) $(THREAD_O) $(USERPROG_O) $(FILESYS_O) $(NETWORK_O) + +S_OFILES = switch.o +OFILES = $(C_OFILES) $(S_OFILES) + +$(PROGRAM): $(OFILES) + $(LD) $(OFILES) $(LDFLAGS) -o $(PROGRAM) + +$(C_OFILES): %.o: + $(CC) $(CFLAGS) -c $< + +switch.o: ../threads/switch.s + cat ../threads/switch.s > swtch.S + $(CPP) $(CPP_AS_FLAGS) -E -P $(INCPATH) $(HOSTCFLAGS) -I../threads swtch.S > swtch.s + $(AS) -o switch.o swtch.s + +depend: $(CFILES) $(HFILES) + $(CC) $(INCPATH) $(DEFINES) $(HOSTCFLAGS) -DCHANGED -M $(CFILES) > makedep + @echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep + @echo '$$r makedep' >>eddep + @echo 'w' >>eddep + @echo 'q' >>eddep + ed - Makefile.dep < eddep + rm eddep makedep + @echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile.dep + @echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.dep + @echo '# see make depend above' >> Makefile.dep + +clean: + $(RM) -f $(OFILES) + $(RM) -f swtch.s + $(RM) -f swtch.S + +distclean: clean + $(RM) -f $(PROGRAM) + $(RM) -f DISK_? + $(RM) -f core + $(RM) -f SOCKET_? + +include Makefile.dep Index: code/build.freebsd_amd64/Makefile.dep =================================================================== RCS file: code/build.freebsd_amd64/Makefile.dep diff -N code/build.freebsd_amd64/Makefile.dep --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ code/build.freebsd_amd64/Makefile.dep 15 Nov 2004 11:16:37 -0000 1.1 @@ -0,0 +1,21 @@ +################################################################## +# Machine Dependencies - this file is included automatically +# into the main Makefile +# +# This file contains definitions below for x86 running Linux +# It has *not* been tested! +################################################################## + +HOSTCFLAGS = -DAMD64 -DBSD +CC = g++ +CPP = gcc +LD = g++ + +#----------------------------------------------------------------- +# Do not put anything below this point - it will be destroyed by +# "make depend" +# +# DO NOT DELETE THIS LINE -- make depend uses it +# DEPENDENCIES MUST END AT END OF FILE +# IF YOU PUT STUFF HERE IT WILL GO AWAY +# see make depend above Index: code/lib/list.cc =================================================================== RCS file: /usr/store/unicvs/nachos/dist/code/lib/list.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- code/lib/list.cc 4 Nov 2004 16:52:38 -0000 1.1.1.1 +++ code/lib/list.cc 15 Nov 2004 11:12:25 -0000 1.2 @@ -237,25 +237,25 @@ ListElement *ptr; // keep track ASSERT(!IsInList(item)); - if (IsEmpty()) { // if list is empty, put at front - first = element; - last = element; - } else if (compare(item, first->item) < 0) { // item goes at front - element->next = first; - first = element; + if (this->IsEmpty()) { // if list is empty, put at front + this->first = element; + this->last = element; + } else if (compare(item, this->first->item) < 0) { // item goes at front + element->next = this->first; + this->first = element; } else { // look for first elt in list bigger than item - for (ptr = first; ptr->next != NULL; ptr = ptr->next) { + for (ptr = this->first; ptr->next != NULL; ptr = ptr->next) { if (compare(item, ptr->next->item) < 0) { element->next = ptr->next; ptr->next = element; - numInList++; + this->numInList++; return; } } - last->next = element; // item goes at end of list - last = element; + this->last->next = element; // item goes at end of list + this->last = element; } - numInList++; + this->numInList++; ASSERT(IsInList(item)); } @@ -338,8 +338,8 @@ ListElement *prev, *ptr; List::SanityCheck(); - if (first != last) { - for (prev = first, ptr = first->next; ptr != NULL; + if (this->first != this->last) { + for (prev = this->first, ptr = this->first->next; ptr != NULL; prev = ptr, ptr = ptr->next) { ASSERT(compare(prev->item, ptr->item) <= 0); } @@ -368,10 +368,10 @@ // should be able to get out everything we put in for (i = 0; i < numEntries; i++) { - q[i] = RemoveFront(); + q[i] = this->RemoveFront(); ASSERT(!IsInList(q[i])); } - ASSERT(IsEmpty()); + ASSERT(this->IsEmpty()); // make sure everything came out in the right order for (i = 0; i < (numEntries - 1); i++) { Index: code/lib/sysdep.cc =================================================================== RCS file: /usr/store/unicvs/nachos/dist/code/lib/sysdep.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- code/lib/sysdep.cc 4 Nov 2004 16:52:38 -0000 1.1.1.1 +++ code/lib/sysdep.cc 4 Nov 2004 17:05:04 -0000 1.2 @@ -80,6 +80,8 @@ #ifdef OSF_OR_AIX int mprotect(const void *, long unsigned int, int); +#elif defined(__FreeBSD__) +/* intentionally left blank */ #else int mprotect(char *, unsigned int, int); #endif @@ -525,7 +527,7 @@ extern int errno; #endif struct sockaddr_un uName; -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) socklen_t size = sizeof(uName); #else int size = sizeof(uName); Index: code/test/Makefile.dep =================================================================== RCS file: /usr/store/unicvs/nachos/dist/code/test/Makefile.dep,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- code/test/Makefile.dep 4 Nov 2004 16:52:38 -0000 1.1.1.1 +++ code/test/Makefile.dep 5 Nov 2004 17:43:24 -0000 1.2 @@ -48,17 +48,14 @@ # try something like this, substituting whatever # uname -s returns on your machine for the XXX # -#ifeq ($(osname),XXX) -#CPP = full path name of your cpp program -#GCCDIR = directory in which your gcc cross-compiler lives -#LDFLAGS = -T script -N -#ASFLAGS = -mips2 -#CPPFLAGS = $(INCDIR) +ifeq ($(osname),FreeBSD) +CPP = /usr/local/nachos/lib/gcc-lib/decstation-ultrix/2.95.2/cpp +GCCDIR = /usr/local/nachos/bin/decstation-ultrix- +LDFLAGS = -T script -N +ASFLAGS = -mips2 +CPPFLAGS = $(INCDIR) #COFF2NOFF = full pathname of your coff2noff program # Note: it has been moved to part of the Nachos distribution -# COFF2NOFF = ../../coff2noff.mipsUltrix -#hosttype = MacOS -#endif - - - +COFF2NOFF = ../../coff2noff/coff2noff +hosttype = FreeBSD +endif Index: code/threads/main.cc =================================================================== RCS file: /usr/store/unicvs/nachos/dist/code/threads/main.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- code/threads/main.cc 4 Nov 2004 16:52:38 -0000 1.1.1.1 +++ code/threads/main.cc 5 Nov 2004 16:20:30 -0000 1.2 @@ -56,7 +56,7 @@ test_runner_singleton runner; } -#endif TUT +#endif // TUT // global variables Kernel *kernel; Index: code/threads/switch.h =================================================================== RCS file: /usr/store/unicvs/nachos/dist/code/threads/switch.h,v retrieving revision 1.1.1.1 retrieving revision 1.5 diff -u -r1.1.1.1 -r1.5 --- code/threads/switch.h 4 Nov 2004 16:52:38 -0000 1.1.1.1 +++ code/threads/switch.h 15 Nov 2004 19:31:05 -0000 1.5 @@ -156,6 +156,30 @@ #endif // x86 +#ifdef AMD64 + +#define PCB_RSP 0 +#define PCB_RBX 8 +#define PCB_RBP 16 // == FramePointer? +#define PCB_R12 24 +#define PCB_R13 32 +#define PCB_R14 40 +#define PCB_R15 48 +#define PCB_RIP 56 + +#define PCState (PCB_RIP / 8 - 1) +#define InitialPCState (PCB_R12 / 8 - 1) +#define InitialArgState (PCB_R13 / 8 - 1) +#define WhenDonePCState (PCB_R14 / 8 - 1) +#define StartupPCState (PCB_R15 / 8 - 1) + +#define InitialPC %r12 +#define InitialArg %r13 +#define WhenDonePC %r14 +#define StartupPC %r15 + +#endif //AMD64 + #ifdef PowerPC #define SP 0 // stack pointer Index: code/threads/switch.s =================================================================== RCS file: /usr/store/unicvs/nachos/dist/code/threads/switch.s,v retrieving revision 1.1.1.1 retrieving revision 1.11 diff -u -r1.1.1.1 -r1.11 --- code/threads/switch.s 4 Nov 2004 16:52:38 -0000 1.1.1.1 +++ code/threads/switch.s 15 Nov 2004 20:20:35 -0000 1.11 @@ -11,6 +11,7 @@ * SUN SPARC (SPARC) * HP PA-RISC (PARISC) * Intel 386 (x86) + * AMD64 (AMD64) * IBM RS6000 (PowerPC) -- I hope it will also work for Mac PowerPC * * We define two routines for each architecture: @@ -374,6 +375,93 @@ #endif // x86 +#ifdef AMD64 +/* + * Porting to AMD64 was done by + * Max Laier and + * Florian Hübner + * + * This port has been tested on FreeBSD/amd64 version 5.3 + * + * TODO: Clear FramePointer on entering ThreadRoot in order to have a + * clean(er) gdb backtrace. + */ + + .text + .p2align 4,0x90 + + .globl ThreadRoot + .globl _ThreadRoot + +/* void ThreadRoot( void ) + * + * expects the following registers to be initialized: + * %r12 points to startup function (interrupt enable) + * %r13 contains inital argument to thread function + * %r14 points to thread function + * %r15 point to Thread::Finish() + */ + +_ThreadRoot: +ThreadRoot: + /* XXX: Clear FramePointer ?!? */ + + callq *StartupPC + + movq InitialArg, %rdi + callq *InitialPC + callq *WhenDonePC + + /* NOT REACHED! */ + + /* XXX: More Framepointer Magic!?! */ + ret + +/* void SWITCH( thread *t1, thread *t2 ) + * + * on entry, stack looks like this: + * %rdi -> thread *t1 + * %rsi -> thread *t2 + * + * we push the current eax on the stack so that we can use it as + * a pointer to t1, this decrements esp by 4, so when we use it + * to reference stuff on the stack, we add 4 to the offset. + */ + + .globl SWITCH + .globl _SWITCH +_SWITCH: +SWITCH: + /* Switch to new thread. First, save context. */ + movq %rdi,%r8 + + movq (%rsp),%rax /* Hardware registers */ + movq %rax,PCB_RIP(%r8) + movq %rbx,PCB_RBX(%r8) + movq %rsp,PCB_RSP(%r8) + movq %rbp,PCB_RBP(%r8) + movq %r12,PCB_R12(%r8) + movq %r13,PCB_R13(%r8) + movq %r14,PCB_R14(%r8) + movq %r15,PCB_R15(%r8) + + /* Save is done. Now fire up new thread. */ + movq %rsi, %r8 + + /* Restore context. */ + movq PCB_RBX(%r8),%rbx + movq PCB_RSP(%r8),%rsp + movq PCB_RBP(%r8),%rbp + movq PCB_R12(%r8),%r12 + movq PCB_R13(%r8),%r13 + movq PCB_R14(%r8),%r14 + movq PCB_R15(%r8),%r15 + movq PCB_RIP(%r8),%rax + movq %rax,(%rsp) + + ret + +#endif //AMD64 #if defined(ApplePowerPC) Index: code/threads/thread.cc =================================================================== RCS file: /usr/store/unicvs/nachos/dist/code/threads/thread.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- code/threads/thread.cc 4 Nov 2004 16:52:38 -0000 1.1.1.1 +++ code/threads/thread.cc 15 Nov 2004 13:01:14 -0000 1.2 @@ -94,8 +94,12 @@ Interrupt *interrupt = kernel->interrupt; Scheduler *scheduler = kernel->scheduler; IntStatus oldLevel; - + +#ifdef AMD64 + DEBUG(dbgThread, "Forking thread: " << name << " f(a): " << (uint64_t) func << " " << arg); +#else DEBUG(dbgThread, "Forking thread: " << name << " f(a): " << (int) func << " " << arg); +#endif StackAllocate(func, arg); @@ -345,6 +349,15 @@ *(--stackTop) = (int) ThreadRoot; *stack = STACK_FENCEPOST; #endif + +#ifdef AMD64 + // XXX the x86 passes the return address on the stack. In order for SWITCH() + // XXX to go to ThreadRoot when we switch to this thread, the return addres + // XXX used in SWITCH() must be the starting address of ThreadRoot. + stackTop = stack + StackSize - 8; // -8 to be on the safe side! + *(--stackTop) = (int64_t) ThreadRoot; + *stack = STACK_FENCEPOST; +#endif #ifdef PARISC machineState[PCState] = PLabelToAddr(ThreadRoot);