forked from trothr/znetboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
znetboot.exec
192 lines (169 loc) · 5.87 KB
/
znetboot.exec
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
185
186
187
188
189
190
/*
* Name: ZNETBOOT EXEC
* Date: 2014-Dec-10 (Wed) and following
* 2017-Oct-21 (Sat) for RPH
*
*/
/* set some needed variables to default values */
baseurl = "http://znetboot.casita.net/znetboot"
kfile = "image"
rfile = "ramdisk.gz"
check = "znetboot.exec curl.rexx"
mycl = "I"
raddr = "00C"
paddr = "00D"
bparm = ""
naddr = ""
/* get the VM ID we're running as as the default config file name */
Parse Value Diag(08,'QUERY USERID') With vmid . node . '15'x .
Parse Upper Arg args "(" . ")" .
If args /= "" Then Parse Var args vmid .
/* load those per-server variables from the config file */
'pipe state' vmid 'znetboot *'
If rc /= 0 Then Do
Upper vmid
Say "# you need a" vmid "ZNETBOOT file for boot parameters"
Say "# Create it with XEDIT or upload from another system."
End
If rc /= 0 Then Exit rc
Say "# reading" vmid "ZNETBOOT for boot parameters"
'pipe (end !) <' vmid 'znetboot | strip' ,
'| nlocate 1.1 /#/ | na: nlocate 1.9 /ZNETBOOT_/' ,
'| append strliteral # # | join * / / | strip | var parms' ,
'! na: | stem na.'
If rc /= 0 Then Exit rc
/* parse the stuff we loaded from that config file */
kfile = baseurl || "/" || kfile
rfile = baseurl || "/" || rfile
nc.0 = 0
pstat = ""
Do i = 1 to na.0
Parse Var na.i vn "=" vv
Select
When vv = "" Then nop
When vn = "ZNETBOOT_KERNEL" Then kfile = vv
When vn = "ZNETBOOT_INITRD" Then rfile = vv
When vn = "ZNETBOOT_BOOTPARMS" Then bparm = vv
When vn = "ZNETBOOT_NICADDR" Then naddr = vv
When vn = "ZNETBOOT_TOFILE" Then Do
j = nc.0 + 1
nc.j = vv
nc.0 = j
End
When vn = "ZNETBOOT_PROGRESS" Then pstat = vv
Otherwise nop
End
End
bparm = bparm parms
/* check CMS support files for consistency -- this is ONLY a check */
Do While check /= ""
Parse Var check cfile check
wfile = baseurl || "/" || cfile
'pipe curl --text' wfile '| strip | stem c0.'
If rc /= 0 Then Iterate
Parse Upper Var cfile fn "." ft
'pipe <' fn ft '| strip | stem c1.'
If c1.0 /= c0.0 Then Do
Say "# CMS support file" fn ft "mismatch; consider updating; continuing ..."
Iterate
End
Do i = 1 to c0.0
If c1.i = c0.i Then Iterate
Say "# CMS support file" fn ft "mismatch; consider updating; continuing ..."
Leave
End
End
/* conditionally save a CMS "conffile" and set boot parms for it */
If nc.0 > 0 Then Do
Say "# creating" vmid "CONFFILE for supplemental parameters"
'vmlink * 191 (w invoke' ,
'pipe stem nc. 1 | >' vmid 'CONFFILE .fm1'
If rc /= 0 Then Exit rc
bparm = bparm "CMSDASD=191" ,
"CMSCONFFILE=" || vmid || ".CONFFILE"
End
/* optionally construct and append a progress status reporter */
If pstat /= "" Then Do
Upper pstat
psbs = 1
Select /* blocksize */
When Right(pstat,1) = "M" Then Do ; psbs = 1048576
pstat = Left(pstat,Length(pstat)-1) ; End
When Right(pstat,1) = "P" Then Do ; psbs = 4096
pstat = Left(pstat,Length(pstat)-1) ; End
When Right(pstat,1) = "K" Then Do ; psbs = 1024
pstat = Left(pstat,Length(pstat)-1) ; End
When Right(pstat,1) = "B" Then Do ; psbs = 1
pstat = Left(pstat,Length(pstat)-1) ; End
When Datatype(pstat,"W") Then psbs = 1
Otherwise psbs = 0
End /* Select blocksize */
If psbs = 0 Then pstat = "" ; Else Do
pstat = '| FBLOCK' psbs ,
'| SPEC RECNO FROM' psbs 'BY' psbs 'NW' ,
'| SPEC /#/ NW W1 NW /bytes received/ NW' ,
'| DROP LAST' ,
'| CONSOLE'
End
End
/* optionally check that we have a NIC at the expected I/O address */
If naddr /= "" Then Do
Parse Value DiagRC(08,'Q V NIC' naddr) With 1 rc 10 . 17 rs '15'x .
If rc = 40 Then Do
Say "# you need a NIC at" naddr
Say "# Define it with 'CP DEF NIC" naddr "TYPE QDIO'"
Say "# and then 'CP COUPLE' it to the appropriate VSwitch."
End
If rs /= "" Then Say rs
If rc /= 0 Then Exit rc
End
/* query current reader and punch settings */
Parse Value Diag(08,'Q V' raddr) ,
With . . . rcl rcont rhold . '15'x . . . rkeep .
Parse Value Diag(08,'Q V' paddr) ,
With . . . pcl pcont phold . ,
'15'x . tofor ptarg . '15'x . '15'x . . . . pkeep .
/* set reader and punch to CLASS I for IPL */
'CP SP' raddr 'CL' mycl 'NOCONT NOHOLD NOKEEP'
'CP SP' paddr 'CL' mycl 'NOCONT NOHOLD NOKEEP TO' Userid()
/* pull the kernel directly to spool space */
Say "# fetching kernel and punching it"
Say "+" 'pipe curl --binary' kfile '| fblock 80 00 | punch'
'pipe curl --binary' kfile '| fblock 80 00 | punch' pstat
/* '| count bytes | var kbytes' */
Call Diag 08, 'CLOSE' paddr
If rc /= 0 Then Do
Call Diag 08, 'SP' raddr 'CL' rcl rcont rhold rkeep
Call Diag 08, 'SP' paddr 'CL' pcl pcont phold pkeep tofor ptarg
Exit rc
End
/* punch a boot parm line */
Say "# punching boot parm line"
Say "+" 'pipe var bparm | fblock 80 00 | punch'
'pipe var bparm | fblock 80 00 | punch'
/* '| count bytes | var pbytes' */
Call Diag 08, 'CLOSE' paddr
If rc /= 0 Then Do
Call Diag 08, 'SP' raddr 'CL' rcl rcont rhold rkeep
Call Diag 08, 'SP' paddr 'CL' pcl pcont phold pkeep tofor ptarg
Exit rc
End
/* pull the root FS directly to spool space */
Say "# fetching root FS and punching it"
Say "+" 'pipe curl --binary' rfile '| fblock 80 00 | punch'
'pipe curl --binary' rfile '| fblock 80 00 | punch' pstat
/* '| count bytes | var rbytes' */
Call Diag 08, 'CLOSE' paddr
If rc /= 0 Then Do
Call Diag 08, 'SP' raddr 'CL' rcl rcont rhold rkeep
Call Diag 08, 'SP' paddr 'CL' pcl pcont phold pkeep tofor ptarg
Exit rc
End
/* Say "#" kbytes "bytes kernel," pbytes "bytes parm data," rbytes "bytes root FS" */
Say "# booting the kernel now ..."
Say "+" 'IPL' raddr 'CLEAR'
'IPL' raddr 'CLEAR' ; _rc = rc
/* if somehow the IPL failed then restore reader and punch settings */
'CP SP' raddr 'CL' rcl rcont rhold rkeep
'CP SP' paddr 'CL' pcl pcont phold pkeep tofor ptarg
Exit _rc