summaryrefslogtreecommitdiff
path: root/sys/src/9/xen/mkfile
blob: e7bbe950329db4702f17fd16e31a43066d960d69 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
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

ptclbsum386.$O:	../pc/ptclbsum386.s
	$AS $AFLAGS ../pc/ptclbsum386.s

# 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