CVS commit: src/sys/arch/ofppc/stand/ofwboot

2021-05-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon May 17 20:21:05 UTC 2021

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: mbr.c rdb.c

Log Message:
include libkern.h for moved dkcksum().


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/ofppc/stand/ofwboot/mbr.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ofppc/stand/ofwboot/rdb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/mbr.c
diff -u src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.5 src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.6
--- src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.5	Wed Mar 30 21:14:54 2016
+++ src/sys/arch/ofppc/stand/ofwboot/mbr.c	Mon May 17 20:21:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.c,v 1.5 2016/03/30 21:14:54 christos Exp $	*/
+/*	$NetBSD: mbr.c,v 1.6 2021/05/17 20:21:05 mrg Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -34,6 +34,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 

Index: src/sys/arch/ofppc/stand/ofwboot/rdb.c
diff -u src/sys/arch/ofppc/stand/ofwboot/rdb.c:1.2 src/sys/arch/ofppc/stand/ofwboot/rdb.c:1.3
--- src/sys/arch/ofppc/stand/ofwboot/rdb.c:1.2	Sat Jun 19 08:48:33 2010
+++ src/sys/arch/ofppc/stand/ofwboot/rdb.c	Mon May 17 20:21:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rdb.c,v 1.2 2010/06/19 08:48:33 kiyohara Exp $	*/
+/*	$NetBSD: rdb.c,v 1.3 2021/05/17 20:21:05 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2009 Frank Wille.
@@ -31,6 +31,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include "rdb.h"



CVS commit: src/sys/arch/ofppc/stand/ofwboot

2016-06-11 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Jun 11 06:35:38 UTC 2016

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: boot.c

Log Message:
PR 51200 gets in libsa considered harmful: use kgets


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/ofppc/stand/ofwboot/boot.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/boot.c
diff -u src/sys/arch/ofppc/stand/ofwboot/boot.c:1.23 src/sys/arch/ofppc/stand/ofwboot/boot.c:1.24
--- src/sys/arch/ofppc/stand/ofwboot/boot.c:1.23	Sat Jan 22 19:19:21 2011
+++ src/sys/arch/ofppc/stand/ofwboot/boot.c	Sat Jun 11 06:35:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.23 2011/01/22 19:19:21 joerg Exp $	*/
+/*	$NetBSD: boot.c,v 1.24 2016/06/11 06:35:38 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -230,7 +230,7 @@ main(void)
 
 		if (boothowto & RB_ASKNAME) {
 			printf("Boot: ");
-			gets(bootline);
+			kgets(bootline, sizeof(bootline));
 			parseargs(bootline, );
 		}
 



CVS commit: src/sys/arch/ofppc/stand/ofwboot

2016-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 30 21:14:55 UTC 2016

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: mbr.c

Log Message:
PR/51015: David Binderman: remove useless code


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/ofppc/stand/ofwboot/mbr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/mbr.c
diff -u src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.4 src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.5
--- src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.4	Thu Feb  2 16:54:34 2012
+++ src/sys/arch/ofppc/stand/ofwboot/mbr.c	Wed Mar 30 17:14:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.c,v 1.4 2012/02/02 21:54:34 phx Exp $	*/
+/*	$NetBSD: mbr.c,v 1.5 2016/03/30 21:14:54 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -130,7 +130,6 @@ find_mbr_part(struct of_dev *devp, uint3
 		}
 	}
 
-	recursion--;
 	return 0;
 }
 



CVS commit: src/sys/arch/ofppc/stand/ofwboot

2014-09-20 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Sep 20 23:10:46 UTC 2014

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: Locore.c ofwstart.S version

Log Message:
A stack size of 8K is too small for a block buffer of 65536 bytes.
Increased the stack size to 128K. This makes ofwboot work with FirmWorks
OpenFirmware systems again (tested with Motorola PowerStack II).


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/ofppc/stand/ofwboot/Locore.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ofppc/stand/ofwboot/ofwstart.S
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/ofppc/stand/ofwboot/version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/Locore.c
diff -u src/sys/arch/ofppc/stand/ofwboot/Locore.c:1.22 src/sys/arch/ofppc/stand/ofwboot/Locore.c:1.23
--- src/sys/arch/ofppc/stand/ofwboot/Locore.c:1.22	Mon Jan 12 07:49:57 2009
+++ src/sys/arch/ofppc/stand/ofwboot/Locore.c	Sat Sep 20 23:10:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: Locore.c,v 1.22 2009/01/12 07:49:57 tsutsui Exp $	*/
+/*	$NetBSD: Locore.c,v 1.23 2014/09/20 23:10:46 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -46,7 +46,7 @@ static void setup(void);
 
 /* this pad gets the rodata laignment right, don't EVER fiddle it */
 char *pad __attribute__((__aligned__ (8))) = pad;
