shithub: riscv

ref: 0cb4115b8234946b5468f3f0fe29d4c6a94f1026
dir: /sys/src/9/xen/mkfile/

View raw version
CONF=xenpcf
CONFLIST=xenpcf

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

KTZERO=0x80010000
KZERO=0x80000000
KPZERO=0x10000
PAE=yes

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

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

XEN=\
	xengrant.$O\
	xentimer.$O\
	xensystem.$O\

SCHED=`{ls -p xen-public/sched*.h >[2]/dev/null}
ARCH=`{test -d xen-public/arch-x86 && echo arch-x86/xen-x86_32.h arch-x86/xen.h || echo arch-x86_32.h }

XENHEADERS=\
	$ARCH\
	xen.h\
	event_channel.h\
	grant_table.h\
	memory.h\
	physdev.h\
	$SCHED\
	io/ring.h\
	io/blkif.h\
	io/console.h\
	io/netif.h\
	io/xenbus.h\
	io/xs_wire.h\

OBJ=\
	l.$O\
	plan9l.$O\
	xen.$O\
	main.$O\
	mmu.$O\
	random.$O\
	rdb.$O\
	trap.$O\
	$CONF.root.$O\
	$CONF.rootc.$O\
	$DEVS\
	$PORT\
	$XEN\

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\

ETHER=`{echo devether.c ether*.c | sed 's/\.c/.'$O'/g'}
VGA=`{echo devvga.c screen.c vga*.c | sed 's/\.c/.'$O'/g'}
SDEV=`{echo devsd.c sd*.c | sed 's/\.c/.'$O'/g'}

PAE=`{echo $PAE | sed 's/yes/yes[extended-cr3]/'}
XENELF='LOADER=generic,XEN_VER=xen-3.0,ELF_PADDR_OFFSET=0,VIRT_BASE='$KZERO',VIRT_ENTRY='$KTZERO',PAE='$PAE

#$p$CONF:	$CONF.c $OBJ $LIB xenbin.$cputype
#	$CC $CFLAGS '-DKERNDATE='`{date -n} $CONF.c
#	$LD -o $target.tmp -T$KTZERO -l $OBJ $CONF.$O $LIB
#	./xenbin.$cputype <$target.tmp >$target
#	rm $target.tmp
#	size $target

$p$CONF:	$CONF.c $OBJ $LIB xenelf.$cputype
	$CC $CFLAGS '-DKERNDATE='`{date -n} $CONF.c
	$LD -o $target.elf -H5 -T$KTZERO -P$KPZERO -l $OBJ $CONF.$O $LIB
	./xenelf.$cputype $target.elf $target __xen_guest ''$XENELF''
	size $target

$p$CONF.gz: $p$CONF
	#strip -o /fd/1 $p$CONF | gzip -9 > $p$CONF.gz
	gzip -9 $p$CONF > $p$CONF.gz

install:V: $p$CONF $p$CONF.gz
	cp $p$CONF $p$CONF.gz /$objtype/
	# import lookout / /n/lookout && cp $p$CONF $p$CONF.gz /n/lookout/$objtype/

# copies generated by the rule below
PCHEADERS=uncached.h ethermii.h mp.h io.h

REPCH=`{echo $PCHEADERS | sed 's/\.h//g; s/ /|/g'}
^($REPCH)\.h:R:	'../pc/\1.h'
	cp $prereq .

REPCC=`{../port/mkfilelist ../pc}
^($REPCC)\.$O:R:	'../pc/\1.c'
	$CC $CFLAGS -I. -. ../pc/$stem1.c

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

# we inherited these.. revisit.
$ETHER: 	../port/etherif.h ../port/netif.h
$SDEV:	../port/sd.h
main.$O:	init.h reboot.h
trap.$O:	/sys/include/tos.h

%.$O:	/$objtype/include/u.h ../port/lib.h mem.h dat.h fns.h io.h ../port/error.h ../port/portdat.h ../port/portfns.h xendat.h xendefs.h

xendefs.h: xendat.h
	grep '^#define[ 	]+FLAT_' xendat.h >$target

xendat.h:
	{ echo '#define __i386__ __i386__'; \
	  echo '#define __XEN_INTERFACE_VERSION__ 0x00030201'; \
	  echo '#define XEN_GUEST_HANDLE_00030205(type) type *'; \
	  cat xen-public/^($XENHEADERS) } | \
	./cppx > $target

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

reboot.h:	../pc/rebootcode.s
	$AS ../pc/rebootcode.s
	$LD -l -s -T0x1000 -R4 -o reboot.out rebootcode.$O
	{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

acid:V:
	$CC -a -w main.c>acid

dpart: dpart.$O
	$LD -o dpart dpart.$O

xenstore: xenstore.$O
	$LD -o xenstore xenstore.$O

xenbin.$cputype xenelf.$cputype:	utilmkfile
	mk -f utilmkfile $target

%.clean:V:
	rm -f $stem.c [9bz]$stem [9bz]$stem.gz 9$stem.elf boot$stem.* reboot.h init.h xendat.h xendefs.h $PCHEADERS dpart xenbin.$cputype xenelf.$cputype xenstore