1 |
/* VM address spaces. |
/* VM address spaces. |
2 |
Copyright 1999, 2000, 2001 Johan Rydberg, jrydberg@opencores.org. |
Copyright 1999, 2000, 2001, 2002 Johan Rydberg, jrydberg@opencores.org. |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
148 |
return new_entry; |
return new_entry; |
149 |
} |
} |
150 |
|
|
151 |
|
/* Conveneince function for scanning MAP for a entry that is |
152 |
|
located at OFFSET. If found, it's returned - otherwise NULL. */ |
153 |
|
|
154 |
|
static inline struct vm_map_entry * |
155 |
|
lookup_entry_in_map (struct vm_map *map, vm_address_t offset) |
156 |
|
{ |
157 |
|
struct vm_map_entry *entry; |
158 |
|
|
159 |
|
entry = vm_map_entry_first (map); |
160 |
|
while (entry) |
161 |
|
{ |
162 |
|
if ((offset >= entry->start) && (offset < entry->end)) |
163 |
|
return entry; |
164 |
|
|
165 |
|
entry = vm_map_entry_next (map, entry); |
166 |
|
} |
167 |
|
return 0; |
168 |
|
} |
169 |
|
|
170 |
/* Initialize the VM map part of the VM system. */ |
/* Initialize the VM map part of the VM system. */ |
171 |
|
|
172 |
void |
void |
405 |
|
|
406 |
vm_map_lock (map); |
vm_map_lock (map); |
407 |
|
|
408 |
|
/* Check so that we the entry in the map is already allocated. */ |
409 |
|
if (lookup_entry_in_map (map, offset) |
410 |
|
|| lookup_entry_in_map (map, vm_trunc_page ((offset + size - 1)))) |
411 |
|
{ |
412 |
|
vm_map_unlock (map); |
413 |
|
return KERN_NO_SPACE; |
414 |
|
} |
415 |
|
|
416 |
search_entry = (struct vm_map_entry *) vm_map_entry_first (map); |
search_entry = (struct vm_map_entry *) vm_map_entry_first (map); |
417 |
|
|
418 |
start_address = offset; |
start_address = offset; |
554 |
return KERN_SUCCESS; |
return KERN_SUCCESS; |
555 |
} |
} |
556 |
|
|
|
/* Conveneince function for scanning MAP for a entry that is |
|
|
located at OFFSET. If found, it's returned - otherwise NULL. */ |
|
|
|
|
|
static inline struct vm_map_entry * |
|
|
lookup_entry_in_map (struct vm_map *map, vm_address_t offset) |
|
|
{ |
|
|
struct vm_map_entry *entry; |
|
|
|
|
|
entry = vm_map_entry_first (map); |
|
|
while (entry) |
|
|
{ |
|
|
if ((offset >= entry->start) && (offset < entry->end)) |
|
|
return entry; |
|
|
|
|
|
entry = vm_map_entry_next (map, entry); |
|
|
} |
|
|
return 0; |
|
|
} |
|
|
|
|
|
|
|
557 |
|
|
558 |
/* Function searches for a entry located at OFFSET in MAP. If found, |
/* Function searches for a entry located at OFFSET in MAP. If found, |
559 |
information about it is returned in OBJECTP, ADDRESSP, PROTP and |
information about it is returned in OBJECTP, ADDRESSP, PROTP and |