Skip to content

Commit 26ade46

Browse files
committed
Initial carry forwarded open commit.
0 parents  commit 26ade46

File tree

318 files changed

+69533
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+69533
-0
lines changed

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Files to be excluded
3+
#
4+
.*
5+
*.o
6+
*.elf
7+
*.bin
8+
*.lnk
9+
*.dis
10+
*.txt
11+
gdbinit0
12+
gdbinit1
13+
build/
14+
test_*objs/
15+
cscope.*
16+
*~
17+
tools/openconf/lex.zconf.c
18+
tools/openconf/conf
19+
tools/openconf/mconf
20+
tools/openconf/zconf.hash.c
21+
patches
22+
create-flash-image
23+
flash
24+
#
25+
# Exceptions
26+
#
27+
!.mambacfg
28+
!.gitignore
29+
30+
tags
31+
.*.swp

COPYING

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
#/**
2+
# Copyright (c) 2010 Anup Patel.
3+
# All rights reserved.
4+
#
5+
# This program is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation; either version 2, or (at your option)
8+
# any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program; if not, write to the Free Software
17+
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18+
#
19+
# @file Makefile
20+
# @version 1.0
21+
# @author Anup Patel ([email protected])
22+
# @brief toplevel makefile to build VMM source code
23+
# */
24+
25+
# Find out source & build directories
26+
src_dir=$(CURDIR)
27+
ifdef O
28+
build_dir=$(shell readlink -f $(O))
29+
else
30+
build_dir=$(CURDIR)/build
31+
endif
32+
33+
# Check if verbosity is ON for build process
34+
VERBOSE_DEFAULT := 0
35+
CMD_PREFIX_DEFAULT := @
36+
ifdef VERBOSE
37+
ifeq ("$(origin VERBOSE)", "command line")
38+
VB := $(VERBOSE)
39+
else
40+
VB := $(VERBOSE_DEFAULT)
41+
endif
42+
else
43+
VB := $(VERBOSE_DEFAULT)
44+
endif
45+
ifeq ($(VB), 1)
46+
V :=
47+
else
48+
V := $(CMD_PREFIX_DEFAULT)
49+
endif
50+
51+
# Name & Version
52+
export PROJECT_NAME = Xvisor (eXtensible Versatile hypervISOR)
53+
export PROJECT_VERSION = 0.1
54+
export CONFIG_DIR=$(build_dir)/tmpconf
55+
export CONFIG_FILE=$(build_dir)/.config
56+
export DEPENDENCY_FILE=$(build_dir)/.deps
57+
58+
# Openconf settings
59+
export OPENCONF_PROJECT = $(PROJECT_NAME)
60+
export OPENCONF_VERSION = $(PROJECT_VERSION)
61+
export OPENCONF_INPUT = openconf.cfg
62+
export OPENCONF_CONFIG = $(CONFIG_FILE)
63+
export OPENCONF_TMPDIR = $(CONFIG_DIR)
64+
export OPENCONF_AUTOCONFIG = openconf.conf
65+
export OPENCONF_AUTOHEADER = openconf.h
66+
67+
# Include configuration file if present
68+
-include $(CONFIG_FILE)
69+
CONFIG_ARCH:=$(shell echo $(CONFIG_ARCH))
70+
CONFIG_CPU:=$(shell echo $(CONFIG_CPU))
71+
CONFIG_BOARD:=$(shell echo $(CONFIG_BOARD))
72+
73+
# Setup path of directories
74+
export core_dir=$(CURDIR)/core
75+
export cpu_dir=$(CURDIR)/arch/$(CONFIG_ARCH)/cpu/$(CONFIG_CPU)
76+
export cpu_common_dir=$(CURDIR)/arch/$(CONFIG_ARCH)/cpu/common
77+
export board_dir=$(CURDIR)/arch/$(CONFIG_ARCH)/board/$(CONFIG_BOARD)
78+
export board_common_dir=$(CURDIR)/arch/$(CONFIG_ARCH)/board/common
79+
export tools_dir=$(CURDIR)/tools
80+
export drivers_dir=$(CURDIR)/drivers
81+
export emulators_dir=$(CURDIR)/emulators
82+
83+
# Setup list of objects for compilation
84+
cpu-object-mks=$(shell if [ -d $(cpu_dir) ]; then find $(cpu_dir) -iname "objects.mk"; fi)
85+
cpu-common-object-mks=$(shell if [ -d $(cpu_common_dir) ]; then find $(cpu_common_dir) -iname "objects.mk"; fi)
86+
board-object-mks=$(shell if [ -d $(board_dir) ]; then find $(board_dir) -iname "objects.mk"; fi)
87+
board-common-object-mks=$(shell if [ -d $(board_common_dir) ]; then find $(board_common_dir) -iname "objects.mk"; fi)
88+
core-object-mks=$(shell if [ -d $(core_dir) ]; then find $(core_dir) -iname "objects.mk"; fi)
89+
drivers-object-mks=$(shell if [ -d $(drivers_dir) ]; then find $(drivers_dir) -iname "objects.mk"; fi)
90+
emulators-object-mks=$(shell if [ -d $(emulators_dir) ]; then find $(emulators_dir) -iname "objects.mk"; fi)
91+
include $(cpu-object-mks)
92+
include $(cpu-common-object-mks)
93+
include $(board-object-mks)
94+
include $(board-common-object-mks)
95+
include $(core-object-mks)
96+
include $(drivers-object-mks)
97+
include $(emulators-object-mks)
98+
objs-y=$(foreach obj,$(cpu-objs-y),$(build_dir)/arch/$(CONFIG_ARCH)/cpu/$(CONFIG_CPU)/$(obj))
99+
objs-y+=$(foreach obj,$(cpu-common-objs-y),$(build_dir)/arch/$(CONFIG_ARCH)/cpu/common/$(obj))
100+
objs-y+=$(foreach obj,$(board-objs-y),$(build_dir)/arch/$(CONFIG_ARCH)/board/$(CONFIG_BOARD)/$(obj))
101+
objs-y+=$(foreach obj,$(board-common-objs-y),$(build_dir)/arch/$(CONFIG_ARCH)/board/common/$(obj))
102+
objs-y+=$(foreach obj,$(core-objs-y),$(build_dir)/core/$(obj))
103+
objs-y+=$(foreach obj,$(drivers-objs-y),$(build_dir)/drivers/$(obj))
104+
objs-y+=$(foreach obj,$(emulators-objs-y),$(build_dir)/emulators/$(obj))
105+
106+
# Setup list of deps files for compilation
107+
deps-y=$(objs-y:.o=.dep)
108+
109+
# Setup list of tools for compilation
110+
include $(tools_dir)/tools.mk
111+
112+
# Setup list of targets for compilation
113+
targets-y=$(build_dir)/vmm.elf
114+
targets-y+=$(build_dir)/vmm.bin
115+
116+
# Setup compilation environment
117+
cpp=$(CROSS_COMPILE)cpp
118+
cppflags=-include $(OPENCONF_TMPDIR)/$(OPENCONF_AUTOHEADER)
119+
cppflags+=-I$(cpu_dir)/include
120+
cppflags+=-I$(cpu_common_dir)/include
121+
cppflags+=-I$(board_dir)/include
122+
cppflags+=-I$(board_common_dir)/include
123+
cppflags+=-I$(core_dir)/include
124+
cppflags+=-I$(drivers_dir)/include
125+
cppflags+=-I$(emulators_dir)/include
126+
cppflags+=$(cpu-cppflags)
127+
cppflags+=$(board-cppflags)
128+
cc=$(CROSS_COMPILE)gcc
129+
cflags=-g -Wall -nostdlib
130+
cflags+=$(board-cflags)
131+
cflags+=$(cpu-cflags)
132+
cflags+=$(cppflags)
133+
as=$(CROSS_COMPILE)gcc
134+
asflags=-g -Wall -nostdlib -D__ASSEMBLY__
135+
asflags+=$(board-asflags)
136+
asflags+=$(cpu-asflags)
137+
asflags+=$(cppflags)
138+
ar=$(CROSS_COMPILE)ar
139+
arflasgs=rcs
140+
ld=$(CROSS_COMPILE)gcc
141+
ldflags=-g -Wall -nostdlib
142+
ldflags+=$(board-ldflags)
143+
ldflags+=$(cpu-ldflags)
144+
ldflags+=-Wl,-T$(build_dir)/linker.ld
145+
objcopy=$(CROSS_COMPILE)objcopy
146+
147+
# Default rule "make"
148+
.PHONY: all
149+
all: $(CONFIG_FILE) $(DEPENDENCY_FILE) $(tools-y) $(targets-y)
150+
151+
# Generate and Include dependency rules
152+
-include $(DEPENDENCY_FILE)
153+
$(DEPENDENCY_FILE): $(CONFIG_FILE) $(deps-y)
154+
$(V)cat $(deps-y) > $(DEPENDENCY_FILE)
155+
156+
# Include additional rules for tools
157+
include $(tools_dir)/rules.mk
158+
159+
# Rules to build .S and .c files
160+
$(build_dir)/vmm.bin: $(build_dir)/vmm.elf
161+
$(V)mkdir -p `dirname $@`
162+
$(if $(V), @echo " (objcopy) $(subst $(build_dir)/,,$@)")
163+
$(V)$(objcopy) -O binary $< $@
164+
165+
$(build_dir)/vmm.elf: $(build_dir)/linker.ld $(objs-y)
166+
$(V)mkdir -p `dirname $@`
167+
$(if $(V), @echo " (ld) $(subst $(build_dir)/,,$@)")
168+
$(V)$(ld) $(objs-y) $(ldflags) -o $@
169+
170+
$(build_dir)/linker.ld: $(cpu_dir)/linker.ld
171+
$(V)mkdir -p `dirname $@`
172+
$(if $(V), @echo " (cpp) $(subst $(build_dir)/,,$@)")
173+
$(V)$(cpp) $(cppflags) $< | grep -v "\#" > $@
174+
175+
$(build_dir)/%.dep: $(src_dir)/%.S
176+
$(V)mkdir -p `dirname $@`
177+
$(if $(V), @echo " (as-dep) $(subst $(build_dir)/,,$@)")
178+
$(V)echo -n `dirname $@`/ > $@
179+
$(V)$(as) $(asflags) -I`dirname $<` -MM $< >> $@
180+
181+
$(build_dir)/%.dep: $(src_dir)/%.c
182+
$(V)mkdir -p `dirname $@`
183+
$(if $(V), @echo " (cc-dep) $(subst $(build_dir)/,,$@)")
184+
$(V)echo -n `dirname $@`/ > $@
185+
$(V)$(cc) $(cflags) -I`dirname $<` -MM $< >> $@
186+
187+
$(build_dir)/%.o: $(src_dir)/%.S
188+
$(V)mkdir -p `dirname $@`
189+
$(if $(V), @echo " (as) $(subst $(build_dir)/,,$@)")
190+
$(V)$(as) $(asflags) -I`dirname $<` -c $< -o $@
191+
192+
$(build_dir)/%.o: $(build_dir)/%.S
193+
$(V)mkdir -p `dirname $@`
194+
$(if $(V), @echo " (as) $(subst $(build_dir)/,,$@)")
195+
$(V)$(as) $(asflags) -I`dirname $<` -c $< -o $@
196+
197+
$(build_dir)/%.o: $(src_dir)/%.c
198+
$(V)mkdir -p `dirname $@`
199+
$(if $(V), @echo " (cc) $(subst $(build_dir)/,,$@)")
200+
$(V)$(cc) $(cflags) -I`dirname $<` -c $< -o $@
201+
202+
$(build_dir)/%.o: $(build_dir)/%.c
203+
$(V)mkdir -p `dirname $@`
204+
$(if $(V), @echo " (cc) $(subst $(build_dir)/,,$@)")
205+
$(V)$(cc) $(cflags) -I`dirname $<` -c $< -o $@
206+
207+
# Rule for "make clean"
208+
.PHONY: clean
209+
clean: $(CONFIG_FILE)
210+
ifeq ($(build_dir),$(CURDIR)/build)
211+
$(if $(V), @echo " (rm) $(build_dir)")
212+
$(V)rm -rf $(build_dir)
213+
endif
214+
$(V)$(MAKE) -C $(src_dir)/tools/dtc clean
215+
216+
# Rule for "make distclean"
217+
.PHONY: distclean
218+
distclean:
219+
$(V)$(MAKE) -C $(src_dir)/tools/openconf clean
220+
221+
# Include config file rules
222+
-include $(CONFIG_FILE).cmd
223+
224+
# Rule for "make menuconfig"
225+
.PHONY: menuconfig
226+
menuconfig:
227+
$(V)mkdir -p $(OPENCONF_TMPDIR)
228+
$(V)$(MAKE) -C tools/openconf menuconfig
229+
./tools/openconf/mconf $(OPENCONF_INPUT)
230+
231+
# Rule for "make oldconfig"
232+
.PHONY: oldconfig
233+
oldconfig:
234+
$(V)mkdir -p $(OPENCONF_TMPDIR)
235+
$(V)$(MAKE) -C tools/openconf oldconfig
236+
$(V)cp $(src_dir)/arch/$(ARCH)/board/$(BOARD)/defconfig $(OPENCONF_CONFIG)
237+
./tools/openconf/conf -o $(OPENCONF_INPUT)
238+
239+
# Rule for "make defconfig"
240+
.PHONY: defconfig
241+
defconfig:
242+
$(V)mkdir -p $(OPENCONF_TMPDIR)
243+
$(V)$(MAKE) -C tools/openconf defconfig
244+
$(V)cp $(src_dir)/arch/$(ARCH)/board/$(BOARD)/defconfig $(OPENCONF_CONFIG)
245+
./tools/openconf/conf -s $(OPENCONF_INPUT)
246+
247+
.PHONY: tags
248+
tags:
249+
$(V)ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
250+
$(V)echo "Generating tags ..."
251+
252+
.PHONY: cscope
253+
cscope:
254+
$(V)echo "Generating cscope database ..."
255+
$(V)find ./ -name "*.[CHSchs]" > cscope.files
256+
$(V)cscope -bqk

0 commit comments

Comments
 (0)