Source-Changes-HG archive

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

[src/sommerfeld_i386mp_1]: src/sys/arch/i386/stand b*()->mem*()



details:   https://anonhg.NetBSD.org/src/rev/32bb664b5739
branches:  sommerfeld_i386mp_1
changeset: 482423:32bb664b5739
user:      perry <perry%NetBSD.org@localhost>
date:      Sat Jul 07 22:57:58 2001 +0000

description:
b*()->mem*()

diffstat:

 sys/arch/i386/stand/installboot/getmount.c  |  157 ++++++
 sys/arch/i386/stand/lib/biosdisk.c          |  299 +++++++++++++
 sys/arch/i386/stand/lib/biosdisk_ll.c       |  220 +++++++++
 sys/arch/i386/stand/lib/bootinfo_biosgeom.c |  109 ++++
 sys/arch/i386/stand/lib/bootinfo_memmap.c   |   67 ++
 sys/arch/i386/stand/lib/dosfile.c           |  262 +++++++++++
 sys/arch/i386/stand/lib/netif/am7990.c      |  278 ++++++++++++
 sys/arch/i386/stand/lib/test/ether_bpf.c    |  223 +++++++++
 sys/arch/i386/stand/libsa/nfs.c             |  640 ++++++++++++++++++++++++++++
 9 files changed, 2255 insertions(+), 0 deletions(-)

diffs (truncated from 2291 to 300 lines):

