Subject: port-macppc/13756: booting from slave IDE drive get boot device:
To: None <gnats-bugs@gnats.netbsd.org>
From: None <makoto@ki.nu>
List: netbsd-bugs
Date: 08/20/2001 11:38:54
>Number:         13756
>Category:       port-macppc
>Synopsis:       Booting from slave IDE drive did not find boot-device
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-macppc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 19 19:37:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        20010806
>Organization:
	www.ki.nu
>Environment:
	
System: NetBSD u 1.5X NetBSD 1.5X (GENERIC) #43: Mon Aug 20 11:16:51 JST 2001 makoto@iBook366:/export/20010806/sys/arch/macppc/compile/GENERIC macppc
Architecture: powerpc
Machine: macppc (PowerMac G4)
>Description:

Cannot find boot device for slave (wdc) IDE drive.

The IDE drive shipped with PowerMac G4 is setup as master drive (#0). 
NetBSD recognizes it as wd0. If we add another drive as slave, 
it will be seen as wd1.

With sysinst installer, NetBSD may be installed in that wd1.
But the kernel booted from wd1 does not recognize boot device.
It will say 
boot device: <unknown>.

In that case, if you have another NetBSD installed in wd0, wd0 will be 
mounted as a root device.  This may be said root device was
hardcoded as wd0.

By applying following patch, this problem will be resolved.

Original code compares channel number with specified drive #
at boot time. The new code compares drive number in the 'boot-file'
string instead.

>How-To-Repeat:
	Described in above.
        (1) add slave IDE drive on PowerMac G4.
        (2) Install NetBSD onto that wd1
        (3) boot enet:0 ultra1:0
            boot enet:0 /pci@f2000000/pci-bridge@d/mac-io@7/ata-4/disk@1:0
>Fix:
--- sys/arch/macppc/macppc/autoconf.c-ooo	Sun Jul 22 20:29:47 2001
+++ sys/arch/macppc/macppc/autoconf.c	Mon Aug 20 11:16:25 2001
@@ -120,6 +120,13 @@
 	/* Back up the last component for later use. */
 	if ((p = strrchr(cbootpath, '/')) != NULL)
 		strcpy(last, p + 1);
+	else  
+	if ((p = strrchr(bootpath, ':')) != NULL) { /* ultra1:0 -> @1:0  */
+	    *( p - 2) = '@'; 
+	    strcpy(last, p - 2);
+	    if ((p = strchr(last, '/')) != NULL)
+	      *p = 0;  /* strip kernel name from bootpath -> last*/
+	      }
 	else
 		last[0] = 0;
 
@@ -263,7 +270,7 @@
 	} else if (DEVICE_IS(dev->dv_parent, "wdc")) {
 		struct ata_atapi_attach *aa = aux;
 
:
-		if (addr != aa->aa_channel)
+		if (addr != aa->aa_drv_data->drive)
 			return;
 	} else
 		return;
>Release-Note:
>Audit-Trail:
>Unformatted: