shithub: riscv

ref: 82559c3fdcc8242a1a542a3b4d3076e133fd02a9
dir: /sys/src/9/teg2/mkfile/

View raw version
CONF=ts
CONFLIST=ts
EXTRACOPIES=

# allegedly u-boot uses the bottom 4MB (up to 0x400000) so avoid that,
# and leave 64K for plan9.ini.  loadaddr must match KTZERO in mem.h
# and CONFADDR must be 0x10000 lower.
loadaddr=0xc0410000

objtype=arm
</$objtype/mkfile
p=9

DEVS=`{rc ../port/mkdevlist $CONF}

PORT=\
	alarm.$O\
	alloc.$O\
	allocb.$O\
	auth.$O\
	cache.$O\
	chan.$O\
	dev.$O\
	edf.$O\
	fault.$O\
	mul64fract.$O\
	rebootcmd.$O\
	page.$O\
	parse.$O\
	pgrp.$O\
	portclock.$O\
	print.$O\
	proc.$O\
	qio.$O\
	qlock.$O\
	segment.$O\
	syscallfmt.$O\
	sysfile.$O\
	sysproc.$O\
	taslock.$O\
	tod.$O\
	xalloc.$O\

OBJ=\
	l.$O\
	lexception.$O\
	lproc.$O\
	arch.$O\
	clock.$O\
	clock-tegra.$O\
	main.$O\
	mmu.$O\
	random.$O\
	trap.$O\
	syscall.$O\
	$CONF.root.$O\
	$CONF.rootc.$O\
	$DEVS\
	$PORT\

HFILES=\
	arm.h\
	dat.h\
	../port/error.h\
	errstr.h\
	fns.h\
	io.h\
	../port/lib.h\
	mem.h\
	../port/portdat.h\
	../port/portfns.h\
	/$objtype/include/u.h\

LIB=\
	/$objtype/lib/libmemlayer.a\
	/$objtype/lib/libmemdraw.a\
	/$objtype/lib/libdraw.a\
	/$objtype/lib/libip.a\
	/$objtype/lib/libsec.a\
	/$objtype/lib/libmp.a\
	/$objtype/lib/libc.a\

9:V: $p$CONF s$p$CONF

$p$CONF:DQ:	$CONF.c $OBJ $LIB mkfile
	$CC $CFLAGS '-DKERNDATE='`{date -n} $CONF.c
	echo '# linking raw kernel'	# H6: no headers, data segment aligned
	$LD -o $target -H6 -R4096 -T$loadaddr -l $OBJ $CONF.$O $LIB

s$p$CONF:DQ:	$CONF.$O $OBJ $LIB
	echo '# linking 9 kernel with symbols'
#	$LD -o $target -R4096 -T$loadaddr -l -a $OBJ $CONF.$O $LIB >$target.list
	$LD -o $target -R4096 -T$loadaddr -l $OBJ $CONF.$O $LIB
	size $target

$p$CONF.gz:D:	$p$CONF
	gzip -9 <$p$CONF >$target

$OBJ: $HFILES

install:V: /$objtype/$p$CONF

/$objtype/$p$CONF:D: $p$CONF s$p$CONF
	cp -x $p$CONF s$p$CONF /$objtype/ &
	for(i in $EXTRACOPIES)
		{ 9fs $i && cp $p$CONF s$p$CONF /n/$i/$objtype && echo -n $i... & }
	wait
	echo
	touch $target

<../boot/bootmkfile
<../port/portmkfile
<|../port/mkbootrules $CONF

CFLAGS= -I. -I../port $CFLAGS	# hack to compile private sysproc.c (e.g.)

arch.$O clock.$O fpiarm.$O main.$O mmu.$O screen.$O sdscsi.$O syscall.$O \
	trap.$O: /$objtype/include/ureg.h

archtegra.$O devether.$0 ether9221.$O: ../port/etherif.h ../port/netif.h
archtegra.$O devflash.$O flashtegra.$O flashigep.$O: ../port/flashif.h
ecc.$O flashtegra.$O flashigep.$O: ../port/nandecc.h io.h
fpi.$O fpiarm.$O fpimem.$O: fpi.h
l.$O lexception.$O lproc.$O mmu.$O: arm.s mem.h
l.$O rebootcode.$O: cache.v7.s
main.$O: errstr.h init.h reboot.h
devusb.$O: ../port/usb.h
usbehci.$O usbohci.$O usbuhci.$O: ../port/usb.h usbehci.h uncached.h

init.h:D:	../port/initcode.c init9.s
	$CC ../port/initcode.c
	$AS init9.s
	$LD -l -R1 -s -o init.out init9.$O initcode.$O /$objtype/lib/libc.a
	{echo 'uchar initcode[]={'
	 xd -1x <init.out |
		sed -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
	 echo '};'} > init.h

reboot.h:D:	rebootcode.s cache.v7.s arm.s arm.h mem.h
	$AS rebootcode.s
	# -lc is only for memmove.  -T arg is PADDR(REBOOTADDR)
#	$LD -l -a -s -T0x100 -R4 -o reboot.out rebootcode.$O -lc >reboot.list
	$LD -l -s -T0x100 -R4 -o reboot.out rebootcode.$O -lc
	{echo 'uchar rebootcode[]={'
	 xd -1x reboot.out |
		sed -e '1,2d' -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
	 echo '};'} > reboot.h
errstr.h:D:	../port/mkerrstr ../port/error.h
	rc ../port/mkerrstr > errstr.h

$CONF.clean:
	rm -rf $p$CONF s$p$CONF errstr.h reboot.h $CONF.c boot$CONF.c