Fixed broken mmu_allocate_physical():

* Now it checks whether the given physical range exists at all.
* Not only check whether any range of the given size is free, but also check
  whether the given range is free.
* B_BAD_VALUE is not a particularly good return value for a function supposed
  to return a bool

Fixes #5911. With only 64 MB RAM the usual debug syslog buffer location may
be outside the actually existing physical memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36632 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-05-05 21:15:33 +00:00
parent 863c623f9a
commit 8588e7fc6f
1 changed files with 10 additions and 3 deletions

View File

@ -450,11 +450,18 @@ mmu_allocate(void *virtualAddress, size_t size)
bool
mmu_allocate_physical(addr_t base, size_t size)
{
// check whether the physical memory range exists at all
if (!is_address_range_covered(gKernelArgs.physical_memory_range,
gKernelArgs.num_physical_memory_ranges, base, size)) {
return false;
}
// check whether the physical range is still free
addr_t foundBase;
if (!get_free_address_range(gKernelArgs.physical_allocated_range,
gKernelArgs.num_physical_allocated_ranges, sNextPhysicalAddress,
size, &foundBase)) {
return B_BAD_VALUE;
size, &foundBase) || foundBase != base) {
return false;
}
return insert_physical_allocated_range(base, size) == B_OK;
@ -717,7 +724,7 @@ mmu_init(void)
}
} else {
bios_regs regs;
// We dont have an extended map, assume memory is contiguously mapped
// at 0x0, but leave out the BIOS range ((640k - 1 page) to 1 MB).
gKernelArgs.physical_memory_range[0].start = 0;