Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/bebox/stand/boot Support kernel load from IDE HDD w...



details:   https://anonhg.NetBSD.org/src/rev/2bc1d06c14f7
branches:  trunk
changeset: 758026:2bc1d06c14f7
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Thu Oct 14 06:50:43 2010 +0000

description:
Support kernel load from IDE HDD with onboard wdc.  like cobalt, sandpoint.

diffstat:

 sys/arch/bebox/stand/boot/Makefile     |    4 +-
 sys/arch/bebox/stand/boot/boot.c       |   20 +-
 sys/arch/bebox/stand/boot/conf.c       |    7 +-
 sys/arch/bebox/stand/boot/filesystem.c |    5 +-
 sys/arch/bebox/stand/boot/version      |    3 +-
 sys/arch/bebox/stand/boot/wd.c         |  320 ++++++++++++++++++++++
 sys/arch/bebox/stand/boot/wdc.c        |  479 +++++++++++++++++++++++++++++++++
 sys/arch/bebox/stand/boot/wdvar.h      |   96 ++++++
 8 files changed, 923 insertions(+), 11 deletions(-)

diffs (truncated from 1034 to 300 lines):

diff -r 5774f646c3dc -r 2bc1d06c14f7 sys/arch/bebox/stand/boot/Makefile
--- a/sys/arch/bebox/stand/boot/Makefile        Thu Oct 14 06:39:52 2010 +0000
+++ b/sys/arch/bebox/stand/boot/Makefile        Thu Oct 14 06:50:43 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.27 2010/10/14 06:17:29 kiyohara Exp $
+#      $NetBSD: Makefile,v 1.28 2010/10/14 06:50:43 kiyohara Exp $
 
 NOMAN= # defined
 
@@ -23,7 +23,7 @@
 SRCS= srt0.s
 SRCS+= boot.c clock.c com.c conf.c cons.c cpu.c devopen.c
 SRCS+= fd.c filesystem.c inkernel.c io.c kbd.c monitor.c ns16550.c
-SRCS+= pci.c prf.c tgets.c vers.c vga.c video.c vreset.c
+SRCS+= pci.c prf.c tgets.c vers.c vga.c video.c vreset.c wdc.c wd.c
 SRCS+= setjmp.S
 
 CFLAGS= -Wno-main -ffreestanding
diff -r 5774f646c3dc -r 2bc1d06c14f7 sys/arch/bebox/stand/boot/boot.c
--- a/sys/arch/bebox/stand/boot/boot.c  Thu Oct 14 06:39:52 2010 +0000
+++ b/sys/arch/bebox/stand/boot/boot.c  Thu Oct 14 06:50:43 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.21 2010/10/14 06:39:52 kiyohara Exp $       */
+/*     $NetBSD: boot.c,v 1.22 2010/10/14 06:50:44 kiyohara Exp $       */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -40,9 +40,12 @@
 #include <machine/cpu.h>
 
 #include "boot.h"
+#include "wdvar.h"
 
 char *names[] = {
+       "/dev/disk/ide/0/master/0_0:/netbsd",
        "/dev/disk/floppy:netbsd",      "/dev/disk/floppy:netbsd.gz",
+       "/dev/disk/ide/0/master/0_0:/onetbsd",
        "/dev/disk/floppy:onetbsd",     "/dev/disk/floppy:onetbsd.gz"
        "in",
 };
@@ -115,11 +118,6 @@
        p += sizeof (btinfo_console);
        memcpy(p, (void *)&btinfo_clock, sizeof (btinfo_clock));
 
-       /*
-        * attached kernel check
-        */
-       init_in();
-
        runCPU1((void *)start_CPU1);
        wait_for(&CPU1_alive);
 
@@ -127,6 +125,16 @@
        printf(">> (%s, %s)\n", bootprog_maker, bootprog_date);
        printf(">> Memory: %d k\n", btinfo_memory.memsize / 1024);
 
