Fix #3079 and #9074 Memory allocation beyond 256MB

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Jerome Leveque 2015-02-07 12:34:18 +01:00 committed by Jérôme Duval
parent ffb788fe58
commit 711d2087c3
2 changed files with 13 additions and 13 deletions

View File

@ -2,6 +2,7 @@ SubDir HAIKU_TOP src add-ons kernel drivers audio ice1712 ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateKernelHeaders ;
UsePrivateHeaders media ;
KernelAddon ice1712 :

View File

@ -12,11 +12,13 @@
#include <OS.h>
#include <string.h>
#include <vm/vm.h>
#include <vm/VMAddressSpace.h>
#include "debug.h"
#include "util.h"
static spinlock slock = B_SPINLOCK_INITIALIZER;
static uint32 round_to_pagesize(uint32 size);
cpu_status
lock(void)
@ -35,27 +37,24 @@ unlock(cpu_status status)
}
uint32
round_to_pagesize(uint32 size)
{
return (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
}
area_id
alloc_mem(physical_entry *phy, addr_t *log, size_t size, const char *name)
{
void * logadr;
area_id areaid;
status_t rv;
virtual_address_restrictions virtualRestrictions = {};
virtualRestrictions.address_specification = B_ANY_KERNEL_ADDRESS;
physical_address_restrictions physicalRestrictions = {};
physicalRestrictions.high_address = 1 << 28;
// ICE1712 chipset can not deal with memory area beyond 256MB
ITRACE("Allocating %s: ", name);
size = round_to_pagesize(size);
areaid = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS, size,
B_32_BIT_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
// TODO: The rest of the code doesn't deal correctly with physical
// addresses > 4 GB, so we have to force 32 bit addresses here.
areaid = vm_create_anonymous_area(B_SYSTEM_TEAM, name, size, B_CONTIGUOUS,
B_READ_AREA | B_WRITE_AREA, 0, 0,
&virtualRestrictions, &physicalRestrictions, true, &logadr);
if (areaid < B_OK) {
ITRACE("couldn't allocate\n");
return B_ERROR;