Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat Added the map_memory method for the IOKit, plus a...
details: https://anonhg.NetBSD.org/src/rev/e25a4707b5cd
branches: trunk
changeset: 546488:e25a4707b5cd
user: manu <manu%NetBSD.org@localhost>
date: Tue Apr 29 22:16:38 2003 +0000
description:
Added the map_memory method for the IOKit, plus an implementation
for the IOHIDSystem driver in Darwin. IOHIDSystem provides access
to user interface devices.
Communication between userspace and kernel is done through a shared
memory page. Our plan is to have a kernel thread waiting on wscons
events (for now it just does nothing), and have it feeding the
shared page.
diffstat:
sys/compat/darwin/darwin_ioframebuffer.c | 5 +-
sys/compat/darwin/darwin_iohidsystem.c | 125 +++++++++++++++++-
sys/compat/darwin/darwin_iohidsystem.h | 220 ++++++++++++++++++++++++++++++-
sys/compat/mach/mach_iokit.c | 42 +++++-
sys/compat/mach/mach_iokit.h | 26 +++-
sys/compat/mach/mach_namemap.c | 5 +-
6 files changed, 413 insertions(+), 10 deletions(-)
diffs (truncated from 563 to 300 lines):
diff -r 7a83462b9f6d -r e25a4707b5cd sys/compat/darwin/darwin_ioframebuffer.c
--- a/sys/compat/darwin/darwin_ioframebuffer.c Tue Apr 29 22:12:51 2003 +0000
+++ b/sys/compat/darwin/darwin_ioframebuffer.c Tue Apr 29 22:16:38 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: darwin_ioframebuffer.c,v 1.3 2003/03/09 18:33:29 manu Exp $ */
+/* $NetBSD: darwin_ioframebuffer.c,v 1.4 2003/04/29 22:16:38 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: darwin_ioframebuffer.c,v 1.3 2003/03/09 18:33:29 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: darwin_ioframebuffer.c,v 1.4 2003/04/29 22:16:38 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -84,6 +84,7 @@
"</dict>",
darwin_ioframebuffer_registry_entry_get_property,
darwin_ioframebuffer_connect_method_scalari_scalaro,
+ NULL,
"IOFramebuffer",
};
diff -r 7a83462b9f6d -r e25a4707b5cd sys/compat/darwin/darwin_iohidsystem.c
--- a/sys/compat/darwin/darwin_iohidsystem.c Tue Apr 29 22:12:51 2003 +0000
+++ b/sys/compat/darwin/darwin_iohidsystem.c Tue Apr 29 22:16:38 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: darwin_iohidsystem.c,v 1.3 2003/03/09 18:33:30 manu Exp $ */
+/* $NetBSD: darwin_iohidsystem.c,v 1.4 2003/04/29 22:16:38 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: darwin_iohidsystem.c,v 1.3 2003/03/09 18:33:30 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: darwin_iohidsystem.c,v 1.4 2003/04/29 22:16:38 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -47,6 +47,11 @@
#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/device.h>
+#include <sys/kthread.h>
+
+#include <uvm/uvm_extern.h>
+#include <uvm/uvm_map.h>
+#include <uvm/uvm.h>
#include <compat/mach/mach_types.h>
#include <compat/mach/mach_message.h>
@@ -57,12 +62,17 @@
#include <compat/darwin/darwin_iohidsystem.h>
#include <compat/darwin/darwin_iokit.h>
+static struct uvm_object *darwin_iohidsystem_shmem = NULL;
+static void darwin_iohidsystem_shmeminit(vaddr_t);
+static void darwin_iohidsystem_thread(void *);
+
struct mach_iokit_devclass darwin_iohidsystem_devclass = {
"<dict ID=\"0\"><key>IOProviderClass</key>"
"<string ID=\"1\">IOHIDSystem</string></dict>",
NULL,
NULL,
darwin_iohidsystem_connect_method_scalari_scalaro,
+ darwin_iohidsystem_connect_map_memory,
"IOHIDSystem",
};
@@ -88,3 +98,114 @@
*msglen = sizeof(*rep) - ((4096 + rep->rep_outcount) * sizeof(int));
return 0;
}
+
+int
+darwin_iohidsystem_connect_map_memory(args)
+ struct mach_trap_args *args;
+{
+ mach_io_connect_map_memory_request_t *req = args->smsg;
+ mach_io_connect_map_memory_reply_t *rep = args->rmsg;
+ size_t *msglen = args->rsize;
+ struct proc *p = args->l->l_proc;
+ struct proc *newpp;
+ int error;
+ size_t memsize;
+ vaddr_t pvaddr;
+ vaddr_t kvaddr;
+
+#ifdef DEBUG_DARWIN
+ printf("darwin_iohidsystem_connect_map_memory()\n");
+#endif
+ memsize = round_page(sizeof(struct darwin_iohidsystem_shmem));
+
+ /* If it has not been used yet, initialize it */
+ if (darwin_iohidsystem_shmem == NULL) {
+ darwin_iohidsystem_shmem = uao_create(memsize, 0);
+
+ error = uvm_map(kernel_map, &kvaddr, memsize,
+ darwin_iohidsystem_shmem, 0, PAGE_SIZE,
+ UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW,
+ UVM_INH_SHARE, UVM_ADV_RANDOM, 0));
+ if (error != 0) {
+ uao_detach(darwin_iohidsystem_shmem);
+ darwin_iohidsystem_shmem = NULL;
+ return error;
+ }
+
+ error = uvm_map_pageable(kernel_map, kvaddr,
+ kvaddr + memsize, FALSE, 0);
+ if (error != 0) {
+ uao_detach(darwin_iohidsystem_shmem);
+ darwin_iohidsystem_shmem = NULL;
+ return error;
+ }
+
+ darwin_iohidsystem_shmeminit(kvaddr);
+
+ kthread_create1(darwin_iohidsystem_thread,
+ (void *)kvaddr, &newpp, "iohidsystem");
+ }
+
+ uao_reference(darwin_iohidsystem_shmem);
+ pvaddr = VM_DEFAULT_ADDRESS(p->p_vmspace->vm_daddr, memsize);
+
+ if ((error = uvm_map(&p->p_vmspace->vm_map, &pvaddr,
+ memsize, darwin_iohidsystem_shmem, 0, PAGE_SIZE,
+ UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW,
+ UVM_INH_SHARE, UVM_ADV_RANDOM, 0))) != 0)
+ return mach_msg_error(args, error);
+
+#ifdef DEBUG_DARWIN
+ printf("pvaddr = 0x%08lx\n", (long)pvaddr);
+#endif
+ rep->rep_msgh.msgh_bits =
+ MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
+ rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
+ rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port;
+ rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
+ rep->rep_retval = 0;
+ rep->rep_addr = pvaddr;
+ rep->rep_len = sizeof(struct darwin_iohidsystem_shmem);
+ rep->rep_trailer.msgh_trailer_size = 8;
+
+ *msglen = sizeof(*rep);
+
+ return 0;
+}
+
+static void
+darwin_iohidsystem_thread(shmem)
+ void *shmem;
+{
+#ifdef DEBUG_DARWIN
+ printf("darwin_iohidsystem_thread: start\n");
+#endif
+ /*
+ * This will receive wscons events and modify the IOHIDSystem
+ * shared page. But for now it just sleep forever.
+ */
+ (void)tsleep(shmem, PZERO | PCATCH, "iohidsystem", 0);
+#ifdef DEBUG_DARWIN
+ printf("darwin_iohidsystem_thread: exit\n");
+#endif
+ return;
+};
+
+static void
+darwin_iohidsystem_shmeminit(kvaddr)
+ vaddr_t kvaddr;
+{
+ struct darwin_iohidsystem_shmem *shmem;
+ struct darwin_iohidsystem_evglobals *evglobals;
+
+ shmem = (struct darwin_iohidsystem_shmem *)kvaddr;
+ shmem->dis_global_offset =
+ (size_t)&shmem->dis_evglobals - (size_t)&shmem->dis_global_offset;
+ shmem->dis_private_offset =
+ shmem->dis_global_offset + sizeof(*evglobals);
+
+ evglobals = &shmem->dis_evglobals;
+ evglobals->die_struct_size = sizeof(*evglobals);
+
+ return;
+}
diff -r 7a83462b9f6d -r e25a4707b5cd sys/compat/darwin/darwin_iohidsystem.h
--- a/sys/compat/darwin/darwin_iohidsystem.h Tue Apr 29 22:12:51 2003 +0000
+++ b/sys/compat/darwin/darwin_iohidsystem.h Tue Apr 29 22:16:38 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: darwin_iohidsystem.h,v 1.2 2003/02/20 22:39:43 manu Exp $ */
+/* $NetBSD: darwin_iohidsystem.h,v 1.3 2003/04/29 22:16:39 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -41,6 +41,224 @@
extern struct mach_iokit_devclass darwin_iohidsystem_devclass;
+typedef volatile int darwin_ev_lock_data_t; /* aka IOSharedLockData */
+
+typedef struct {
+ int16_t x;
+ int16_t y;
+} darwin_iogpoint;
+
+typedef struct {
+ int16_t width;
+ int16_t height;
+} darwin_iogsize;
+
+typedef struct {
+ int16_t minx;
+ int16_t maxx;
+ int16_t miny;
+ int16_t maxy;
+} darwin_iogbounds;
+
+/* Events and event queue */
+
+typedef struct {
+ uint16_t tabletid;
+ uint16_t pointerid;
+ uint16_t deviceid;
+ uint16_t system_tabletid;
+ uint16_t vendor_pointertype;
+ uint32_t pointer_serialnum;
+ uint64_t uniqueid;
+ uint32_t cap_mask;
+ uint8_t ptrtype;
+ uint8_t enter_proximity;
+ int16_t reserved1;
+} darwin_iohidsystem_tabletproxymity;
+
+typedef struct {
+ int32_t x;
+ int32_t y;
+ int32_t z;
+ uint16_t buttons;
+ uint16_t pressure;
+ struct {
+ int16_t x;
+ int16_t y;
+ } tilt;
+ uint16_t rotation;
+ uint16_t tanpressure;
+ uint16_t devid;
+ uint16_t vendor1;
+ uint16_t vendor2;
+ uint16_t vendor3;
+} darwin_iohidsystem_tabletpoint;
+
+typedef union {
+ struct {
+ uint8_t subx;
+ uint8_t suby;
+ int16_t buttonid;
+ int32_t click;
+ uint8_t pressure;
+ uint8_t reserved1;
+ uint8_t subtype;
+ uint8_t reserved2;
+ uint32_t reserved3;
+ union {
+ darwin_iohidsystem_tabletpoint point;
+ darwin_iohidsystem_tabletproxymity proximity;
+ } tablet;
+ } mouse;
+ struct {
+ int32_t dx;
+ int32_t dy;
+ uint8_t subx;
+ uint8_t suby;
+ uint8_t subtype;
+ uint8_t reserved1;
+ int32_t reserved2;
+ union {
+ darwin_iohidsystem_tabletpoint point;
+ darwin_iohidsystem_tabletproxymity proximity;
+ } tablet;
+ } mouse_move;
+ struct {
+ uint16_t origi_charset;
+ int16_t repeat;
+ uint16_t charset;
+ uint16_t charcode;
+ uint16_t keycode;
+ uint16_t orig_charcode;
+ int32_t reserved1;
+ int32_t keyboardtype;
+ int32_t reserved2[7];
+ } key;
+ struct {
+ int16_t reserved;
+ int16_t eventnum;
+ int32_t trackingnum;
+ int32_t userdata;
Home |
Main Index |
Thread Index |
Old Index