1 # Northwestern University
2 # (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
3 # (c) 2008, Peter Dinda <pdinda@northwestern.edu>
4 # (c) 2008, Lei Xia <lxia@northwestern.edu>
5 # (c) 2008, The V3VEE Project <http://www.v3vee.org>
8 VPATH := $(PROJECT_ROOT)/src
10 #when -DNDEBUG is set the kassert functions are disabled
13 # DEBUG=1 means VMM_DEBUG, VMM_INFO, and VMM_TRACE are enabled
14 # as are SERIAL_PRINT_DEBUG
17 ifeq ($(LEAN_AND_MEAN),1)
27 DEBUG_SECTIONS:= $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING -DDEBUG_NESTED_PAGING -DDEBUG_CTRL_REGS -DDEBUG_INTERRUPTS -DDEBUG_KEYBOARD -DDEBUG_PIC -DDEBUG_PIT -DDEBUG_NVRAM -DDEBUG_EMULATOR -DDEBUG_XED -DDEBUG_HALT -DDEBUG_DEV_MGR
28 # -DDEBUG_IO -DDEBUG_GENERIC -DDEBUG_IDE
32 ifeq ($(DEBUG_SHADOW_PAGING),1)
33 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING
35 ifeq ($(DEBUG_SHADOW_PAGING),0)
36 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_SHADOW_PAGING
40 ifeq ($(DEBUG_NESTED_PAGING),1)
41 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NESTED_PAGING
43 ifeq ($(DEBUG_NESTED_PAGING),0)
44 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_NESTED_PAGING
48 ifeq ($(DEBUG_CTRL_REGS),1)
49 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_CTRL_REGS
51 ifeq ($(DEBUG_CTRL_REGS),0)
52 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_CTRL_REGS
56 ifeq ($(DEBUG_INTERRUPTS),1)
57 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_INTERRUPTS
59 ifeq ($(DEBUG_INTERRUPTS),0)
60 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_INTERRUPTS
65 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_IO
68 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_IO
72 ifeq ($(DEBUG_KEYBOARD),1)
73 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_KEYBOARD
75 ifeq ($(DEBUG_KEYBOARD),0)
76 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_KEYBOARD
81 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIC
84 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIC
89 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIT
92 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIT
96 ifeq ($(DEBUG_NVRAM),1)
97 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NVRAM
99 ifeq ($(DEBUG_NVRAM),0)
100 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_NVRAM
104 ifeq ($(DEBUG_GENERIC),1)
105 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_GENERIC
107 ifeq ($(DEBUG_GENERIC),0)
108 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_GENERIC
112 ifeq ($(DEBUG_EMULATOR),1)
113 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_EMULATOR
115 ifeq ($(DEBUG_EMULATOR),0)
116 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_EMULATOR
120 ifeq ($(DEBUG_IDE),1)
121 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_IDE
123 ifeq ($(DEBUG_IDE),0)
124 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_IDE
128 ifeq ($(DEBUG_XED),1)
129 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_XED
131 ifeq ($(DEBUG_XED),0)
132 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_XED
136 ifeq ($(DEBUG_HALT),1)
137 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_HALT
139 ifeq ($(DEBUG_HALT),0)
140 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_HALT
144 ifeq ($(DEBUG_APIC),1)
145 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_APIC
147 ifeq ($(DEBUG_APIC),0)
148 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_APIC
152 ifeq ($(DEBUG_PCI),1)
153 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PCI
155 ifeq ($(DEBUG_PCI),0)
156 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PCI
160 ifeq ($(DEBUG_DEV_MGR),1)
161 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_DEV_MGR
163 ifeq ($(DEBUG_DEV_MGR),0)
164 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_DEV_MGR
170 JRLDEBUG= -DVMM_DEBUG -DVMM_INFO -DVMM_TRACE $(DEBUG_SECTIONS)
176 ifeq ($(INSTRUMENT_VMM),1)
177 EXTRA_C_OPTS:= -DINSTRUMENT_VMM
178 INSTRUMENT_OPT := -finstrument-functions
179 OBJ_FILES := palacios/vmm_instrument.o
184 CFLAGS = -fno-stack-protector
189 ALL_TARGETS := vmm force_payload
191 # Compilation Objects
195 palacios/vm_guest.o \
197 palacios/svm_handler.o \
199 palacios/vmm_util.o \
200 palacios/vmm_ctrl_regs.o \
203 palacios/vmm_paging.o \
205 palacios/vmm_debug.o \
207 palacios/vmm_intr.o \
208 palacios/vmm_excp.o \
209 palacios/vmm_time.o \
210 palacios/vmm_shadow_paging.o \
211 palacios/vm_guest_mem.o \
213 palacios/vmm_dev_mgr.o \
214 palacios/vmm_decoder.o \
215 palacios/svm_halt.o \
216 palacios/svm_pause.o \
217 palacios/svm_wbinvd.o \
218 palacios/vmm_config.o \
219 palacios/vmm_hashtable.o \
220 palacios/vmm_string.o \
221 palacios/vmm_emulator.o \
222 palacios/vmm_queue.o \
223 palacios/vmm_host_events.o \
224 palacios/svm_lowlevel.o \
227 palacios/vmm_socket.o \
229 palacios/vmm_rbtree.o \
230 palacios/vmm_profiler.o \
231 palacios/vmm_direct_paging.o \
232 palacios/vmm_ringbuffer.o \
233 palacios/vmm_hypercall.o \
236 # vmx.c vmcs_gen.c vmcs.c
238 # Extra C flags for the VMM objects
239 $(VMM_OBJS) :: EXTRA_CFLAGS = \
240 $(JRLDEBUG) $(CFLAGS)\
245 xed/v3-xed-compat.o \
246 xed/v3-udiv-compat.o \
248 $(XED_OBJS) :: EXTRA_CFLAGS = \
249 $(JRLDEBUG) $(CFLAGS)\
256 devices/simple_pic.o \
260 devices/bochs_debug.o \
275 $(DEVICES_OBJS) :: EXTRA_CFLAGS = \
276 $(JRLDEBUG) $(CFLAGS)\
280 # ----------------------------------------------------------------------
282 # This section defines programs that are used to build GeekOS.
283 # ----------------------------------------------------------------------
286 V3_ARCH := __V3_64BIT__
288 V3_ARCH := __V3_32BIT__
293 EXTRA_C_OPTS := $(EXTRA_C_OPTS) -DCRAY_XT
297 # Uncomment if cross compiling
298 #TARGET_CC_PREFIX := $(PROJECT_ROOT)/../devtools/i386/bin/i386-elf-
299 #TARGET_CC_PREFIX := i386-elf-
302 TARGET_CC := $(TARGET_CC_PREFIX)gcc -m64
304 TARGET_CC := $(TARGET_CC_PREFIX)gcc -m32
308 # Target linker. GNU ld is probably to only one that will work.
309 TARGET_LD := $(TARGET_CC_PREFIX)ld -melf_i386
312 TARGET_AR := $(TARGET_CC_PREFIX)ar
315 TARGET_RANLIB := $(TARGET_CC_PREFIX)ranlib
318 TARGET_NM := $(TARGET_CC_PREFIX)nm
321 TARGET_OBJCOPY := $(TARGET_CC_PREFIX)objcopy
333 # Tool to build PFAT filesystem images.
334 BUILDFAT := tools/builtFat.exe
339 # Pad a file so its size is a multiple of some unit (i.e., sector size)
340 PAD := $(PERL) $(PROJECT_ROOT)/scripts/pad
342 # Create a file filled with zeroes.
343 ZEROFILE := $(PERL) $(PROJECT_ROOT)/scripts/zerofile
345 # Calculate size of file in sectors
346 NUMSECS := $(PERL) $(PROJECT_ROOT)/scripts/numsecs
349 FD_SECTORS_PER_TRACK := $(PERL) $(PROJECT_ROOT)/scripts/numsecs_per_track
352 # ----------------------------------------------------------------------
354 # Options passed to the tools.
355 # ----------------------------------------------------------------------
357 # Flags used for all C source files
367 -I$(PROJECT_ROOT)/include \
371 -Wp,-MD,$(@D)/.$(@F).d \
378 # Flags passed to objcopy program (strip unnecessary sections from kernel.exe)
379 OBJCOPY_FLAGS := -R .dynamic -R .note -R .comment
381 # ----------------------------------------------------------------------
383 # Describes how to compile the source files.
384 # ----------------------------------------------------------------------
386 # Compilation of kernel C source files
388 # $(call build,TAG,commandline)
390 # If V=1 on the command line or the environment, then the actual
391 # command executed will be echoed to the terminal. Otherwise
392 # only the tag and the output file will be printed to make
393 # any warnings stand out from the compile messages.
396 @if [ -z "$V" ]; then \
407 $(call build,CC,$(TARGET_CC) \
417 $(call build,AS,$(TARGET_CC) \
435 # ----------------------------------------------------------------------
437 # Specifies files to be built
438 # ----------------------------------------------------------------------
440 # Default target - see definition of ALL_TARGETS in Configuration section
444 ln -s -f ../src/vmboot/rombios/BIOS-bochs-latest rombios
447 ln -s -f ../src/vmboot/vgabios/VGABIOS-lgpl-latest.bin vgabios
450 force_payload: rombios_link vgabios_link
451 ../scripts/make_payload.pl payload_layout.txt vm_kernel
453 inter1: force_payload
458 vmm: palacios/vmm.lib
461 # Loadable (flat) kernel image.
462 palacios/vmm.bin : palacios/vmm.lib
463 $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary palacios/vmm.lib palacios/vmm.bin
466 # The kernel executable and symbol map.
467 palacios/vmm.lib: libv3vee.a
473 $(call build,AR,$(TARGET_AR) rcs $@ $^)
481 # Clean build directories of generated files
483 for d in palacios devices xed; do \
484 (cd $$d && rm -f * .*.d); \
488 # Include all of the generated dependency files if they exist