Cosmetic changes to reduce diffs from arc.
This commit is contained in:
parent
ab74ed35be
commit
fa657c9ce8
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: devopen.c,v 1.4 2003/09/28 08:21:08 tsutsui Exp $ */
|
/* $NetBSD: devopen.c,v 1.5 2005/04/21 13:59:14 tsutsui Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
|
@ -42,13 +42,12 @@
|
||||||
* file name if any.
|
* file name if any.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
devopen(f, fname, file)
|
devopen(struct open_file *f, const char *fname, char **file)
|
||||||
struct open_file *f;
|
|
||||||
const char *fname;
|
|
||||||
char **file; /* out */
|
|
||||||
{
|
{
|
||||||
/* int ctlr = 0, unit = 0, part = 0; */
|
#if 0
|
||||||
int rc;
|
int ctlr = 0, unit = 0, part = 0;
|
||||||
|
#endif
|
||||||
|
int error;
|
||||||
char namebuf[128];
|
char namebuf[128];
|
||||||
char devtype[16];
|
char devtype[16];
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
@ -99,11 +98,11 @@ devopen(f, fname, file)
|
||||||
|
|
||||||
printf("devopen: %s type %s file %s\n", namebuf, devtype, cp);
|
printf("devopen: %s type %s file %s\n", namebuf, devtype, cp);
|
||||||
#ifdef LIBSA_SINGLE_DEVICE
|
#ifdef LIBSA_SINGLE_DEVICE
|
||||||
rc = DEV_OPEN(dp)(f, fname);
|
error = DEV_OPEN(dp)(f, fname);
|
||||||
#else /* !LIBSA_SINGLE_DEVICE */
|
#else /* !LIBSA_SINGLE_DEVICE */
|
||||||
for (dp = devsw, i = 0; i < ndevs; dp++, i++)
|
for (dp = devsw, i = 0; i < ndevs; dp++, i++)
|
||||||
if (dp->dv_name && strcmp(devtype, dp->dv_name) == 0)
|
if (dp->dv_name && strcmp(devtype, dp->dv_name) == 0)
|
||||||
goto fnd;
|
goto found;
|
||||||
printf("Unknown device '%s'\nKnown devices are:", devtype);
|
printf("Unknown device '%s'\nKnown devices are:", devtype);
|
||||||
for (dp = devsw, i = 0; i < ndevs; dp++, i++)
|
for (dp = devsw, i = 0; i < ndevs; dp++, i++)
|
||||||
if (dp->dv_name)
|
if (dp->dv_name)
|
||||||
|
@ -111,11 +110,11 @@ devopen(f, fname, file)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return ENXIO;
|
return ENXIO;
|
||||||
|
|
||||||
fnd:
|
found:
|
||||||
rc = (dp->dv_open)(f, namebuf);
|
error = (dp->dv_open)(f, namebuf);
|
||||||
#endif /* !LIBSA_SINGLE_DEVICE */
|
#endif /* !LIBSA_SINGLE_DEVICE */
|
||||||
if (rc)
|
if (error)
|
||||||
return rc;
|
return error;
|
||||||
|
|
||||||
#ifndef LIBSA_SINGLE_DEVICE
|
#ifndef LIBSA_SINGLE_DEVICE
|
||||||
f->f_dev = dp;
|
f->f_dev = dp;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: disk.c,v 1.6 2005/04/18 15:38:00 tsutsui Exp $ */
|
/* $NetBSD: disk.c,v 1.7 2005/04/21 13:59:15 tsutsui Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
|
@ -50,24 +50,19 @@
|
||||||
extern const struct arcbios_fv *ARCBIOS;
|
extern const struct arcbios_fv *ARCBIOS;
|
||||||
|
|
||||||
struct disk_softc {
|
struct disk_softc {
|
||||||
u_long sc_fd; /* PROM file id */
|
u_long sc_fd; /* ARCBIOS file id */
|
||||||
int sc_part; /* disk partition number */
|
int sc_part; /* disk partition number */
|
||||||
struct disklabel sc_label; /* disk label for this disk */
|
struct disklabel sc_label; /* disk label for this disk */
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
diskstrategy(devdata, rw, bn, reqcnt, addr, cnt)
|
diskstrategy(void *devdata, int rw, daddr_t bn, size_t reqcnt, void *addr,
|
||||||
void *devdata;
|
size_t *cnt)
|
||||||
int rw;
|
|
||||||
daddr_t bn;
|
|
||||||
size_t reqcnt;
|
|
||||||
void *addr;
|
|
||||||
size_t *cnt; /* out: number of bytes transfered */
|
|
||||||
{
|
{
|
||||||
struct disk_softc *sc = (struct disk_softc *)devdata;
|
struct disk_softc *sc = (struct disk_softc *)devdata;
|
||||||
int part = sc->sc_part;
|
int part = sc->sc_part;
|
||||||
struct partition *pp = &sc->sc_label.d_partitions[part];
|
struct partition *pp = &sc->sc_label.d_partitions[part];
|
||||||
int s;
|
long error;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
u_long count;
|
u_long count;
|
||||||
|
|
||||||
|
@ -78,7 +73,7 @@ diskstrategy(devdata, rw, bn, reqcnt, addr, cnt)
|
||||||
*/
|
*/
|
||||||
if (reqcnt & (DEV_BSIZE - 1)) {
|
if (reqcnt & (DEV_BSIZE - 1)) {
|
||||||
*cnt = 0;
|
*cnt = 0;
|
||||||
return (EINVAL);
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += pp->p_offset;
|
offset += pp->p_offset;
|
||||||
|
@ -91,14 +86,15 @@ diskstrategy(devdata, rw, bn, reqcnt, addr, cnt)
|
||||||
*/
|
*/
|
||||||
offset *= DEV_BSIZE;
|
offset *= DEV_BSIZE;
|
||||||
|
|
||||||
s = ARCBIOS->Seek(sc->sc_fd, &offset, 0);
|
error = (*ARCBIOS->Seek)(sc->sc_fd, &offset, 0);
|
||||||
s = ARCBIOS->Read(sc->sc_fd, addr, reqcnt, &count);
|
if (error != ARCBIOS_ESUCCESS)
|
||||||
|
return EIO;
|
||||||
if (s < 0)
|
error = (*ARCBIOS->Read)(sc->sc_fd, addr, reqcnt, &count);
|
||||||
return (EIO);
|
if (error != ARCBIOS_ESUCCESS)
|
||||||
|
return EIO;
|
||||||
|
|
||||||
*cnt = count;
|
*cnt = count;
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -110,7 +106,10 @@ diskopen(struct open_file *f, ...)
|
||||||
struct disklabel *lp;
|
struct disklabel *lp;
|
||||||
#ifdef arc
|
#ifdef arc
|
||||||
char *msg, buf[DEV_BSIZE];
|
char *msg, buf[DEV_BSIZE];
|
||||||
|
size_t cnt;
|
||||||
|
int mbrp_off, i;
|
||||||
#endif
|
#endif
|
||||||
|
int error;
|
||||||
u_long fd;
|
u_long fd;
|
||||||
char *device;
|
char *device;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -131,12 +130,13 @@ diskopen(struct open_file *f, ...)
|
||||||
*/
|
*/
|
||||||
part = 0;
|
part = 0;
|
||||||
|
|
||||||
if (part >= 16)
|
if (part >= MAXPARTITIONS)
|
||||||
return (ENXIO);
|
return ENXIO;
|
||||||
|
|
||||||
if (ARCBIOS->Open(device, 0, &fd)) {
|
error = (*ARCBIOS->Open)(device, 0, &fd);
|
||||||
printf("open failed\n");
|
if (error) {
|
||||||
return (ENXIO);
|
printf("diskopen: open failed, errno = %d\n", error);
|
||||||
|
return ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc = alloc(sizeof(struct disk_softc));
|
sc = alloc(sizeof(struct disk_softc));
|
||||||
|
@ -155,35 +155,51 @@ diskopen(struct open_file *f, ...)
|
||||||
lp->d_partitions[part].p_size = 0x7fffffff;
|
lp->d_partitions[part].p_size = 0x7fffffff;
|
||||||
|
|
||||||
#ifdef arc
|
#ifdef arc
|
||||||
i = diskstrategy(sc, F_READ, (daddr_t)LABELSECTOR, DEV_BSIZE,
|
error = diskstrategy(sc, F_READ, (daddr_t)LABELSECTOR, DEV_BSIZE,
|
||||||
buf, &cnt);
|
buf, &cnt);
|
||||||
if (i || cnt != DEV_BSIZE) {
|
if (error || cnt != DEV_BSIZE) {
|
||||||
printf("%s: error reading disk label\n", device);
|
printf("%s: can't read disklabel, errno = %d\n",
|
||||||
|
device, error);
|
||||||
free(sc, sizeof(struct disk_softc));
|
free(sc, sizeof(struct disk_softc));
|
||||||
return (ENXIO);
|
return ENXIO;
|
||||||
}
|
}
|
||||||
msg = getdisklabel(buf, lp);
|
msg = getdisklabel(buf, lp);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
/* If no label, just assume 0 and return */
|
/* If no label, just assume 0 and return */
|
||||||
return (0);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On arc, we can't open whole disk, but can open each partition with
|
||||||
|
* OSLOADPARTITION like scsi(0)disk(0)rdisk()partition(1) etc.
|
||||||
|
* Thus, we don't have to add offset of the MBR partition.
|
||||||
|
*/
|
||||||
|
/* XXX magic: partition 2 is whole NetBSD partition */
|
||||||
|
mbrp_off = lp->d_partitions[2].p_offset;
|
||||||
|
for (i = 0; i < MAXPARTITIONS; i++) {
|
||||||
|
if (lp->d_partitions[i].p_fstype != FS_UNUSED &&
|
||||||
|
lp->d_partitions[i].p_offset >= mbrp_off)
|
||||||
|
lp->d_partitions[i].p_offset -= mbrp_off;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (part >= lp->d_npartitions ||
|
||||||
|
lp->d_partitions[part].p_fstype == FS_UNUSED ||
|
||||||
|
lp->d_partitions[part].p_size == 0) {
|
||||||
|
free(sc, sizeof(struct disk_softc));
|
||||||
|
return ENXIO;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return 0;
|
||||||
if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0) {
|
|
||||||
free(sc, sizeof(struct disk_softc));
|
|
||||||
return (ENXIO);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef LIBSA_NO_DEV_CLOSE
|
#ifndef LIBSA_NO_DEV_CLOSE
|
||||||
int
|
int
|
||||||
diskclose(f)
|
diskclose(struct open_file *f)
|
||||||
struct open_file *f;
|
|
||||||
{
|
{
|
||||||
ARCBIOS->Close(((struct disk_softc *)(f->f_devdata))->sc_fd);
|
|
||||||
|
(*ARCBIOS->Close)(((struct disk_softc *)(f->f_devdata))->sc_fd);
|
||||||
free(f->f_devdata, sizeof(struct disk_softc));
|
free(f->f_devdata, sizeof(struct disk_softc));
|
||||||
f->f_devdata = (void *)0;
|
f->f_devdata = NULL;
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: disk.h,v 1.2 2004/02/08 13:15:42 sekiya Exp $ */
|
/* $NetBSD: disk.h,v 1.3 2005/04/21 13:59:15 tsutsui Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
|
* Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: getchar.c,v 1.4 2005/04/18 15:38:00 tsutsui Exp $ */
|
/* $NetBSD: getchar.c,v 1.5 2005/04/21 13:59:15 tsutsui Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||||
|
@ -42,11 +42,13 @@
|
||||||
extern const struct arcbios_fv *ARCBIOS;
|
extern const struct arcbios_fv *ARCBIOS;
|
||||||
|
|
||||||
int
|
int
|
||||||
getchar()
|
getchar(void)
|
||||||
{
|
{
|
||||||
char ch;
|
char ch;
|
||||||
u_long count;
|
u_long count;
|
||||||
|
|
||||||
(*ARCBIOS->Read)(0, &ch, 1, &count);
|
if ((*ARCBIOS->Read)(0, &ch, 1, &count) != ARCBIOS_ESUCCESS)
|
||||||
return(ch);
|
return -1;
|
||||||
|
|
||||||
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: getopt.c,v 1.1 2003/11/11 06:28:15 sekiya Exp $ */
|
/* $NetBSD: getopt.c,v 1.2 2005/04/21 13:59:15 tsutsui Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1987, 1993, 1994
|
* Copyright (c) 1987, 1993, 1994
|
||||||
|
@ -49,10 +49,7 @@ char *optarg; /* argument associated with option */
|
||||||
* Parse argc/argv argument vector.
|
* Parse argc/argv argument vector.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
getopt(nargc, nargv, ostr)
|
getopt(int nargc, char * const *nargv, const char *ostr)
|
||||||
int nargc;
|
|
||||||
char * const *nargv;
|
|
||||||
const char *ostr;
|
|
||||||
{
|
{
|
||||||
static char *place = EMSG; /* option letter processing */
|
static char *place = EMSG; /* option letter processing */
|
||||||
char *oli; /* option letter list index */
|
char *oli; /* option letter list index */
|
||||||
|
@ -61,12 +58,12 @@ getopt(nargc, nargv, ostr)
|
||||||
optreset = 0;
|
optreset = 0;
|
||||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return (-1);
|
return -1;
|
||||||
}
|
}
|
||||||
if (place[1] && *++place == '-') { /* found "--" */
|
if (place[1] && *++place == '-') { /* found "--" */
|
||||||
++optind;
|
++optind;
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return (-1);
|
return -1;
|
||||||
}
|
}
|
||||||
} /* option letter okay? */
|
} /* option letter okay? */
|
||||||
if ((optopt = (int)*place++) == (int)':' ||
|
if ((optopt = (int)*place++) == (int)':' ||
|
||||||
|
@ -76,12 +73,12 @@ getopt(nargc, nargv, ostr)
|
||||||
* assume it means -1.
|
* assume it means -1.
|
||||||
*/
|
*/
|
||||||
if (optopt == (int)'-')
|
if (optopt == (int)'-')
|
||||||
return (-1);
|
return -1;
|
||||||
if (!*place)
|
if (!*place)
|
||||||
++optind;
|
++optind;
|
||||||
if (opterr && *ostr != ':')
|
if (opterr && *ostr != ':')
|
||||||
printf("illegal option -- %c\n", optopt);
|
printf("illegal option -- %c\n", optopt);
|
||||||
return (BADCH);
|
return BADCH;
|
||||||
}
|
}
|
||||||
if (*++oli != ':') { /* don't need argument */
|
if (*++oli != ':') { /* don't need argument */
|
||||||
optarg = NULL;
|
optarg = NULL;
|
||||||
|
@ -94,16 +91,16 @@ getopt(nargc, nargv, ostr)
|
||||||
else if (nargc <= ++optind) { /* no arg */
|
else if (nargc <= ++optind) { /* no arg */
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
if (*ostr == ':')
|
if (*ostr == ':')
|
||||||
return (BADARG);
|
return BADARG;
|
||||||
if (opterr)
|
if (opterr)
|
||||||
printf("option requires an argument -- %c\n",
|
printf("option requires an argument -- %c\n",
|
||||||
optopt);
|
optopt);
|
||||||
return (BADCH);
|
return BADCH;
|
||||||
}
|
}
|
||||||
else /* white space */
|
else /* white space */
|
||||||
optarg = nargv[optind];
|
optarg = nargv[optind];
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
++optind;
|
++optind;
|
||||||
}
|
}
|
||||||
return (optopt); /* dump back option letter */
|
return optopt; /* dump back option letter */
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: putchar.c,v 1.4 2005/04/18 15:38:00 tsutsui Exp $ */
|
/* $NetBSD: putchar.c,v 1.5 2005/04/21 13:59:15 tsutsui Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||||
|
@ -42,12 +42,16 @@
|
||||||
extern const struct arcbios_fv *ARCBIOS;
|
extern const struct arcbios_fv *ARCBIOS;
|
||||||
|
|
||||||
void
|
void
|
||||||
putchar(c)
|
putchar(int c)
|
||||||
int c;
|
|
||||||
{
|
{
|
||||||
static char ch[2] = "?\r";
|
char ch;
|
||||||
u_long count;
|
u_long count;
|
||||||
|
|
||||||
ch[0] = c;
|
if (c == '\n') {
|
||||||
(*ARCBIOS->Write)(1, &ch, c == '\n' ? 2 : 1, &count);
|
ch = '\r';
|
||||||
|
(*ARCBIOS->Write)(1, &ch, 1, &count);
|
||||||
|
}
|
||||||
|
|
||||||
|
ch = c;
|
||||||
|
(*ARCBIOS->Write)(1, &ch, 1, &count);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue