Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat Added io_service_close and the io_connect_map_mem...



details:   https://anonhg.NetBSD.org/src/rev/51dcd446f28f
branches:  trunk
changeset: 547185:51dcd446f28f
user:      manu <manu%NetBSD.org@localhost>
date:      Wed May 14 18:28:04 2003 +0000

description:
Added io_service_close and the io_connect_map_memory method for
ioframebuffer's shared meory (used to handle the cursor).

XDarwin and WindowServer now fail on framebuffer mapping.

diffstat:

 sys/compat/darwin/darwin_ioframebuffer.c |  109 +++++++++++++++++++++++++++++-
 sys/compat/darwin/darwin_ioframebuffer.h |   32 ++++++++-
 sys/compat/darwin/darwin_iohidsystem.c   |    6 +-
 sys/compat/darwin/darwin_iohidsystem.h   |   21 +-----
 sys/compat/darwin/darwin_iokit.h         |   23 ++++++-
 sys/compat/mach/mach_iokit.c             |   24 ++++++-
 sys/compat/mach/mach_iokit.h             |   16 ++++-
 sys/compat/mach/mach_namemap.c           |    5 +-
 8 files changed, 202 insertions(+), 34 deletions(-)

diffs (truncated from 404 to 300 lines):

diff -r 182272cbec19 -r 51dcd446f28f sys/compat/darwin/darwin_ioframebuffer.c
--- a/sys/compat/darwin/darwin_ioframebuffer.c  Wed May 14 18:22:07 2003 +0000
+++ b/sys/compat/darwin/darwin_ioframebuffer.c  Wed May 14 18:28:04 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: darwin_ioframebuffer.c,v 1.7 2003/05/14 15:50:38 manu Exp $ */
+/*     $NetBSD: darwin_ioframebuffer.c,v 1.8 2003/05/14 18:28:05 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.7 2003/05/14 15:50:38 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: darwin_ioframebuffer.c,v 1.8 2003/05/14 18:28:05 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -48,14 +48,21 @@
 #include <sys/proc.h>
 #include <sys/device.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>
 #include <compat/mach/mach_port.h>
 #include <compat/mach/mach_errno.h>
 #include <compat/mach/mach_iokit.h>
 
+#include <compat/darwin/darwin_iokit.h>
 #include <compat/darwin/darwin_ioframebuffer.h>
-#include <compat/darwin/darwin_iokit.h>
+
+static struct uvm_object *darwin_ioframebuffer_shmem = NULL;
+static void darwin_ioframebuffer_shmeminit(vaddr_t);
 
 /* This is ugly, but we hope to see it going away quickly */
 
@@ -81,7 +88,7 @@
        darwin_ioframebuffer_connect_method_scalari_scalaro,
        darwin_ioframebuffer_connect_method_scalari_structo,
        darwin_ioframebuffer_connect_method_structi_structo,
-       NULL,
+       darwin_ioframebuffer_connect_map_memory,
        "IOFramebuffer",
 };
 
@@ -345,3 +352,97 @@
        rep->rep_msgh.msgh_size = *msglen - sizeof(rep->rep_trailer);
        return 0;
 }