-int stack[8192/4 + 4] __attribute__((__aligned__ (4), __used__));
+int stack[0x2/4 + 4] __attribute__((__aligned__ (4), __used__));
 char *heapspace __attribute__((__aligned__ (4)));
 char altheap[0x2] __attribute__((__aligned__ (4)));
 

Index: src/sys/arch/ofppc/stand/ofwboot/ofwstart.S
diff -u src/sys/arch/ofppc/stand/ofwboot/ofwstart.S:1.3 src/sys/arch/ofppc/stand/ofwboot/ofwstart.S:1.4
--- src/sys/arch/ofppc/stand/ofwboot/ofwstart.S:1.3	Mon Apr 28 20:23:31 2008
+++ src/sys/arch/ofppc/stand/ofwboot/ofwstart.S	Sat Sep 20 23:10:46 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ofwstart.S,v 1.3 2008/04/28 20:23:31 martin Exp $ */
+/* $NetBSD: ofwstart.S,v 1.4 2014/09/20 23:10:46 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -95,9 +95,8 @@ _entry:
 _start:
 	sync
 	isync
-	lis	%r1,stack@ha
-	addi	%r1,%r1,stack@l
-	addi	%r1,%r1,8192
+	lis	%r1,stack+0x2@ha
+	addi	%r1,%r1,stack+0x2@l
 
 	mfmsr	%r8
 	li	%r0,0

Index: src/sys/arch/ofppc/stand/ofwboot/version
diff -u src/sys/arch/ofppc/stand/ofwboot/version:1.12 src/sys/arch/ofppc/stand/ofwboot/version:1.13
--- src/sys/arch/ofppc/stand/ofwboot/version:1.12	Thu Aug 18 09:03:28 2011
+++ src/sys/arch/ofppc/stand/ofwboot/version	Sat Sep 20 23:10:46 2014
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.12 2011/08/18 09:03:28 phx Exp $
+$NetBSD: version,v 1.13 2014/09/20 23:10:46 phx Exp $
 
 1.1:		Boot program for OpenFirmware; initial revision
 1.2:		Boot program rearrangement
@@ -12,3 +12,4 @@ $NetBSD: version,v 1.12 2011/08/18 09:03
 1.10:		Change note to indicate real mode, add ldscript to support 7046
 1.11:		Support for RDB partitions.
 1.12:		Fixed MBR support, which had been broken in 1.11.
+1.13:		Fixed stack size. Make it work with FirmWorks again.



CVS commit: src/sys/arch/ofppc/stand/ofwboot

2013-08-21 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Aug 21 06:46:26 UTC 2013

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: Makefile

Log Message:
Use bsd.klinks.mk
Add ${_MKTARGET_LINK}


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/ofppc/stand/ofwboot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/Makefile
diff -u src/sys/arch/ofppc/stand/ofwboot/Makefile:1.27 src/sys/arch/ofppc/stand/ofwboot/Makefile:1.28
--- src/sys/arch/ofppc/stand/ofwboot/Makefile:1.27	Mon Jan 24 19:27:18 2011
+++ src/sys/arch/ofppc/stand/ofwboot/Makefile	Wed Aug 21 06:46:26 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.27 2011/01/24 19:27:18 joerg Exp $
+#	$NetBSD: Makefile,v 1.28 2013/08/21 06:46:26 matt Exp $
 
 S!=	cd ${.CURDIR}/../../../.. ; pwd
 
@@ -14,6 +14,7 @@ CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP 
 CPPFLAGS+=	-DHEAP_VARIABLE
 
 .include bsd.own.mk
+.include bsd.klinks.mk
 
 DBG=		-Os -mmultiple
 
@@ -46,14 +47,6 @@ CPPFLAGS+=	-DRELOC=0x${RELOC}
 CPPFLAGS+=	-DFIRMWORKSBUGS
 CPPFLAGS+=	-DCOMPAT_386BSD_MBRPART
 
-.if !make(obj)  !make(clean)  !make(cleandir)
-.BEGIN:
-	@[ -h machine ] || ln -s ${S}/arch/${MACHINE}/include machine
-	@[ -h powerpc ] || ln -s ${S}/arch/powerpc/include powerpc
-.endif
-.NOPATH: machine powerpc
-CLEANFILES+= machine powerpc
-
 ### find out what to use for libkern
 KERN_AS=	library
 .include ${S}/lib/libkern/Makefile.inc
@@ -76,6 +69,7 @@ vers.c: version
 	${.CURDIR}/version ofppc ${NEWVERSWHAT}
 
 ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
+	${_MKTARGET_LINK}
 	${LD} -s -N -T ${.CURDIR}/ldscript -Ttext ${RELOC} -Bstatic \
 	-e ${ENTRY} -o ${PROG}.X ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
 	mv -f ${PROG}.X ${PROG}



CVS commit: src/sys/arch/ofppc/stand/ofwboot

2011-08-21 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Aug 21 13:08:58 UTC 2011

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: mbr.c

Log Message:
When there is no NetBSD MBR partition with a valid disklabel, look for
the first FAT partition and construct a disklabel with an MSDOS filesystem
in partition 'a'.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ofppc/stand/ofwboot/mbr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/mbr.c
diff -u src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.2 src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.3
--- src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.2	Thu Aug 18 09:03:28 2011
+++ src/sys/arch/ofppc/stand/ofwboot/mbr.c	Sun Aug 21 13:08:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.c,v 1.2 2011/08/18 09:03:28 phx Exp $	*/
+/*	$NetBSD: mbr.c,v 1.3 2011/08/21 13:08:57 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -39,14 +39,9 @@
 
 #include mbr.h
 
-
-static u_long
-get_long(const void *p)
-{
-	const unsigned char *cp = p;
-
-	return cp[0] | (cp[1]  8) | (cp[2]  16) | (cp[3]  24);
-}
+static int find_mbr_part(struct of_dev *, uint32_t, char *,
+struct disklabel *, uint32_t, uint8_t, int);
+static void make_dos_label(struct disklabel *, uint32_t);
 
 /*
  * Find a valid MBR disklabel.
@@ -55,58 +50,109 @@
 search_mbr_label(struct of_dev *devp, u_long off, char *buf,
 struct disklabel *lp, u_long off0)
 {
+	static uint8_t fat_types[] = {
+		MBR_PTYPE_FAT12, MBR_PTYPE_FAT16S, MBR_PTYPE_FAT16B,
+		MBR_PTYPE_FAT32, MBR_PTYPE_FAT32L, MBR_PTYPE_FAT16L
+	};
+	size_t read;
+	uint32_t poff;
+	int i;
+
+	/* Find a disklabel in a NetBSD or 386BSD partition. */
+	poff = find_mbr_part(devp, off, buf, lp, 0, MBR_PTYPE_NETBSD, 0);
+#ifdef COMPAT_386BSD_MBRPART
+	if (poff == 0) {
+		poff = find_mbr_part(devp, off, buf, lp, 0,
+		MBR_PTYPE_386BSD, 0);
+		if (poff != 0)
+			printf(WARNING: old BSD partition ID!\n);
+	}
+#endif
+	if (poff != 0) {
+		if (strategy(devp, F_READ, poff + MBR_LABELSECTOR, DEV_BSIZE,
+		buf, read) == 0  read == DEV_BSIZE)
+			if (getdisklabel(buf, lp) == NULL)
+return 0;
+	}
+
+	/*
+	 * No BSD partition with a valid disklabel found, so try to
+	 * construct a label from a DOS partition.
+	 */
+	for (i = 0; i  sizeof(fat_types); i++) {
+		poff = find_mbr_part(devp, off, buf, lp, 0, fat_types[i], 0);
+		if (poff != 0) {
+			make_dos_label(lp, poff);
+			return 0;
+		}
+	}
+
+	return ERDLAB;
+}
+
+static int
+find_mbr_part(struct of_dev *devp, uint32_t off, char *buf,
+struct disklabel *lp, uint32_t off0, uint8_t ptype, int recursion)
+{
 	size_t read;
 	struct mbr_partition *p;
 	int i;
-	u_long poff;
-	static int recursion;
+	uint32_t poff;
 
 	if (strategy(devp, F_READ, off, DEV_BSIZE, buf, read)
 	|| read != DEV_BSIZE)
-		return ERDLAB;
+		return 0;
 
-	if (*(u_int16_t *)buf[MBR_MAGIC_OFFSET] != sa_htole16(MBR_MAGIC))
-		return ERDLAB;
+	if (*(uint16_t *)buf[MBR_MAGIC_OFFSET] != sa_htole16(MBR_MAGIC))
+		return 0;
 
 	if (recursion++ = 1)
 		off0 += off;
+
 	for (p = (struct mbr_partition *)(buf + MBR_PART_OFFSET), i = 0;
 	 i  MBR_PART_COUNT; i++, p++) {
-		if (p-mbrp_type == MBR_PTYPE_NETBSD
-#ifdef COMPAT_386BSD_MBRPART
-		|| (p-mbrp_type == MBR_PTYPE_386BSD 
-			(printf(WARNING: old BSD partition ID!\n), 1)
-			/* XXX XXX - libsa printf() is void */ )
-#endif
-		) {
-			poff = get_long(p-mbrp_start) + off0;
-			if (strategy(devp, F_READ, poff + MBR_LABELSECTOR,
- DEV_BSIZE, buf, read) == 0
-			 read == DEV_BSIZE) {
-if (getdisklabel(buf, lp) == NULL) {
-	recursion--;
-	return 0;
-}
-			}
-			if (strategy(devp, F_READ, off, DEV_BSIZE, buf, read)
-			|| read != DEV_BSIZE) {
-recursion--;
-return ERDLAB;
-			}
-		} else if (p-mbrp_type == MBR_PTYPE_EXT) {
-			poff = get_long(p-mbrp_start);
-			if (!search_mbr_label(devp, poff, buf, lp, off0)) {
+		if (p-mbrp_type == ptype) {
+			recursion--;
+			return sa_le32toh(p-mbrp_start) + off0;
+		}
+		else if (p-mbrp_type == MBR_PTYPE_EXT) {
+			poff = find_mbr_part(devp, sa_le32toh(p-mbrp_start),
+			buf, lp, off0, ptype, recursion);
+			if (poff != 0) {
 recursion--;
-return 0;
+return poff;
 			}
 			if (strategy(devp, F_READ, off, DEV_BSIZE, buf, read)
 			|| read != DEV_BSIZE) {
 recursion--;
-return ERDLAB;
+return 0;
 			}
 		}
 	}
 
 	recursion--;
-	return ERDLAB;
+	return 0;
+}
+
+static void
+make_dos_label(struct disklabel *lp, uint32_t poff)
+{
+	int i;
+
+	/* clear all partitions */
+	lp-d_npartitions = RAW_PART + 1;
+	for (i = 0; i  MAXPARTITIONS; i++) {
+		lp-d_partitions[i].p_size = 0;
+		lp-d_partitions[i].p_offset = 0;
+		lp-d_partitions[i].p_fstype = 0;
+	}
+
+	/* set DOS partition as root partition */
+	lp-d_partitions[0].p_offset = poff;
+	lp-d_partitions[0].p_fstype = FS_MSDOS;
+
+	/* disklabel is valid */
+	lp-d_magic = 

CVS commit: src/sys/arch/ofppc/stand/ofwboot

2011-08-21 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Aug 21 13:12:48 UTC 2011

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: ofdev.c

Log Message:
Fixed booting from disks without a valid disklabel (e.g. CDROM). This
became broken with my last changes in rev.1.18..


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/ofppc/stand/ofwboot/ofdev.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/ofdev.c
diff -u src/sys/arch/ofppc/stand/ofwboot/ofdev.c:1.18 src/sys/arch/ofppc/stand/ofwboot/ofdev.c:1.19
--- src/sys/arch/ofppc/stand/ofwboot/ofdev.c:1.18	Thu Aug 18 09:03:28 2011
+++ src/sys/arch/ofppc/stand/ofwboot/ofdev.c	Sun Aug 21 13:12:48 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofdev.c,v 1.18 2011/08/18 09:03:28 phx Exp $	*/
+/*	$NetBSD: ofdev.c,v 1.19 2011/08/21 13:12:48 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -292,14 +292,15 @@
 			ofdev.partoff = 0;
 		} else if (error != 0)
 			goto bad;
-
-		part = partition ? partition - 'a' : 0;
-		ofdev.partoff = label.d_partitions[part].p_offset;
-		if (label.d_partitions[part].p_fstype == FS_RAID) {
+		else {
+			part = partition ? partition - 'a' : 0;
+			ofdev.partoff = label.d_partitions[part].p_offset;
+			if (label.d_partitions[part].p_fstype == FS_RAID) {
 #define RF_PROTECTED_SECTORS 64
-			ofdev.partoff += RF_PROTECTED_SECTORS;
-			DPRINTF(devopen: found RAID partition, 
-			adjusting offset to %lx\n, ofdev.partoff);
+ofdev.partoff += RF_PROTECTED_SECTORS;
+DPRINTF(devopen: found RAID partition, 
+adjusting offset to %lx\n, ofdev.partoff);
+			}
 		}
 		of-f_dev = devsw;
 		of-f_devdata = ofdev;



CVS commit: src/sys/arch/ofppc/stand/ofwboot

2011-08-18 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Aug 18 09:03:28 UTC 2011

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: mbr.c ofdev.c version

Log Message:
Finding the disklabel on MBR partitioned disks did no longer work since RDB
support was added. Fixed that and bumped the version to 1.12.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/ofppc/stand/ofwboot/mbr.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/ofppc/stand/ofwboot/ofdev.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/ofppc/stand/ofwboot/version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/mbr.c
diff -u src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.1 src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.2
--- src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.1	Fri Sep 11 12:00:12 2009
+++ src/sys/arch/ofppc/stand/ofwboot/mbr.c	Thu Aug 18 09:03:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.c,v 1.1 2009/09/11 12:00:12 phx Exp $	*/
+/*	$NetBSD: mbr.c,v 1.2 2011/08/18 09:03:28 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -48,7 +48,6 @@
 	return cp[0] | (cp[1]  8) | (cp[2]  16) | (cp[3]  24);
 }
 
-
 /*
  * Find a valid MBR disklabel.
  */
@@ -81,10 +80,10 @@
 #endif
 		) {
 			poff = get_long(p-mbrp_start) + off0;
-			if (strategy(devp, F_READ, poff + LABELSECTOR,
+			if (strategy(devp, F_READ, poff + MBR_LABELSECTOR,
  DEV_BSIZE, buf, read) == 0
 			 read == DEV_BSIZE) {
-if (!getdisklabel(buf, lp)) {
+if (getdisklabel(buf, lp) == NULL) {
 	recursion--;
 	return 0;
 }

Index: src/sys/arch/ofppc/stand/ofwboot/ofdev.c
diff -u src/sys/arch/ofppc/stand/ofwboot/ofdev.c:1.17 src/sys/arch/ofppc/stand/ofwboot/ofdev.c:1.18
--- src/sys/arch/ofppc/stand/ofwboot/ofdev.c:1.17	Fri Sep 11 12:00:12 2009
+++ src/sys/arch/ofppc/stand/ofwboot/ofdev.c	Thu Aug 18 09:03:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofdev.c,v 1.17 2009/09/11 12:00:12 phx Exp $	*/
+/*	$NetBSD: ofdev.c,v 1.18 2011/08/18 09:03:28 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -96,13 +96,12 @@
 for (cp = lp;
  --cp = str  *cp != '/'  *cp != ':';)
 	;
-if (cp = str  *cp == ':') {
 
+if (cp = str  *cp == ':') {
 	/*
 	 * found some arguments,
 	 * make OFW ignore them.
 	 */
-
 	*cp = 0;
 	for (cp = lp; *--cp  *cp != ',';)
 		;
@@ -122,7 +121,7 @@
 
 int
 strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf,
-	 size_t *rsize)
+size_t *rsize)
 {
 	struct of_dev *dev = devdata;
 	u_quad_t pos;
@@ -150,7 +149,9 @@
 }
 
 static int
-devopen_dummy(struct open_file *of, ...) {
+devopen_dummy(struct open_file *of, ...)
+{
+
 	return -1;
 }
 
@@ -186,7 +187,6 @@
 char opened_name[256];
 int floppyboot;
 
-
 int
 devopen(struct open_file *of, const char *name, char **file)
 {
@@ -204,6 +204,7 @@
 		panic(devopen);
 	if (of-f_flags != F_READ)
 		return EPERM;
+
 	strcpy(fname, name);
 	cp = filename(fname, partition);
 	if (cp) {
@@ -213,6 +214,7 @@
 	}
 	if (!cp || !*buf)
 		strcpy(buf, DEFAULT_KERNEL);
+
 	if (!*fname)
 		strcpy(fname, bootdev);
 	DPRINTF(fname=%s\n, fname);
@@ -230,74 +232,75 @@
 	if (partition) {
 		*file += 2;
 	}
+
 	if ((handle = OF_finddevice(fname)) == -1) {
 		DPRINTF(OF_finddevice(\%s\) failed\n, fname);
 		return ENOENT;
 	}
+
 	if (OF_getprop(handle, name, buf, sizeof buf)  0)
 		return ENXIO;
 	floppyboot = !strcmp(buf, floppy);
 	if (OF_getprop(handle, device_type, buf, sizeof buf)  0)
 		return ENXIO;
 	if (!strcmp(buf, block)) {
-
 		/*
 		 * For block devices, indicate raw partition
 		 * (:0 in OpenFirmware)
 		 */
-
 		strcat(fname, :0);
 	}
+
 	DPRINTF(calling OF_open(fname=%s)\n, fname);
 	if ((handle = OF_open(fname)) == -1)
 		return ENXIO;
 	memset(ofdev, 0, sizeof ofdev);
 	ofdev.handle = handle;
+
 	if (!strcmp(buf, block)) {
 		ofdev.type = OFDEV_DISK;
 		ofdev.bsize = DEV_BSIZE;
 
-		/* First try to find a disklabel without MBR/RDB partitions */
-		if (strategy(ofdev, F_READ,
-			 LABELSECTOR, DEV_BSIZE, buf, read) != 0
-		|| read != DEV_BSIZE
-		|| getdisklabel(buf, label)) {
-
-			/* Else try MBR partitions */
-			error = search_mbr_label(ofdev, 0, buf, label, 0);
-			if (error  error != ERDLAB)
-goto bad;
+		/* First try to read a disklabel from a NetBSD MBR partition */
+		error = search_mbr_label(ofdev, 0, buf, label, 0);
 
-			/* and finally try RDB partitions */
+		if (error == ERDLAB) {
+			/* Try to construct a disklabel from RDB partitions */
 			error = search_rdb_label(ofdev, buf, label);
-			if (error  error != ERDLAB)
-goto bad;
+
+			if (error == ERDLAB) {
+/* At last read a raw NetBSD disklabel */
+error = strategy(ofdev, F_READ, LABELSECTOR,
+DEV_BSIZE, buf, read);
+if (error == 0  read != DEV_BSIZE)
+	error = EIO;
+if (error == 0)
+	if (getdisklabel(buf, label) != NULL)
+		error = ERDLAB;
+			}
 		}
 
 		if 

CVS commit: src/sys/arch/ofppc/stand/ofwboot

2011-01-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Jan 24 19:27:18 UTC 2011

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: Makefile

Log Message:
Ensure that NOMAN is defined earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/ofppc/stand/ofwboot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/Makefile
diff -u src/sys/arch/ofppc/stand/ofwboot/Makefile:1.26 src/sys/arch/ofppc/stand/ofwboot/Makefile:1.27
--- src/sys/arch/ofppc/stand/ofwboot/Makefile:1.26	Sat Jan 22 19:19:21 2011
+++ src/sys/arch/ofppc/stand/ofwboot/Makefile	Mon Jan 24 19:27:18 2011
@@ -1,10 +1,9 @@
-#	$NetBSD: Makefile,v 1.26 2011/01/22 19:19:21 joerg Exp $
+#	$NetBSD: Makefile,v 1.27 2011/01/24 19:27:18 joerg Exp $
 
 S!=	cd ${.CURDIR}/../../../.. ; pwd
 
-.include bsd.own.mk
-
 PROG=		ofwboot
+NOMAN=		# defined
 SRCS=		ofwstart.S Locore.c boot.c ofdev.c net.c netif_of.c
 SRCS+=		mbr.c rdb.c vers.c
 CFLAGS+=	-msoft-float -Wno-main -ffreestanding
@@ -13,6 +12,9 @@
 #CPPFLAGS+=	-DOFWDUMP
 CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP -I${.CURDIR}
 CPPFLAGS+=	-DHEAP_VARIABLE
+
+.include bsd.own.mk
+
 DBG=		-Os -mmultiple
 
 SRCS+=		ofwmagic.S
@@ -21,7 +23,6 @@
 SRCS+=		byteorder.c
 .PATH:		${S}/lib/libsa
 
-NOMAN=		# defined
 STRIPFLAG=
 BINMODE=	444
 



CVS commit: src/sys/arch/ofppc/stand/ofwboot

2010-06-19 Thread KIYOHARA Takashi
Module Name:src
Committed By:   kiyohara
Date:   Sat Jun 19 08:48:33 UTC 2010

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: rdb.c

Log Message:
Support load from FAT.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/ofppc/stand/ofwboot/rdb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/rdb.c
diff -u src/sys/arch/ofppc/stand/ofwboot/rdb.c:1.1 src/sys/arch/ofppc/stand/ofwboot/rdb.c:1.2
--- src/sys/arch/ofppc/stand/ofwboot/rdb.c:1.1	Fri Sep 11 12:00:12 2009
+++ src/sys/arch/ofppc/stand/ofwboot/rdb.c	Sat Jun 19 08:48:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rdb.c,v 1.1 2009/09/11 12:00:12 phx Exp $	*/
+/*	$NetBSD: rdb.c,v 1.2 2010/06/19 08:48:33 kiyohara Exp $	*/
 
 /*-
  * Copyright (c) 2009 Frank Wille.
@@ -99,6 +99,10 @@
 		adt.archtype = ADT_RAID;
 		adt.fstype = FS_RAID;
 		return adt;
+	case DOST_MSD:
+		adt.archtype = ADT_MSD;
+		adt.fstype = FS_MSDOS;
+		return adt;
 	default:
 		adt.archtype = ADT_UNKNOWN;
 		adt.fstype = FS_UNUSED;



CVS commit: src/sys/arch/ofppc/stand/ofwboot

2009-09-11 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Fri Sep 11 12:00:13 UTC 2009

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: Makefile ofdev.c ofdev.h version
Added Files:
src/sys/arch/ofppc/stand/ofwboot: mbr.c mbr.h rdb.c rdb.h

Log Message:
Added support for RDB partitions.
Moved MBR parition code out of ofdev.c into mbr.c.
Tested on Pegasos2 (RDB and MBR) and RS6000.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/ofppc/stand/ofwboot/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/ofppc/stand/ofwboot/mbr.c \
src/sys/arch/ofppc/stand/ofwboot/mbr.h \
src/sys/arch/ofppc/stand/ofwboot/rdb.c \
src/sys/arch/ofppc/stand/ofwboot/rdb.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/ofppc/stand/ofwboot/ofdev.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ofppc/stand/ofwboot/ofdev.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/ofppc/stand/ofwboot/version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ofppc/stand/ofwboot/Makefile
diff -u src/sys/arch/ofppc/stand/ofwboot/Makefile:1.24 src/sys/arch/ofppc/stand/ofwboot/Makefile:1.25
--- src/sys/arch/ofppc/stand/ofwboot/Makefile:1.24	Mon Jan 12 07:49:57 2009
+++ src/sys/arch/ofppc/stand/ofwboot/Makefile	Fri Sep 11 12:00:12 2009
@@ -1,9 +1,10 @@
-#	$NetBSD: Makefile,v 1.24 2009/01/12 07:49:57 tsutsui Exp $
+#	$NetBSD: Makefile,v 1.25 2009/09/11 12:00:12 phx Exp $
 
 S!=	cd ${.CURDIR}/../../../.. ; pwd
 
 PROG=		ofwboot
-SRCS=		ofwstart.S Locore.c boot.c ofdev.c net.c netif_of.c vers.c
+SRCS=		ofwstart.S Locore.c boot.c ofdev.c net.c netif_of.c
+SRCS+=		mbr.c rdb.c vers.c
 CFLAGS+=	-msoft-float -Wno-main -ffreestanding
 CFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
 #CPPFLAGS+=	-g -DALLOC_TRACE -DDEBUG #-DOFW_DEBUG -DNETIF_DEBUG

Index: src/sys/arch/ofppc/stand/ofwboot/ofdev.c
diff -u src/sys/arch/ofppc/stand/ofwboot/ofdev.c:1.16 src/sys/arch/ofppc/stand/ofwboot/ofdev.c:1.17
--- src/sys/arch/ofppc/stand/ofwboot/ofdev.c:1.16	Mon Jan 12 07:49:57 2009
+++ src/sys/arch/ofppc/stand/ofwboot/ofdev.c	Fri Sep 11 12:00:12 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofdev.c,v 1.16 2009/01/12 07:49:57 tsutsui Exp $	*/
+/*	$NetBSD: ofdev.c,v 1.17 2009/09/11 12:00:12 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -37,8 +37,6 @@
 #include ofdev.h
 
 #include sys/param.h
-#include sys/disklabel.h
-#include sys/bootblock.h
 
 #include netinet/in.h
 
@@ -52,6 +50,8 @@
 
 #include net.h
 #include openfirm.h
+#include mbr.h
+#include rdb.h
 
 extern char bootdev[];
 
@@ -120,7 +120,7 @@
 	return 0;
 }
 
-static int
+int
 strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf,
 	 size_t *rsize)
 {
@@ -186,76 +186,6 @@
 char opened_name[256];
 int floppyboot;
 
-static u_long
-get_long(const void *p)
-{
-	const unsigned char *cp = p;
-
-	return cp[0] | (cp[1]  8) | (cp[2]  16) | (cp[3]  24);
-}
-
-/*
- * Find a valid disklabel.
- */
-static int
-search_label(struct of_dev *devp, u_long off, char *buf, struct disklabel *lp,
-u_long off0)
-{
-	size_t read;
-	struct mbr_partition *p;
-	int i;
-	u_long poff;
-	static int recursion;
-
-	if (strategy(devp, F_READ, off, DEV_BSIZE, buf, read)
-	|| read != DEV_BSIZE)
-		return ERDLAB;
-
-	if (*(u_int16_t *)buf[MBR_MAGIC_OFFSET] != sa_htole16(MBR_MAGIC))
-		return ERDLAB;
-
-	if (recursion++ = 1)
-		off0 += off;
-	for (p = (struct mbr_partition *)(buf + MBR_PART_OFFSET), i = 0;
-	 i  MBR_PART_COUNT; i++, p++) {
-		if (p-mbrp_type == MBR_PTYPE_NETBSD
-#ifdef COMPAT_386BSD_MBRPART
-		|| (p-mbrp_type == MBR_PTYPE_386BSD 
-			(printf(WARNING: old BSD partition ID!\n), 1)
-			/* XXX XXX - libsa printf() is void */ )
-#endif
-		) {
-			poff = get_long(p-mbrp_start) + off0;
-			if (strategy(devp, F_READ, poff + LABELSECTOR,
- DEV_BSIZE, buf, read) == 0
-			 read == DEV_BSIZE) {
-if (!getdisklabel(buf, lp)) {
-	recursion--;
-	return 0;
-}
-			}
-			if (strategy(devp, F_READ, off, DEV_BSIZE, buf, read)
-			|| read != DEV_BSIZE) {
-recursion--;
-return ERDLAB;
-			}
-		} else if (p-mbrp_type == MBR_PTYPE_EXT) {
-			poff = get_long(p-mbrp_start);
-			if (!search_label(devp, poff, buf, lp, off0)) {
-recursion--;
-return 0;
-			}
-			if (strategy(devp, F_READ, off, DEV_BSIZE, buf, read)
-			|| read != DEV_BSIZE) {
-recursion--;
-return ERDLAB;
-			}
-		}
-	}
-
-	recursion--;
-	return ERDLAB;
-}
 
 int
 devopen(struct open_file *of, const char *name, char **file)
@@ -263,11 +193,12 @@
 	char *cp;
 	char partition;
 	char fname[256];
-	char buf[DEV_BSIZE];
 	struct disklabel label;
 	int handle, part;
 	size_t read;
 	int error = 0;
+	/* allow disk blocks up to 65536 bytes */
+	char buf[DEV_BSIZE7];
 
 	if (ofdev.handle != -1)
 		panic(devopen);
@@ -326,14 +257,19 @@
 		ofdev.type = OFDEV_DISK;
 		ofdev.bsize = DEV_BSIZE;
 
-		/* First try to find a disklabel without MBR partitions */
+