-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootl4
executable file
·124 lines (103 loc) · 2.95 KB
/
bootl4
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
#!/bin/bash
set -x
NAME=bootl4
VERSION=0.1
declare -i launchcon=1
declare -i verbose=0
user=$USER
kernel=powerpc-kernel
sigma0=sigma0
kickstart=kickstart.uimage
roottask=khvmm
kerneladdr=1400000
sigma0addr=1500000
roottaskaddr=1600000
moduleaddr=1700000
ubootscriptaddr=20000000
linuxaddr=21000000
ramdiskaddr=22000000
function help()
{
echo -e "\`$NAME' boots a set of nodes with L4\n\n" \
"Usage: $NAME [num]\n" \
" -r <roottask> set roottask\n" \
" -l <linux> load linux\n" \
" -d <disk> load ramdisk\n" \
" -m <module> load module\n" \
" -s <script> load uboot script\n" \
" -u <user> user allocating nodes\n" \
" -c launch console window\n" \
" -v verbose kickstart\n" \
" -h show this help statement\n"
}
optcount=0;
while getopts "u:r:m:l:d:s:chv" OPT
do
case $OPT in
("r") roottask="$OPTARG"; (( optcount+=2 ));;
("m") module="$OPTARG"; (( optcount+=2 ));;
("l") linux="$OPTARG"; (( optcount+=2 ));;
("d") ramdisk="$OPTARG"; (( optcount+=2 ));;
("s") ubootscript="$OPTARG"; (( optcount+=2 ));;
("u") user="$OPTARG"; (( optcount+=2 ));;
("c") launchcon=1; (( optcount+= 1 ));;
("v") verbose=1; (( optcount+= 1));;
("h") help; exit -1;;
esac
done
shift $optcount
cd ~/boot/
for i in $kernel $sigma0 $kickstart $roottask $module
do if [[ ! -a $i ]]
then
echo "file \"$i\" not found"
exit -1
fi
done
a0="$(khget $user $1)"
if (( $? != 0 ))
then
echo "Node allocation failed ($a0)"
exit -1
fi
if (( launchcon != 0 )); then
echo "$a0" | khdo concmd "khxcon -s "l4{khctlserver##*.}" -t \"-echo -echonl -echoprt -echoke -icrnl -icanon time 0 min 1\" %con% &"
fi
echo "$a0"
echo "$a0" | khdo loadkernel $kickstart
echo "$a0" | khdo loadfile $kerneladdr $kernel
echo "$a0" | khdo loadfile $sigma0addr $sigma0
echo "$a0" | khdo loadfile $roottaskaddr $roottask
# FDT manipulation
setfdtcmd="fdt mknode / l4 && fdt set /l4 kernel <$kerneladdr> && fdt set /l4 sigma0 <$sigma0addr> && fdt set /l4 roottask <$roottaskaddr>"
echo "$a0" | khdo write "$setfdtcmd"
declare -i modnum=0
for i in $module
do
echo "$a0" | khdo loadfile $moduleaddr $i
echo "$a0" | khdo write "fdt set /l4 module$modnum <$moduleaddr>"
(( modnum++ ))
done
if [[ -n $linux && -f $linux ]]
then
echo "$a0" | khdo loadfile $linuxaddr $linux
fi
if [[ -n $ramdisk && -f $ramdisk ]]
then
echo "$a0" | khdo loadfile $ramdiskaddr $ramdisk
#echo "$a0" | khdo loadramdisk $ramdisk
fi
if [[ -n $ubootscript && -f $ubootscript ]]
then
echo "$a0" | khdo loadfile $ubootscriptaddr $ubootscript
fi
# set the kernel debugger output
echo "$a0" | khdo write "fdt set /l4 dbgcon \$bgtty_sendid,\$bgtty_rcvid,\$bgtty_dest"
if (( verbose != 0 )); then
echo "$a0" | khdo write "fdt set /l4 kickstart verbose"
fi
#echo "press key to boot..."
#read
echo "$a0" | khdo write "bootm \$loadaddr - \$fdtbootaddr"
echo "$a0"
echo "$a0" > ~/bootl4.log