Port-macppc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ofwboot problem on OF2 machines



Hi,

I wrote back in October 2010 in the following thread:
http://mail-index.NetBSD.org/port-macppc/2010/10/17/msg001237.html

> > Indeed. Sorry. I have uploaded the whole ofdev.c to ftp.netbsd.org under
> >   pub/NetBSD/misc/phx/macppc/ofwboot/ofdev.c.gz
> 
> I've tried this one and it works fine (no bad side effect)
> on my Apus2000 with OF 2.0.

Sorry for old topic, but I tried recent ofwboot on my Apus2000
and noticed it didn't work properly, probably due to OF 2.0 quirks:
---
0 > boot 
OF_open bootpath=ata/ATA-Disk@0
read stage 2 blocks: 01234567. done!
starting stage 2...

>> NetBSD/macppc OpenFirmware Boot, Revision 1.12 (Sat Feb 18 09:59:52 JST 2012)
Cannot use bootpath
Using boot-device instead
@@@@@@@@@open /netbsd: Input/output error
@@@@@@@@@open /netbsd.gz: Input/output error
@@@@@@@@@open /netbsd.macppc: Input/output error
Boot: 
---

I don't remember how I tested your ofdev.c patch at that time,
but the following change causes a problem:

---
--- src/sys/arch/macppc/stand/ofwboot/ofdev.c   2009/01/28 15:03:28     1.22
+++ src/sys/arch/macppc/stand/ofwboot/ofdev.c   2010/10/17 15:33:04     1.23
-#if 0
-       if (!strcmp(buf, "block"))
-               /*
-                * For block devices, indicate raw partition
-                * (:0 in OpenFirmware)
-                */
+       if (!strcmp(buf, "block") && strrchr(devname, ':') == NULL)
+               /* indicate raw partition, when missing */
                strlcat(devname, ":0", sizeof(devname));
-#endif
        if ((handle = OF_open(devname)) == -1)
                return ENXIO;
        memset(&ofdev, 0, sizeof ofdev);


---

because OF 2.x doesn't like this ':0' partition strings and
actually prom2boot() explicitly removes it in boot.c
before the above devopen() function is called:

---
static void
prom2boot(char *dev)
{
        char *cp;

        cp = dev + strlen(dev) - 1;
        for (; *cp; cp--) {
                if (*cp == ':') {
                        if (ofw_version < 3) {
                                /* sd@0:0 -> sd@0 */
                                *cp = 0;
                                break;
                        } else {
                                /* disk@0:5,boot -> disk@0:0 */
                                strcpy(cp, ":0");
                                break;
                        }
                }
        }
}

---

I'm not sure if this ':0' strings added in devopen() are
actually necessary for OF3 machines to boot from APM partition.
Is it really required for your macppc?

If it's for lazy defaults, adding the following ofw_version check
makes it work even on my Apus2000. What do you think about this?
Should it be done rather in the above prom2boot() function?

Thanks,

---
Index: boot.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/stand/ofwboot/boot.c,v
retrieving revision 1.26
diff -u -p -r1.26 boot.c
--- boot.c      22 Jan 2011 19:19:19 -0000      1.26
+++ boot.c      18 Feb 2012 01:21:41 -0000
@@ -96,8 +96,8 @@ char bootdev[MAXBOOTPATHLEN];
 char bootfile[MAXBOOTPATHLEN];
 int boothowto;
 bool floppyboot;
+int ofw_version = 0;
 
-static int ofw_version = 0;
 static const char *kernels[] = { "/netbsd", "/netbsd.gz", "/netbsd.macppc", 
NULL };
 
 static void
Index: boot.h
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/stand/ofwboot/boot.h,v
retrieving revision 1.3
diff -u -p -r1.3 boot.h
--- boot.h      28 Jan 2009 15:03:28 -0000      1.3
+++ boot.h      18 Feb 2012 01:21:41 -0000
@@ -10,6 +10,7 @@ void main(void);
 #define MAXBOOTPATHLEN 256
 extern char bootdev[MAXBOOTPATHLEN];
 extern bool floppyboot;
+extern int ofw_version;
 
 #ifdef HAVE_CHANGEDISK_HOOK
 struct open_file;
Index: ofdev.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/stand/ofwboot/ofdev.c,v
retrieving revision 1.25
diff -u -p -r1.25 ofdev.c
--- ofdev.c     1 Feb 2012 21:48:22 -0000       1.25
+++ ofdev.c     18 Feb 2012 01:21:41 -0000
@@ -425,7 +425,8 @@ devopen(struct open_file *of, const char
                return ENXIO;
        if (!strcmp(buf, "block") && strrchr(devname, ':') == NULL)
                /* indicate raw partition, when missing */
-               strlcat(devname, ":0", sizeof(devname));
+               if (ofw_version >= 3)
+                       strlcat(devname, ":0", sizeof(devname));
        if ((handle = OF_open(devname)) == -1)
                return ENXIO;
        memset(&ofdev, 0, sizeof ofdev);

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index