From d1e6cc9002b832fd97843e9068c35c8388380965 Mon Sep 17 00:00:00 2001 From: itohy Date: Sat, 15 Oct 2005 11:34:17 +0000 Subject: [PATCH] Add code to parse device name specified in the boot prompt. Update boot version to 1.3. --- sys/arch/hp700/stand/boot/boot.c | 20 ++++++++++---------- sys/arch/hp700/stand/boot/version | 4 +++- sys/arch/hp700/stand/common/dev_hppa.c | 19 ++++++++++++++++++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/sys/arch/hp700/stand/boot/boot.c b/sys/arch/hp700/stand/boot/boot.c index 6cccc3ca453e..7b6b8fa23b7c 100644 --- a/sys/arch/hp700/stand/boot/boot.c +++ b/sys/arch/hp700/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.5 2003/10/21 12:18:02 itohy Exp $ */ +/* $NetBSD: boot.c,v 1.6 2005/10/15 11:34:17 itohy Exp $ */ /*- * Copyright (c) 1982, 1986, 1990, 1993 @@ -102,8 +102,6 @@ char *names[] = { }; #define NUMNAMES (sizeof(names) / sizeof(char *)) -static int bdev, badapt, bctlr, bunit, bpart; - void boot(dev_t boot_dev); int main(void); void getbootdev(int *); @@ -139,12 +137,6 @@ main(void) printf(">> (%s, %s)\n", bootprog_maker, bootprog_date); printf(">> Enter \"reset\" to reset system.\n"); - bdev = B_TYPE(bootdev); - badapt = B_ADAPTOR(bootdev); - bctlr = B_CONTROLLER(bootdev); - bunit = B_UNIT(bootdev); - bpart = B_PARTITION(bootdev); - for (;;) { name = names[currname++]; if (currname == NUMNAMES) @@ -172,9 +164,17 @@ void getbootdev(int *boot_howto) { char c, *ptr = line; + int bdev, badapt, bctlr, bunit, bpart; + + bdev = B_TYPE(bootdev); + badapt = B_ADAPTOR(bootdev); + bctlr = B_CONTROLLER(bootdev); + bunit = B_UNIT(bootdev); + bpart = B_PARTITION(bootdev); printf("Boot: [[[%s%d%c:]%s][-a][-c][-d][-s][-v][-q]] :- ", - devsw[bdev].dv_name, bctlr + (8 * badapt), 'a' + bpart, name); + devsw[bdev].dv_name, badapt << 8 | bctlr << 4 | bunit, + 'a' + bpart, name); if (tgets(line)) { if (strcmp(line, "reset") == 0) { diff --git a/sys/arch/hp700/stand/boot/version b/sys/arch/hp700/stand/boot/version index 2c0f0d99227f..b4e2eba9ca2c 100644 --- a/sys/arch/hp700/stand/boot/version +++ b/sys/arch/hp700/stand/boot/version @@ -1,4 +1,6 @@ -$NetBSD: version,v 1.2 2003/10/21 12:40:15 itohy Exp $ +$NetBSD: version,v 1.3 2005/10/15 11:34:17 itohy Exp $ 1.1: Initial version 1.2: Support disklabel. +1.3: Add support for specifying boot device on the prompt. + Allow boot from partitions in the middle of disks. diff --git a/sys/arch/hp700/stand/common/dev_hppa.c b/sys/arch/hp700/stand/common/dev_hppa.c index b9e05057d30d..6764f00918ae 100644 --- a/sys/arch/hp700/stand/common/dev_hppa.c +++ b/sys/arch/hp700/stand/common/dev_hppa.c @@ -1,4 +1,4 @@ -/* $NetBSD: dev_hppa.c,v 1.4 2003/10/21 13:10:42 itohy Exp $ */ +/* $NetBSD: dev_hppa.c,v 1.5 2005/10/15 11:34:17 itohy Exp $ */ /* $OpenBSD: dev_hppa.c,v 1.5 1999/04/20 20:01:01 mickey Exp $ */ @@ -71,6 +71,9 @@ devopen(struct open_file *f, const char *fname, char **file) { struct hppa_dev *hpd; const struct pdc_devs *dp = pdc_devs; + int bdev, badapt, bctlr, bunit, bpart; + unsigned long n; + char *p; int rc = 1; if (!(*file = strchr(fname, ':'))) @@ -89,6 +92,20 @@ devopen(struct open_file *f, const char *fname, char **file) if (dp >= &pdc_devs[NENTS(pdc_devs)] || dp->dev_type < 0) return ENODEV; + bdev = dp->dev_type; + n = strtoul(fname + sizeof(dp->name)-1, &p, 10); + if (n == ULONG_MAX) + return ENODEV; + bunit = n & 0xf; + bctlr = (n >> 4) & 0xf; + badapt = (n >> 8) & 0xf; + if (*p >= 'a' && *p < 'a' + MAXPARTITIONS) { + bpart = *p - 'a'; + } else { + bpart = 0; + } + bootdev = MAKEBOOTDEV(bdev, badapt, bctlr, bunit, bpart); + #ifdef DEBUGBUG if (debug) printf("%s\n", dp->name);