Source-Changes-HG archive

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

[src/trunk]: src - add MBR editing menu to sysinst.



details:   https://anonhg.NetBSD.org/src/rev/6a87a367c79b
branches:  trunk
changeset: 773573:6a87a367c79b
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Tue Feb 07 09:06:04 2012 +0000

description:
- add MBR editing menu to sysinst.
- fix typos in timecounter names.
- make sure to drain Tx FIFO to avoid clobbering
  kernel boot messages.
- allow to have the 3rd UART.
- add missing time-of-day clock support.

Ok by releng.

diffstat:

 distrib/utils/sysinst/arch/evbarm/Makefile |    4 +-
 distrib/utils/sysinst/arch/evbarm/md.c     |   34 +++++-
 distrib/utils/sysinst/arch/evbarm/md.h     |    6 +-
 sys/arch/arm/s3c2xx0/files.s3c2440         |    7 +-
 sys/arch/arm/s3c2xx0/s3c2440_rtc.c         |  173 +++++++++++++++++++++++++++++
 sys/arch/arm/s3c2xx0/s3c2440reg.h          |   19 +++
 sys/arch/arm/s3c2xx0/s3c24x0_clk.c         |    6 +-
 sys/arch/arm/s3c2xx0/s3c2800_clk.c         |    8 +-
 sys/arch/arm/s3c2xx0/sscom.c               |   14 +-
 sys/arch/arm/s3c2xx0/sscom_s3c2440.c       |   49 +++----
 10 files changed, 276 insertions(+), 44 deletions(-)

diffs (truncated from 537 to 300 lines):

diff -r b29b720a6a8d -r 6a87a367c79b distrib/utils/sysinst/arch/evbarm/Makefile
--- a/distrib/utils/sysinst/arch/evbarm/Makefile        Mon Feb 06 23:30:14 2012 +0000
+++ b/distrib/utils/sysinst/arch/evbarm/Makefile        Tue Feb 07 09:06:04 2012 +0000
@@ -1,8 +1,10 @@
-#      $NetBSD: Makefile,v 1.5 2005/02/19 17:00:39 dsl Exp $
+#      $NetBSD: Makefile,v 1.6 2012/02/07 09:06:04 nisimura Exp $
 #
 # Makefile for evbarm
 #
 
+MENUS_MD= menus.md.${SYSINSTLANG} menus.mbr
+MSG_MD= msg.md.${SYSINSTLANG} msg.mbr.${SYSINSTLANG}
 MD_OPTIONS=    AOUT2ELF
 
 .include "../../Makefile.inc"
diff -r b29b720a6a8d -r 6a87a367c79b distrib/utils/sysinst/arch/evbarm/md.c
--- a/distrib/utils/sysinst/arch/evbarm/md.c    Mon Feb 06 23:30:14 2012 +0000
+++ b/distrib/utils/sysinst/arch/evbarm/md.c    Tue Feb 07 09:06:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.25 2011/11/04 11:27:02 martin Exp $ */
+/*     $NetBSD: md.c,v 1.26 2012/02/07 09:06:04 nisimura Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -67,6 +67,15 @@
        int fd;
        char dev_name[100];
 
+       if (no_mbr)
+               return 1;
+
+       if (read_mbr(diskdev, &mbr) < 0)
+               memset(&mbr.mbr, 0, sizeof(mbr.mbr)-2);
+
+       if (edit_mbr(&mbr) == 0)
+               return 0;
+
        if (strncmp(diskdev, "wd", 2) == 0)
                disktype = "ST506";
        else
@@ -131,6 +140,17 @@
 int
 md_pre_disklabel(void)
 {
+       if (no_mbr)
+               return 0;
+
+       msg_display(MSG_dofdisk);
+
+       /* write edited MBR onto disk. */
+       if (write_mbr(diskdev, &mbr, 1) != 0) {
+               msg_display(MSG_wmbrfail);
+               process_menu(MENU_ok, NULL);
+               return 1;
+       }
        return 0;
 }
 
@@ -187,3 +207,15 @@
 {
        return 0;
 }