+       /*
+        * attached kernel check and copy.
+        */
+       init_in();
+
+       printf("\n");
+
+       /* Initialize wdc@isa port 0x1f0 */
+       wdc_init(0x1f0);
+
        for (;;) {
                name = names[n++];
                if (n >= NUMNAMES)
diff -r 5774f646c3dc -r 2bc1d06c14f7 sys/arch/bebox/stand/boot/conf.c
--- a/sys/arch/bebox/stand/boot/conf.c  Thu Oct 14 06:39:52 2010 +0000
+++ b/sys/arch/bebox/stand/boot/conf.c  Thu Oct 14 06:50:43 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.7 2010/10/14 06:39:52 kiyohara Exp $        */
+/*     $NetBSD: conf.c,v 1.8 2010/10/14 06:50:44 kiyohara Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -42,8 +42,13 @@
 extern int inopen(struct open_file *, ...);
 extern int inclose(struct open_file *);
 
+extern int wdstrategy(void *, int, daddr_t, size_t, void *, size_t *);
+extern int wdopen(struct open_file *, ...);
+extern int wdclose(struct open_file *);
+
 struct devsw devsw[] = {
        { "fd", fdstrategy, fdopen, fdclose, noioctl },
+       { "wd", wdstrategy, wdopen, wdclose, noioctl },
 
        { NULL, NULL,       NULL,   NULL,    NULL },
 };
diff -r 5774f646c3dc -r 2bc1d06c14f7 sys/arch/bebox/stand/boot/filesystem.c
--- a/sys/arch/bebox/stand/boot/filesystem.c    Thu Oct 14 06:39:52 2010 +0000
+++ b/sys/arch/bebox/stand/boot/filesystem.c    Thu Oct 14 06:50:43 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filesystem.c,v 1.7 2008/05/26 16:28:39 kiyohara Exp $  */
+/*     $NetBSD: filesystem.c,v 1.8 2010/10/14 06:50:44 kiyohara Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -30,8 +30,11 @@
  */
 
 #include <lib/libsa/stand.h>
+#include <ufs.h>
 
 struct fs_ops file_system[] = {
+       FS_OPS(ffsv1),
+       FS_OPS(ffsv2),
        FS_OPS(null),
 };
 
diff -r 5774f646c3dc -r 2bc1d06c14f7 sys/arch/bebox/stand/boot/version
--- a/sys/arch/bebox/stand/boot/version Thu Oct 14 06:39:52 2010 +0000
+++ b/sys/arch/bebox/stand/boot/version Thu Oct 14 06:50:43 2010 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.8 2010/10/14 06:23:27 kiyohara Exp $
+$NetBSD: version,v 1.9 2010/10/14 06:50:44 kiyohara Exp $
 
 1.1:           Boot program for BeBox; initial revision
 1.2:           check BUS FREQ, add clock information
@@ -8,3 +8,4 @@
                Headers.
 1.6:           Support framebuffer and vga.
                Split boot{,_com0,_vga}.
+1.7:           Support kernel load from IDE HDD with onboard wdc.
diff -r 5774f646c3dc -r 2bc1d06c14f7 sys/arch/bebox/stand/boot/wd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/bebox/stand/boot/wd.c    Thu Oct 14 06:50:43 2010 +0000
@@ -0,0 +1,320 @@
+/*     $NetBSD: wd.c,v 1.1 2010/10/14 06:50:43 kiyohara Exp $  */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Manuel Bouyer.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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/types.h>
+#include <sys/stdint.h>
+
+#include <lib/libsa/stand.h>
+#include <lib/libkern/libkern.h>
+
+#include <machine/param.h>
+#include <machine/stdarg.h>
+#include <dev/raidframe/raidframevar.h>                /* For RF_PROTECTED_SECTORS */
+
+#include "boot.h"
+#include "wdvar.h"
+
+#ifdef DEBUG
+#define DPRINTF(x)     printf x
+#else
+#define DPRINTF(x)
+#endif
+
+static int  wd_get_params(struct wd_softc *wd);
+static int  wdgetdisklabel(struct wd_softc *wd);
+static void wdgetdefaultlabel(struct wd_softc *wd, struct disklabel *lp);
+
+int wdopen(struct open_file *, ...);
+int wdclose(struct open_file *);
+int wdstrategy(void *, int, daddr_t, size_t, void *, size_t *);
+
+/*
+ * Get drive parameters through 'device identify' command.
+ */
+int
+wd_get_params(struct wd_softc *wd)
+{
+       int error;
+       uint8_t buf[DEV_BSIZE];
+
+       if ((error = wdc_exec_identify(wd, buf)) != 0)
+               return error;
+
+       wd->sc_params = *(struct ataparams *)buf;
+
+       /* 48-bit LBA addressing */
+       if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0)
+               wd->sc_flags |= WDF_LBA48;
+
+       /* Prior to ATA-4, LBA was optional. */
+       if ((wd->sc_params.atap_capabilities1 & WDC_CAP_LBA) != 0)
+               wd->sc_flags |= WDF_LBA;
+       
+       if ((wd->sc_flags & WDF_LBA48) != 0) {
+               DPRINTF(("Drive supports LBA48.\n"));
+               wd->sc_capacity =
+                   ((uint64_t)wd->sc_params.atap_max_lba[3] << 48) |
+                   ((uint64_t)wd->sc_params.atap_max_lba[2] << 32) |
+                   ((uint64_t)wd->sc_params.atap_max_lba[1] << 16) |
+                   ((uint64_t)wd->sc_params.atap_max_lba[0] <<  0);
+               DPRINTF(("atap_max_lba = (0x%x, 0x%x, 0x%x, 0x%x)\n",
+                   wd->sc_params.atap_max_lba[3],
+                   wd->sc_params.atap_max_lba[2],
+                   wd->sc_params.atap_max_lba[1],
+                   wd->sc_params.atap_max_lba[0]));
+               wd->sc_capacity28 =
+                   ((uint32_t)wd->sc_params.atap_capacity[1] << 16) |
+                   ((uint32_t)wd->sc_params.atap_capacity[0] <<  0);
+               DPRINTF(("atap_capacity = (0x%x, 0x%x)\n",
+                   wd->sc_params.atap_capacity[1],
+                   wd->sc_params.atap_capacity[0]));
+       } else if ((wd->sc_flags & WDF_LBA) != 0) {
+               DPRINTF(("Drive supports LBA.\n"));
+               wd->sc_capacity =
+                   ((uint32_t)wd->sc_params.atap_capacity[1] << 16) |
+                   ((uint32_t)wd->sc_params.atap_capacity[0] <<  0);
+               wd->sc_capacity28 =
+                   ((uint32_t)wd->sc_params.atap_capacity[1] << 16) |
+                   ((uint32_t)wd->sc_params.atap_capacity[0] <<  0);
+       } else {
+               DPRINTF(("Drive doesn't support LBA; using CHS.\n"));
+               wd->sc_capacity = wd->sc_capacity28 =
+                   wd->sc_params.atap_cylinders *
+                   wd->sc_params.atap_heads *
+                   wd->sc_params.atap_sectors;
+       }
+       DPRINTF(("wd->sc_capacity = %" PRId64 ", wd->sc_capacity28 = %d.\n",
+           wd->sc_capacity, wd->sc_capacity28));
+
+       return 0;
+}
+
+/*
+ * Initialize disk label to the default value.
+ */
+void
+wdgetdefaultlabel(struct wd_softc *wd, struct disklabel *lp)
+{
+
+       memset(lp, 0, sizeof(struct disklabel));
+
+       lp->d_secsize = DEV_BSIZE;
+       lp->d_ntracks = wd->sc_params.atap_heads;
+       lp->d_nsectors = wd->sc_params.atap_sectors;
+       lp->d_ncylinders = wd->sc_params.atap_cylinders;
+       lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+
+       if (strcmp((const char *)wd->sc_params.atap_model, "ST506") == 0)
+               lp->d_type = DTYPE_ST506;
+       else
+               lp->d_type = DTYPE_ESDI;
+
+       strncpy(lp->d_typename, (const char *)wd->sc_params.atap_model, 16);
+       strncpy(lp->d_packname, "fictitious", 16);
+       if (wd->sc_capacity > UINT32_MAX)
+               lp->d_secperunit = UINT32_MAX;
+       else
+               lp->d_secperunit = wd->sc_capacity;
+       lp->d_rpm = 3600;
+       lp->d_interleave = 1;
+       lp->d_flags = 0;
+
+       lp->d_partitions[RAW_PART].p_offset = 0;
+       lp->d_partitions[RAW_PART].p_size =
+       lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+       lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
+       lp->d_npartitions = MAXPARTITIONS;      /* RAW_PART + 1 ??? */
+
+       lp->d_magic = DISKMAGIC;
+       lp->d_magic2 = DISKMAGIC;
+       lp->d_checksum = dkcksum(lp);
+}
+
+/*
+ * Read disk label from the device.
+ */
+int
+wdgetdisklabel(struct wd_softc *wd)
+{
+       struct mbr_sector *mbr;
+       struct mbr_partition *mp;



Home | Main Index | Thread Index | Old Index