Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Implement vm_read, vm_write, and a framework for vm_mach...
details: https://anonhg.NetBSD.org/src/rev/b5ff9417e849
branches: trunk
changeset: 555823:b5ff9417e849
user: manu <manu%NetBSD.org@localhost>
date: Sat Nov 29 23:56:08 2003 +0000
description:
Implement vm_read, vm_write, and a framework for vm_machine_attribute.
THe machine dependent bit nees to be written.
diffstat:
sys/arch/powerpc/powerpc/mach_machdep.c | 48 ++++++++-
sys/compat/mach/mach_services.c | 12 +-
sys/compat/mach/mach_services.h | 9 +-
sys/compat/mach/mach_services.master | 8 +-
sys/compat/mach/mach_services_names.c | 12 +-
sys/compat/mach/mach_vm.c | 182 +++++++++++++++++++++++++++++++-
sys/compat/mach/mach_vm.h | 74 ++++++++++++-
7 files changed, 320 insertions(+), 25 deletions(-)
diffs (truncated from 515 to 300 lines):
diff -r 02538e70df5b -r b5ff9417e849 sys/arch/powerpc/powerpc/mach_machdep.c
--- a/sys/arch/powerpc/powerpc/mach_machdep.c Sat Nov 29 22:27:56 2003 +0000
+++ b/sys/arch/powerpc/powerpc/mach_machdep.c Sat Nov 29 23:56:08 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_machdep.c,v 1.17 2003/11/11 18:12:40 manu Exp $ */
+/* $NetBSD: mach_machdep.c,v 1.18 2003/11/29 23:56:09 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_machdep.c,v 1.17 2003/11/11 18:12:40 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_machdep.c,v 1.18 2003/11/29 23:56:09 manu Exp $");
#include "opt_ppcarch.h"
#include <sys/param.h>
@@ -61,6 +61,7 @@
#include <compat/mach/mach_types.h>
#include <compat/mach/mach_host.h>
#include <compat/mach/mach_thread.h>
+#include <compat/mach/mach_vm.h>
#include <machine/cpu.h>
#include <machine/psl.h>
@@ -226,3 +227,46 @@
return 0;
}
+
+int
+mach_vm_machine_attribute_machdep(l, addr, size, valp)
+ struct lwp *l;
+ vaddr_t addr;
+ size_t size;
+ int *valp;
+{
+ int error = 0;
+
+ switch (*valp) {
+ case MACH_MATTR_VAL_CACHE_FLUSH:
+#ifdef DEBUG_MACH
+ printf("MACH_MATTR_VAL_CACHE_FLUSH\n");
+#endif
+ break;
+
+ case MACH_MATTR_VAL_DCACHE_FLUSH:
+#ifdef DEBUG_MACH
+ printf("MACH_MATTR_VAL_DCACHE_FLUSH\n");
+#endif
+ break;
+
+ case MACH_MATTR_VAL_ICACHE_FLUSH:
+#ifdef DEBUG_MACH
+ printf("MACH_MATTR_VAL_ICACHE_FLUSH\n");
+#endif
+ break;
+
+ case MACH_MATTR_VAL_CACHE_SYNC:
+#ifdef DEBUG_MACH
+ printf("MACH_MATTR_VAL_CACHE_SYNC\n");
+#endif
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+
+ return error;
+}
+
diff -r 02538e70df5b -r b5ff9417e849 sys/compat/mach/mach_services.c
--- a/sys/compat/mach/mach_services.c Sat Nov 29 22:27:56 2003 +0000
+++ b/sys/compat/mach/mach_services.c Sat Nov 29 23:56:08 2003 +0000
@@ -1,14 +1,14 @@
-/* $NetBSD: mach_services.c,v 1.7 2003/11/18 01:40:18 manu Exp $ */
+/* $NetBSD: mach_services.c,v 1.8 2003/11/29 23:56:08 manu Exp $ */
/*
* Mach services table.
*
* DO NOT EDIT -- this file is automatically generated.
- * created from $NetBSD: mach_services.c,v 1.7 2003/11/18 01:40:18 manu Exp $
+ * created from $NetBSD: mach_services.c,v 1.8 2003/11/29 23:56:08 manu Exp $
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_services.c,v 1.7 2003/11/18 01:40:18 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_services.c,v 1.8 2003/11/29 23:56:08 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -279,15 +279,15 @@
{3802, mach_vm_deallocate, "vm_deallocate", sizeof(mach_vm_deallocate_request_t), sizeof(mach_vm_deallocate_reply_t)},
{3803, mach_vm_protect, "vm_protect", sizeof(mach_vm_protect_request_t), sizeof(mach_vm_protect_reply_t)},
{3804, mach_vm_inherit, "vm_inherit", sizeof(mach_vm_inherit_request_t), sizeof(mach_vm_inherit_reply_t)},
- {3805, NULL, "unimpl. vm_read", 0, 0},
+ {3805, mach_vm_read, "vm_read", sizeof(mach_vm_read_request_t), sizeof(mach_vm_read_reply_t)},
{3806, NULL, "unimpl. vm_read_list", 0, 0},
- {3807, NULL, "unimpl. vm_write", 0, 0},
+ {3807, mach_vm_write, "vm_write", sizeof(mach_vm_write_request_t), sizeof(mach_vm_write_reply_t)},
{3808, mach_vm_copy, "vm_copy", sizeof(mach_vm_copy_request_t), sizeof(mach_vm_copy_reply_t)},
{3809, NULL, "unimpl. vm_read_overwrite", 0, 0},
{3810, mach_vm_msync, "vm_msync", sizeof(mach_vm_msync_request_t), sizeof(mach_vm_msync_reply_t)},
{3811, NULL, "unimpl. vm_behavior_set", 0, 0},
{3812, mach_vm_map, "vm_map", sizeof(mach_vm_map_request_t), sizeof(mach_vm_map_reply_t)},
- {3813, NULL, "unimpl. vm_machine_attribute", 0, 0},
+ {3813, mach_vm_machine_attribute, "vm_machine_attribute", sizeof(mach_vm_machine_attribute_request_t), sizeof(mach_vm_machine_attribute_reply_t)},
{3814, NULL, "unimpl. vm_remap", 0, 0},
{3815, NULL, "unimpl. task_wire", 0, 0},
{3816, NULL, "unimpl. make_memory_entry", 0, 0},
diff -r 02538e70df5b -r b5ff9417e849 sys/compat/mach/mach_services.h
--- a/sys/compat/mach/mach_services.h Sat Nov 29 22:27:56 2003 +0000
+++ b/sys/compat/mach/mach_services.h Sat Nov 29 23:56:08 2003 +0000
@@ -1,15 +1,15 @@
-/* $NetBSD: mach_services.h,v 1.7 2003/11/18 01:40:18 manu Exp $ */
+/* $NetBSD: mach_services.h,v 1.8 2003/11/29 23:56:08 manu Exp $ */
/*
* Mach services prototypes.
*
* DO NOT EDIT -- this file is automatically generated.
* DO NOT EDIT -- this file is automatically generated.
- * created from $NetBSD: mach_services.h,v 1.7 2003/11/18 01:40:18 manu Exp $
+ * created from $NetBSD: mach_services.h,v 1.8 2003/11/29 23:56:08 manu Exp $
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_services.h,v 1.7 2003/11/18 01:40:18 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_services.h,v 1.8 2003/11/29 23:56:08 manu Exp $");
#include <compat/mach/mach_types.h>
#include <compat/mach/mach_message.h>
@@ -81,8 +81,11 @@
int mach_vm_deallocate(struct mach_trap_args *);
int mach_vm_protect(struct mach_trap_args *);
int mach_vm_inherit(struct mach_trap_args *);
+int mach_vm_read(struct mach_trap_args *);
+int mach_vm_write(struct mach_trap_args *);
int mach_vm_copy(struct mach_trap_args *);
int mach_vm_msync(struct mach_trap_args *);
int mach_vm_map(struct mach_trap_args *);
+int mach_vm_machine_attribute(struct mach_trap_args *);
int mach_vm_region_64(struct mach_trap_args *);
int mach_make_memory_entry_64(struct mach_trap_args *);
diff -r 02538e70df5b -r b5ff9417e849 sys/compat/mach/mach_services.master
--- a/sys/compat/mach/mach_services.master Sat Nov 29 22:27:56 2003 +0000
+++ b/sys/compat/mach/mach_services.master Sat Nov 29 23:56:08 2003 +0000
@@ -1,4 +1,4 @@
- $NetBSD: mach_services.master,v 1.5 2003/11/18 01:40:18 manu Exp $
+ $NetBSD: mach_services.master,v 1.6 2003/11/29 23:56:08 manu Exp $
;
; Mach services list.
;
@@ -361,15 +361,15 @@
3802 STD vm_deallocate
3803 STD vm_protect
3804 STD vm_inherit
-3805 UNIMPL vm_read
+3805 STD vm_read
3806 UNIMPL vm_read_list
-3807 UNIMPL vm_write
+3807 STD vm_write
3808 STD vm_copy
3809 UNIMPL vm_read_overwrite
3810 STD vm_msync
3811 UNIMPL vm_behavior_set
3812 STD vm_map
-3813 UNIMPL vm_machine_attribute
+3813 STD vm_machine_attribute
3814 UNIMPL vm_remap
3815 UNIMPL task_wire
3816 UNIMPL make_memory_entry
diff -r 02538e70df5b -r b5ff9417e849 sys/compat/mach/mach_services_names.c
--- a/sys/compat/mach/mach_services_names.c Sat Nov 29 22:27:56 2003 +0000
+++ b/sys/compat/mach/mach_services_names.c Sat Nov 29 23:56:08 2003 +0000
@@ -1,14 +1,14 @@
-/* $NetBSD: mach_services_names.c,v 1.4 2003/11/18 01:40:18 manu Exp $ */
+/* $NetBSD: mach_services_names.c,v 1.5 2003/11/29 23:56:08 manu Exp $ */
/*
* Mach services names. This file is not built
* by the kernel, it is included by kdump sources.
*
- * created from $NetBSD: mach_services_names.c,v 1.4 2003/11/18 01:40:18 manu Exp $
+ * created from $NetBSD: mach_services_names.c,v 1.5 2003/11/29 23:56:08 manu Exp $
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_services_names.c,v 1.4 2003/11/18 01:40:18 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_services_names.c,v 1.5 2003/11/29 23:56:08 manu Exp $");
struct mach_service_name {
int srv_id;
@@ -268,15 +268,15 @@
{3802, "vm_deallocate"},
{3803, "vm_protect"},
{3804, "vm_inherit"},
- {3805, "unimpl. vm_read"},
+ {3805, "vm_read"},
{3806, "unimpl. vm_read_list"},
- {3807, "unimpl. vm_write"},
+ {3807, "vm_write"},
{3808, "vm_copy"},
{3809, "unimpl. vm_read_overwrite"},
{3810, "vm_msync"},
{3811, "unimpl. vm_behavior_set"},
{3812, "vm_map"},
- {3813, "unimpl. vm_machine_attribute"},
+ {3813, "vm_machine_attribute"},
{3814, "unimpl. vm_remap"},
{3815, "unimpl. task_wire"},
{3816, "unimpl. make_memory_entry"},
diff -r 02538e70df5b -r b5ff9417e849 sys/compat/mach/mach_vm.c
--- a/sys/compat/mach/mach_vm.c Sat Nov 29 22:27:56 2003 +0000
+++ b/sys/compat/mach/mach_vm.c Sat Nov 29 23:56:08 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_vm.c,v 1.39 2003/11/28 08:03:14 manu Exp $ */
+/* $NetBSD: mach_vm.c,v 1.40 2003/11/29 23:56:08 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.39 2003/11/28 08:03:14 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.40 2003/11/29 23:56:08 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -575,7 +575,8 @@
rep->rep_obj.copy = 0;
rep->rep_obj.pad1 = 0x11;
rep->rep_obj.type = 0;
- rep->rep_size = PAGE_SIZE; /* XXX Why? */
+ rep->rep_addr = vme->start;
+ rep->rep_size = vme->end - vme->start;
rep->rep_count = req->req_count;
rbi = (struct mach_vm_region_basic_info *)&rep->rep_info[0];
@@ -746,3 +747,178 @@
*msglen = sizeof(*rep);
return 0;
}
+
+int
+mach_vm_read(args)
+ struct mach_trap_args *args;
+{
+ mach_vm_read_request_t *req = args->smsg;
+ mach_vm_read_reply_t *rep = args->rmsg;
+ size_t *msglen = args->rsize;
+ struct lwp *l = args->l;
+ struct lwp *tl = args->tl;
+ char *buf;
+ void *addr;
+ vaddr_t va;
+ size_t size;
+ int error;
+
+ size = req->req_size;
+ va = vm_map_min(&l->l_proc->p_vmspace->vm_map);
+ if ((error = uvm_map(&l->l_proc->p_vmspace->vm_map, &va,
+ round_page(size), NULL, UVM_UNKNOWN_OFFSET, 0,
+ UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_ALL,
+ UVM_INH_COPY, UVM_ADV_NORMAL, UVM_FLAG_COPYONW))) != 0) {
+ printf("uvm_map error = %d\n", error);
+ return mach_msg_error(args, EFAULT);
+ }
+
+ /*
+ * Copy the data from the target process to the current process
+ * This is reasonnable for small chunk of data, but we should
+ * remap COW for areas bigger than a page.
+ */
+ buf = malloc(size, M_EMULDATA, M_WAITOK);
+
+ addr = (void *)req->req_addr;
+ if ((error = copyin_proc(tl->l_proc, addr, buf, size)) != 0) {
+ printf("copyin_proc error = %d, addr = %p, size = %x\n", error, addr, size);
+ free(buf, M_WAITOK);
+ return mach_msg_error(args, EFAULT);
+ }
+
+ if ((error = copyout(buf, (void *)va, size)) != 0) {
+ printf("copyout error = %d\n", error);
+ free(buf, M_WAITOK);
+ return mach_msg_error(args, EFAULT);
+ }
+
+ free(buf, M_WAITOK);
+
+ 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;
Home |
Main Index |
Thread Index |
Old Index