42 |
uintptr_t ip, addr; |
uintptr_t ip, addr; |
43 |
struct map *map; |
struct map *map; |
44 |
uintptr_t store_offset; |
uintptr_t store_offset; |
45 |
struct frame *frame; |
struct hurd_memory *memory; |
46 |
|
|
47 |
/* Enter an infinite loop waiting for page faults. */ |
/* Enter an infinite loop waiting for page faults. */ |
48 |
for (;;) |
for (;;) |
71 |
sender, addr, ip, access); |
sender, addr, ip, access); |
72 |
#endif |
#endif |
73 |
|
|
|
/* Round address down to the nearest base page address. */ |
|
|
addr &= ~(getpagesize () - 1); |
|
|
|
|
74 |
/* Find the mapping on which the region faulted. */ |
/* Find the mapping on which the region faulted. */ |
75 |
map = map_find (addr, 1); |
map = map_find_first (addr, 1); |
76 |
if (EXPECT_FALSE (! map)) |
if (EXPECT_FALSE (! map)) |
77 |
/* XXX: Segmentation fault. */ |
/* XXX: Segmentation fault. */ |
78 |
panic ("Virtual address %x is unmapped. Cannot handle fault! " |
panic ("Virtual address %x is unmapped. Cannot handle fault! " |
80 |
|
|
81 |
assert (map->store); |
assert (map->store); |
82 |
|
|
83 |
store_offset = addr - map->vm.start + map->store_offset; |
store_offset = map->store_offset + addr - map->vm.start; |
84 |
|
|
85 |
/* The mapping might be cached in physical memory but not |
/* The mapping might be cached in physical memory but not |
86 |
properly mapped. */ |
properly mapped. */ |
87 |
frame = frame_find_first (map->store, store_offset, 1); |
for (;;) |
|
if (! frame) |
|
|
/* It isn't. We need to page the data in to physical memory |
|
|
(or, in the case of anonymous memory, allocate physical |
|
|
memory to cover the region). */ |
|
88 |
{ |
{ |
89 |
if (map->store == &swap_store) |
memory = hurd_store_find_cached (map->store, store_offset, 1); |
90 |
{ |
if (memory) |
91 |
/* XXX: Until we have a real swap server we (correctly) |
break; |
92 |
assume that if there is no frame then memory has just |
|
93 |
not yet been allocated (i.e. it is not just paged |
/* It isn't. We need to page the data in to physical memory |
94 |
out). */ |
(or, in the case of anonymous memory, allocate physical |
95 |
frame = frame_alloc (getpagesize ()); |
memory to cover the region). */ |
96 |
if (! frame) |
map->store->fault (map->store, map->store->hook, sender, |
97 |
panic ("frame_alloc failed."); |
map->vm, store_offset, |
98 |
|
addr, access); |
|
frame_insert (map->store, store_offset, frame); |
|
|
} |
|
|
else |
|
|
panic ("Unallocated non-swap memory?!"); |
|
99 |
} |
} |
100 |
|
|
101 |
err = frame_map (frame, 0, frame->store.size, |
err = hurd_memory_map (memory, 0, memory->store.size, |
102 |
map->vm.start + frame->store.start - map->store_offset); |
map->vm.start); |
103 |
assert_perror (err); |
assert_perror (err); |
104 |
} |
} |
105 |
|
|