Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/mach Added vm_inherit mach trap.



details:   https://anonhg.NetBSD.org/src/rev/c6a2af48d820
branches:  trunk
changeset: 540400:c6a2af48d820
user:      manu <manu%NetBSD.org@localhost>
date:      Wed Dec 11 21:23:37 2002 +0000

description:
Added vm_inherit mach trap.

diffstat:

 sys/compat/mach/mach_namemap.c |   5 ++-
 sys/compat/mach/mach_vm.c      |  43 +++++++++++++++++++++++++++++++++++++++--
 sys/compat/mach/mach_vm.h      |  20 ++++++++++++++++++-
 3 files changed, 62 insertions(+), 6 deletions(-)

diffs (136 lines):

diff -r ff6d9c37af01 -r c6a2af48d820 sys/compat/mach/mach_namemap.c
--- a/sys/compat/mach/mach_namemap.c    Wed Dec 11 21:20:15 2002 +0000
+++ b/sys/compat/mach/mach_namemap.c    Wed Dec 11 21:23:37 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_namemap.c,v 1.8 2002/12/10 21:36:45 manu Exp $ */
+/*     $NetBSD: mach_namemap.c,v 1.9 2002/12/11 21:23:37 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.8 2002/12/10 21:36:45 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.9 2002/12/11 21:23:37 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -70,6 +70,7 @@
        { 3801, mach_vm_allocate, "vm_allocate" },
        { 3802, mach_vm_deallocate, "vm_deallocate" },
        { 3803, mach_vm_protect, "vm_protect" },
+       { 3804, mach_vm_inherit, "vm_inherit" },
        { 3812, mach_vm_map, "vm_map" },
        { 0, NULL, NULL },
 };
diff -r ff6d9c37af01 -r c6a2af48d820 sys/compat/mach/mach_vm.c
--- a/sys/compat/mach/mach_vm.c Wed Dec 11 21:20:15 2002 +0000
+++ b/sys/compat/mach/mach_vm.c Wed Dec 11 21:23:37 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_vm.c,v 1.18 2002/12/10 21:36:45 manu Exp $ */
+/*     $NetBSD: mach_vm.c,v 1.19 2002/12/11 21:23:37 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.18 2002/12/10 21:36:45 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.19 2002/12/11 21:23:37 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -127,9 +127,11 @@
        case MACH_VM_INHERIT_SHARE:
                SCARG(&cup, flags) |= MAP_INHERIT;
                break;
+       case MACH_VM_INHERIT_COPY:
+               SCARG(&cup, flags) |= MAP_COPY;
+               break;
        case MACH_VM_INHERIT_NONE:
                break;
-       case MACH_VM_INHERIT_COPY:
        case MACH_VM_INHERIT_DONATE_COPY:
        default:
                uprintf("mach_vm_map: unsupported inherance flag %d\n",
@@ -445,3 +447,38 @@
        return error;
 }
  
+int
+mach_vm_inherit(p, msgh, maxlen, dst)
+       struct proc *p;
+       mach_msg_header_t *msgh;
+       size_t maxlen;
+       mach_msg_header_t *dst;
+{
+       mach_vm_inherit_request_t req;
+       mach_vm_inherit_reply_t rep;
+       struct sys_minherit_args cup;
+       register_t retval;
+       int error;
+
+       if ((error = copyin(msgh, &req, sizeof(req))) != 0)
+               return error;
+
+       bzero(&rep, sizeof(rep));
+
+       SCARG(&cup, addr) = (void *)req.req_addr;
+       SCARG(&cup, len) = req.req_size;
+       /* Flags map well between Mach and NetBSD, just a 8 bit shift */
+       SCARG(&cup, inherit) = req.req_inh << 8;
+
+       if ((error = sys_minherit(p, &cup, &retval)) != 0)
+               return MACH_MSG_ERROR(p, msgh, &req, &rep, error, maxlen, dst);
+       
+       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_trailer.msgh_trailer_size = 8;
+
+       return MACH_MSG_RETURN(p, &rep, msgh, sizeof(rep), maxlen, dst);
+}
diff -r ff6d9c37af01 -r c6a2af48d820 sys/compat/mach/mach_vm.h
--- a/sys/compat/mach/mach_vm.h Wed Dec 11 21:20:15 2002 +0000
+++ b/sys/compat/mach/mach_vm.h Wed Dec 11 21:23:37 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_vm.h,v 1.9 2002/12/10 21:36:45 manu Exp $ */
+/*     $NetBSD: mach_vm.h,v 1.10 2002/12/11 21:23:37 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -164,6 +164,22 @@
        mach_msg_trailer_t rep_trailer;
 } mach_vm_protect_reply_t;
 
+/* vm_inherit */
+typedef struct {
+       mach_msg_header_t req_msgh;
+       mach_ndr_record_t req_ndr;
+       mach_vm_address_t req_addr;
+       mach_vm_size_t req_size;
+       mach_vm_inherit_t req_inh;
+} mach_vm_inherit_request_t;
+
+typedef struct {
+       mach_msg_header_t rep_msgh;
+       mach_ndr_record_t rep_ndr;
+       mach_kern_return_t rep_retval;
+       mach_msg_trailer_t rep_trailer;
+} mach_vm_inherit_reply_t;
+
 int mach_vm_map(struct proc *, mach_msg_header_t *,
     size_t, mach_msg_header_t *);
 int mach_vm_allocate(struct proc *, mach_msg_header_t *,
@@ -174,5 +190,7 @@
     size_t, mach_msg_header_t *);
 int mach_vm_protect(struct proc *, mach_msg_header_t *,
     size_t, mach_msg_header_t *);
+int mach_vm_inherit(struct proc *, mach_msg_header_t *,
+    size_t, mach_msg_header_t *);
 
 #endif /* _MACH_VM_H_ */



Home | Main Index | Thread Index | Old Index