Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


moved vmm_lowlevel.asm to C header file vmm_lowlevel.h
[palacios.git] / palacios / build / Makefile
1 # Makefile for GeekOS kernel, userspace, and tools
2 #
3 #  Northwestern University 
4 # (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
5 # (c) 2008, Peter Dinda <pdinda@northwestern.edu> 
6 # (c) 2008, Lei Xia <xiaxlei@gmail.com>
7 # (c) 2008, The V3VEE Project <http://www.v3vee.org> 
8 #
9 # Based on GeekOS Makefile:
10 # Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
11 # $Revision: 1.71 $
12
13
14 # This is free software.  You are permitted to use,
15 # redistribute, and modify it as specified in the file "COPYING".
16
17 # Required software to build GeekOS:
18 # - GNU Make (http://www.gnu.org/software/make)
19 # - gcc 2.95.2 generating code for target (i386/ELF) and host platforms
20 # - nasm (http://nasm.sourceforge.net)
21 # - Perl5, AWK (any version), egrep
22 #
23 # Cygwin (http://cygwin.com) may be used to build GeekOS.
24 # Make sure that gcc, binutils, nasm, and perl are installed.
25
26 # NOTES:
27 # - This makefile has been written carefully to work correctly
28 #   with the -j (parallel make) option.  I regularly use "make -j 2"
29 #   to speed the build process on 2 processor systems.
30
31
32 # Base address of kernel
33 #
34 # Note: at top of memory minus three pages (GDT/TSS/IDT) 
35 # minus maximum size
36 #
37 #
38 # Note that the code will initially load at 0x10000
39 #
40 # The setup code needs to copy it up to this address and jump there
41 #
42
43
44
45
46 PROJECT_ROOT := ..
47 VPATH := $(PROJECT_ROOT)/src
48
49 #when -DNDEBUG is set the kassert functions are disabled
50 #JRLDEBUG=-DNDEBUG
51
52 # DEBUG=1 means VMM_DEBUG, VMM_INFO, and VMM_TRACE are enabled
53 # as are SERIAL_PRINT_DEBUG
54
55
56 ifeq ($(LEAN_AND_MEAN),1) 
57 DEBUG=0
58 DEBUG_SECTIONS=
59 else
60 DEBUG=1
61 DEBUG_SECTIONS= 
62 endif
63
64
65 ifeq ($(DEBUG_ALL),1)
66   DEBUG_SECTIONS:= $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING -DDEBUG_CTRL_REGS -DDEBUG_INTERRUPTS -DDEBUG_IO -DDEBUG_KEYBOARD -DDEBUG_PIC -DDEBUG_PIT -DDEBUG_NVRAM -DDEBUG_EMULATOR -DDEBUG_GENERIC -DDEBUG_RAMDISK -DDEBUG_XED -DDEBUG_HALT -DDEBUG_DEV_MGR
67 endif
68
69 ifeq ($(DEBUG_SHADOW_PAGING),1)
70 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING
71 else 
72 ifeq ($(DEBUG_SHADOW_PAGING),0) 
73 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_SHADOW_PAGING
74 endif
75 endif
76
77 ifeq ($(DEBUG_CTRL_REGS),1)
78 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_CTRL_REGS
79 else 
80 ifeq ($(DEBUG_CTRL_REGS),0) 
81 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_CTRL_REGS
82 endif
83 endif
84
85 ifeq ($(DEBUG_INTERRUPTS),1)
86 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_INTERRUPTS
87 else 
88 ifeq ($(DEBUG_INTERRUPTS),0) 
89 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_INTERRUPTS
90 endif
91 endif
92
93 ifeq ($(DEBUG_IO),1)
94 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_IO
95 else 
96 ifeq ($(DEBUG_IO),0) 
97 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_IO
98 endif
99 endif
100
101 ifeq ($(DEBUG_KEYBOARD),1)
102 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_KEYBOARD
103 else 
104 ifeq ($(DEBUG_KEYBOARD),0) 
105 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_KEYBOARD
106 endif
107 endif
108
109 ifeq ($(DEBUG_PIC),1)
110 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIC
111 else 
112 ifeq ($(DEBUG_PIC),0) 
113 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIC
114 endif
115 endif
116
117 ifeq ($(DEBUG_PIT),1)
118 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIT
119 else 
120 ifeq ($(DEBUG_PIT),0) 
121 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIT
122 endif
123 endif
124
125 ifeq ($(DEBUG_NVRAM),1)
126 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NVRAM
127 else 
128 ifeq ($(DEBUG_NVRAM),0) 
129 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_NVRAM
130 endif
131 endif
132
133 ifeq ($(DEBUG_GENERIC),1)
134 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_GENERIC
135 else 
136 ifeq ($(DEBUG_GENERIC),0) 
137 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_GENERIC
138 endif
139 endif
140
141 ifeq ($(DEBUG_EMULATOR),1)
142 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_EMULATOR
143 else 
144 ifeq ($(DEBUG_EMULATOR),0) 
145 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_EMULATOR
146 endif
147 endif
148
149 ifeq ($(DEBUG_RAMDISK),1)
150 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_RAMDISK
151 else 
152 ifeq ($(DEBUG_RAMDISK),0) 
153 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_RAMDISK
154 endif
155 endif
156
157 ifeq ($(TRACE_RAMDISK),1)
158 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DTRACE_RAMDISK
159 else
160 ifeq ($(TRACE_RAMDSK),0)
161 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UTRACE_RAMDISK
162 endif
163 endif
164
165 ifeq ($(DEBUG_XED),1)
166 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_XED
167 else 
168 ifeq ($(DEBUG_XED),0) 
169 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_XED
170 endif
171 endif
172
173 ifeq ($(DEBUG_HALT),1)
174 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_HALT
175 else 
176 ifeq ($(DEBUG_HALT),0) 
177 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_HALT
178 endif
179 endif
180
181 ifeq ($(DEBUG_DEV_MGR),1)
182 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_DEV_MGR
183 else 
184 ifeq ($(DEBUG_DEV_MGR),0)
185 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_DEV_MGR
186 endif
187 endif
188
189 #DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DTEST_NE2K
190
191 ifeq ($(DEBUG),1)
192   JRLDEBUG=  -DVMM_DEBUG -DVMM_INFO -DVMM_TRACE $(DEBUG_SECTIONS)
193 else
194
195 endif
196
197
198 #
199 # DECODER is the decoder that will be used 
200 # currently we only support xed
201 #
202 DECODER=XED
203
204 DECODER_FLAGS=
205 DECODER_SRCS=
206 DECODER_LIBS=
207
208 ifeq ($(DECODER),XED)
209 DECODER_SRCS := vmm_xed.c
210 DECODER_FLAGS :=  -L../lib/xed
211 DECODER_LIBS := $(PROJECT_ROOT)/lib/xed/libxed.a
212 else
213 # This is an error
214 endif
215
216
217
218
219
220
221 #
222 # This is wrong for current cygwin - no changes needed
223 #
224 # Figure out if we're compiling with cygwin, http://cygwin.com
225 #
226
227 #SYSTEM_NAME := $(shell uname -s)
228 #ifeq ($(findstring CYGWIN,$(SYSTEM_NAME)),CYGWIN)
229 #SYM_PFX            := _
230 #EXTRA_C_OPTS       := -DNEED_UNDERSCORE -DGNU_WIN32
231 #EXTRA_NASM_OPTS    := -DNEED_UNDERSCORE
232 #NON_ELF_SYSTEM     := yes
233 #EXTRA_CC_USER_OPTS := -Dmain=geekos_main
234 #endif
235
236
237
238
239 # ----------------------------------------------------------------------
240 # Configuration -
241 #   Various options specifying how GeekOS should be built,
242 #   what source files to build, which user programs to build,
243 #   etc.  This is generally the only section of the makefile
244 #   that will need to be modified.
245 # ----------------------------------------------------------------------
246
247 # List of targets to build by default.
248 # These targets encompass everything needed to boot
249 # and run GeekOS.
250 ALL_TARGETS := vmm vm_kernel
251
252
253
254
255
256
257 VMM_ASM_SRCS :=  svm_lowlevel.asm\
258 #                       vmx_lowlevel.asm
259
260 VMM_ASM_OBJS := $(VMM_ASM_SRCS:%.asm=palacios/%.o)
261
262
263 VMM_C_SRCS :=   vm_guest.c \
264                 svm.c svm_handler.c vmm.c vmm_util.c vmm_ctrl_regs.c \
265                 vmcb.c vmm_mem.c vmm_paging.c vmm_io.c vmm_debug.c svm_io.c \
266                 vmm_intr.c vmm_time.c \
267                 vmm_shadow_paging.c vm_guest_mem.c  \
268                 vm_dev.c vmm_dev_mgr.c vmm_decoder.c \
269                 svm_halt.c svm_pause.c svm_wbinvd.c \
270                 vmm_config.c vmm_hashtable.c \
271                 vmm_string.c vmm_emulator.c vmm_queue.c\
272                 vmm_host_events.c \
273                  $(DECODER_SRCS)
274 #               vmx.c vmcs_gen.c vmcs.c
275
276 VMM_C_OBJS := $(VMM_C_SRCS:%.c=palacios/%.o)
277
278 VMM_OBJS := $(VMM_C_OBJS) $(VMM_ASM_OBJS)
279
280
281
282 XED_C_SRCS := v3-xed-compat.c
283
284 XED_C_OBJS := $(XED_C_SRCS:%.c=xed/%.o)
285
286 XED_GAS_SRCS := v3-udiv-compat.s
287
288 XED_GAS_OBJS := $(XED_GAS_SRCS:%.s=xed/%.o)
289
290 XED_OBJS := $(XED_C_OBJS) $(XED_GAS_OBJS)
291
292
293
294 DEVICE_C_SRCS := generic.c keyboard.c nvram.c timer.c simple_pic.c 8259a.c 8254.c serial.c ramdisk.c cdrom.c bochs_debug.c
295
296 DEVICE_C_OBJS := $(DEVICE_C_SRCS:%.c=devices/%.o)
297
298 DEVICE_OBJS := $(DEVICE_C_OBJS)
299
300 V3LIBS := $(DECODER_LIBS)
301
302
303
304
305
306 # ----------------------------------------------------------------------
307 # Tools -
308 #   This section defines programs that are used to build GeekOS.
309 # ----------------------------------------------------------------------
310
311
312 V3_ARCH := __V3_32BIT__
313 #V3_ARCH := __V3_64BIT__
314
315 # Uncomment if cross compiling
316 #TARGET_CC_PREFIX :=  $(PROJECT_ROOT)/../devtools/i386/bin/i386-elf-
317 #TARGET_CC_PREFIX :=  i386-elf-
318
319 # Target C compiler.  gcc 2.95.2 or later should work.
320 TARGET_CC := $(TARGET_CC_PREFIX)gcc -m32
321 #TARGET_CC := $(TARGET_CC_PREFIX)gcc34 -m32
322
323
324 # Target linker.  GNU ld is probably to only one that will work.
325 TARGET_LD := $(TARGET_CC_PREFIX)ld -melf_i386
326
327 # Target archiver
328 TARGET_AR := $(TARGET_CC_PREFIX)ar
329
330 # Target ranlib
331 TARGET_RANLIB := $(TARGET_CC_PREFIX)ranlib
332
333 # Target nm
334 TARGET_NM := $(TARGET_CC_PREFIX)nm
335
336 # Target objcopy
337 TARGET_OBJCOPY := $(TARGET_CC_PREFIX)objcopy
338
339 # Nasm (http://nasm.sourceforge.net)
340 NASM := $(PROJECT_ROOT)/../devtools/bin/nasm
341 #NASM := /opt/vmm-tools/bin/nasm
342
343 AS = as --32
344
345 # Tool to build PFAT filesystem images.
346 BUILDFAT := tools/builtFat.exe
347
348 # Perl5 or later
349 PERL := perl
350
351 # Pad a file so its size is a multiple of some unit (i.e., sector size)
352 PAD := $(PERL) $(PROJECT_ROOT)/scripts/pad
353
354 # Create a file filled with zeroes.
355 ZEROFILE := $(PERL) $(PROJECT_ROOT)/scripts/zerofile
356
357 # Calculate size of file in sectors
358 NUMSECS := $(PERL) $(PROJECT_ROOT)/scripts/numsecs
359
360
361 FD_SECTORS_PER_TRACK := $(PERL) $(PROJECT_ROOT)/scripts/numsecs_per_track
362
363
364 # ----------------------------------------------------------------------
365 # Definitions -
366 #   Options passed to the tools.
367 # ----------------------------------------------------------------------
368
369 # Flags used for all C source files
370 #GENERAL_OPTS := -O -Wall $(EXTRA_C_OPTS) $(VMM_FLAGS) -fPIC #-fvisibility=hidden
371 GENERAL_OPTS :=  -O -Wall  $(EXTRA_C_OPTS) $(VMM_FLAGS) -fPIC -Werror#-fvisibility=hidden
372 CC_GENERAL_OPTS := $(GENERAL_OPTS) 
373
374 # Flags used for VMM C source files
375 CC_VMM_OPTS := -g -I$(PROJECT_ROOT)/include -D__V3VEE__ -D$(V3_ARCH) $(DECODER_FLAGS) $(JRLDEBUG)
376
377 # Flags used for VMM C ASM files
378 NASM_VMM_OPTS := -I$(PROJECT_ROOT)/src/palacios/ -f elf $(EXTRA_NASM_OPTS)
379
380
381
382
383
384 # Flags passed to objcopy program (strip unnecessary sections from kernel.exe)
385 OBJCOPY_FLAGS := -R .dynamic -R .note -R .comment
386
387 # ----------------------------------------------------------------------
388 # Rules -
389 #   Describes how to compile the source files.
390 # ----------------------------------------------------------------------
391
392
393
394 palacios/%.o : palacios/%.c
395         $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o palacios/$*.o
396
397 palacios/%.o : palacios/%.asm
398         $(NASM) $(NASM_VMM_OPTS) $< -o palacios/$*.o
399
400 devices/%.o : devices/%.c
401         $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o devices/$*.o
402
403 devices/%.o : devices/%.asm
404         $(NASM) $(NASM_VMM_OPTS) $< -o devices/$*.o
405
406
407 xed/%.o : xed/%.c
408         $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o xed/$*.o
409
410 xed/%.o : xed/%.s
411         $(AS) $< -o xed/$*.o
412
413
414 # ----------------------------------------------------------------------
415 # Targets -
416 #   Specifies files to be built
417 # ----------------------------------------------------------------------
418
419 # Default target - see definition of ALL_TARGETS in Configuration section
420 all : $(ALL_TARGETS)
421
422
423 #geekos/vmx_lowlevel.o: $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm
424 #       $(NASM) -O99 \
425 #       -f elf \
426 #               -I$(PROJECT_ROOT)/src/geekos/ \
427 #               $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm \
428 #       -o $@
429
430
431 #geekos/test: geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o 
432 #       $(CC) geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o  -o geekos/test
433
434
435
436 rombios_link:
437         ln -s -f ../src/vmboot/rombios/BIOS-bochs-latest rombios
438
439 vgabios_link:
440         ln -s -f ../src/vmboot/vgabios/VGABIOS-lgpl-latest.bin vgabios
441
442
443 force_rombios: rombios_link
444         (cd ../src/vmboot/rombios; make clean; make)
445
446 force_vgabios: vgabios_link
447         (cd ../src/vmboot/vgabios; make clean; make)
448
449 force_payload: force_rombios force_vgabios
450         ../scripts/make_payload.pl payload_layout.txt vm_kernel
451
452 inter1: force_payload
453         -make clean
454
455 world: inter1 vmm
456
457 vmm: palacios/vmm.lib 
458
459
460
461
462 # Loadable (flat) kernel image.
463 palacios/vmm.bin : palacios/vmm.lib
464         $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary palacios/vmm.lib palacios/vmm.bin
465
466
467 # The kernel executable and symbol map.
468 palacios/vmm.lib: $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS) vm_kernel
469 #       $(TARGET_LD) -o palacios/vmm.lib  \
470 #               $(DECODER_FLAGS) \
471 #                $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS) $(V3LIBS) -b binary vm_kernel
472 #       $(TARGET_NM) palacios/vmm.lib > palacios/vmm.syms
473         $(TARGET_AR) rcs libv3vee.a  \
474                  $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS)
475
476
477
478 force:
479
480
481
482
483
484 # Clean build directories of generated files
485 clean :
486         for d in palacios devices; do \
487                 (cd $$d && rm -f *); \
488         done
489
490
491 # Build header file dependencies, so source files are recompiled when
492 # header files they depend on are modified.
493 depend : $(GENERATED_LIBC_SRCS)
494
495         $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
496                 $(VMM_C_SRCS:%.c=$(PROJECT_ROOT)/src/palacios/%.c) \
497                 | $(PERL) -n -e 's,^(\S),palacios/$$1,;print' \
498                 >> depend.mak
499         $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
500                 $(DEVICE_C_SRCS:%.c=$(PROJECT_ROOT)/src/devices/%.c) \
501                 | $(PERL) -n -e 's,^(\S),devices/$$1,;print' \
502                 >> depend.mak
503
504 # By default, there are no header file dependencies.
505 depend.mak :
506         touch $@
507
508 include depend.mak