+
+int
+md_check_mbr(mbr_info_t *mbri)
+{
+       return 2;
+}
+
+int
+md_mbr_use_wholedisk(mbr_info_t *mbri)
+{
+       return mbr_use_wholedisk(mbri);
+}
diff -r b29b720a6a8d -r 6a87a367c79b distrib/utils/sysinst/arch/evbarm/md.h
--- a/distrib/utils/sysinst/arch/evbarm/md.h    Mon Feb 06 23:30:14 2012 +0000
+++ b/distrib/utils/sysinst/arch/evbarm/md.h    Tue Feb 07 09:06:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.h,v 1.18 2012/02/03 00:35:35 nisimura Exp $ */
+/*     $NetBSD: md.h,v 1.19 2012/02/07 09:06:04 nisimura Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -35,11 +35,15 @@
 
 /* md.h -- Machine specific definitions for evbarm */
 
+#include "mbr.h"
+
 /* Constants and defines */
 
 /* Megs required for a full X installation. */
 #define XNEEDMB 60
 
+#define HAVE_UFS2_BOOT
+
 /*
  *  Default filesets to fetch and install during installation
  *  or upgrade. The standard sets are:
diff -r b29b720a6a8d -r 6a87a367c79b sys/arch/arm/s3c2xx0/files.s3c2440
--- a/sys/arch/arm/s3c2xx0/files.s3c2440        Mon Feb 06 23:30:14 2012 +0000
+++ b/sys/arch/arm/s3c2xx0/files.s3c2440        Tue Feb 07 09:06:04 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.s3c2440,v 1.1 2012/01/30 03:28:33 nisimura Exp $
+#      $NetBSD: files.s3c2440,v 1.2 2012/02/07 09:06:04 nisimura Exp $
 #
 # Configuration info for Samsung S3C2440
 #
@@ -49,3 +49,8 @@
 device sstouch: wsmousedev, tpcalib
 attach sstouch at ssio
 file   arch/arm/s3c2xx0/s3c2440_touch.c        sstouch
+
+# RTC
+device ssrtc
+attach ssrtc at ssio
+file   arch/arm/s3c2xx0/s3c2440_rtc.c          ssrtc
diff -r b29b720a6a8d -r 6a87a367c79b sys/arch/arm/s3c2xx0/s3c2440_rtc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/s3c2xx0/s3c2440_rtc.c        Tue Feb 07 09:06:04 2012 +0000
@@ -0,0 +1,173 @@
+/*--
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Fleischer <paul%xpg.dk@localhost>
+ *
+ * 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/cdefs.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+#include <sys/time.h>
+
+#include <dev/clock_subr.h>
+
+#include <arm/s3c2xx0/s3c24x0var.h>
+#include <arm/s3c2xx0/s3c2440var.h>
+#include <arm/s3c2xx0/s3c2440reg.h>
+
+#ifdef SSRTC_DEBUG
+#define DPRINTF(s) do { printf s; } while (/*CONSTCOND*/0)
+#else
+#define DPRINTF(s) do {} while (/*CONSTCOND*/0)
+#endif
+
+/* As the RTC keeps track of Leap years, we need to use the right zero-year */
+#define SSRTC_YEAR_ZERO 2000
+
+struct ssrtc_softc {
+       device_t                sc_dev;
+       bus_space_tag_t         sc_iot;
+       bus_space_handle_t      sc_ioh;
+       struct todr_chip_handle sc_todr;
+};
+
+static int  ssrtc_match(device_t, cfdata_t, void *);
+static void ssrtc_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(ssrtc, sizeof(struct ssrtc_softc),
+  ssrtc_match, ssrtc_attach, NULL, NULL);
+
+static int ssrtc_todr_gettime(struct todr_chip_handle *, struct timeval *);
+static int ssrtc_todr_settime(struct todr_chip_handle *, struct timeval *);
+
+static int
+ssrtc_match(device_t parent, cfdata_t cf, void *aux)
+{
+       return 1;
+}
+
+static void
+ssrtc_attach(device_t parent, device_t self, void *aux)
+{
+       struct ssrtc_softc *sc = device_private(self);
+       struct s3c2xx0_attach_args *sa = aux;
+
+       sc->sc_dev = self;
+       sc->sc_iot = sa->sa_iot;
+
+       if (bus_space_map(sc->sc_iot, S3C2440_RTC_BASE,
+                         S3C2440_RTC_SIZE, 0, &sc->sc_ioh)) {
+               aprint_error(": failed to map registers");
+               return;
+       }
+       aprint_normal(": RTC \n");
+
+       sc->sc_todr.cookie = sc;
+       sc->sc_todr.todr_gettime = ssrtc_todr_gettime;
+       sc->sc_todr.todr_settime = ssrtc_todr_settime;
+       sc->sc_todr.todr_setwen = NULL;
+
+       todr_attach(&sc->sc_todr);
+}
+
+static int
+ssrtc_todr_gettime(struct todr_chip_handle *h, struct timeval *tv)
+{
+       struct ssrtc_softc *sc = h->cookie;
+       struct clock_ymdhms dt;
+       uint8_t reg;
+
+       reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDSEC);
+       DPRINTF(("BCDSEC: %02X\n", reg));
+       dt.dt_sec = FROMBCD(reg);
+
+       reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMIN);
+       DPRINTF(("BCDMIN: %02X\n", reg));
+       dt.dt_min = FROMBCD(reg);
+
+       reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDHOUR);
+       DPRINTF(("BCDHOUR: %02X\n", reg));
+       dt.dt_hour = FROMBCD(reg);
+
+       reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDATE);
+       DPRINTF(("BCDDATE: %02X\n", reg));
+       dt.dt_day = FROMBCD(reg);
+
+       reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDAY);
+       DPRINTF(("BCDDAY: %02X\n", reg));
+       dt.dt_wday = FROMBCD(reg);
+
+       reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMON);
+       DPRINTF(("BCDMON: %02X\n", reg));
+       dt.dt_mon = FROMBCD(reg);
+
+       reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDYEAR);
+       DPRINTF(("BCDYEAR: %02X\n", reg));
+       dt.dt_year = SSRTC_YEAR_ZERO + FROMBCD(reg);
+
+       DPRINTF(("Seconds: %d\n", dt.dt_sec));
+       DPRINTF(("Minutes: %d\n", dt.dt_min));
+       DPRINTF(("Hour: %d\n", dt.dt_hour));
+       DPRINTF(("Mon: %d\n", dt.dt_mon));
+       DPRINTF(("Date: %d\n", dt.dt_day));
+       DPRINTF(("Day: %d\n", dt.dt_wday));
+       DPRINTF(("Year: %d\n", dt.dt_year));
+
+       tv->tv_sec = clock_ymdhms_to_secs(&dt);
+       tv->tv_usec = 0;
+
+       return 0;
+}
+
+static int
+ssrtc_todr_settime(struct todr_chip_handle *h, struct timeval *tv)
+{
+       struct ssrtc_softc *sc = h->cookie;
+       struct clock_ymdhms dt;
+       uint8_t reg;
+
+       clock_secs_to_ymdhms(tv->tv_sec, &dt);
+
+       DPRINTF(("ssrtc_todr_settime"));
+
+       /* Set RTCEN */
+       reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON);
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON, reg | RTCCON_RTCEN);
+
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDSEC, TOBCD(dt.dt_sec));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMIN, TOBCD(dt.dt_min));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDHOUR, TOBCD(dt.dt_hour));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDATE, TOBCD(dt.dt_day));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDAY, TOBCD(dt.dt_wday));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMON, TOBCD(dt.dt_mon));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDYEAR, TOBCD(dt.dt_year-SSRTC_YEAR_ZERO));
+
+       /* Clear RTCEN */
+       reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON);
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON, reg & ~RTCCON_RTCEN);
+       return 0;
+}
diff -r b29b720a6a8d -r 6a87a367c79b sys/arch/arm/s3c2xx0/s3c2440reg.h
--- a/sys/arch/arm/s3c2xx0/s3c2440reg.h Mon Feb 06 23:30:14 2012 +0000
+++ b/sys/arch/arm/s3c2xx0/s3c2440reg.h Tue Feb 07 09:06:04 2012 +0000
@@ -102,6 +102,8 @@
 #define        S3C2440_IIS_BASE        0x55000000
 #define        S3C2440_GPIO_BASE       0x56000000



Home | Main Index | Thread Index | Old Index