summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2011-03-25 11:52:31 +0000
committerkib <kib@FreeBSD.org>2011-03-25 11:52:31 +0000
commit948b7589fcf961fe76d3f86de580dccb0814fdb7 (patch)
tree51df5e7602f70c1e1f49aafd33a036a2fea8b755
parent0d40bf4b19470cb32fb5710521b366713b8d7edd (diff)
downloadFreeBSD-src-948b7589fcf961fe76d3f86de580dccb0814fdb7.zip
FreeBSD-src-948b7589fcf961fe76d3f86de580dccb0814fdb7.tar.gz
Implement compat32 MEMRANGE_GET and MEMRANGE_SET. This is needed to
run 32bit Xorg server with VESA driver. Submitted by: John Wehle <john feith com> MFC after: 1 week
-rw-r--r--sys/compat/freebsd32/freebsd32_ioctl.c51
-rw-r--r--sys/compat/freebsd32/freebsd32_ioctl.h8
2 files changed, 59 insertions, 0 deletions
diff --git a/sys/compat/freebsd32/freebsd32_ioctl.c b/sys/compat/freebsd32/freebsd32_ioctl.c
index 227a08b..c163a2a 100644
--- a/sys/compat/freebsd32/freebsd32_ioctl.c
+++ b/sys/compat/freebsd32/freebsd32_ioctl.c
@@ -38,7 +38,9 @@ __FBSDID("$FreeBSD$");
#include <sys/filio.h>
#include <sys/file.h>
#include <sys/ioccom.h>
+#include <sys/malloc.h>
#include <sys/mdioctl.h>
+#include <sys/memrange.h>
#include <sys/proc.h>
#include <sys/syscall.h>
#include <sys/syscallsubr.h>
@@ -55,6 +57,7 @@ __FBSDID("$FreeBSD$");
CTASSERT((sizeof(struct md_ioctl32)+4) == 436);
CTASSERT(sizeof(struct ioc_read_toc_entry32) == 8);
CTASSERT(sizeof(struct ioc_toc_header32) == 4);
+CTASSERT(sizeof(struct mem_range_op32) == 12);
static int
@@ -191,6 +194,49 @@ freebsd32_ioctl_fiodgname(struct thread *td,
return (error);
}
+static int
+freebsd32_ioctl_memrange(struct thread *td,
+ struct freebsd32_ioctl_args *uap, struct file *fp)
+{
+ struct mem_range_op mro;
+ struct mem_range_op32 mro32;
+ int error;
+ u_long com;
+
+ if ((error = copyin(uap->data, &mro32, sizeof(mro32))) != 0)
+ return (error);
+
+ PTRIN_CP(mro32, mro, mo_desc);
+ CP(mro32, mro, mo_arg[0]);
+ CP(mro32, mro, mo_arg[1]);
+
+ com = 0;
+ switch (uap->com) {
+ case MEMRANGE_GET32:
+ com = MEMRANGE_GET;
+ break;
+
+ case MEMRANGE_SET32:
+ com = MEMRANGE_SET;
+ break;
+
+ default:
+ panic("%s: unknown MEMRANGE %#x", __func__, uap->com);
+ }
+
+ if ((error = fo_ioctl(fp, com, (caddr_t)&mro, td->td_ucred, td)) != 0)
+ return (error);
+
+ if ( (com & IOC_OUT) ) {
+ CP(mro, mro32, mo_arg[0]);
+ CP(mro, mro32, mo_arg[1]);
+
+ error = copyout(&mro32, uap->data, sizeof(mro32));
+ }
+
+ return (error);
+}
+
int
freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap)
{
@@ -229,6 +275,11 @@ freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap)
error = freebsd32_ioctl_fiodgname(td, uap, fp);
break;
+ case MEMRANGE_GET32: /* FALLTHROUGH */
+ case MEMRANGE_SET32:
+ error = freebsd32_ioctl_memrange(td, uap, fp);
+ break;
+
default:
fdrop(fp, td);
ap.fd = uap->fd;
diff --git a/sys/compat/freebsd32/freebsd32_ioctl.h b/sys/compat/freebsd32/freebsd32_ioctl.h
index fddf553..ac87a67 100644
--- a/sys/compat/freebsd32/freebsd32_ioctl.h
+++ b/sys/compat/freebsd32/freebsd32_ioctl.h
@@ -67,6 +67,12 @@ struct fiodgname_arg32 {
caddr_t32 buf;
};
+struct mem_range_op32
+{
+ caddr_t32 mo_desc;
+ int mo_arg[2];
+};
+
#define CDIOREADTOCENTRYS_32 _IOWR('c', 5, struct ioc_read_toc_entry32)
#define CDIOREADTOCHEADER_32 _IOR('c', 4, struct ioc_toc_header32)
#define MDIOCATTACH_32 _IOC(IOC_INOUT, 'm', 0, sizeof(struct md_ioctl32) + 4)
@@ -74,5 +80,7 @@ struct fiodgname_arg32 {
#define MDIOCQUERY_32 _IOC(IOC_INOUT, 'm', 2, sizeof(struct md_ioctl32) + 4)
#define MDIOCLIST_32 _IOC(IOC_INOUT, 'm', 3, sizeof(struct md_ioctl32) + 4)
#define FIODGNAME_32 _IOW('f', 120, struct fiodgname_arg32)
+#define MEMRANGE_GET32 _IOWR('m', 50, struct mem_range_op32)
+#define MEMRANGE_SET32 _IOW('m', 51, struct mem_range_op32)
#endif /* _COMPAT_FREEBSD32_IOCTL_H_ */
OpenPOWER on IntegriCloud