38 |
vm_offset_t map_offset, address; |
vm_offset_t map_offset, address; |
39 |
bool wired_p; |
bool wired_p; |
40 |
|
|
|
printf ("---\n"); |
|
|
|
|
|
trace_printf ("vm fault at %x in map %p (fault type %s)", offset, |
|
|
map, fault_type == VM_PROT_READ ? "read" : "write"); |
|
41 |
|
|
42 |
/* If we have a fault from user mode we subtract user mode offset. */ |
/* If we have a fault from user mode we subtract user mode offset. */ |
43 |
|
|
51 |
if (kr != KERN_SUCCESS) |
if (kr != KERN_SUCCESS) |
52 |
return kr; |
return kr; |
53 |
|
|
|
trace_printf ("object %p address %x prot %d wired %d", |
|
|
object, address, prot, wired_p); |
|
|
|
|
54 |
page = vm_page_lookup (object, map_offset - address); |
page = vm_page_lookup (object, map_offset - address); |
55 |
|
|
56 |
|
|
76 |
if (page) |
if (page) |
77 |
break; |
break; |
78 |
|
|
|
trace_printf ("src_object %p offset %x", src_object, |
|
|
(map_offset - address) + object->shadow_offset); |
|
|
|
|
79 |
src_object = src_object->shadow_object; |
src_object = src_object->shadow_object; |
80 |
} |
} |
81 |
|
|
89 |
if (page == 0) |
if (page == 0) |
90 |
return KERN_RESOURCE_SHORTAGE; |
return KERN_RESOURCE_SHORTAGE; |
91 |
|
|
|
trace_printf ("alloc inserting page %p into object %p at %x", |
|
|
page, object, map_offset - address); |
|
|
|
|
92 |
/* Insert page into object. */ |
/* Insert page into object. */ |
93 |
|
|
94 |
vm_page_insert (page, object, map_offset - address); |
vm_page_insert (page, object, map_offset - address); |
95 |
} |
} |
96 |
|
|
108 |
|
|
109 |
vm_page_copy (new_page, page); |
vm_page_copy (new_page, page); |
110 |
|
|
|
trace_printf ("alloc inserting page %p into object %p at %x (COW)", |
|
|
new_page, object, map_offset - address); |
|
|
|
|
111 |
/* Insert page into object. */ |
/* Insert page into object. */ |
|
vm_page_insert (new_page, object, map_offset - address); |
|
112 |
|
|
113 |
|
vm_page_insert (new_page, object, map_offset - address); |
114 |
page = new_page; |
page = new_page; |
115 |
} |
} |
116 |
|
|
118 |
the protection for the page to read-only. */ |
the protection for the page to read-only. */ |
119 |
|
|
120 |
else if (fault_type & VM_PROT_READ) |
else if (fault_type & VM_PROT_READ) |
121 |
{ |
prot = VM_PROT_READ; |
|
trace_printf ("lowering protection"); |
|
|
prot = VM_PROT_READ; |
|
|
} |
|
122 |
} |
} |
123 |
|
|
124 |
|
|
131 |
/* ??? implement */ |
/* ??? implement */ |
132 |
} |
} |
133 |
|
|
134 |
|
#if 0 |
135 |
trace_printf ("map page %p (%p) at %x in pmap %p (%s)", |
trace_printf ("map page %p (%p) at %x in pmap %p (%s)", |
136 |
page, page->phys_addr, offset, map->pmap, |
page, page->phys_addr, offset, map->pmap, |
137 |
prot == VM_PROT_READ |
prot == VM_PROT_READ |
138 |
? "read" : prot == VM_PROT_WRITE |
? "read" : prot == VM_PROT_WRITE |
139 |
? "write" : "all"); |
? "write" : "all"); |
140 |
|
#endif |
141 |
|
|
142 |
/* Enter the page into the physical map and return success. */ |
/* Enter the page into the physical map and return success. */ |
143 |
|
|