summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPer Fogelstrom <pefo@cvs.openbsd.org>2004-08-26 13:30:26 +0000
committerPer Fogelstrom <pefo@cvs.openbsd.org>2004-08-26 13:30:26 +0000
commitd7d363616fb62c8be4ef5e021cb86de4e38403f3 (patch)
treeab12a70430448ce56d5285174b1dce444ccb50ca /sys
parent37d781de0c90c8782cf14fe6877cdd9a4c6b074e (diff)
diskboot changes
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sgi/sgi/autoconf.c115
-rw-r--r--sys/arch/sgi/sgi/machdep.c85
2 files changed, 97 insertions, 103 deletions
diff --git a/sys/arch/sgi/sgi/autoconf.c b/sys/arch/sgi/sgi/autoconf.c
index c671ce16063..0ed9c6a1b0c 100644
--- a/sys/arch/sgi/sgi/autoconf.c
+++ b/sys/arch/sgi/sgi/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.4 2004/08/10 19:16:18 deraadt Exp $ */
+/* $OpenBSD: autoconf.c,v 1.5 2004/08/26 13:30:25 pefo Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
* Copyright (c) 1995 Theo de Raadt
@@ -66,10 +66,20 @@ void swapconf(void);
extern void dumpconf(void);
static int findblkmajor(struct device *);
static struct device * getdisk(char *, int, int, dev_t *);
-struct device * getdevunit(char *, int);
-static struct devmap * findtype(char **);
-void makebootdev(char *cp);
-int getpno(char **);
+struct device *getdevunit(char *, int);
+struct devmap *boot_findtype(char *);
+void makebootdev(const char *cp);
+const char *boot_get_path_component(const char *, char *, int *);
+
+/* Struct translating from ARCS to bsd. */
+struct devmap {
+ char *att;
+ char *dev;
+ int what;
+};
+#define DEVMAP_TYPE 0x01
+#define DEVMAP_UNIT 0x02
+#define DEVMAP_PART 0x04
/*
* The following several variables are related to
@@ -440,73 +450,90 @@ getdevunit(name, unit)
return dev;
}
-struct devmap {
- char *att;
- char *dev;
-};
-
-static struct devmap *
-findtype(s)
- char **s;
+struct devmap *
+boot_findtype(char *s)
{
static struct devmap devmap[] = {
- { "/dev/sd", "sd" },
- { "/dev/wd", "wd" },
- { "sd", "sd" },
- { "wd", "wd" },
+ { "scsi", "sd", DEVMAP_TYPE },
+ { "disk", "", DEVMAP_UNIT },
+ { "part", "", DEVMAP_PART },
+ { "partition", "", DEVMAP_PART },
{ NULL, NULL }
};
struct devmap *dp = &devmap[0];
while (dp->att) {
- if (strncmp (*s, dp->att, strlen(dp->att)) == 0) {
- *s += strlen(dp->att);
+ if (strcmp (s, dp->att) == 0) {
break;
}
dp++;
}
- return(dp);
+ if (dp->att)
+ return dp ;
+ else
+ return NULL;
}
/*
* Look at the string 'bp' and decode the boot device.
- * Boot names look like: '/dev/sd0/bsd'
- * '/dev/wd0/bsd
+ * Boot names look like: 'scsi()disk(n)rdisk()partition(0)/bsd'
*/
void
-makebootdev(bp)
- char *bp;
+makebootdev(const char *bp)
{
- int unit;
- char *dev, *cp;
+ char namebuf[256];
+ const char *cp, *ncp, *ecp, *devname;
+ int i, unit, partition;
struct devmap *dp;
- cp = bp;
- while(*cp && *cp != '/') {
- cp++;
+ ecp = cp = bp;
+ unit = partition = 0;
+ devname = NULL;
+
+ while ((ncp = boot_get_path_component(cp, namebuf, &i)) != NULL) {
+ if ((dp = boot_findtype(namebuf)) != NULL) {
+ switch(dp->what) {
+ case DEVMAP_TYPE:
+ devname = dp->dev;
+ break;
+ case DEVMAP_UNIT:
+ unit = i - 1;
+ break;
+ case DEVMAP_PART:
+ partition = i;
+ break;
+ }
+ }
+ cp = ncp;
}
- dp = findtype(&cp);
- if (!dp->att) {
+
+ if (devname == NULL) {
printf("Warning: boot device unrecognized: %s\n", bp);
return;
}
- dev = dp->dev;
- unit = getpno(&cp);
- snprintf(bootdev, sizeof(bootdev), "%s%d%c", dev, unit, 'a');
+ snprintf(bootdev, sizeof(bootdev), "%s%d%c", devname, unit, 'a');
}
-int
-getpno(cp)
- char **cp;
+const char *
+boot_get_path_component(const char *p, char *comp, int *no)
{
- int val = 0;
- char *cx = *cp;
+ while (*p && *p != '(') {
+ *comp++ = *p++;
+ }
+ *comp = '\0';
+
+ if (*p == NULL)
+ return NULL;
- while(*cx && *cx >= '0' && *cx <= '9') {
- val = val * 10 + *cx - '0';
- cx++;
+ *no = 0;
+ p++;
+ while (*p && *p != ')') {
+ if (*p >= '0' && *p <= '9')
+ *no = *no * 10 + *p++ - '0';
+ else
+ return NULL;
}
- *cp = cx;
- return val;
+ return ++p;
}
+
diff --git a/sys/arch/sgi/sgi/machdep.c b/sys/arch/sgi/sgi/machdep.c
index 81b811fff49..06da2691bb6 100644
--- a/sys/arch/sgi/sgi/machdep.c
+++ b/sys/arch/sgi/sgi/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.7 2004/08/23 14:28:39 pefo Exp $ */
+/* $OpenBSD: machdep.c,v 1.8 2004/08/26 13:30:25 pefo Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -84,7 +84,7 @@
extern struct consdev *cn_tab;
extern char kernel_text[];
-extern void makebootdev(char *);
+extern void makebootdev(const char *);
extern void stacktrace(void);
/* the following is used externally (sysctl_hw) */
@@ -144,7 +144,7 @@ void dumpsys(void);
void dumpconf(void);
caddr_t allocsys(caddr_t);
-static void dobootopts(char *cp);
+static void dobootopts(int, int32_t *);
static int atoi(const char *, int, const char **);
#if BYTE_ORDER == BIG_ENDIAN
@@ -163,7 +163,6 @@ caddr_t
mips_init(int argc, int32_t *argv)
{
char *cp;
- char *arg0;
int i;
unsigned firstaddr;
caddr_t sd;
@@ -173,7 +172,6 @@ mips_init(int argc, int32_t *argv)
extern char tlb_miss_tramp[], e_tlb_miss_tramp[];
extern char xtlb_miss_tramp[], e_xtlb_miss_tramp[];
extern char exception[], e_exception[];
- char xxx[100];
/*
* Clean up any mess.
@@ -282,14 +280,10 @@ mips_init(int argc, int32_t *argv)
/*
* Figure out where we was booted from.
*/
- if (argc > 1)
- arg0 = (char *)(long)argv[1];
- else
- arg0 = Bios_GetEnvironmentVariable("bootdev");
-
- if (arg0 == 0)
- arg0 = "unknown";
- makebootdev(arg0);
+ cp = Bios_GetEnvironmentVariable("OSLoadPartition");
+ if (cp == NULL)
+ cp = "unknown";
+ makebootdev(cp);
/*
* Look at arguments passed to us and compute boothowto.
@@ -302,14 +296,7 @@ mips_init(int argc, int32_t *argv)
boothowto = RB_SINGLE | RB_ASKNAME;
#endif /* RAMDISK_HOOKS */
- dobootopts(Bios_GetEnvironmentVariable("osloadoptions"));
-
- /* Check any extra arguments which override. */
- for(i = 2; i < argc; i++) {
- if (*((char *)(long)argv[i]) == '-') {
- dobootopts((char *)(long)argv[i] + 1);
- }
- }
+ dobootopts(argc, argv);
/* Check l3cache size and disable (hard) if non present. */
if (Bios_GetEnvironmentVariable("l3cache") != 0) {
@@ -513,45 +500,27 @@ allocsys(caddr_t v)
* Decode boot options.
*/
static void
-dobootopts(cp)
- char *cp;
+dobootopts(int argc, int32_t *argv)
{
- while(cp && *cp) {
- switch (*cp++) {
- case 'm': /* multiuser */
- boothowto &= ~RB_SINGLE;
- break;
-
- case 's': /* singleuser */
- boothowto |= RB_SINGLE;
- break;
-
- case 'd': /* use compiled in default root */
- boothowto |= RB_DFLTROOT;
- break;
-
- case 'a': /* ask for names */
- boothowto |= RB_ASKNAME;
- break;
-
- case 'A': /* don't ask for names */
- boothowto &= ~RB_ASKNAME;
- break;
-
- case 't': /* use serial console */
- boothowto |= RB_SERCONS;
- break;
-
- case 'c': /* boot configure */
- boothowto |= RB_CONFIG;
- break;
+ char *cp;
+ int i;
- case 'B': /* Enter debugger */
- boothowto |= RB_KDB;
- break;
+ /* XXX Should this be done differently, eg env vs. args? */
+ for (i = 1; i < argc; i++) {
+ cp = (char *)argv[i];
+ if (cp != NULL && strncmp(cp, "OSLoadOptions=", 14) == 0) {
+ if (strcmp(&cp[14], "auto") == 0)
+ boothowto &= ~(RB_SINGLE|RB_ASKNAME);
+ else if (strcmp(&cp[14], "single") == 0)
+ boothowto |= RB_SINGLE;
+ else if (strcmp(&cp[14], "debug") == 0)
+ boothowto |= RB_KDB;
}
-
}
+
+ cp = Bios_GetEnvironmentVariable("ConsoleOut");
+ if (cp != NULL && strncmp(cp, "serial", 6) == 0)
+ boothowto |= RB_SERCONS;
}
@@ -764,8 +733,7 @@ setregs(p, pack, stack, retval)
int waittime = -1;
void
-boot(howto)
- register int howto;
+boot(int howto)
{
/* take a snap shot before clobbering any registers */
@@ -1018,7 +986,6 @@ printf("perfcnt select %x, proc %p\n", arg1, p);
cntval = p->p_md.md_pc_count;
cntval += (quad_t)p->p_md.md_pc_spill << 31;
result = copyout(&cntval, (void *)arg1, sizeof(cntval));
-printf("perfcnt read %d:%d -> %p\n", p->p_md.md_pc_count, p->p_md.md_pc_spill, arg1);
break;
default: