blob: 94e543441a6a62075f4bc9407f3d2719343658d2 (
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Some vars.
/act.nop 0 def
/act.boot 1 def
/.sm.setup 0 def
/.sm.ok 1 def
/serial.action act.nop def
/serial.setup /serial.setup.start def
/serial.menu.index 0 def
/serial.line.status 0 def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% serial line input event handling
%
% ( key -- input_buffer menu_entry action )
%
% key
% bit 0-7 ascii
% bit 24-32 scan code (0xf0 + serial line number)
%
% action
% 0: ok, stay in input loop
% 1: switch to text mode
% >=2: start linux
%
/serial.input {
dup 24 shr 0x0f and 1 exch shl serial.line.status or /serial.line.status exch def
0xffffff and
% ^? -> ^H
dup 0x7f eq { pop 8 } if
serial.setup exec
serial.edit
dup 0 eq { pop "" -1 0 return } if
1 eq { serial.menu.ok } { serial.menu.prev } ifelse
window.action actCloseInfo eq {
/window.action actNothing def
window.done
} if
serial.action act.boot eq {
% /serial.setup serial.menu.layout serial.menu.index get .sm.setup get def
serial.cmdline serial.menu_idx 2
return
} if
"" -1 0
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Write string to serial line.
%
% ( str1 -- )
%
/serial.show {
{
dup 0x0a eq { 0x0d serial.putc } if
serial.putc
} forall
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% ( str1 -- )
%
/serial.edit.init {
serial.edit.buf exch strcpy
"> " serial.show serial.show
} def
/serial.edit.buf 1024 string def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% ( int1 -- int2 )
%
/serial.edit {
dup 0x0d eq {
"\n\n" serial.show
pop 1 return
} if
dup 0x1b eq {
"\n\n" serial.show
pop 2 return
} if
dup 0x08 eq {
serial.edit.buf length 0 gt {
serial.edit.buf dup length 1 sub 0 put
"\x08 \x08" serial.show
} if
pop 0 return
} if
dup 0x15 eq {
serial.edit.buf length 0 gt {
serial.edit.buf length {
"\x08 \x08" serial.show
} repeat
serial.edit.buf 0 0 put
} if
pop 0 return
} if
dup 0x20 ge over 0x7e le and {
serial.edit.buf cvp length serial.edit.buf length 1 add gt {
serial.edit.buf dup length add dup 1 0 put 0 2 index put
serial.putc 0 return
} if
} if
pop 0
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% ( -- )
%
/serial.smenu.init {
"\n=== " serial.show
smenu .xm_title get exec serial.show
" ===\n\n" serial.show
smenu .xm_text get exec serial.show
"\n\n" serial.show
/serial.smenu.cnt 0 def
/serial.smenu.tmp 256 string def
smenu .xm_list get {
exec
serial.smenu.cnt smenu .xm_current get eq { " * " } { " " } ifelse
/serial.smenu.cnt inc
serial.smenu.cnt
smenu .xm_list get length 10 ge { "%2d)%s%s\n" } { "%d)%s%s\n" } ifelse
serial.smenu.tmp sprintf
serial.smenu.tmp serial.show
} forall
/serial.smenu.tmp xfree
"\n" serial.show
"" serial.edit.init
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Draw main menu.
%
% ( int1 -- int2 )
%
% int1: key
% int2: key
%
/serial.setup.start {
/serial.menu.layout [
[ /serial.main.setup /serial.main.ok ]
xmenu.bits .xm_list get length 1 gt { [ /serial.bits.setup /serial.bits.ok ] } if
xmenu.kernelopts .undef ne { [ /serial.kernel.setup /serial.kernel.ok ] } if
[ /serial.options.setup /serial.options.ok ]
[ /serial.infobox.setup /serial.infobox.ok ]
] def
% go for text mode (or use 0?)
xmenu.video .xm_current 1 put
"\nopenSUSE 11.1 installation\n\n" serial.show
/serial.setup /serial.nop def
serial.menu.again
pop 0
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Setup main menu.
%
% ( -- )
%
/serial.main.setup {
smenu.main .undef eq {
/smenu.main .xm_size array def
smenu.main .xm_current menu.entry put
smenu.main .xm_title "Main Menu" put
smenu.main .xm_text "Select a boot entry." put
smenu.main .xm_list [ menu.texts { menuitemmap } forall ] put
} if
/smenu smenu.main def
serial.smenu.init
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Leave main menu.
%
% ( -- )
%
/serial.main.ok {
serial.edit.buf to_number
menu.entry false MenuSelect
serial.smenu.select {
/menu.entry smenu .xm_current get def
serial.menu.next
} {
serial.menu.again
} ifelse
menu.entry true MenuSelect
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Setup kernel menu.
%
% ( -- )
%
/serial.kernel.setup {
xmenu.kernelopts .xm_text "Select a predefined set of kernel options." put
/smenu xmenu.kernelopts def
serial.smenu.init
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Leave kernel menu.
%
% ( -- )
%
/serial.kernel.ok {
serial.edit.buf to_number
serial.smenu.select { serial.menu.next } { serial.menu.again } ifelse
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Setup arch menu.
%
% ( -- )
%
/serial.bits.setup {
xmenu.bits .xm_text "32 or 64 bit?" put
/smenu xmenu.bits def
serial.smenu.init
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Leave arch menu.
%
% ( -- )
%
/serial.bits.ok {
serial.edit.buf to_number
serial.smenu.select { serial.menu.next } { serial.menu.again } ifelse
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Setup lang menu.
%
% ( -- )
%
/serial.lang.setup {
/smenu xmenu.lang def
serial.smenu.init
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Leave lang menu.
%
% ( -- )
%
/serial.lang.ok {
serial.edit.buf to_number
serial.smenu.select { serial.menu.next } { serial.menu.again } ifelse
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Setup options menu.
%
% ( -- )
%
/serial.options.setup {
"=== Boot Options ===\n" serial.show
"
Edit boot options.
- lang=<locale> selects the default language
- install=<url> sets the install repository
- dud=<url> adds a driverupdate (option can be given more than once)
"
serial.show
boot.ed.list buildcmdline /serial.menu_idx exch def /serial.cmdline exch def
serial.console.option dup .undef ne {
" %s" serial.cmdline dup length add sprintf
} { pop } ifelse
serial.cmdline serial.edit.init
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Options -> Boot.
%
% ( -- )
%
/serial.options.ok {
serial.cmdline serial.edit.buf strcpy pop
% point to infobox
/serial.menu.index inc
/serial.action act.boot def
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Setup infobox.
%
% ( -- )
%
/serial.infobox.setup {
/smenu serial.infobox def
serial.smenu.init
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Leave infobox.
%
% ( -- )
%
/serial.infobox.ok {
serial.edit.buf to_number
serial.smenu.select {
serial.menu.prev
/window.action actCloseInfo def
} {
serial.menu.again
} ifelse
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Do nothing.
%
% ( -- )
%
/serial.nop {
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Convert String to number.
%
% ( str1 -- int1 )
%
% Returns -1 if str1 is not a number.
%
/to_number {
dup cvn
dup 0 ne { exch pop return } if
pop
dup "" eq exch "0" eq or { 0 } { -1 } ifelse
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Ensure serial.menu.index has a valid value.
%
% ( -- )
%
/serial.menu.index.normalize {
serial.menu.index serial.menu.layout length gt { /serial.menu.index serial.menu.layout length def } if
serial.menu.index 0 lt { /serial.menu.index 0 def } if
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Reinit current menu.
%
% ( -- )
%
/serial.menu.again {
serial.menu.index.normalize
serial.menu.layout serial.menu.index get .sm.setup get exec
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Run 'ok' action for current menu.
%
% ( -- )
%
/serial.menu.ok {
serial.menu.index.normalize
serial.menu.layout serial.menu.index get .sm.ok get exec
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Go to next menu.
%
% ( -- )
%
/serial.menu.next {
/serial.menu.index inc
serial.menu.again
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Go to previous menu.
%
% ( -- )
%
/serial.menu.prev {
/serial.menu.index dec
serial.menu.again
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Select menu item (update smenu->.xm_current).
%
% ( int1 -- bool1 )
%
/serial.smenu.select {
smenu .xm_list get length over lt over 0 lt or {
pop
false
} {
dup 0 eq { pop smenu .xm_current get 1 add } if
1 sub smenu .xm_current rot put
true
} ifelse
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Build 'console' option for kernel.
%
% ( -- str1 )
%
/serial.console.option {
/serial.tmp.bm 0 def
{
serial.line.status 1 serial.tmp.bm shl and { exit } if
/serial.tmp.bm inc
serial.tmp.bm 8 ge { /serial.tmp.bm .undef def exit } if
} loop
serial.tmp.bm .undef eq { .undef return } if
serial.lines length serial.tmp.bm le { .undef return } if
serial.lines serial.tmp.bm get 2 aget dup .undef ne {
serial.tmp.bm serial.getbaud exch
"console=%s,%d" serial.console.buf sprintf
serial.console.buf
} if
} def
/serial.console.buf 64 string def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Setup serial lines.
%
0 1 serial.lines length 1 sub {
serial.lines over get dup length 2 ge {
dup 0 get cvn exch 1 get cvn serial.setconfig
} {
pop pop
} ifelse
} for
serial.init
|