22 |
#include "vm-pager.h" |
#include "vm-pager.h" |
23 |
#include "vm-object.h" |
#include "vm-object.h" |
24 |
#include "ipc-port.h" |
#include "ipc-port.h" |
25 |
|
#include "thread.h" |
26 |
|
#include "trace.h" |
27 |
|
|
28 |
/* Someone is requesting page at OFFSET in object COOKIE, from our PAGER. |
/* Someone is requesting page at OFFSET in object COOKIE, from our PAGER. |
29 |
since we are providing physical memory, COOKIE is the physical address. */ |
since we are providing physical memory, COOKIE is the physical address. */ |
|
|
|
30 |
static kern_return_t |
static kern_return_t |
31 |
host_page_request (struct vm_pager *pager, void *cookie, vm_offset_t offset, |
host_pager_request (void *cookie, struct vm_object *object, |
32 |
vm_prot_t desired_access, struct vm_page **pagep) |
vm_offset_t offset, vm_prot_t desired_access, |
33 |
|
struct vm_page *page) |
34 |
{ |
{ |
35 |
vm_offset_t pa = ((vm_offset_t) cookie) + offset; |
page->absent_p = 0; |
36 |
|
vm_page_assign (page, offset); |
37 |
/* We allocate a fictitious page and assign (PA + OFFSET) to it. */ |
VM_PAGE_WAKEUP_DONE (page); |
|
*pagep = vm_page_fictitious_allocate (); |
|
|
if (! *pagep) |
|
|
return KERN_RESOURCE_SHORTAGE; |
|
|
vm_page_assign (*pagep, pa); |
|
|
|
|
38 |
return KERN_SUCCESS; |
return KERN_SUCCESS; |
39 |
} |
} |
40 |
|
|
41 |
/* Initialize host pager on OBJECT. PHYS_ADDR is the physical address |
/* Initialize host pager on OBJECT. PHYS_ADDR is the physical address |
42 |
that the object should map into memory. */ |
that the object should map into memory. */ |
43 |
|
/* Initialize new object OBJECT. Pager is provided through COOKIE. */ |
44 |
kern_return_t |
kern_return_t |
45 |
host_pager_init_object (struct vm_object *object, vm_offset_t phys_addr) |
host_pager_init_object (void *cookie, struct vm_object *object) |
46 |
{ |
{ |
47 |
object->pager_cookie = (void *) phys_addr; |
object->pager_created_p = 1; |
48 |
object->pager_object = & pager_host; |
object->pager_ready_p = 1; |
49 |
object->object_port = ipc_port_create_kernel (); |
return KERN_SUCCESS; |
50 |
ipc_port_set_kobject (object->object_port, |
} |
|
IPC_KOBJECT_TYPE_MEMORY_OBJECT, object); |
|
51 |
|
|
52 |
|
kern_return_t |
53 |
|
host_pager_write_data (void *cookie, struct vm_object *old_object, |
54 |
|
vm_offset_t offset, struct vm_object *object, |
55 |
|
vm_size_t size, int dirty_p, int kernel_copy_p) |
56 |
|
{ |
57 |
|
panic ("host pager write data"); |
58 |
return KERN_SUCCESS; |
return KERN_SUCCESS; |
59 |
} |
} |
60 |
|
|
62 |
|
|
63 |
struct vm_pager pager_host = |
struct vm_pager pager_host = |
64 |
{ |
{ |
65 |
host_page_request, |
host_pager_request, |
66 |
0 |
host_pager_init_object, |
67 |
|
host_pager_write_data |
68 |
}; |
}; |