diff -r 8008c0878c92 -r 32bb664b5739 sys/arch/i386/stand/installboot/getmount.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/installboot/getmount.c        Sat Jul 07 22:57:58 2001 +0000
@@ -0,0 +1,157 @@
+/*     $NetBSD: getmount.c,v 1.6.4.2 2001/07/07 22:57:58 perry Exp $ */
+
+/*
+ * Copyright (c) 1996
+ *     Matthias Drochner.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed for the NetBSD Project
+ *     by Matthias Drochner.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <ufs/ufs/ufsmount.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <err.h>
+
+#include "installboot.h"
+
+static int tempmounted = 0;
+
+static char *getbdev __P((char *));
+static char *dotempmount __P((char *));
+
+/* make block device name from character device name */
+static char *
+getbdev(dev)
+       char *dev;
+{
+       static char bdiskdev[MAXPATHLEN];
+
+       if (strncmp(dev, "/dev/r", 6)) {
+               warnx("bad device name %s", dev);
+               return (0);
+       }
+       (void) sprintf(bdiskdev, "/dev/%s", dev + 6);
+       return (bdiskdev);
+}
+
+/*
+ * create mountpoint and mount given block device there, return
+ * mountpoint
+ */
+static char *
+dotempmount(bdiskdev)
+       char *bdiskdev;
+{
+       static char dirtmpl[] = "/tmp/installbootXXXXXX";
+       char *dir;
+       struct ufs_args data;
+
+       if ((dir = mkdtemp(dirtmpl)) == NULL) {
+               warnx("mkdtemp failed");
+               return (0);
+       }
+       memset(&data, 0, sizeof(data));
+       data.fspec = bdiskdev;
+
+       /* this code if FFS only */
+       if (mount(MOUNT_FFS, dir, 0, &data) == -1) {
+               warn("mount %s->%s failed", bdiskdev, dir);
+               (void) rmdir(dir);
+               return (0);
+       }
+       if (verbose)
+               (void) fprintf(stderr, "mounted %s at %s\n", bdiskdev, dir);
+       tempmounted = 1;
+       return (dir);
+}
+
+/*
+ * Find out if given character device is already mounted. If not, mount it
+ * temporarily.
+ */
+char           *
+getmountpoint(diskdev)
+       char *diskdev;
+{
+       char *bdiskdev;
+       struct statfs *buf;
+       int num, i;
+
+       bdiskdev = getbdev(diskdev);
+       if (bdiskdev == NULL)
+               return (0);
+
+       num = getmntinfo(&buf, MNT_WAIT);
+       if (num == 0) {
+               warn("getmntinfo");
+               return (0);
+       }
+       for (i = 0; i < num; i++)
+               if (strncmp(bdiskdev, buf[i].f_mntfromname, MNAMELEN) == 0) {
+                       int j;
+
+                       /* Device is mounted. If there are more devices mounted
+                        at the same point, the fs could be hidden. Don't think
+                        too much about layering order - simply refuse. */
+                       for (j = 0; j < num; j++)
+                               if ((i != j) && (strncmp(buf[i].f_mntonname,
+                                                        buf[j].f_mntonname,
+                                                        MNAMELEN) == 0)) {
+                                       warnx("there is more than 1 mount at %s",
+                                             buf[i].f_mntonname);
+                                       return (0);
+                               }
+                       /* this code is FFS only */
+                       if (strncmp(buf[i].f_fstypename, MOUNT_FFS, MFSNAMELEN)) {
+                               warnx("%s: must be a FFS filesystem", bdiskdev);
+                               return (0);
+                       }
+                       return (buf[i].f_mntonname);
+               }
+       if (verbose)
+               (void) fprintf(stderr, "%s is not mounted\n", bdiskdev);
+       return (dotempmount(bdiskdev));
+}
+
+void 
+cleanupmount(dir)
+       char *dir;
+{
+       if (tempmounted) {
+               if (verbose)
+                       (void) fprintf(stderr, "unmounting\n");
+               (void) unmount(dir, 0);
+               (void) rmdir(dir);
+               tempmounted = 0;
+       }
+}
diff -r 8008c0878c92 -r 32bb664b5739 sys/arch/i386/stand/lib/biosdisk.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/lib/biosdisk.c        Sat Jul 07 22:57:58 2001 +0000
@@ -0,0 +1,299 @@
+/*     $NetBSD: biosdisk.c,v 1.15.4.2 2001/07/07 22:57:58 perry Exp $  */
+
+/*
+ * Copyright (c) 1996, 1998
+ *     Matthias Drochner.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed for the NetBSD Project
+ *     by Matthias Drochner.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*
+ * raw BIOS disk device for libsa.
+ * needs lowlevel parts from bios_disk.S and biosdisk_ll.c
+ * partly from netbsd:sys/arch/i386/boot/disk.c
+ * no bad144 handling!
+ */
+
+/*
+ * Ported to boot 386BSD by Julian Elischer (julian%tfs.com@localhost) Sept 1992
+ *
+ * Mach Operating System
+ * Copyright (c) 1992, 1991 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution%CS.CMU.EDU@localhost
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#include <sys/types.h>
+#include <sys/disklabel.h>
+
+#include <lib/libsa/stand.h>
+#include <lib/libsa/saerrno.h>
+#include <machine/stdarg.h>
+
+#include "libi386.h"
+#include "biosdisk_ll.h"
+#include "biosdisk.h"
+#ifdef _STANDALONE
+#include "bootinfo.h"
+#endif
+
+#define BUFSIZE (1 * BIOSDISK_SECSIZE)
+
+struct biosdisk {
+       struct biosdisk_ll ll;
+       int             boff;
+       char            buf[BUFSIZE];
+};
+
+#ifdef _STANDALONE
+static struct btinfo_bootdisk bi_disk;
+#endif
+
+#define        RF_PROTECTED_SECTORS    64      /* XXX refer to <.../rf_optnames.h> */
+
+int 
+biosdiskstrategy(devdata, flag, dblk, size, buf, rsize)
+       void           *devdata;
+       int             flag;
+       daddr_t         dblk;
+       size_t          size;
+       void           *buf;
+       size_t         *rsize;
+{
+       struct biosdisk *d;
+       int             blks, frag;
+
+       if (flag != F_READ)
+               return (EROFS);
+
+       d = (struct biosdisk *) devdata;
+
+       dblk += d->boff;
+
+       blks = size / BIOSDISK_SECSIZE;
+       if (blks && readsects(&d->ll, dblk, blks, buf, 0)) {
+               if (rsize)
+                       *rsize = 0;
+               return (EIO);
+       }
+       /* do we really need this? */
+       frag = size % BIOSDISK_SECSIZE;
+       if (frag) {
+               if (readsects(&d->ll, dblk + blks, 1, d->buf, 0)) {
+                       if (rsize)
+                               *rsize = blks * BIOSDISK_SECSIZE;
+                       return (EIO);
+               }
+               memcpy(buf + blks * BIOSDISK_SECSIZE, d->buf, frag);
+       }
+       if (rsize)
+               *rsize = size;
+       return (0);



Home | Main Index | Thread Index | Old Index