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 svm_lowlevel.asm over to gas syntax in svm_lowlevel.S
[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 :=
258 VMM_ASM_OBJS := $(VMM_ASM_SRCS:%.asm=palacios/%.o)
259
260 VMM_GAS_SRCS := svm_lowlevel.s
261 VMM_GAS_OBJS := $(VMM_GAS_SRCS:%.s=palacios/%.o)
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) $(VMM_GAS_OBJS)
279
280
281
282 XED_C_SRCS := v3-xed-compat.c
283 XED_C_OBJS := $(XED_C_SRCS:%.c=xed/%.o)
284
285 XED_GAS_SRCS := v3-udiv-compat.s
286 XED_GAS_OBJS := $(XED_GAS_SRCS:%.s=xed/%.o)
287
288 XED_OBJS := $(XED_C_OBJS) $(XED_GAS_OBJS)
289
290
291
292 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
293
294 DEVICE_C_OBJS := $(DEVICE_C_SRCS:%.c=devices/%.o)
295
296 DEVICE_OBJS := $(DEVICE_C_OBJS)
297
298 V3LIBS := $(DECODER_LIBS)
299
300
301
302
303
304 # ----------------------------------------------------------------------
305 # Tools -
306 #   This section defines programs that are used to build GeekOS.
307 # ----------------------------------------------------------------------
308
309
310 V3_ARCH := __V3_32BIT__
311 #V3_ARCH := __V3_64BIT__
312
313 # Uncomment if cross compiling
314 #TARGET_CC_PREFIX :=  $(PROJECT_ROOT)/../devtools/i386/bin/i386-elf-
315 #TARGET_CC_PREFIX :=  i386-elf-
316
317 # Target C compiler.  gcc 2.95.2 or later should work.
318 TARGET_CC := $(TARGET_CC_PREFIX)gcc -m32
319 #TARGET_CC := $(TARGET_CC_PREFIX)gcc34 -m32
320
321
322 # Target linker.  GNU ld is probably to only one that will work.
323 TARGET_LD := $(TARGET_CC_PREFIX)ld -melf_i386
324
325 # Target archiver
326 TARGET_AR := $(TARGET_CC_PREFIX)ar
327
328 # Target ranlib
329 TARGET_RANLIB := $(TARGET_CC_PREFIX)ranlib
330
331 # Target nm
332 TARGET_NM := $(TARGET_CC_PREFIX)nm
333
334 # Target objcopy
335 TARGET_OBJCOPY := $(TARGET_CC_PREFIX)objcopy
336
337 # Nasm (http://nasm.sourceforge.net)
338 NASM := $(PROJECT_ROOT)/../devtools/bin/nasm
339 #NASM := /opt/vmm-tools/bin/nasm
340
341 CPP := cpp
342
343
344 AS = as --32
345
346 # Tool to build PFAT filesystem images.
347 BUILDFAT := tools/builtFat.exe
348
349 # Perl5 or later
350 PERL := perl
351
352 # Pad a file so its size is a multiple of some unit (i.e., sector size)
353 PAD := $(PERL) $(PROJECT_ROOT)/scripts/pad
354
355 # Create a file filled with zeroes.
356 ZEROFILE := $(PERL) $(PROJECT_ROOT)/scripts/zerofile
357
358 # Calculate size of file in sectors
359 NUMSECS := $(PERL) $(PROJECT_ROOT)/scripts/numsecs
360
361
362 FD_SECTORS_PER_TRACK := $(PERL) $(PROJECT_ROOT)/scripts/numsecs_per_track
363
364
365 # ----------------------------------------------------------------------
366 # Definitions -
367 #   Options passed to the tools.
368 # ----------------------------------------------------------------------
369
370 # Flags used for all C source files
371 #GENERAL_OPTS := -O -Wall $(EXTRA_C_OPTS) $(VMM_FLAGS) -fPIC #-fvisibility=hidden
372 GENERAL_OPTS :=  -O -Wall  $(EXTRA_C_OPTS) $(VMM_FLAGS) -fPIC -Werror#-fvisibility=hidden
373 CC_GENERAL_OPTS := $(GENERAL_OPTS) 
374
375 # Flags used for VMM C source files
376 CC_VMM_OPTS := -g -I$(PROJECT_ROOT)/include -D__V3VEE__ -D$(V3_ARCH) $(DECODER_FLAGS) $(JRLDEBUG)
377
378 # Flags used for VMM C ASM files
379 NASM_VMM_OPTS := -I$(PROJECT_ROOT)/src/palacios/ -f elf $(EXTRA_NASM_OPTS)
380
381
382
383
384
385 # Flags passed to objcopy program (strip unnecessary sections from kernel.exe)
386 OBJCOPY_FLAGS := -R .dynamic -R .note -R .comment
387
388 # ----------------------------------------------------------------------
389 # Rules -
390 #   Describes how to compile the source files.
391 # ----------------------------------------------------------------------
392
393
394
395 palacios/%.o : palacios/%.c
396         $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o palacios/$*.o
397
398 palacios/%.o : palacios/%.asm
399         $(NASM) $(NASM_VMM_OPTS) $< -o palacios/$*.o
400
401 palacios/%.o : palacios/%.S
402         $(CPP) $(CC_VMM_OPTS) $< | $(AS) -o palacios/$*.o
403
404
405
406 devices/%.o : devices/%.c
407         $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o devices/$*.o
408
409 devices/%.o : devices/%.asm
410         $(NASM) $(NASM_VMM_OPTS) $< -o devices/$*.o
411
412
413 xed/%.o : xed/%.c
414         $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o xed/$*.o
415
416 xed/%.o : xed/%.s
417         $(AS) $< -o xed/$*.o
418
419
420 # ----------------------------------------------------------------------
421 # Targets -
422 #   Specifies files to be built
423 # ----------------------------------------------------------------------
424
425 # Default target - see definition of ALL_TARGETS in Configuration section
426 all : $(ALL_TARGETS)
427
428
429 #geekos/vmx_lowlevel.o: $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm
430 #       $(NASM) -O99 \
431 #       -f elf \
432 #               -I$(PROJECT_ROOT)/src/geekos/ \
433 #               $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm \
434 #       -o $@
435
436
437 #geekos/test: geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o 
438 #       $(CC) geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o  -o geekos/test
439
440
441
442 rombios_link:
443         ln -s -f ../src/vmboot/rombios/BIOS-bochs-latest rombios
444
445 vgabios_link:
446         ln -s -f ../src/vmboot/vgabios/VGABIOS-lgpl-latest.bin vgabios
447
448
449 force_rombios: rombios_link
450         (cd ../src/vmboot/rombios; make clean; make)
451
452 force_vgabios: vgabios_link
453         (cd ../src/vmboot/vgabios; make clean; make)
454
455 force_payload: force_rombios force_vgabios
456         ../scripts/make_payload.pl payload_layout.txt vm_kernel
457
458 inter1: force_payload
459         -make clean
460
461 world: inter1 vmm
462
463 vmm: palacios/vmm.lib 
464
465
466
467
468 # Loadable (flat) kernel image.
469 palacios/vmm.bin : palacios/vmm.lib
470         $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary palacios/vmm.lib palacios/vmm.bin
471
472
473 # The kernel executable and symbol map.
474 palacios/vmm.lib: $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS) vm_kernel
475 #       $(TARGET_LD) -o palacios/vmm.lib  \
476 #               $(DECODER_FLAGS) \
477 #                $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS) $(V3LIBS) -b binary vm_kernel
478 #       $(TARGET_NM) palacios/vmm.lib > palacios/vmm.syms
479         $(TARGET_AR) rcs libv3vee.a  \
480                  $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS)
481
482
483
484 force:
485
486
487
488
489
490 # Clean build directories of generated files
491 clean :
492         for d in palacios devices; do \
493                 (cd $$d && rm -f *); \
494         done
495
496
497 # Build header file dependencies, so source files are recompiled when
498 # header files they depend on are modified.
499 depend : $(GENERATED_LIBC_SRCS)
500
501         $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
502                 $(VMM_C_SRCS:%.c=$(PROJECT_ROOT)/src/palacios/%.c) \
503                 | $(PERL) -n -e 's,^(\S),palacios/$$1,;print' \
504                 >> depend.mak
505         $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
506                 $(DEVICE_C_SRCS:%.c=$(PROJECT_ROOT)/src/devices/%.c) \
507                 | $(PERL) -n -e 's,^(\S),devices/$$1,;print' \
508                 >> depend.mak
509
510 # By default, there are no header file dependencies.
511 depend.mak :
512         touch $@
513
514 include depend.mak