Ver código fonte

[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 16 anos atrás
pai
commit
7cd08434ea
1 arquivos alterados com 61 adições e 10 exclusões
  1. 61
    10
      src/arch/i386/prefix/romprefix.S

+ 61
- 10
src/arch/i386/prefix/romprefix.S Ver arquivo

130
 	pushaw
130
 	pushaw
131
 	pushw	%ds
131
 	pushw	%ds
132
 	pushw	%es
132
 	pushw	%es
133
+	pushw	%fs
133
 	cld
134
 	cld
134
 	pushw	%cs
135
 	pushw	%cs
135
 	popw	%ds
136
 	popw	%ds
137
+	pushw	$0x40
138
+	popw	%fs
136
 	movw	%di, %bx
139
 	movw	%di, %bx
137
 	xorw	%di, %di
140
 	xorw	%di, %di
138
 	/* Print message as early as possible */
141
 	/* Print message as early as possible */
227
 	loop	1b
230
 	loop	1b
228
 	subb	%bl, checksum
231
 	subb	%bl, checksum
229
 	popal
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
 	/* Restore registers */
278
 	/* Restore registers */
279
+	popw	%fs
235
 	popw	%es
280
 	popw	%es
236
 	popw	%ds
281
 	popw	%ds
237
 	popaw
282
 	popaw
245
 	.size	init_message, . - init_message
290
 	.size	init_message, . - init_message
246
 init_message_pnp:
291
 init_message_pnp:
247
 	.asciz	" PnP"
292
 	.asciz	" PnP"
248
-	.size init_message_pnp, . - init_message_pnp
293
+	.size	init_message_pnp, . - init_message_pnp
249
 init_message_bbs:
294
 init_message_bbs:
250
 	.asciz	" BBS"
295
 	.asciz	" BBS"
251
-	.size init_message_bbs, . - init_message_bbs
296
+	.size	init_message_bbs, . - init_message_bbs
252
 init_message_pmm:
297
 init_message_pmm:
253
 	.asciz	" PMM"
298
 	.asciz	" PMM"
254
-	.size init_message_pmm, . - init_message_pmm
299
+	.size	init_message_pmm, . - init_message_pmm
255
 init_message_pmm_failed:
300
 init_message_pmm_failed:
256
 	.asciz	"(failed)"
301
 	.asciz	"(failed)"
257
-	.size init_message_pmm_failed, . - init_message_pmm_failed
302
+	.size	init_message_pmm_failed, . - init_message_pmm_failed
258
 init_message_int19:
303
 init_message_int19:
259
 	.asciz	" INT19"
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
 /* ROM image location
313
 /* ROM image location
263
  *
314
  *
361
 	.previous
412
 	.previous
362
 
413
 
363
 exec_message:
414
 exec_message:
364
-	.asciz	"gPXE starting boot\n"
415
+	.asciz	"Entering gPXE\n"
365
 	.size exec_message, . - exec_message
416
 	.size exec_message, . - exec_message
366
 
417
 
367
 /* UNDI loader
418
 /* UNDI loader

Carregando…
Cancelar
Salvar