diff options
| author | manu <manu@NetBSD.org> | 2003-03-03 22:07:39 +0000 |
|---|---|---|
| committer | manu <manu@NetBSD.org> | 2003-03-03 22:07:39 +0000 |
| commit | 03dfd69a01aedaecfb773b7365a655a444ebebb9 (patch) | |
| tree | f50996988e863984b269e56522293315208cb990 /sys/compat | |
| parent | 2198701c01d6c3726bfb3e48d28150b39649a8a8 (diff) | |
Added vm_region and vm_msync traps
Diffstat (limited to 'sys/compat')
| -rw-r--r-- | sys/compat/mach/mach_message.h | 11 | ||||
| -rw-r--r-- | sys/compat/mach/mach_namemap.c | 6 | ||||
| -rw-r--r-- | sys/compat/mach/mach_types.h | 5 | ||||
| -rw-r--r-- | sys/compat/mach/mach_vm.c | 98 | ||||
| -rw-r--r-- | sys/compat/mach/mach_vm.h | 67 |
5 files changed, 178 insertions, 9 deletions
diff --git a/sys/compat/mach/mach_message.h b/sys/compat/mach/mach_message.h index 6c58105b75c..cce6cb4dba9 100644 --- a/sys/compat/mach/mach_message.h +++ b/sys/compat/mach/mach_message.h @@ -1,4 +1,4 @@ -/* $NetBSD: mach_message.h,v 1.14 2003/01/21 04:06:07 matt Exp $ */ +/* $NetBSD: mach_message.h,v 1.15 2003/03/03 22:07:39 manu Exp $ */ /*- * Copyright (c) 2001-2003 The NetBSD Foundation, Inc. @@ -194,6 +194,15 @@ typedef struct { } mach_msg_ool_ports_descriptor_t; typedef struct { + void * address; + mach_msg_size_t size; + mach_boolean_t deallocate : 8; + mach_msg_copy_options_t copy : 8; + unsigned int pad1 : 8; + mach_msg_descriptor_type_t type : 8; +} mach_msg_ool_descriptor_t; + +typedef struct { mach_msg_size_t msgh_descriptor_count; } mach_msg_body_t; diff --git a/sys/compat/mach/mach_namemap.c b/sys/compat/mach/mach_namemap.c index 66944691ce5..1a59452cffa 100644 --- a/sys/compat/mach/mach_namemap.c +++ b/sys/compat/mach/mach_namemap.c @@ -1,4 +1,4 @@ -/* $NetBSD: mach_namemap.c,v 1.18 2003/02/28 09:30:23 manu Exp $ */ +/* $NetBSD: mach_namemap.c,v 1.19 2003/03/03 22:07:39 manu Exp $ */ /*- * Copyright (c) 2002-2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.18 2003/02/28 09:30:23 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.19 2003/03/03 22:07:39 manu Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -103,10 +103,12 @@ struct mach_subsystem_namemap mach_namemap[] = { { 3418, mach_semaphore_create, "semaphore_create" }, { 3419, mach_semaphore_destroy, "semaphore_destroy" }, { 3616, mach_thread_policy, "thread_policy" }, + { 3800, mach_vm_region, "vm_region" }, { 3801, mach_vm_allocate, "vm_allocate" }, { 3802, mach_vm_deallocate, "vm_deallocate" }, { 3803, mach_vm_protect, "vm_protect" }, { 3804, mach_vm_inherit, "vm_inherit" }, + { 3810, mach_vm_msync, "vm_msync" }, { 3812, mach_vm_map, "vm_map" }, { 3825, mach_vm_make_memory_entry, "vm_make_memory_entry" }, { 0, NULL, NULL }, diff --git a/sys/compat/mach/mach_types.h b/sys/compat/mach/mach_types.h index 73d3da913ee..9b53418605e 100644 --- a/sys/compat/mach/mach_types.h +++ b/sys/compat/mach/mach_types.h @@ -1,4 +1,4 @@ -/* $NetBSD: mach_types.h,v 1.11 2003/01/21 04:06:08 matt Exp $ */ +/* $NetBSD: mach_types.h,v 1.12 2003/03/03 22:07:40 manu Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -59,6 +59,9 @@ typedef int mach_thread_state_flavor_t; typedef unsigned int mach_natural_t; typedef unsigned long mach_vm_size_t; typedef unsigned long mach_vm_offset_t; +typedef int mach_vm_region_flavor_t; +typedef int mach_vm_behavior_t; +typedef int mach_vm_sync_t; /* * This is called cproc_t in Mach (cthread_t in Darwin). It is a pointer to diff --git a/sys/compat/mach/mach_vm.c b/sys/compat/mach/mach_vm.c index 74ede802ae9..a9f91b07102 100644 --- a/sys/compat/mach/mach_vm.c +++ b/sys/compat/mach/mach_vm.c @@ -1,4 +1,4 @@ -/* $NetBSD: mach_vm.c,v 1.24 2003/01/21 04:06:08 matt Exp $ */ +/* $NetBSD: mach_vm.c,v 1.25 2003/03/03 22:07:40 manu Exp $ */ /*- * Copyright (c) 2002-2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.24 2003/01/21 04:06:08 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.25 2003/03/03 22:07:40 manu Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -90,7 +90,7 @@ mach_vm_map(args) #if 1 /* XXX Darwin fails on mapping a page at address 0 */ if (req->req_address == 0) - return mach_msg_error(args, error); + return mach_msg_error(args, ENOMEM); #endif req->req_size = round_page(req->req_size); @@ -474,7 +474,7 @@ mach_vm_make_memory_entry(args) struct lwp *l = args->l; /* - * XXX Find some documentation wbout what + * XXX Find some documentation about what * this is supposed to do, and implement it. */ printf("pid %d.%d: Unimplemented mach_vm_make_memory_entry\n", @@ -491,3 +491,93 @@ mach_vm_make_memory_entry(args) *msglen = sizeof(*rep); return 0; } + +int +mach_vm_region(args) + struct mach_trap_args *args; +{ + mach_vm_region_request_t *req = args->smsg; + mach_vm_region_reply_t *rep = args->rmsg; + size_t *msglen = args->rsize; + struct lwp *l = args->l; + struct mach_vm_region_basic_info *rbi; + struct vm_map_entry *vme; + + /* + * MACH_VM_REGION_BASIC_INFO is the only + * supported flavor in Darwin. + */ + if (req->req_flavor != MACH_VM_REGION_BASIC_INFO) + return mach_msg_error(args, EINVAL); + if (req->req_count * sizeof(int) < sizeof(*rbi)) + return mach_msg_error(args, EINVAL); + *msglen += ((req->req_count - 9) * sizeof(int)); + + vme = uvm_map_findspace(&l->l_proc->p_vmspace->vm_map, + req->req_addr, 1, (vaddr_t *)&rep->rep_addr, + NULL, 0, 0, UVM_FLAG_FIXED); + if (vme == NULL) + return mach_msg_error(args, ENOMEM); + + rep->rep_msgh.msgh_bits = + MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) | + MACH_MSGH_BITS_COMPLEX; + 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_body.msgh_descriptor_count = 1; + rep->rep_obj.address = (void *)rep->rep_addr; + rep->rep_obj.size = rep->rep_size; + rep->rep_obj.deallocate = 0; + rep->rep_obj.copy = 0; /* XXX */ + rep->rep_obj.type = MACH_MSG_OOL_DESCRIPTOR; + rep->rep_size = (vme->end - vme->start); + rep->rep_count = req->req_count; + + rbi = (struct mach_vm_region_basic_info *)&rep->rep_info[0]; + rbi->protection = vme->protection; + rbi->inheritance = vme->inheritance; + rbi->shared = 0; /* XXX how can we know? */ + rbi->offset = vme->offset; + rbi->behavior = MACH_VM_BEHAVIOR_DEFAULT; /* XXX What is it? */ + rbi->user_wired_count = vme->wired_count; + + rep->rep_info[rep->rep_count + 1] = 8; /* This is the trailer */ + return 0; +} + +int +mach_vm_msync(args) + struct mach_trap_args *args; +{ + mach_vm_msync_request_t *req = args->smsg; + mach_vm_msync_reply_t *rep = args->rmsg; + size_t *msglen = args->rsize; + struct lwp *l = args->l; + struct sys___msync13_args cup; + int error; + register_t dontcare; + + SCARG(&cup, addr) = (void *)req->req_addr; + SCARG(&cup, len) = req->req_size; + SCARG(&cup, flags) = 0; + if (req->req_flags & MACH_VM_SYNC_ASYNCHRONOUS) + SCARG(&cup, flags) |= MS_ASYNC; + if (req->req_flags & MACH_VM_SYNC_SYNCHRONOUS) + SCARG(&cup, flags) |= MS_SYNC; + if (req->req_flags & MACH_VM_SYNC_INVALIDATE) + SCARG(&cup, flags) |= MS_INVALIDATE; + + error = sys___msync13(l, &cup, &dontcare); + + 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 = error; + rep->rep_trailer.msgh_trailer_size = 8; + + *msglen = sizeof(*rep); + return 0; +} diff --git a/sys/compat/mach/mach_vm.h b/sys/compat/mach/mach_vm.h index f2adaa499fb..8e4fed5e4b3 100644 --- a/sys/compat/mach/mach_vm.h +++ b/sys/compat/mach/mach_vm.h @@ -1,4 +1,4 @@ -/* $NetBSD: mach_vm.h,v 1.12 2003/01/04 15:15:01 manu Exp $ */ +/* $NetBSD: mach_vm.h,v 1.13 2003/03/03 22:07:40 manu Exp $ */ /*- * Copyright (c) 2002-2003 The NetBSD Foundation, Inc. @@ -63,6 +63,25 @@ typedef struct mach_sf_mapping { mach_vm_offset_t cksum; } mach_sf_mapping_t; +struct mach_vm_region_basic_info { + mach_vm_prot_t protection; + mach_vm_prot_t max_protection; + mach_vm_inherit_t inheritance; + mach_boolean_t shared; + mach_boolean_t reserved; + mach_vm_offset_t offset; + mach_vm_behavior_t behavior; + unsigned short user_wired_count; +}; + +/* mach_vm_behavior_t values */ +#define MACH_VM_BEHAVIOR_DEFAULT 0 +#define MACH_VM_BEHAVIOR_RANDOM 1 +#define MACH_VM_BEHAVIOR_SEQUENTIAL 2 +#define MACH_VM_BEHAVIOR_RSEQNTL 3 +#define MACH_VM_BEHAVIOR_WILLNEED 4 +#define MACH_VM_BEHAVIOR_DONTNEED 5 + /* vm_map */ #define MACH_VM_INHERIT_SHARE 0 #define MACH_VM_INHERIT_COPY 1 @@ -200,6 +219,50 @@ typedef struct { mach_msg_trailer_t rep_trailer; } mach_vm_make_memory_entry_reply_t; +/* vm_region */ + +#define MACH_VM_REGION_BASIC_INFO 10 +typedef struct { + mach_msg_header_t req_msgh; + mach_ndr_record_t req_ndr; + mach_vm_address_t req_addr; + mach_vm_region_flavor_t req_flavor; + mach_msg_type_number_t req_count; +} mach_vm_region_request_t; + +typedef struct { + mach_msg_header_t rep_msgh; + mach_msg_body_t rep_body; + mach_msg_ool_descriptor_t rep_obj; + mach_ndr_record_t rep_ndr; + mach_msg_type_number_t rep_addr; + mach_vm_size_t rep_size; + mach_msg_type_number_t rep_count; + int rep_info[9]; + mach_msg_trailer_t rep_trailer; +} mach_vm_region_reply_t; + +/* vm_msync */ +#define MACH_VM_SYNC_ASYNCHRONOUS 0x01 +#define MACH_VM_SYNC_SYNCHRONOUS 0x02 +#define MACH_VM_SYNC_INVALIDATE 0x04 +#define MACH_VM_SYNC_KILLPAGES 0x08 +#define MACH_VM_SYNC_DEACTIVATE 0x10 +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_sync_t req_flags; +} mach_vm_msync_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_msync_reply_t; + int mach_vm_map(struct mach_trap_args *); int mach_vm_allocate(struct mach_trap_args *); int mach_vm_deallocate(struct mach_trap_args *); @@ -207,5 +270,7 @@ int mach_vm_wire(struct mach_trap_args *); int mach_vm_protect(struct mach_trap_args *); int mach_vm_inherit(struct mach_trap_args *); int mach_vm_make_memory_entry(struct mach_trap_args *); +int mach_vm_region(struct mach_trap_args *); +int mach_vm_msync(struct mach_trap_args *); #endif /* _MACH_VM_H_ */ |
