Extending cdboot with options "Press any key to boot from CD" prompt

From: Maxim Sobolev <sobomax_at_portaone.com>
Date: Thu, 19 Aug 2004 17:08:51 +0300
Hi,

Please review/comment on attached patch, which extends cdboot with 
"Press any key to boot from CD" prompt inspired by Windows installation 
CDs. IMHO this feature is quite useful for installation CDs, and 
probably for other interactive one-shot CDs, to prevent machine from 
booting off CD again after work is complete. If there is no objections, 
I'd like to request repo copy from cdboot.s into cdboot.S and then 
commit this change. My plan is to keep this feature turned off by 
default, and provide make(1) knob to turn it one if necessary.

Thanks!

-Maxim

? cdboot
Index: cdboot.s
===================================================================
RCS file: /home/ncvs/src/sys/boot/i386/cdboot/cdboot.s,v
retrieving revision 1.13
diff -d -u -r1.13 cdboot.s
--- cdboot.s	22 Jun 2004 21:55:22 -0000	1.13
+++ cdboot.s	19 Aug 2004 14:08:32 -0000
_at__at_ -100,6 +100,13 _at__at_
 		.set DIR_SIZE,10		# Offset of 64-bit length
 		.set DIR_NAMELEN,32		# Offset of 8-bit name len
 		.set DIR_NAME,33		# Offset of dir name
+
+#
+# Various constants
+#
+		.set ASCII_BEL,0x07		# ASCII code for <BEL>
+		.set TICKS,91			# 5 seconds at 18.2 ticks/s
+
 #
 # We expect to be loaded by the BIOS at 0x7c00 (standard boot loader entry
 # point)
_at__at_ -117,7 +124,27 _at__at_
 		mov %ax,%ds			# setup the
 		mov %ax,%es			#  data segments
 		mov %dl,drive			# Save BIOS boot device
-		mov $msg_welcome,%si		# %ds:(%si) -> welcome message
+#if defined(CDBOOT_PROMPT)
+		mov $msg_press,%si		# %ds:(%si) -> press any key message
+		call putstr			# display the press any key message
+		movb $ASCII_BEL,%al		# Signal
+		callw putc			#  beep!
+		xorb %ah,%ah			# BIOS: Get
+		int $0x1a			#  system time
+		movw %dx,%di			# Ticks when
+		addw $TICKS,%di			#  timeout
+pressloop:
+		movb $0x1,%ah			# BIOS: Check
+		int $0x16			#  for keypress
+		jnz bootcd			# Have one, continue cdboot
+		xorb %ah,%ah			# BIOS: Get
+		int $0x1a			#  system time
+		cmpw %di,%dx			# Timeout?
+		jb pressloop			# No
+		int $0x18			# Yes: try another boot device
+		jmp halt			# Should Not Happen[tm]
+#endif
+bootcd:		mov $msg_welcome,%si		# %ds:(%si) -> welcome message
 		call putstr			# display the welcome message
 #
 # Setup the arguments that the loader is expecting from boot[12]
_at__at_ -586,6 +613,9 _at__at_
 msg_lookupfail:	.asciz  "File not found\r\n"
 msg_load2big:	.asciz  "File too big\r\n"
 msg_failed:	.asciz	"Boot failed\r\n"
+#if defined(CDBOOT_PROMPT)
+msg_press:	.asciz	"Press any key to boot from CD\r\n"
+#endif
 twiddle_chars:	.ascii	"|/-\\"
 loader_paths:	.asciz  "/BOOT/LOADER"
 		.asciz	"/boot/loader"
Received on Thu Aug 19 2004 - 12:09:08 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:07 UTC