summaryrefslogtreecommitdiff
path: root/bootwrapper/Makefile
blob: bb59aec4b0c63656c8b27cbd3ac4f05e863115f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#
# Copyright (c) 2012, ARM Limited. All rights reserved.
#
# Redistribution and use in source and binary forms, with
# or without modification, are permitted provided that the
# following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# Redistributions in binary form must reproduce the
# above copyright notice, this list of conditions and
# the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# Neither the name of ARM nor the names of its
# contributors may be used to endorse or promote products
# derived from this software without specific prior written
# permission.
#

# Decrease the verbosity of the make script
# can be made verbose by passing V=1 at the make command line
ifdef V
  KBUILD_VERBOSE = $(V)
else
  KBUILD_VERBOSE = 0
endif

ifeq "$(KBUILD_VERBOSE)" "0"
	Q=@
else
	Q=
endif

VE?=TRUE
T2?=FALSE
L2_POLICY?=WF
LOBASE?=0x800
KERNADDR?=$(LOBASE)08000
# megabyte at which the vectors are located (almost always zero)
VECTBASE?=$(LOBASE)
# Set the megabyte that the BIOS code will execute at
HIBASE?=0x8FF
FSADDR?=0x8e400000
DEBUG=TRUE
# BOOT_CLUSTER is also defined in big-little/Makefile!
BOOT_CLUSTER?=0
# SWITCHER is also defined in big-little/Makefile!
SWITCHER?=TRUE

ifeq "$(BA)" ""
BOOTARGS=mem=255M console=ttyAMA0,115200 migration_cost=500 cachepolicy=writealloc
BA=$(BOOTARGS)
else
BOOTARGS=$(BA)
endif

V7_ASFLAGS=--apcs /inter --cpu=Eagle --keep \
 --pd "BOOTARGS SETS \"$(BOOTARGS)\"" \
 --pd "L2_POLICY SETS \"$(L2_POLICY)\"" \
 --pd "VE SETL {$(VE)}" \
 --pd "HIBASE SETS \"$(HIBASE)\"" 

CFLAGS:=--cpu=Eagle -O2 \
 -DT2=$(T2) \
 -DSETUPMMU=$(SETUPMMU) \
 -DHIBASE=$(HIBASE) \
 -DVE=$(VE) \
 -DBOOT_CLUSTER=$(BOOT_CLUSTER) \
 -DVECTBASE=$(VECTBASE) \
 -DSWITCHER=$(SWITCHER)

ifdef DEBUG
CFLAGS     += -g -O0
ASFLAGS    += -g
V7_ASFLAGS += -g
endif

OBJS=  boot.o bootargs.o c_start.o helpers.o kernel.o filesystem.o uart.o vectors.o bl_sec.o bl.o

.PHONY: all
all: img.axf

.PHONY: bl
bl:
	make -C big-little bl.axf

.PHONY: bl_sec
bl_sec:
	make -C big-little bl_sec.axf wboot.bin

.PHONY: clean

clean:
	@echo "  CLEAN"
	$(Q)rm -f $(OBJS) img.axf *.map bl.S bl_sec.S
	make -C big-little clean

# Extra dependencies
boot.o: emubuild.s
helpers.o : emubuild.s

%.o: %.S
	@echo "  AS      $<"
	$(Q)armasm $(V7_ASFLAGS) -o $@ $<

%.o: %.c
	@echo "  CC      $<"
	$(Q)armcc $(CFLAGS) -o $@ -c $<

bl.S:	
	make -C big-little bl.axf
	@echo "  MAP"
	$(Q)./makemap big-little/bl.axf bl

bl.o:	bl.S
	@echo "  AS      $<"
	$(Q)armasm $(V7_ASFLAGS) -o $@ $<

bl_sec.S:	
	make -C big-little bl_sec.axf wboot.bin
	@echo "  MAP"
	$(Q)./makemap big-little/bl_sec.axf bl_sec

bl_sec.o: bl_sec.S
	@echo "  AS      $<"
	$(Q)armasm $(V7_ASFLAGS) -o $@ $<

img.axf: $(OBJS)
	$(Q)cat boot.map.template > boot.map
	$(Q)cat bl_sec.map >> boot.map
	$(Q)cat bl.map >> boot.map
	$(Q)sed -i \
	-e "s/KERNADDRBA/$(shell perl -e "printf('0x%08X',$(KERNADDR)-0x7f00)")/g" \
	-e "s/FSADDR/${FSADDR}/g" \
	-e "s/HIBASE/${HIBASE}/g" \
	-e "s/KERNADDR/${KERNADDR}/g" \
	-e "s/VECTBASE/${VECTBASE}/g" \
	boot.map
	@echo "  LD      $@"
	$(Q)armlink --entry $(VECTBASE)00000 -o $@ --scatter boot.map $(OBJS)