Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / arch / common.mk
CommitLineData
920dae64
AT
1# ========== Copyright Header Begin ==========================================
2#
3# Hypervisor Software File: common.mk
4#
5# Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6#
7# - Do no alter or remove copyright notices
8#
9# - Redistribution and use of this software in source and binary forms, with
10# or without modification, are permitted provided that the following
11# conditions are met:
12#
13# - Redistribution of source code must retain the above copyright notice,
14# this list of conditions and the following disclaimer.
15#
16# - Redistribution in binary form must reproduce the above copyright notice,
17# this list of conditions and the following disclaimer in the
18# documentation and/or other materials provided with the distribution.
19#
20# Neither the name of Sun Microsystems, Inc. or the names of contributors
21# may be used to endorse or promote products derived from this software
22# without specific prior written permission.
23#
24# This software is provided "AS IS," without a warranty of any kind.
25# ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
26# INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
27# PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
28# MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
29# ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30# DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
31# OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
32# FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
33# DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
34# ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
35# SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
36#
37# You acknowledge that this software is not designed, licensed or
38# intended for use in the design, construction, operation or maintenance of
39# any nuclear facility.
40#
41# ========== Copyright Header End ============================================
42# id: @(#)common.mk 1.24 06/10/13
43# purpose:
44# copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
45# copyright: Use is subject to license terms.
46
47include ${ROOT}/default.mk
48include ${ROOT}/tools/depend.mk
49include ${BP}/forth.mk
50include ${ROOT}/release.mk
51
52# Include the platform specific flags for building
53FFLAGS += ${PLATFLAGS}
54
55# MAGIC files:
56# When you build do a touch <thing> and you get more information
57# VERBOSE = show the filenames as they load
58# EXTERNAL = force all fcode symbols to be external
59# NOTIFY = make the Tokenizing message appear
60# WARNING = enable the tokenizer warning messages
61# HEADERS = include the 'headers' dropin for added symbols
62# FCODE-HEADERS = force non-external fcode symbols to have headers
63# FCODE-HEADERLESS = force non-external fcode symbols to be headerless
64
65#DECOMPSIZ = ${SIZE} -f decomp.o | \
66# ${AWK} -F+ '{ print $$1 $$2 }' |\
67# ${AWK} -F\( ' { print $$2, $$1 }' |\
68# ${AWK} '{ print $$2+($$3+3)-(($$3+3) % 4) }'
69
70DECOMPSIZ = ${SIZE} -f decomp.o | \
71 ${SED} -e 's/+/ /g' -e 's/(./ /g' -e 's/)//g' |\
72 ${AWK} -f getsz.awk
73
74DECOMPSIZE = ${DECOMPSIZ:sh}
75
76# Dont define NormalMAP or CompressMAP; If you want to specify a mapfile
77# just define MAPFILE.
78GetMAP = if [ -z "${MAPFILE}" ]; \
79 then /bin/echo ${SUN4U}/openboot${ROMSIZE}.map; \
80 else /bin/echo ${MAPFILE}; \
81 fi
82
83NormalMAP = ${GetMAP:sh}
84
85VERBOSE:sh = if [ -f VERBOSE ]; \
86 then /bin/echo '-v'; \
87 elif [ -f ../../VERBOSE ]; \
88 then /bin/echo '-v'; \
89 else /bin/echo ; fi ;
90
91COMPILER64:sh = if [ \( -f /usr/bin/optisa -a \
92 "`/usr/bin/optisa sparcv9`" = "sparcv9" \) ]; \
93 then /bin/echo '${BP}/os/unix/sparcv9/forth' ;\
94 else /bin/echo '${BP}/os/unix/simforth/sparc/simforth' ; fi ;
95
96FORTH64 = ${COMPILER64}
97
98NOTIFY:sh = if [ -f NOTIFY ]; \
99 then /bin/echo "/bin/echo"; \
100 else /bin/echo "/bin/true"; fi;
101
102WARNINGS:sh = if [ -f WARNING ];\
103 then /bin/echo "off"; \
104 else /bin/echo "on"; fi ;
105
106EXTERNAL:sh = if [ -f EXTERNAL ];\
107 then /bin/echo "force-external? on"; fi
108
109FCODE-HEADERS:sh = if [ -f FCODE-HEADERS ];\
110 then /bin/echo "force-headers? on"; fi
111
112FCODE-HEADERLESS:sh = if [ -f FCODE-HEADERLESS ];\
113 then /bin/echo "force-headerless? on"; fi
114
115
116FTHFLAGS =
117
118TOKFLAGS = aout-header? off\
119 silent ${WARNINGS}\
120 ${EXTERNAL} ${FCODE-HEADERS} ${FCODE-HEADERLESS}
121
122HDEBUG:sh = if [ -f HEADERS ]; \
123 then echo headers.di; fi
124
125FORTHDI = ${HDEBUG}
126
127# .SUFFIXES: .fc .tok ${SUFFIXES}
128
129etags: ${TOOLS}/fscope fscope.idx FORCE
130 ( BP=${BP}; export BP; \
131 ${TOOLS}/fscope -a -e -o etags -m etag -f fscope.idx; )
132
133tags: ${TOOLS}/fscope fscope.idx FORCE
134 ( BP=${BP}; export BP; \
135 ${TOOLS}/fscope -a -e -o tags -m tag -f fscope.idx; )
136
137decomp.o: ${TOOLDIR}/decomp.c
138 ${ECHO} Compiling $@
139 ${RM} $@
140 ${CC} -DSTANDALONE -fast -c ${TOOLDIR}/decomp.c -o decomp.o
141
142# Provide mechanisms to reuse loadprom, config and dropins files from other
143# platforms
144#
145DROPIN_SRC = if [ -z "${DROPINSRC}" ]; \
146 then /bin/echo ${PLATFORM}/release/dropins.src; \
147 else /bin/echo ${DROPINSRC}; fi
148
149LOADPROM = if [ -z "${LOADFILE}" ]; \
150 then /bin/echo ${PLATFORM}/loadprom.fth; \
151 else /bin/echo ${LOADFILE}; fi
152
153CONFIGLOAD = if [ -z "${CONFIG}" ]; \
154 then if [ -f ${PLATFORM}/setup/configload.fth -o \
155 -f ${PLATFORM}/setup/SCCS/s.configload.fth ]; \
156 then /bin/echo ${PLATFORM}/setup/configload.fth; \
157 else /bin/echo ; fi \
158 else /bin/echo ${CONFIG}; fi
159
160# If the makefile variable or the file MINI_T32 exists then we don't build
161# t16 kernels.
162MINI_T = if [ -z "${MINI_T32}" -a ! -f "MINI_T32" ]; \
163 then /bin/echo "-t16"; \
164 else /bin/echo; fi
165
166MINIFORTH = ${BP}/fm/kernel/sparc/k64mini${MINI_T:sh}
167
168config.bin: ../config.mk ${CONFIGLOAD:sh}
169config.bin: ${FORTH64} ${MINIFORTH}.dic
170 ${NOTIFY} "Building config.bin (${MINI_T:sh})"
171 ( BP=${BP}; export BP; ${FORTH64} -e 800 \
172 -d ${MINIFORTH}.dic \
173 ${VERBOSE} ${RELEASE} ${FFLAGS} \
174 -D kernel-hdr-file=${MINIFORTH}.fth \
175 -D LOADFILE=${CONFIGLOAD:sh} \
176 -D SAVEFILE=config.bin \
177 -D MINIFORTH \
178 ${BP}/arch/preload.fth )
179 ${TOUCH} headers
180 ${SORT} +1 headers > config.headers
181
182config.idx: ${PLATFORM}/setup/configload.fth
183config.idx: ${FORTH64} ${MINIFORTH}-xref.dic
184 ${NOTIFY} Building config.idx
185 ( BP=${BP}; export BP; ${FORTH64} -e 800 \
186 -D MINIFORTH ${RELEASE} -D XREF -x config.idx \
187 -d ${MINIFORTH}-xref.dic ${FFLAGS} \
188 -D XREF-PRELOAD=${MINIFORTH}-xref.dic.idx \
189 -D kernel-hdr-file=${MINIFORTH}-xref.fth \
190 -D LOADFILE=${PLATFORM}/setup/configload.fth \
191 ${BP}/arch/preload.fth )
192
193reset.o: ../reset.mk stand.dic
194reset.o: ${FORTH64} ${RESET} ${BP}/arch/preload.fth
195 ${NOTIFY} Building reset.o
196 ${GREP} headerless acfheaders > headerless
197 ${RM} $@
198 ( BP=${BP}; export BP; ${COMPILER64} \
199 -D dropin-mode -D TARGET-FILE=$@ \
200 -D RESET -D LOADFILE=${RESET} \
201 -e 900 -d stand.dic ${VERBOSE} ${FFLAGS} \
202 -s "d# ${DECOMPSIZE} constant decomp-size" \
203 -s " warning off" headerless \
204 ${BP}/arch/preload.fth )
205 ${RM} headerless
206
207reset.bin: decomp.o reset.o ${NormalMAP} ${ELF2BIN}
208 ${LD} -s -dn -e reset -M ${NormalMAP} reset.o decomp.o -o reset.elf
209 ${ELF2BIN} reset.elf reset.bin
210 ${RM} reset.elf
211
212openboot.bin: builtin.di ${MAKEPROM} reset.bin
213 ${NOTIFY} Building $@
214 ${MAKEPROM} ${MAKEPROM-FLAGS} -o openboot.bin -n reset.bin builtin.di
215
216clean::
217 ${RM} config.bin bootprom.bin reset.bin obp.bin
218 ${RM} config.di bootprom.di resetdi.o *.idx
219
220DATEFMT='+td %M td %H bwjoin td %d td %m bwjoin wljoin td %Y lxjoin'
221
222stand.dic: bootprom.bin
223
224forth.o: bootprom.bin
225 ${ECHO} REMOVE THIS TARGET $@
226
227FIRMWAREREL = cat ${BP}/firmware.rel
228
229bootprom.bin: ${RESET}
230bootprom.bin: ${BP}/firmware.rel ${CONFIGLOAD:sh} ${SUBREL-FILES:sh}
231bootprom.bin: ${LOADPROM:sh} ${BP}/arch/preload.fth
232bootprom.bin: ${FORTH64} ${KERNEL.DIC} builtin.fth
233 ${NOTIFY} "Building Openboot forth image (bootprom.bin)"
234 ${RM} $@ stand.dic sub-release headers
235 if [ ! -f revlevel ]; then echo 0 > revlevel; fi
236 ${ECHO} "headerless" > version.fth
237 ${ECHO} `date ${DATEFMT}` >> version.fth
238 ${ECHO} "constant compile-signature" >> version.fth
239 ${ECHO} "create (sub-release ,\" ${SUB-RELEASE}\"" >> version.fth
240 ${ECHO} "create (obp-release ,\" ${FIRMWAREREL:sh}\"" >> version.fth
241 ${ECHO} "' (sub-release is sub-release" >> version.fth
242 ${ECHO} "' (obp-release is obp-release" >> version.fth
243 ${ECHO} "headers" >> version.fth
244 ${EXPR} `cat revlevel` + 1 > revlevel
245 ( BP=${BP}; export BP; ${FORTH64} -e 800 \
246 -d ${KERNEL.DIC} ${VERBOSE} ${FFLAGS} ${RELEASE} \
247 -D kernel-hdr-file=${KERNEL}.fth \
248 -D LOADFILE=${LOADPROM:sh} \
249 -D SAVEFILE=bootprom.bin \
250 ${BP}/arch/preload.fth )
251 ${TOUCH} headers
252 ${SORT} +1 headers > acfheaders
253
254fscope.idx: ${FORTH64} ${KERNEL}-xref.dic bootprom.bin
255 ${NOTIFY} Creating $@
256 ( BP=${BP}; export BP; ${FORTH64} -e 800 \
257 -d ${KERNEL}-xref.dic ${FFLAGS} ${RELEASE} \
258 -D kernel-hdr-file=${KERNEL}-xref.fth \
259 -D XREF-PRELOAD=${KERNEL}-xref.dic.idx \
260 -D XREF -x fscope.idx \
261 -D LOADFILE=${LOADPROM:sh} \
262 ${BP}/arch/preload.fth )
263
264clean:: ${DIDEPEND} ${DROPIN_SRC:sh}
265 ${RM} dropins.mk builtin.fth
266 ${RM} forth.bin openboot.bin
267 ${RM} forth.bin0 openboot.bin0
268 ${RM} forth.out openboot.prom
269 ${RM} reset.o decomp.o forth.o cforth.o
270 ${RM} version.fth lastversion.fth stand.dic
271 ${RM} kbdtrans.fc sun-logo.dat usbkbds.dat builtin.di
272 ${RM} acfheaders headers revlevel-
273 ${RM} openboot.img
274 ${RM} `${DIDEPEND} ${PLATFLAGS} -t ${DROPIN_SRC:sh}`
275 ${RM} `${DIDEPEND} ${PLATFLAGS} -s ${DROPIN_SRC:sh}`
276 ${RM} *.idx *.fc *.di *.o
277 ${RM} core HEADERS
278
279TOKENRULE = \
280 ( fname=".XX.YY.XX"; for i in $^; do \
281 if ${ECHO} $$i | ${EGREP} -e "\.tok" > /dev/null; then \
282 fname=$$i; \
283 fi; \
284 done; \
285 if [ -f $$fname ]; then \
286 ${NOTIFY} "Tokenizing $$fname"; \
287 BP=${BP}; export BP; \
288 ${TOKENIZE} ${VERBOSE} ${RELEASE} -x $*.idx \
289 -s "${FTHFLAGS}" \
290 -s "${TOKFLAGS} tokenize $$fname $*.fc"; \
291 else \
292 ${RM} $*.fc; \
293 ${MAKE} $*.fc; \
294 fi )
295
296%.fc:
297 ${TOKENRULE}
298
299install: backup
300 @${WHAT} openboot.bin
301 if [ -f RTARGET ]; then \
302 /bin/echo Installing `cat RTARGET`/openboot.bin ;\
303 rcp -p openboot.bin `cat RTARGET`;\
304 if [ -f forth.flash ]; then \
305 /bin/echo Installing `cat RTARGET`/forth.flash ;\
306 rcp -p forth.flash `cat RTARGET`;\
307 fi;\
308 fi ;\
309 if [ -f TARGET ]; then \
310 /bin/echo Installing `cat TARGET` ;\
311 cp -p openboot.bin `cat TARGET`;\
312 fi
313
314DEPEND.MK = ../depend.mk
315DEPEND.MK1 = depend.new
316# As of 2004, the convention is just the current year, not a range of years.
317CDATE:sh = /bin/date '+Copyright %Y Sun Microsystems, Inc.'
318# depend := FFLAGS += -v
319depend:: ${DEPEND.MK} ${TOOLS}/move-if-changed builtin.fth stand.dic FORCE
320 ${RM} ${DEPEND.MK1}
321 ${ECHO} "# id: ""%""Z""%""%""M""%" " %""I""%" " %""E""%">${DEPEND.MK1}
322 ${ECHO} "# purpose: ""%""Y""%" >>${DEPEND.MK1}
323 ${ECHO} "# copyright: ${CDATE} All Rights Reserved" >>${DEPEND.MK1}
324 ${ECHO} "# copyright: Use is subject to license terms." >>${DEPEND.MK1}
325 ${ECHO} "# This is a machine generated file" >>${DEPEND.MK1}
326 ${ECHO} "# DO NOT EDIT IT BY HAND" >>${DEPEND.MK1}
327 ( BP=${BP}; export BP; ${FORTH64} -e 800 -d ${KERNEL.DIC} \
328 -D DEPEND -D kernel-hdr-file=${KERNEL}.fth ${FFLAGS} -u -v \
329 -D LOADFILE=${LOADPROM:sh} \
330 ${BP}/arch/preload.fth ) |\
331 ${GREP} File: |\
332 ${EGREP} -v "( version.fth| headers| loadprom.fth)" |\
333 ${SED} -e 's/File: /bootprom.bin: /'|\
334 ${SED} -e 's:${BP}:$${BP}:' |\
335 ${SORT}|${UNIQ} >>${DEPEND.MK1}
336 ${TOOLS}/move-if-changed ${DEPEND.MK} ${DEPEND.MK1}
337
338depend:: ${DEPEND.MK} ${TOOLS}/move-if-changed builtin.fth stand.dic FORCE
339 ( BP=${BP}; export BP; \
340 if [ ! -z "${CONFIGLOAD:sh}" ]; then \
341 ${RM} ${DEPEND.MK1}; \
342 ${ECHO} "# id: ""%""Z""%""%""M""% %""I""%" " %""E""%">${DEPEND.MK1}; \
343 ${ECHO} "# purpose: ""%""Y""%" >>${DEPEND.MK1}; \
344 ${ECHO} "# copyright: ${CDATE} All Rights Reserved" >>${DEPEND.MK1}; \
345 ${ECHO} "# copyright: Use is subject to license terms." >>${DEPEND.MK1}; \
346 ${ECHO} "# This is a machine generated file" >>${DEPEND.MK1}; \
347 ${ECHO} "# DO NOT EDIT IT BY HAND" >>${DEPEND.MK1}; \
348 ( ${FORTH64} -e 800 -d ${KERNEL.DIC} \
349 -D MINIFORTH -D DEPEND ${RELEASE} \
350 -D kernel-hdr-file=${KERNEL}.fth ${FFLAGS} -u -v \
351 -D LOADFILE=${CONFIGLOAD:sh} \
352 ${BP}/arch/preload.fth ) |\
353 ${GREP} File: | \
354 ${EGREP} -v "( version.fth| headers)" |\
355 ${SED} -e 's/File: /config.bin: /'|\
356 ${SED} -e 's:${BP}:$${BP}:'|\
357 ${SORT}|${UNIQ} >>${DEPEND.MK1}; \
358 ${TOOLS}/move-if-changed ../config.mk ${DEPEND.MK1}; \
359 else \
360 exit 0; \
361 fi; )
362
363depend:: ../reset.mk stand.dic decomp.o ${TOOLS}/move-if-changed FORCE
364 ${GREP} headerless acfheaders > headerless
365 ${RM} reset.o
366 ${RM} ${DEPEND.MK1}
367 ${ECHO} "# id: ""%""Z""%""%""M""%" " %""I""%" " %""E""%">${DEPEND.MK1}
368 ${ECHO} "# purpose: ""%""Y""%" >>${DEPEND.MK1}
369 ${ECHO} "# copyright: ${CDATE} All Rights Reserved" >>${DEPEND.MK1}
370 ${ECHO} "# copyright: Use is subject to license terms." >>${DEPEND.MK1}
371 ${ECHO} "# This is a machine generated file" >>${DEPEND.MK1}
372 ${ECHO} "# DO NOT EDIT IT BY HAND" >>${DEPEND.MK1}
373 ( BP=${BP}; export BP; ${COMPILER64} \
374 -D RESET -D DEPEND ${RELEASE} -D LOADFILE=${RESET} \
375 -e 900 -d stand.dic ${FFLAGS} -v -u \
376 -s "d# ${DECOMPSIZE} constant decomp-size" \
377 -s " warning off" headerless \
378 ${BP}/arch/preload.fth ) |\
379 ${GREP} File: |\
380 ${EGREP} -v "(headerless| reset.fth)" |\
381 ${SED} -e 's/File: /reset.o: /'|\
382 ${SED} -e 's:${BP}:$${BP}:'|\
383 ${SORT}|${UNIQ} >>${DEPEND.MK1}
384 ${TOOLS}/move-if-changed ../reset.mk ${DEPEND.MK1}
385 ${RM} headerless
386
387backup: all ${MAKEPROM}
388 ${RM} forth.flash
389 if [ -f openboot.ok ]; then \
390 ${MAKEPROM} -o forth.flash openboot.bin openboot.ok ;\
391 fi
392
393clobber::
394 ${SCCS} clean
395
396builtin.fth: ${DIDEPEND} ${DROPIN_SRC:sh}
397 ${DIDEPEND} ${PLATFLAGS} -c ${DROPIN_SRC:sh} > builtin.fth
398
399dropins.mk: ${DIDEPEND} ${DROPIN_SRC:sh}
400 ${DIDEPEND} ${PLATFLAGS} -d ${DROPIN_SRC:sh} > dropins.mk
401 ${ECHO} >> dropins.mk
402 ${ECHO} "builtin.di: `${DIDEPEND} ${PLATFLAGS} -t ${DROPIN_SRC:sh}`" >> dropins.mk
403
404headers.di: ${TOOLS}/makedi headers
405 ${ECHO} "\\\ Forth Comment" > headers.dat
406 ${CAT} headers >> headers.dat
407 ${MAKEDI} headers.dat headers
408 ${RM} headers.dat
409
410# Get the dropins that make an image.
411
412DIFCODE = if [ ! -f ${DROPIN_SRC:sh} ]; then \
413 ( cd `dirname ${DROPIN_SRC:sh}`; sccs get dropins.src; ) fi; \
414 ${DIDEPEND} ${PLATFLAGS} -s ${DROPIN_SRC:sh} | \
415 sed -e 's/config.bin//' -e 's/bootprom.bin//'
416
417DITARGETS = ${DIDEPEND} ${PLATFLAGS} -t ${DROPIN_SRC:sh}
418
419builtin.di: ${FORTH} ${TOKENIZEDIC}
420builtin.di: ${DROPIN_SRC:sh} ${TOOLS}/makedi ${FORTHDI} ${DIDEPEND}
421 cat ${FORTHDI} ${DITARGETS:sh} > builtin.di
422
423include dropins.mk