Change format of path for device. A current form strangely feels dissatisfied.
This new format looks like the format of BootROM of BeBox.
This commit is contained in:
parent
246f73effa
commit
9fe16975a7
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: boot.c,v 1.20 2010/10/14 06:17:57 kiyohara Exp $ */
|
/* $NetBSD: boot.c,v 1.21 2010/10/14 06:39:52 kiyohara Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||||
@ -42,10 +42,9 @@
|
|||||||
#include "boot.h"
|
#include "boot.h"
|
||||||
|
|
||||||
char *names[] = {
|
char *names[] = {
|
||||||
"in()",
|
"/dev/disk/floppy:netbsd", "/dev/disk/floppy:netbsd.gz",
|
||||||
"fd(0,1,0)netbsd", "fd(0,1,0)netbsd.gz",
|
"/dev/disk/floppy:onetbsd", "/dev/disk/floppy:onetbsd.gz"
|
||||||
"fd(0,1,0)netbsd.old", "fd(0,1,0)netbsd.old.gz",
|
"in",
|
||||||
"fd(0,1,0)onetbsd", "fd(0,1,0)onetbsd.gz"
|
|
||||||
};
|
};
|
||||||
#define NUMNAMES (sizeof (names) / sizeof (names[0]))
|
#define NUMNAMES (sizeof (names) / sizeof (names[0]))
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: conf.c,v 1.6 2005/12/11 12:17:04 christos Exp $ */
|
/* $NetBSD: conf.c,v 1.7 2010/10/14 06:39:52 kiyohara Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1982, 1986, 1990, 1993
|
* Copyright (c) 1982, 1986, 1990, 1993
|
||||||
@ -34,17 +34,19 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <lib/libsa/stand.h>
|
#include <lib/libsa/stand.h>
|
||||||
|
|
||||||
int fdstrategy(void *, int, daddr_t, size_t, void *, size_t *);
|
extern int fdstrategy(void *, int, daddr_t, size_t, void *, size_t *);
|
||||||
int fdopen(struct open_file *, ...);
|
extern int fdopen(struct open_file *, ...);
|
||||||
int fdclose(struct open_file *);
|
extern int fdclose(struct open_file *);
|
||||||
|
|
||||||
int instrategy(void *, int, daddr_t, size_t, void *, size_t *);
|
extern int instrategy(void *, int, daddr_t, size_t, void *, size_t *);
|
||||||
int inopen(struct open_file *, ...);
|
extern int inopen(struct open_file *, ...);
|
||||||
int inclose(struct open_file *);
|
extern int inclose(struct open_file *);
|
||||||
|
|
||||||
struct devsw devsw[] = {
|
struct devsw devsw[] = {
|
||||||
{ "fd", fdstrategy, fdopen, fdclose, noioctl },
|
{ "fd", fdstrategy, fdopen, fdclose, noioctl },
|
||||||
{ "in", instrategy, inopen, inclose, noioctl },
|
|
||||||
|
{ NULL, NULL, NULL, NULL, NULL },
|
||||||
};
|
};
|
||||||
|
struct devsw pseudo_devsw = { "in", instrategy, inopen, inclose, noioctl };
|
||||||
|
|
||||||
int ndevs = sizeof(devsw) / sizeof(devsw[0]);
|
int ndevs = sizeof(devsw) / sizeof(devsw[0]);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: devopen.c,v 1.9 2008/05/26 16:28:39 kiyohara Exp $ */
|
/* $NetBSD: devopen.c,v 1.10 2010/10/14 06:39:52 kiyohara Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1993 John Brezak
|
* Copyright (c) 1993 John Brezak
|
||||||
@ -33,125 +33,132 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
|
|
||||||
#define ispart(c) ((c) >= 'a' && (c) <= 'h')
|
|
||||||
|
|
||||||
static int atoi(char *);
|
|
||||||
static int devlookup(char *);
|
|
||||||
static int devparse(const char *, int *, int *, int *, int *, int *, char **);
|
static int devparse(const char *, int *, int *, int *, int *, int *, char **);
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
atoi(char *cp)
|
|
||||||
{
|
|
||||||
int val = 0;
|
|
||||||
|
|
||||||
while (isdigit(*cp))
|
|
||||||
val = val * 10 + (*cp++ - '0');
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
devlookup(char *d)
|
|
||||||
{
|
|
||||||
struct devsw *dp = devsw;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < ndevs; i++, dp++)
|
|
||||||
if (dp->dv_name && strcmp(dp->dv_name, d) == 0)
|
|
||||||
return i;
|
|
||||||
|
|
||||||
printf("No such device - Configured devices are:\n");
|
|
||||||
for (dp = devsw, i = 0; i < ndevs; i++, dp++)
|
|
||||||
if (dp->dv_name)
|
|
||||||
printf(" %s", dp->dv_name);
|
|
||||||
printf("\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse a device spec in one of two forms.
|
* Parse a device spec.
|
||||||
* dev(ctlr, unit, part)file
|
* i.e.
|
||||||
|
* /dev/disk/floppy
|
||||||
|
* /dev/disk/ide/0/master/0
|
||||||
|
* /dev/disk/ide/0/slave/0
|
||||||
|
* /dev/disk/scsi/0/0/0
|
||||||
|
* /dev/disk/scsi/0/3/0
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
devparse(const char *fname, int *dev, int *adapt, int *ctlr, int *unit,
|
devparse(const char *fname, int *dev, int *ctlr, int *unit, int *lunit,
|
||||||
int *part, char **file)
|
int *part, char **file)
|
||||||
{
|
{
|
||||||
int argc, flag;
|
int i;
|
||||||
char *s, *args[3];
|
char devdir[] = "/dev/disk/";
|
||||||
extern char nametmp[];
|
char floppy[] = "floppy";
|
||||||
|
char ide[] = "ide";
|
||||||
|
char scsi[] = "scsi";
|
||||||
|
char *p;
|
||||||
|
|
||||||
/* get device name and make lower case */
|
if (strncmp(fname, devdir, strlen(devdir)) != 0)
|
||||||
strcpy(nametmp, (char *)fname);
|
return EINVAL;
|
||||||
for (s = nametmp; *s && *s != '('; s++)
|
p = __UNCONST(fname) + strlen(devdir);
|
||||||
if (isupper(*s)) *s = tolower(*s);
|
|
||||||
|
|
||||||
if (*s == '(') {
|
if (strncmp(p, floppy, strlen(floppy)) == 0) {
|
||||||
/* lookup device and get index */
|
p += strlen(floppy);
|
||||||
*s = NULL;
|
for (i = 0; devsw[i].dv_name != NULL; i++)
|
||||||
if ((*dev = devlookup(nametmp)) < 0)
|
if (strcmp(devsw[i].dv_name, "fd") == 0) {
|
||||||
goto baddev;
|
*dev = i;
|
||||||
|
*ctlr = 0;
|
||||||
/* tokenize device ident */
|
*unit = 1;
|
||||||
for (++s, flag = 0, argc = 0; *s && *s != ')'; s++) {
|
*lunit = 0;
|
||||||
if (*s != ',') {
|
break;
|
||||||
if (!flag) {
|
|
||||||
flag++;
|
|
||||||
args[argc++] = s;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (flag) {
|
|
||||||
*s = NULL;
|
|
||||||
flag = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else if (strncmp(p, ide, strlen(ide)) == 0) {
|
||||||
if (*s == ')')
|
char master[] = "master";
|
||||||
*s = NULL;
|
char slave[] = "slave";
|
||||||
|
|
||||||
switch (argc) {
|
p += strlen(ide);
|
||||||
case 3:
|
if (*p++ != '/' ||
|
||||||
*part = atoi(args[2]);
|
!isdigit(*p++) ||
|
||||||
/* FALLTHROUGH */
|
*p++ != '/')
|
||||||
case 2:
|
return EINVAL;
|
||||||
*unit = atoi(args[1]);
|
*ctlr = *(p - 2) - '0';
|
||||||
/* FALLTHROUGH */
|
if (strncmp(p, master, strlen(master)) == 0) {
|
||||||
case 1:
|
*unit = 0;
|
||||||
*ctlr = atoi(args[0]);
|
p += strlen(master);
|
||||||
break;
|
} else if (strncmp(p, slave, strlen(slave)) == 0) {
|
||||||
}
|
*unit = 1;
|
||||||
*file = ++s;
|
p += strlen(slave);
|
||||||
} else {
|
} else
|
||||||
/* no device present */
|
return EINVAL;
|
||||||
*file = (char *)fname;
|
if (*p++ != '/' ||
|
||||||
|
!isdigit(*p++) ||
|
||||||
|
*p++ != '_' ||
|
||||||
|
!isdigit(*p++))
|
||||||
|
return EINVAL;
|
||||||
|
*lunit = *(p - 3) - '0';
|
||||||
|
*part = *(p - 1) - '0';
|
||||||
|
for (i = 0; devsw[i].dv_name != NULL; i++)
|
||||||
|
if (strcmp(devsw[i].dv_name, "wd") == 0) {
|
||||||
|
*dev = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (devsw[i].dv_name == NULL)
|
||||||
|
return EINVAL;
|
||||||
|
} else if (strncmp(p, scsi, strlen(scsi)) == 0) {
|
||||||
|
p += strlen(scsi);
|
||||||
|
if (*p++ != '/' ||
|
||||||
|
!isdigit(*p++) ||
|
||||||
|
*p++ != '/' ||
|
||||||
|
!isdigit(*p++) ||
|
||||||
|
*p++ != '/' ||
|
||||||
|
!isdigit(*p++) ||
|
||||||
|
*p++ != '_' ||
|
||||||
|
!isdigit(*p++))
|
||||||
|
return EINVAL;
|
||||||
|
*ctlr = *(p - 7) - '0';
|
||||||
|
*unit = *(p - 5) - '0';
|
||||||
|
*lunit = *(p - 3) - '0';
|
||||||
|
*part = *(p - 1) - '0';
|
||||||
|
for (i = 0; devsw[i].dv_name != NULL; i++)
|
||||||
|
if (strcmp(devsw[i].dv_name, "sd") == 0) {
|
||||||
|
*dev = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (devsw[i].dv_name == NULL)
|
||||||
|
return EINVAL;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
|
||||||
baddev:
|
if (*p++ != ':')
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
*file = p;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
devopen(struct open_file *f, const char *fname, char **file)
|
devopen(struct open_file *f, const char *fname, char **file)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
int dev = 0, ctlr = 0, unit = 0, part = 0;
|
int dev = 0, ctlr = 0, unit = 0, lunit = 0, part = 0;
|
||||||
int adapt = 0;
|
|
||||||
struct devsw *dp = &devsw[0];
|
struct devsw *dp = &devsw[0];
|
||||||
|
extern struct devsw pseudo_devsw;
|
||||||
|
|
||||||
if ((error =
|
**file = '\0';
|
||||||
devparse(fname, &dev, &adapt, &ctlr, &unit, &part, file)) != 0)
|
error = devparse(fname, &dev, &ctlr, &unit, &lunit, &part, file);
|
||||||
return error;
|
if (error == 0) {
|
||||||
|
dp = &devsw[dev];
|
||||||
dp = &devsw[dev];
|
if (!dp->dv_open)
|
||||||
if (!dp->dv_open)
|
return ENODEV;
|
||||||
return ENODEV;
|
} else {
|
||||||
|
if (strcmp(fname, "in") == 0)
|
||||||
|
/* special case: kernel in memory */
|
||||||
|
dp = &pseudo_devsw;
|
||||||
|
else
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
f->f_dev = dp;
|
f->f_dev = dp;
|
||||||
if ((error = (*dp->dv_open)(f, ctlr, unit, part)) == 0)
|
if ((error = (*dp->dv_open)(f, ctlr, unit, lunit, part)) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("%s(%d,%d,%d): %s\n", devsw[dev].dv_name,
|
printf("%s %s\n", fname, strerror(error));
|
||||||
ctlr, unit, part, strerror(error));
|
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: fd.c,v 1.9 2009/03/18 10:22:27 cegger Exp $ */
|
/* $NetBSD: fd.c,v 1.10 2010/10/14 06:39:52 kiyohara Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (C) 1997-1998 Kazuki Sakamoto (sakamoto@NetBSD.org)
|
* Copyright (C) 1997-1998 Kazuki Sakamoto (sakamoto@NetBSD.org)
|
||||||
@ -136,7 +136,6 @@ int fdsectors[] = {128, 256, 512, 1024, 2048, 4096};
|
|||||||
struct fd_unit {
|
struct fd_unit {
|
||||||
int ctlr;
|
int ctlr;
|
||||||
int unit;
|
int unit;
|
||||||
int part;
|
|
||||||
u_int un_flags; /* unit status flag */
|
u_int un_flags; /* unit status flag */
|
||||||
int stat[STATUS_MAX]; /* result code */
|
int stat[STATUS_MAX]; /* result code */
|
||||||
FDDTYPE *un_type; /* floppy type (pointer) */
|
FDDTYPE *un_type; /* floppy type (pointer) */
|
||||||
@ -164,7 +163,7 @@ FD_UNIT fd_unit[CTLR_MAX][UNIT_MAX];
|
|||||||
* function declaration
|
* function declaration
|
||||||
*/
|
*/
|
||||||
int fdinit(FD_UNIT *);
|
int fdinit(FD_UNIT *);
|
||||||
int fdopen(struct open_file *, int, int, int);
|
int fdopen(struct open_file *, int, int);
|
||||||
int fdclose(struct open_file *);
|
int fdclose(struct open_file *);
|
||||||
int fdioctl(struct open_file *, u_long, void *);
|
int fdioctl(struct open_file *, u_long, void *);
|
||||||
int fdstrategy(void *, int, daddr_t, size_t, void *, size_t *);
|
int fdstrategy(void *, int, daddr_t, size_t, void *, size_t *);
|
||||||
@ -221,7 +220,7 @@ fdinit(FD_UNIT *un)
|
|||||||
* fdopen *
|
* fdopen *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int
|
int
|
||||||
fdopen(struct open_file *f, int ctlr, int unit, int part)
|
fdopen(struct open_file *f, int ctlr, int unit)
|
||||||
{
|
{
|
||||||
FD_UNIT *un;
|
FD_UNIT *un;
|
||||||
int *stat;
|
int *stat;
|
||||||
|
Loading…
Reference in New Issue
Block a user