From nobody@FreeBSD.org  Tue May  5 19:26:35 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 89B2C106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  5 May 2009 19:26:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 782198FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  5 May 2009 19:26:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n45JQZ3Y045957
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 5 May 2009 19:26:35 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n45JQYtu045956;
	Tue, 5 May 2009 19:26:34 GMT
	(envelope-from nobody)
Message-Id: <200905051926.n45JQYtu045956@www.freebsd.org>
Date: Tue, 5 May 2009 19:26:34 GMT
From: Rick van der Zwet <info@rickvanderzwet.nl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] improvement i386 boot0 error diagnose
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         134242
>Category:       i386
>Synopsis:       [boot0] [patch] improvement i386 boot0 error diagnose
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    rdivacky
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 05 19:30:01 UTC 2009
>Closed-Date:    Tue Apr 05 06:08:06 UTC 2011
>Last-Modified:  Tue Apr 05 06:08:06 UTC 2011
>Originator:     Rick van der Zwet
>Release:        RELENG_7_2
>Organization:
Stichting Wireless Leiden
>Environment:
FreeBSD virbsd 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan  1 14:37:25 UTC 2009     root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

(build machine)
>Description:
While booting it is not clear what kind of error is encountered. Is there an input error, read error or something else? This small patch suggest a few additions to the error handling (enabled during compile time)  
>How-To-Repeat:
Boot a machine and just see one '#' appearing and try to guess if the error is the input device (serial,ps/2, usb keyboard),wrongly pressed key, disk read error or misconfiguration in boot block 'magic'.
>Fix:
Patch attached.

Patch attached with submission follows:

# For the use of debugging boot0 related issues, using special beeps (or hashes)
# for every error:
# 1x = Not F1 .. F5 pressed (if force checked)
# 2x = Option not enabled (invalid input)
# 3x = Sector read error
# 4x = Bootable flag not set
--- /usr/src/sys/boot/i386/boot0/boot0.S	2009-04-15 03:14:26.000000000 +0000
+++ boot0.S	2009-05-05 14:59:44.000000000 +0000
@@ -43,6 +43,11 @@
 #define SAVE_MORE_MEMORY
 #endif
 
+#ifdef DEBUG_USING_BEEP
+#define SAVE_MEMORY
+#define SAVE_MORE_MEMORY
+#endif
+
 /*
  * Note - this code uses many tricks to save space and fit in one sector.
  * This includes using side effects of certain instructions, reusing
@@ -338,7 +343,16 @@
 
 /*
  * Here we have the code waiting for user input or a timeout.
+ * XXX: To compile correctly 
  */
+#ifdef DEBUG_USING_BEEP
+beep4:		movb $ASCII_BEL,%al		# Input error, print or beep
+		callw putchr
+beep3:		movb $ASCII_BEL,%al		# Input error, print or beep
+		callw putchr
+beep2:		movb $ASCII_BEL,%al		# Input error, print or beep
+		callw putchr
+#endif
 beep:		movb $ASCII_BEL,%al		# Input error, print or beep
 		callw putchr
 
@@ -429,7 +443,11 @@
  */
 		cbtw				# Extend (%ah=0 used later)
 		btw %ax,_MNUOPT(%bp)	 	# Option enabled?
-		jnc beep			# No
+#ifdef DEBUG_USING_BEEP
+		jnc beep2			# No
+#else
+		jnc beep 			# No
+#endif
 /*
  * Save the info in the original tables
  * for rewriting to the disk.
@@ -486,9 +504,17 @@
 	3:	movw $LOAD,%bx			# Address for read
 		movb $0x2,%ah			# Read sector
 		callw intx13			#  from disk
-		jc beep				# If error
+#ifdef DEBUG_USING_BEEP
+		jc beep3			# If error
+#else
+		jc beep 			# If error
+#endif
 		cmpw $MAGIC,0x1fe(%bx)		# Bootable?
-		jne beep			# No
+#ifdef DEBUG_USING_BEEP
+		jne beep4			# No
+#else
+		jne beep 			# No
+#endif
 		pushw %si			# Save ptr to selected part.
 		callw putn			# Leave some space
 		popw %si			# Restore, next stage uses it


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->rdivacky 
Responsible-Changed-By: remko 
Responsible-Changed-When: Wed Mar 30 06:14:57 UTC 2011 
Responsible-Changed-Why:  
Hi Roman, you are working on compressing boot* recently to get it working 
properly for clang if I recall right. Can you also shed a light on this 
patch from Rick? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134242 
State-Changed-From-To: open->closed 
State-Changed-By: remko 
State-Changed-When: Tue Apr 5 06:08:05 UTC 2011 
State-Changed-Why:  
Hello, my apologies but this will not be committed. It is a debugging 
only feature, which you are encouraged to keep locally. Interested 
parties can find the information in your ticket. Thanks for contributing 
to FreeBSD! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134242 
>Unformatted:
