sparc mmu: fix free physical range search
The code was ignoring most of the memory and eventually didn't find enough of it to load all kernel modules. Change-Id: I8abcb6cd20eb2a37147d720eb63af1c2820628f3 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3576 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
19024bc416
commit
75c2a94a87
@ -299,8 +299,7 @@ find_physical_memory_range(size_t size)
|
||||
static void *
|
||||
find_free_physical_range(size_t size)
|
||||
{
|
||||
// just do a simple linear search at the end of the allocated
|
||||
// ranges (dumb memory allocation)
|
||||
// If nothing is allocated, just return the first address in RAM
|
||||
if (gKernelArgs.num_physical_allocated_ranges == 0) {
|
||||
if (gKernelArgs.num_physical_memory_ranges == 0)
|
||||
return PHYSINVAL;
|
||||
@ -308,6 +307,7 @@ find_free_physical_range(size_t size)
|
||||
return find_physical_memory_range(size);
|
||||
}
|
||||
|
||||
// Try to find space after an already allocated range
|
||||
for (uint32 i = 0; i < gKernelArgs.num_physical_allocated_ranges; i++) {
|
||||
void *address
|
||||
= (void *)(addr_t)(gKernelArgs.physical_allocated_range[i].start
|
||||
@ -317,6 +317,20 @@ find_free_physical_range(size_t size)
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there is enough space at the start of one of the physical ranges
|
||||
// (that memory isn't after an already allocated range so it wouldn't be
|
||||
// found by the method above for ranges where there isn't already an initial
|
||||
// allocation at the start)
|
||||
for (uint32 i = 0; i < gKernelArgs.num_physical_memory_ranges; i++) {
|
||||
void *address = (void *)gKernelArgs.physical_memory_range[i].start;
|
||||
if (gKernelArgs.physical_memory_range[i].size > size
|
||||
&& !is_physical_allocated(address, size)) {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
||||
// We're really out of memory
|
||||
return PHYSINVAL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user