diff options
-rw-r--r-- | sys/arch/arm/arm/openprom.c | 64 | ||||
-rw-r--r-- | sys/arch/arm64/arm64/openprom.c | 64 | ||||
-rw-r--r-- | sys/arch/octeon/octeon/openprom.c | 64 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/openprom.c | 64 | ||||
-rw-r--r-- | sys/dev/ofw/fdt.c | 9 | ||||
-rw-r--r-- | sys/dev/ofw/openfirm.h | 4 |
6 files changed, 50 insertions, 219 deletions
diff --git a/sys/arch/arm/arm/openprom.c b/sys/arch/arm/arm/openprom.c index cfb8231a02a..56566cc9835 100644 --- a/sys/arch/arm/arm/openprom.c +++ b/sys/arch/arm/arm/openprom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openprom.c,v 1.2 2016/05/23 00:05:34 deraadt Exp $ */ +/* $OpenBSD: openprom.c,v 1.3 2020/07/06 15:18:03 kettenis Exp $ */ /* $NetBSD: openprom.c,v 1.4 2002/01/10 06:21:53 briggs Exp $ */ /* @@ -55,13 +55,11 @@ #include <dev/ofw/openfirm.h> -#define OPROMMAXPARAM 32 +static int lastnode; /* speed hack */ +static int optionsnode; /* node ID of ROM's options */ -static int lastnode; /* speed hack */ -static int optionsnode; /* node ID of ROM's options */ - -static int openpromcheckid(int, int); -static int openpromgetstr(int, char *, char **); +int openpromcheckid(int, int); +int openpromgetstr(int, char *, char **); void openpromattach(int); void @@ -115,15 +113,11 @@ int openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { struct opiocdesc *op; - int node, len, ok, error, s; + int node, len, ok, error; char *name, *value, *nextprop; - static char buf[32]; /* XXX */ - if (optionsnode == 0) { - s = splhigh(); + if (optionsnode == 0) optionsnode = OF_getnodebyname(0, "options"); - splx(s); - } /* All too easy... */ if (cmd == OPIOCGETOPTNODE) { @@ -136,9 +130,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) node = op->op_nodeid; if (node != 0 && node != lastnode && node != optionsnode) { /* Not an easy one, must search for it */ - s = splhigh(); ok = openpromcheckid(OF_peer(0), node); - splx(s); if (!ok) return (EINVAL); lastnode = node; @@ -156,10 +148,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = openpromgetstr(op->op_namelen, op->op_name, &name); if (error) break; - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - len = OF_getproplen(node, buf); - splx(s); + len = OF_getproplen(node, name); if (len > op->op_buflen) { error = ENOMEM; break; @@ -169,34 +158,10 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) if (len <= 0) break; value = malloc(len, M_TEMP, M_WAITOK); - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - OF_getprop(node, buf, value, len); - splx(s); + OF_getprop(node, name, value, len); error = copyout(value, op->op_buf, len); break; -#if 0 - case OPIOCSET: - if ((flags & FWRITE) == 0) - return (EBADF); - if (node == 0) - return (EINVAL); - error = openpromgetstr(op->op_namelen, op->op_name, &name); - if (error) - break; - error = openpromgetstr(op->op_buflen, op->op_buf, &value); - if (error) - break; - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - len = OF_setprop(node, buf, value, op->op_buflen + 1); - splx(s); - if (len != op->op_buflen) - error = EINVAL; - break; -#endif - case OPIOCNEXTPROP: if ((flags & FREAD) == 0) return (EBADF); @@ -209,16 +174,13 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = ENAMETOOLONG; break; } - value = nextprop = malloc(OPROMMAXPARAM, M_TEMP, + value = nextprop = malloc(OFMAXPARAM, M_TEMP, M_WAITOK | M_CANFAIL); if (nextprop == NULL) { error = ENOMEM; break; } - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - error = OF_nextprop(node, buf, nextprop); - splx(s); + error = OF_nextprop(node, name, nextprop); if (error == -1) { error = EINVAL; break; @@ -241,9 +203,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) case OPIOCGETNEXT: if ((flags & FREAD) == 0) return (EBADF); - s = splhigh(); node = OF_peer(node); - splx(s); *(int *)data = lastnode = node; break; @@ -252,9 +212,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return (EBADF); if (node == 0) return (EINVAL); - s = splhigh(); node = OF_child(node); - splx(s); *(int *)data = lastnode = node; break; diff --git a/sys/arch/arm64/arm64/openprom.c b/sys/arch/arm64/arm64/openprom.c index 4d399058440..e18f42ca6c3 100644 --- a/sys/arch/arm64/arm64/openprom.c +++ b/sys/arch/arm64/arm64/openprom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openprom.c,v 1.1 2017/01/23 12:34:06 kettenis Exp $ */ +/* $OpenBSD: openprom.c,v 1.2 2020/07/06 15:18:03 kettenis Exp $ */ /* $NetBSD: openprom.c,v 1.4 2002/01/10 06:21:53 briggs Exp $ */ /* @@ -55,13 +55,11 @@ #include <dev/ofw/openfirm.h> -#define OPROMMAXPARAM 32 +static int lastnode; /* speed hack */ +static int optionsnode; /* node ID of ROM's options */ -static int lastnode; /* speed hack */ -static int optionsnode; /* node ID of ROM's options */ - -static int openpromcheckid(int, int); -static int openpromgetstr(int, char *, char **); +int openpromcheckid(int, int); +int openpromgetstr(int, char *, char **); void openpromattach(int); void @@ -115,15 +113,11 @@ int openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { struct opiocdesc *op; - int node, len, ok, error, s; + int node, len, ok, error; char *name, *value, *nextprop; - static char buf[32]; /* XXX */ - if (optionsnode == 0) { - s = splhigh(); + if (optionsnode == 0) optionsnode = OF_getnodebyname(0, "options"); - splx(s); - } /* All too easy... */ if (cmd == OPIOCGETOPTNODE) { @@ -136,9 +130,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) node = op->op_nodeid; if (node != 0 && node != lastnode && node != optionsnode) { /* Not an easy one, must search for it */ - s = splhigh(); ok = openpromcheckid(OF_peer(0), node); - splx(s); if (!ok) return (EINVAL); lastnode = node; @@ -156,10 +148,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = openpromgetstr(op->op_namelen, op->op_name, &name); if (error) break; - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - len = OF_getproplen(node, buf); - splx(s); + len = OF_getproplen(node, name); if (len > op->op_buflen) { error = ENOMEM; break; @@ -169,34 +158,10 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) if (len <= 0) break; value = malloc(len, M_TEMP, M_WAITOK); - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - OF_getprop(node, buf, value, len); - splx(s); + OF_getprop(node, name, value, len); error = copyout(value, op->op_buf, len); break; -#if 0 - case OPIOCSET: - if ((flags & FWRITE) == 0) - return (EBADF); - if (node == 0) - return (EINVAL); - error = openpromgetstr(op->op_namelen, op->op_name, &name); - if (error) - break; - error = openpromgetstr(op->op_buflen, op->op_buf, &value); - if (error) - break; - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - len = OF_setprop(node, buf, value, op->op_buflen + 1); - splx(s); - if (len != op->op_buflen) - error = EINVAL; - break; -#endif - case OPIOCNEXTPROP: if ((flags & FREAD) == 0) return (EBADF); @@ -209,16 +174,13 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = ENAMETOOLONG; break; } - value = nextprop = malloc(OPROMMAXPARAM, M_TEMP, + value = nextprop = malloc(OFMAXPARAM, M_TEMP, M_WAITOK | M_CANFAIL); if (nextprop == NULL) { error = ENOMEM; break; } - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - error = OF_nextprop(node, buf, nextprop); - splx(s); + error = OF_nextprop(node, name, nextprop); if (error == -1) { error = EINVAL; break; @@ -241,9 +203,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) case OPIOCGETNEXT: if ((flags & FREAD) == 0) return (EBADF); - s = splhigh(); node = OF_peer(node); - splx(s); *(int *)data = lastnode = node; break; @@ -252,9 +212,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return (EBADF); if (node == 0) return (EINVAL); - s = splhigh(); node = OF_child(node); - splx(s); *(int *)data = lastnode = node; break; diff --git a/sys/arch/octeon/octeon/openprom.c b/sys/arch/octeon/octeon/openprom.c index 1b107958e90..56566cc9835 100644 --- a/sys/arch/octeon/octeon/openprom.c +++ b/sys/arch/octeon/octeon/openprom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openprom.c,v 1.2 2016/07/05 13:41:46 visa Exp $ */ +/* $OpenBSD: openprom.c,v 1.3 2020/07/06 15:18:03 kettenis Exp $ */ /* $NetBSD: openprom.c,v 1.4 2002/01/10 06:21:53 briggs Exp $ */ /* @@ -55,13 +55,11 @@ #include <dev/ofw/openfirm.h> -#define OPROMMAXPARAM 32 +static int lastnode; /* speed hack */ +static int optionsnode; /* node ID of ROM's options */ -static int lastnode; /* speed hack */ -static int optionsnode; /* node ID of ROM's options */ - -static int openpromcheckid(int, int); -static int openpromgetstr(int, char *, char **); +int openpromcheckid(int, int); +int openpromgetstr(int, char *, char **); void openpromattach(int); void @@ -115,15 +113,11 @@ int openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { struct opiocdesc *op; - int node, len, ok, error, s; + int node, len, ok, error; char *name, *value, *nextprop; - static char buf[32]; /* XXX */ - if (optionsnode == 0) { - s = splhigh(); + if (optionsnode == 0) optionsnode = OF_getnodebyname(0, "options"); - splx(s); - } /* All too easy... */ if (cmd == OPIOCGETOPTNODE) { @@ -136,9 +130,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) node = op->op_nodeid; if (node != 0 && node != lastnode && node != optionsnode) { /* Not an easy one, must search for it */ - s = splhigh(); ok = openpromcheckid(OF_peer(0), node); - splx(s); if (!ok) return (EINVAL); lastnode = node; @@ -156,10 +148,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = openpromgetstr(op->op_namelen, op->op_name, &name); if (error) break; - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - len = OF_getproplen(node, buf); - splx(s); + len = OF_getproplen(node, name); if (len > op->op_buflen) { error = ENOMEM; break; @@ -169,34 +158,10 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) if (len <= 0) break; value = malloc(len, M_TEMP, M_WAITOK); - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - OF_getprop(node, buf, value, len); - splx(s); + OF_getprop(node, name, value, len); error = copyout(value, op->op_buf, len); break; -#if 0 - case OPIOCSET: - if ((flags & FWRITE) == 0) - return (EBADF); - if (node == 0) - return (EINVAL); - error = openpromgetstr(op->op_namelen, op->op_name, &name); - if (error) - break; - error = openpromgetstr(op->op_buflen, op->op_buf, &value); - if (error) - break; - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - len = OF_setprop(node, buf, value, op->op_buflen + 1); - splx(s); - if (len != op->op_buflen) - error = EINVAL; - break; -#endif - case OPIOCNEXTPROP: if ((flags & FREAD) == 0) return (EBADF); @@ -209,16 +174,13 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = ENAMETOOLONG; break; } - value = nextprop = malloc(OPROMMAXPARAM, M_TEMP, + value = nextprop = malloc(OFMAXPARAM, M_TEMP, M_WAITOK | M_CANFAIL); if (nextprop == NULL) { error = ENOMEM; break; } - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - error = OF_nextprop(node, buf, nextprop); - splx(s); + error = OF_nextprop(node, name, nextprop); if (error == -1) { error = EINVAL; break; @@ -241,9 +203,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) case OPIOCGETNEXT: if ((flags & FREAD) == 0) return (EBADF); - s = splhigh(); node = OF_peer(node); - splx(s); *(int *)data = lastnode = node; break; @@ -252,9 +212,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return (EBADF); if (node == 0) return (EINVAL); - s = splhigh(); node = OF_child(node); - splx(s); *(int *)data = lastnode = node; break; diff --git a/sys/arch/powerpc64/powerpc64/openprom.c b/sys/arch/powerpc64/powerpc64/openprom.c index e98cbee2e28..0a733c8741a 100644 --- a/sys/arch/powerpc64/powerpc64/openprom.c +++ b/sys/arch/powerpc64/powerpc64/openprom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openprom.c,v 1.1 2020/06/27 21:39:05 kettenis Exp $ */ +/* $OpenBSD: openprom.c,v 1.2 2020/07/06 15:18:04 kettenis Exp $ */ /* $NetBSD: openprom.c,v 1.4 2002/01/10 06:21:53 briggs Exp $ */ /* @@ -55,13 +55,11 @@ #include <dev/ofw/openfirm.h> -#define OPROMMAXPARAM 32 +static int lastnode; /* speed hack */ +static int optionsnode; /* node ID of ROM's options */ -static int lastnode; /* speed hack */ -static int optionsnode; /* node ID of ROM's options */ - -static int openpromcheckid(int, int); -static int openpromgetstr(int, char *, char **); +int openpromcheckid(int, int); +int openpromgetstr(int, char *, char **); void openpromattach(int); void @@ -115,15 +113,11 @@ int openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { struct opiocdesc *op; - int node, len, ok, error, s; + int node, len, ok, error; char *name, *value, *nextprop; - static char buf[32]; /* XXX */ - if (optionsnode == 0) { - s = splhigh(); + if (optionsnode == 0) optionsnode = OF_getnodebyname(0, "options"); - splx(s); - } /* All too easy... */ if (cmd == OPIOCGETOPTNODE) { @@ -136,9 +130,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) node = op->op_nodeid; if (node != 0 && node != lastnode && node != optionsnode) { /* Not an easy one, must search for it */ - s = splhigh(); ok = openpromcheckid(OF_peer(0), node); - splx(s); if (!ok) return (EINVAL); lastnode = node; @@ -156,10 +148,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = openpromgetstr(op->op_namelen, op->op_name, &name); if (error) break; - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - len = OF_getproplen(node, buf); - splx(s); + len = OF_getproplen(node, name); if (len > op->op_buflen) { error = ENOMEM; break; @@ -169,34 +158,10 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) if (len <= 0) break; value = malloc(len, M_TEMP, M_WAITOK); - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - OF_getprop(node, buf, value, len); - splx(s); + OF_getprop(node, name, value, len); error = copyout(value, op->op_buf, len); break; -#if 0 - case OPIOCSET: - if ((flags & FWRITE) == 0) - return (EBADF); - if (node == 0) - return (EINVAL); - error = openpromgetstr(op->op_namelen, op->op_name, &name); - if (error) - break; - error = openpromgetstr(op->op_buflen, op->op_buf, &value); - if (error) - break; - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - len = OF_setprop(node, buf, value, op->op_buflen + 1); - splx(s); - if (len != op->op_buflen) - error = EINVAL; - break; -#endif - case OPIOCNEXTPROP: if ((flags & FREAD) == 0) return (EBADF); @@ -209,16 +174,13 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = ENAMETOOLONG; break; } - value = nextprop = malloc(OPROMMAXPARAM, M_TEMP, + value = nextprop = malloc(OFMAXPARAM, M_TEMP, M_WAITOK | M_CANFAIL); if (nextprop == NULL) { error = ENOMEM; break; } - s = splhigh(); - strlcpy(buf, name, 32); /* XXX */ - error = OF_nextprop(node, buf, nextprop); - splx(s); + error = OF_nextprop(node, name, nextprop); if (error == -1) { error = EINVAL; break; @@ -241,9 +203,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) case OPIOCGETNEXT: if ((flags & FREAD) == 0) return (EBADF); - s = splhigh(); node = OF_peer(node); - splx(s); *(int *)data = lastnode = node; break; @@ -252,9 +212,7 @@ openpromioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return (EBADF); if (node == 0) return (EINVAL); - s = splhigh(); node = OF_child(node); - splx(s); *(int *)data = lastnode = node; break; diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c index 186cbe6ff2b..ddc837fa858 100644 --- a/sys/dev/ofw/fdt.c +++ b/sys/dev/ofw/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.23 2019/08/10 13:16:01 kettenis Exp $ */ +/* $OpenBSD: fdt.c,v 1.24 2020/07/06 15:18:03 kettenis Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net> @@ -24,9 +24,6 @@ #include <dev/ofw/fdt.h> #include <dev/ofw/openfirm.h> -/* XXX */ -#define OPROMMAXPARAM 32 - unsigned int fdt_check_head(void *); char *fdt_get_str(u_int32_t); void *skip_property(u_int32_t *); @@ -904,13 +901,13 @@ OF_nextprop(int handle, char *prop, void *nextprop) if (fdt_node_property(node, "name", &data) == -1) { if (strcmp(prop, "") == 0) - return strlcpy(nextprop, "name", OPROMMAXPARAM); + return strlcpy(nextprop, "name", OFMAXPARAM); if (strcmp(prop, "name") == 0) prop = ""; } if (fdt_next_property(node, prop, &data)) - return strlcpy(nextprop, data, OPROMMAXPARAM); + return strlcpy(nextprop, data, OFMAXPARAM); return -1; } diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h index 45f8086d047..57022b05c85 100644 --- a/sys/dev/ofw/openfirm.h +++ b/sys/dev/ofw/openfirm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: openfirm.h,v 1.15 2017/12/27 11:40:14 kettenis Exp $ */ +/* $OpenBSD: openfirm.h,v 1.16 2020/07/06 15:18:03 kettenis Exp $ */ /* $NetBSD: openfirm.h,v 1.1 1996/09/30 16:35:10 ws Exp $ */ /* @@ -38,6 +38,8 @@ #include <sys/param.h> #include <sys/device.h> +#define OFMAXPARAM 64 + int openfirmware(void *); extern char OF_buf[]; |