From b40cbf61a76fe81a54d64f6f5a7df3778888e956 Mon Sep 17 00:00:00 2001
From: Hellmuth Michaelis <hm@FreeBSD.org>
Date: Wed, 28 Mar 2001 14:11:15 +0000
Subject: [PATCH] In case the driver runs on an HP NetRaid controller, attempt
 to properly decode the BIOS and firmware version and announce the board as HP
 NetRaid.

This has been tested with a NetRaid 3si controller, the BIOS/firmware
printout should also work for other NetRaid controllers but the type
detection for other NetRaids (such as the 1si) will not work due to the
lack of hardware.

Reviewed by:	msmith
---
 sys/dev/amr/amr.c | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c
index e17f38a269c6..a8be1369b1dd 100644
--- a/sys/dev/amr/amr.c
+++ b/sys/dev/amr/amr.c
@@ -1573,9 +1573,43 @@ amr_describe_controller(struct amr_softc *sc)
     } else {
 	prod = "unsupported controller";
     }
-    device_printf(sc->amr_dev, "<%s> Firmware %.4s, BIOS %.4s, %dMB RAM\n", 
-		  prod, ae->ae_adapter.aa_firmware, ae->ae_adapter.aa_bios,
-		  ae->ae_adapter.aa_memorysize);
+
+    /*
+     * HP NetRaid controllers have a special encoding of the firmware and
+     * BIOS versions. The AMI version seems to have it as strings whereas
+     * the HP version does it with a leading uppercase character and two
+     * binary numbers.
+     */
+     
+    if(ae->ae_adapter.aa_firmware[2] >= 'A' &&
+       ae->ae_adapter.aa_firmware[2] <= 'Z' &&
+       ae->ae_adapter.aa_firmware[1] <  ' ' &&
+       ae->ae_adapter.aa_firmware[0] <  ' ' &&
+       ae->ae_adapter.aa_bios[2] >= 'A'     &&
+       ae->ae_adapter.aa_bios[2] <= 'Z'     &&
+       ae->ae_adapter.aa_bios[1] <  ' '     &&
+       ae->ae_adapter.aa_bios[0] <  ' ') {
+
+	/* this looks like we have an HP NetRaid version of the MegaRaid */
+
+    	if(ae->ae_signature == AMR_SIG_438) {
+    		/* the AMI 438 is an NetRaid 3si in HP-land */
+    		prod = "HP NetRaid 3si";
+    	}
+    	
+	device_printf(sc->amr_dev, "<%s> Firmware %c.%02d.%02d, BIOS %c.%02d.%02d, %dMB RAM\n",
+		      prod, ae->ae_adapter.aa_firmware[2],
+		      ae->ae_adapter.aa_firmware[1],
+		      ae->ae_adapter.aa_firmware[0],
+		      ae->ae_adapter.aa_bios[2],
+		      ae->ae_adapter.aa_bios[1],
+		      ae->ae_adapter.aa_bios[0],
+		      ae->ae_adapter.aa_memorysize);		
+    } else {
+	device_printf(sc->amr_dev, "<%s> Firmware %.4s, BIOS %.4s, %dMB RAM\n", 
+		      prod, ae->ae_adapter.aa_firmware, ae->ae_adapter.aa_bios,
+		      ae->ae_adapter.aa_memorysize);
+    }    	
     free(ae, M_DEVBUF);
 }