+
+int 
+darwin_ioframebuffer_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;
+       int error;
+       size_t memsize;
+       size_t len;
+       vaddr_t pvaddr;
+       vaddr_t kvaddr;
+
+#ifdef DEBUG_DARWIN
+       printf("darwin_ioframebuffer_connect_map_memory()\n");
+#endif
+       switch (req->req_memtype) {
+       case DARWIN_IOFRAMEBUFFER_CURSOR_MEMORY:
+               len = sizeof(struct darwin_ioframebuffer_shmem);
+               memsize = round_page(len);
+               if (darwin_ioframebuffer_shmem == NULL) {
+                       darwin_ioframebuffer_shmem = uao_create(memsize, 0);
+
+                       error = uvm_map(kernel_map, &kvaddr, memsize,
+                           darwin_ioframebuffer_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_ioframebuffer_shmem);
+                               darwin_ioframebuffer_shmem = NULL;
+                               return mach_msg_error(args, error);
+                       }
+
+                       if ((error = uvm_map_pageable(kernel_map, kvaddr,
+                           kvaddr + memsize, FALSE, 0)) != 0) {
+                               uao_detach(darwin_ioframebuffer_shmem);
+                               darwin_ioframebuffer_shmem = NULL;
+                               return mach_msg_error(args, error);
+                       }
+
+                       darwin_ioframebuffer_shmeminit(kvaddr);
+               }
+
+               uao_reference(darwin_ioframebuffer_shmem);
+               pvaddr = VM_DEFAULT_ADDRESS(p->p_vmspace->vm_daddr, memsize);
+
+               if ((error = uvm_map(&p->p_vmspace->vm_map, &pvaddr,
+                   memsize, darwin_ioframebuffer_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
+               break;
+
+       case DARWIN_IOFRAMEBUFFER_SYSTEM_APERTURE:
+       case DARWIN_IOFRAMEBUFFER_VRAM_MEMORY:
+       default:
+#ifdef DEBUG_DARWIN
+               printf("unimplemented memtype %d\n", req->req_memtype);
+#endif
+               return mach_msg_error(args, EINVAL);
+               break;
+       }
+
+       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 = len;
+       rep->rep_trailer.msgh_trailer_size = 8;
+
+       *msglen = sizeof(*rep);
+
+       return 0;
+}
+
+void
+darwin_ioframebuffer_shmeminit(kvaddr)
+       vaddr_t kvaddr;
+{
+       struct darwin_ioframebuffer_shmem *shmem;
+
+       shmem = (struct darwin_ioframebuffer_shmem *)kvaddr;
+
+       return;
+}
diff -r 182272cbec19 -r 51dcd446f28f sys/compat/darwin/darwin_ioframebuffer.h
--- a/sys/compat/darwin/darwin_ioframebuffer.h  Wed May 14 18:22:07 2003 +0000
+++ b/sys/compat/darwin/darwin_ioframebuffer.h  Wed May 14 18:28:04 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: darwin_ioframebuffer.h,v 1.5 2003/05/14 14:41:05 manu Exp $ */
+/*     $NetBSD: darwin_ioframebuffer.h,v 1.6 2003/05/14 18:28:05 manu Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -41,11 +41,41 @@
 
 extern struct mach_iokit_devclass darwin_ioframebuffer_devclass;
 
+#define DARWIN_IOFRAMEBUFFER_CURSOR_MEMORY     100
+#define DARWIN_IOFRAMEBUFFER_VRAM_MEMORY       110
+#define DARWIN_IOFRAMEBUFFER_SYSTEM_APERTURE   0
+
+struct darwin_ioframebuffer_shmem {
+       darwin_ev_lock_data_t dis_sem;
+       char dis_cursshow;
+       char dis_sursobscured;
+       char dis_shieldflag;
+       char dis_dhielded;
+       darwin_iogbounds dis_saverect;
+       darwin_iogbounds dis_shieldrect;
+       darwin_iogpoint dis_location;
+       darwin_iogbounds dis_cursrect;
+       darwin_iogbounds dis_oldcursrect;
+       darwin_iogbounds dis_screen;
+       int version;
+       darwin_absolutetime dis_vbltime;
+       darwin_absolutetime dis_vbldelta;
+       unsigned int dis_reserved1[30];
+       unsigned char dis_hwcurscapable;
+       unsigned char dis_hwcursactive;
+       unsigned char dis_hwcursshields;
+       unsigned char dis_reserved2;
+       darwin_iogsize dis_cursorsize[4];
+       darwin_iogpoint dis_hotspot[4];
+       unsigned char dis_curs[0];
+};
+
 int 
 darwin_ioframebuffer_connect_method_scalari_scalaro(struct mach_trap_args *);
 int 
 darwin_ioframebuffer_connect_method_scalari_structo(struct mach_trap_args *);
 int
 darwin_ioframebuffer_connect_method_structi_structo(struct mach_trap_args *);
+int darwin_ioframebuffer_connect_map_memory(struct mach_trap_args *);
 
 #endif /* _DARWIN_IOFRAMEBUFFER_H_ */
diff -r 182272cbec19 -r 51dcd446f28f sys/compat/darwin/darwin_iohidsystem.c
--- a/sys/compat/darwin/darwin_iohidsystem.c    Wed May 14 18:22:07 2003 +0000
+++ b/sys/compat/darwin/darwin_iohidsystem.c    Wed May 14 18:28:04 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: darwin_iohidsystem.c,v 1.5 2003/05/14 14:41:05 manu Exp $ */
+/*     $NetBSD: darwin_iohidsystem.c,v 1.6 2003/05/14 18:28:05 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.5 2003/05/14 14:41:05 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: darwin_iohidsystem.c,v 1.6 2003/05/14 18:28:05 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -59,8 +59,8 @@
 #include <compat/mach/mach_errno.h>
 #include <compat/mach/mach_iokit.h>
 
+#include <compat/darwin/darwin_iokit.h>
 #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);
diff -r 182272cbec19 -r 51dcd446f28f sys/compat/darwin/darwin_iohidsystem.h
--- a/sys/compat/darwin/darwin_iohidsystem.h    Wed May 14 18:22:07 2003 +0000
+++ b/sys/compat/darwin/darwin_iohidsystem.h    Wed May 14 18:28:04 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: darwin_iohidsystem.h,v 1.3 2003/04/29 22:16:39 manu Exp $ */
+/*     $NetBSD: darwin_iohidsystem.h,v 1.4 2003/05/14 18:28:05 manu Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -41,25 +41,6 @@
 
 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 {
diff -r 182272cbec19 -r 51dcd446f28f sys/compat/darwin/darwin_iokit.h
--- a/sys/compat/darwin/darwin_iokit.h  Wed May 14 18:22:07 2003 +0000
+++ b/sys/compat/darwin/darwin_iokit.h  Wed May 14 18:28:04 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: darwin_iokit.h,v 1.2 2003/02/20 22:39:43 manu Exp $ */
+/*     $NetBSD: darwin_iokit.h,v 1.3 2003/05/14 18:28:05 manu Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -39,6 +39,27 @@
 #ifndef        _DARWIN_IOKIT_H_
 #define        _DARWIN_IOKIT_H_
 
+typedef uint64_t darwin_unsignedwide;
+typedef darwin_unsignedwide darwin_absolutetime;
+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;
+
 #include <compat/darwin/darwin_iohidsystem.h> 
 #include <compat/darwin/darwin_ioframebuffer.h>
 
diff -r 182272cbec19 -r 51dcd446f28f sys/compat/mach/mach_iokit.c



Home | Main Index | Thread Index | Old Index