Procházet zdrojové kódy

[prefix] Prompt for entering gPXE shell during POST

The ROM prefix now prompts the user to enter the gPXE shell during POST;
this allows for configuring gPXE without needing to attempt to boot from
it.  (It also slows down system boot by three seconds per gPXE ROM, but
hey.)

This is apparently a certain OEM's requirement for option ROMs.
tags/v0.9.4
Michael Brown před 16 roky
rodič
revize
7cd08434ea
1 změnil soubory, kde provedl 61 přidání a 10 odebrání
  1. 61
    10
      src/arch/i386/prefix/romprefix.S

+ 61
- 10
src/arch/i386/prefix/romprefix.S Zobrazit soubor

@@ -130,9 +130,12 @@ init:
130 130
 	pushaw
131 131
 	pushw	%ds
132 132
 	pushw	%es
133
+	pushw	%fs
133 134
 	cld
134 135
 	pushw	%cs
135 136
 	popw	%ds
137
+	pushw	$0x40
138
+	popw	%fs
136 139
 	movw	%di, %bx
137 140
 	xorw	%di, %di
138 141
 	/* Print message as early as possible */
@@ -227,11 +230,53 @@ gotpmm:	/* PMM allocation succeeded: copy ROM to PMM block */
227 230
 	loop	1b
228 231
 	subb	%bl, checksum
229 232
 	popal
230
-no_pmm:
231
-	/* Print CRLF to terminate messages */
232
-	movw	$'\n', %ax
233
-	call	print_character
233
+no_pmm:	/* Prompt for POST-time shell */
234
+	movw	$init_message_prompt, %si
235
+	call	print_message
236
+	/* Empty the keyboard buffer before waiting for input */
237
+empty_keyboard_buffer:
238
+	movb	$0x01, %ah
239
+	int	$0x16
240
+	jz	1f
241
+	xorw	%ax, %ax
242
+	int	$0x16
243
+	jmp	empty_keyboard_buffer
244
+1:	/* Wait for up to 3s for a key press */
245
+	movw	$(18 * 3), %cx	/* Approx 3s worth of timer ticks */
246
+wait_for_key:
247
+	decw	%cx
248
+	jz	no_key_pressed
249
+	/* Wait for timer tick to be updated */
250
+	movl	%fs:(0x6c), %eax
251
+1:	pushf
252
+	sti
253
+	hlt
254
+	popf
255
+	cmpl	%fs:(0x6c), %eax
256
+	je	1b
257
+	/* Check to see if a key was pressed */
258
+	movb	$0x01, %ah
259
+	int	$0x16
260
+	jz	wait_for_key
261
+	/* Check to see if key was Ctrl-B */
262
+	cmpb	$0x02, %al
263
+	je	1f
264
+	/* Key was not Ctrl-B: remove from buffer and stop waiting */
265
+	xorw	%ax, %ax
266
+	int	$0x16
267
+	jmp	no_key_pressed
268
+1:	/* Key was Ctrl-B: leave in keyboard buffer and invoke gPXE.
269
+	 * The keypress will be picked up by the initial shell
270
+	 * prompt, and we will drop into a shell.
271
+	 */
272
+	pushw	%cs
273
+	call	exec
274
+no_key_pressed:
275
+	/* Print blank lines to terminate messages */
276
+	movw	$init_message_end, %si
277
+	call	print_message
234 278
 	/* Restore registers */
279
+	popw	%fs
235 280
 	popw	%es
236 281
 	popw	%ds
237 282
 	popaw
@@ -245,19 +290,25 @@ init_message:
245 290
 	.size	init_message, . - init_message
246 291
 init_message_pnp:
247 292
 	.asciz	" PnP"
248
-	.size init_message_pnp, . - init_message_pnp
293
+	.size	init_message_pnp, . - init_message_pnp
249 294
 init_message_bbs:
250 295
 	.asciz	" BBS"
251
-	.size init_message_bbs, . - init_message_bbs
296
+	.size	init_message_bbs, . - init_message_bbs
252 297
 init_message_pmm:
253 298
 	.asciz	" PMM"
254
-	.size init_message_pmm, . - init_message_pmm
299
+	.size	init_message_pmm, . - init_message_pmm
255 300
 init_message_pmm_failed:
256 301
 	.asciz	"(failed)"
257
-	.size init_message_pmm_failed, . - init_message_pmm_failed
302
+	.size	init_message_pmm_failed, . - init_message_pmm_failed
258 303
 init_message_int19:
259 304
 	.asciz	" INT19"
260
-	.size init_message_int19, . - init_message_int19
305
+	.size	init_message_int19, . - init_message_int19
306
+init_message_prompt:
307
+	.asciz	"\nPress Ctrl-B to configure gPXE..."
308
+	.size	init_message_prompt, . - init_message_prompt
309
+init_message_end:
310
+	.asciz	"\n\n\n"
311
+	.size	init_message_end, . - init_message_end
261 312
 
262 313
 /* ROM image location
263 314
  *
@@ -361,7 +412,7 @@ exec:	/* Set %ds = %cs */
361 412
 	.previous
362 413
 
363 414
 exec_message:
364
-	.asciz	"gPXE starting boot\n"
415
+	.asciz	"Entering gPXE\n"
365 416
 	.size exec_message, . - exec_message
366 417
 
367 418
 /* UNDI loader

Načítá se…
Zrušit
Uložit