diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2015-03-14 20:52:42 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2015-03-14 20:52:42 +0000 |
commit | e68712cff387cb5ed0383506c6a9b4ac7c73cc8a (patch) | |
tree | 76fcf97e22bcb9e97e79e165eef9072b498a30d1 /sys/arch/macppc/stand | |
parent | bf999123b14839366957e1253058a239d20407a0 (diff) |
Allow for multiple concurrent devopen() calls, and fill the .readdir member
of fs_ops; makes the `ls' command finally work in the boot loader.
Diffstat (limited to 'sys/arch/macppc/stand')
-rw-r--r-- | sys/arch/macppc/stand/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/macppc/stand/hfs.c | 8 | ||||
-rw-r--r-- | sys/arch/macppc/stand/hfs.h | 3 | ||||
-rw-r--r-- | sys/arch/macppc/stand/ofdev.c | 60 | ||||
-rw-r--r-- | sys/arch/macppc/stand/ofwboot/version | 6 |
5 files changed, 43 insertions, 38 deletions
diff --git a/sys/arch/macppc/stand/conf.c b/sys/arch/macppc/stand/conf.c index 323f0cceede..8549e952941 100644 --- a/sys/arch/macppc/stand/conf.c +++ b/sys/arch/macppc/stand/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.5 2013/12/28 02:53:04 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.6 2015/03/14 20:52:41 miod Exp $ */ /* * Copyright (c) 2007 Dale Rahn <drahn@openbsd.org> * @@ -21,7 +21,7 @@ #include <lib/libsa/stand.h> -const char version[] = "1.3"; +const char version[] = "1.4"; int debug = 0; void ofc_probe(struct consdev *); diff --git a/sys/arch/macppc/stand/hfs.c b/sys/arch/macppc/stand/hfs.c index 2462cd08378..6c3df0c2153 100644 --- a/sys/arch/macppc/stand/hfs.c +++ b/sys/arch/macppc/stand/hfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hfs.c,v 1.5 2011/11/19 16:15:11 mpi Exp $ */ +/* $OpenBSD: hfs.c,v 1.6 2015/03/14 20:52:41 miod Exp $ */ /* $NetBSD: hfs.c,v 1.1 2000/11/14 11:25:35 tsubai Exp $ */ /*- @@ -104,3 +104,9 @@ hfs_stat(struct open_file *f, struct stat *sb) { return 0; } + +int +hfs_readdir(struct open_file *f, char *name) +{ + return ENXIO; +} diff --git a/sys/arch/macppc/stand/hfs.h b/sys/arch/macppc/stand/hfs.h index 4f8e3fcc707..5195b5258ee 100644 --- a/sys/arch/macppc/stand/hfs.h +++ b/sys/arch/macppc/stand/hfs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hfs.h,v 1.1 2001/09/01 15:39:02 drahn Exp $ */ +/* $OpenBSD: hfs.h,v 1.2 2015/03/14 20:52:41 miod Exp $ */ /* $NetBSD: hfs.h,v 1.1 2000/11/14 11:25:35 tsubai Exp $ */ int hfs_open(char *, struct open_file *); @@ -7,3 +7,4 @@ int hfs_read(struct open_file *, void *, size_t, size_t *); int hfs_write(struct open_file *, void *, size_t, size_t *); off_t hfs_seek(struct open_file *, off_t, int); int hfs_stat(struct open_file *, struct stat *); +int hfs_readdir(struct open_file *, char *); diff --git a/sys/arch/macppc/stand/ofdev.c b/sys/arch/macppc/stand/ofdev.c index 0d9dbed3acc..1c0487568a8 100644 --- a/sys/arch/macppc/stand/ofdev.c +++ b/sys/arch/macppc/stand/ofdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofdev.c,v 1.20 2013/03/21 21:57:15 deraadt Exp $ */ +/* $OpenBSD: ofdev.c,v 1.21 2015/03/14 20:52:41 miod Exp $ */ /* $NetBSD: ofdev.c,v 1.1 1997/04/16 20:29:20 thorpej Exp $ */ /* @@ -125,7 +125,7 @@ devclose(struct open_file *of) op->dmabuf, MAXBSIZE); OF_close(op->handle); - op->handle = -1; + free(op, sizeof *op); } struct devsw devsw[1] = { @@ -138,26 +138,25 @@ struct devsw devsw[1] = { int ndevs = sizeof devsw / sizeof devsw[0]; static struct fs_ops file_system_ufs = { - ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat + ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat, + ufs_readdir }; static struct fs_ops file_system_cd9660 = { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, - cd9660_stat + cd9660_stat, cd9660_readdir }; static struct fs_ops file_system_hfs = { - hfs_open, hfs_close, hfs_read, hfs_write, hfs_seek, hfs_stat + hfs_open, hfs_close, hfs_read, hfs_write, hfs_seek, hfs_stat, + hfs_readdir }; static struct fs_ops file_system_nfs = { - nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat + nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat, + nfs_readdir }; struct fs_ops file_system[3]; int nfsys; -static struct of_dev ofdev = { - -1, -}; - static u_long get_long(p) const void *p; @@ -292,6 +291,7 @@ search_label(devp, off, buf, lp, off0) int devopen(struct open_file *of, const char *name, char **file) { + struct of_dev *ofdev; char fname[256]; char buf[DEV_BSIZE]; struct disklabel label; @@ -299,8 +299,6 @@ devopen(struct open_file *of, const char *name, char **file) size_t read; int error = 0; - if (ofdev.handle != -1) - panic("devopen"); if (of->f_flags != F_READ) return EPERM; @@ -320,24 +318,30 @@ devopen(struct open_file *of, const char *name, char **file) * (:0 in OpenFirmware) */ strlcat(fname, ":0", sizeof fname); - if ((handle = OF_open(fname)) == -1) + if ((ofdev = alloc(sizeof *ofdev)) == NULL) + return ENOMEM; + bzero(ofdev, sizeof *ofdev); + + if ((handle = OF_open(fname)) == -1) { + free(ofdev, sizeof *ofdev); return ENXIO; - bzero(&ofdev, sizeof ofdev); - ofdev.handle = handle; - ofdev.dmabuf = NULL; - OF_call_method("dma-alloc", handle, 1, 1, MAXBSIZE, &ofdev.dmabuf); + } + + ofdev->handle = handle; + ofdev->dmabuf = NULL; + OF_call_method("dma-alloc", handle, 1, 1, MAXBSIZE, &ofdev->dmabuf); if (!strcmp(buf, "block")) { - ofdev.type = OFDEV_DISK; - ofdev.bsize = DEV_BSIZE; + ofdev->type = OFDEV_DISK; + ofdev->bsize = DEV_BSIZE; /* First try to find a disklabel without MBR partitions */ - if (strategy(&ofdev, F_READ, + if (strategy(ofdev, F_READ, LABELSECTOR, DEV_BSIZE, buf, &read) != 0 || read != DEV_BSIZE || getdisklabel(buf, &label)) { /* Else try MBR partitions */ - error = read_mac_label(&ofdev, buf, &label); + error = read_mac_label(ofdev, buf, &label); if (error == ERDLAB) - error = search_label(&ofdev, 0, buf, &label, 0); + error = search_label(ofdev, 0, buf, &label, 0); if (error && error != ERDLAB) goto bad; @@ -345,14 +349,14 @@ devopen(struct open_file *of, const char *name, char **file) if (error == ERDLAB) { /* No label, just use complete disk */ - ofdev.partoff = 0; + ofdev->partoff = 0; } else { part = 0; /* how to pass this parameter */ - ofdev.partoff = label.d_partitions[part].p_offset; + ofdev->partoff = label.d_partitions[part].p_offset; } of->f_dev = devsw; - of->f_devdata = &ofdev; + of->f_devdata = ofdev; bcopy(&file_system_ufs, file_system, sizeof file_system[0]); bcopy(&file_system_cd9660, file_system + 1, sizeof file_system[0]); @@ -362,18 +366,18 @@ devopen(struct open_file *of, const char *name, char **file) return 0; } if (!strcmp(buf, "network")) { - ofdev.type = OFDEV_NET; + ofdev->type = OFDEV_NET; of->f_dev = devsw; of->f_devdata = &ofdev; bcopy(&file_system_nfs, file_system, sizeof file_system[0]); nfsys = 1; - if (error = net_open(&ofdev)) + if (error = net_open(ofdev)) goto bad; return 0; } error = EFTYPE; bad: OF_close(handle); - ofdev.handle = -1; + free(ofdev, sizeof *ofdev); return error; } diff --git a/sys/arch/macppc/stand/ofwboot/version b/sys/arch/macppc/stand/ofwboot/version deleted file mode 100644 index 30e3cfb725b..00000000000 --- a/sys/arch/macppc/stand/ofwboot/version +++ /dev/null @@ -1,6 +0,0 @@ -$OpenBSD: version,v 1.1 2001/09/01 15:34:13 drahn Exp $ -$NetBSD: version,v 1.3 1997/04/19 01:40:08 thorpej Exp $ - -1.1: Boot program for OpenFirmware; initial revision -1.2: Boot program rearrangement -1.3: Added support for loading ELF kernels |