home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.mach
- Path: sparky!uunet!mcsun!sun4nl!utrcu1!infnews!infnews!matena
- From: matena@cs.utwente.nl (Wim Matena)
- Subject: wiring down memory
- Message-ID: <1992Aug18.161726@cs.utwente.nl>
- Keywords: privileged host port
- Sender: usenet@cs.utwente.nl
- Nntp-Posting-Host: eufraat
- Organization: University of Twente, Dept. of Computer Science
- Date: Tue, 18 Aug 1992 14:17:26 GMT
- Lines: 43
-
- Dear reader,
-
- In our attempts to allocate a piece of user-space memory that can be WIRED DOWN
- we have stumbled upon the 'task_by_pid(-1)' system call of the BSD server.
- This call returns the much needed 'privileged_host_port'. However, the
- vm_wire system call still doesn't work properly. It returns the well known
- 'KERN_FAILURE' error message. Could anyone help us out here?
- Our test program follows below. Any other solutions to wiring down a piece of
- memory are also VERY welcome!
-
- Thanks in advance...
-
- Wim & Kees
-
-
-
- #include <mach.h>
- #include <stdio.h>
- #include <mach_error.h>
- #include <mach/message.h>
-
- void main() {
- mach_port_t host_priv_port;
- kern_return_t kr;
- int *ptr;
-
- host_priv_port = task_by_pid(-1);
- printf("host_priv_port = 0x%X\n", host_priv_port);
- if (vm_allocate(mach_task_self(), &ptr, 4096, TRUE) !=
- KERN_SUCCESS) {
- printf("vm_allocate failed \n");
- }
- if (vm_protect(mach_task_self(), ptr, 4096, TRUE, VM_PROT_ALL) != KERN_SUCCESS) {
- printf("vm_protect failed\n");
- }
- if ((kr=vm_wire(host_priv_port, mach_task_self(), ptr, 4096, VM_PROT_ALL))
- != KERN_SUCCESS) {
- mach_error("vm_wire failed", kr);
- }
- }
-
-
-
-