Actually aligning physical alloc requests.

This commit is contained in:
Ben Vanik 2013-10-19 18:18:19 -07:00
parent 49ee9d05b9
commit b8edeba195
3 changed files with 5 additions and 4 deletions

View File

@ -199,7 +199,7 @@ uint32_t xe_memory_search_aligned(xe_memory_ref memory, size_t start,
uint32_t xe_memory_heap_alloc(
xe_memory_ref memory, uint32_t base_address, uint32_t size,
uint32_t flags) {
uint32_t flags, uint32_t alignment) {
XEASSERT(flags == 0);
// If we were given a base address we are outside of the normal heap and
@ -207,7 +207,7 @@ uint32_t xe_memory_heap_alloc(
if (!base_address) {
// Normal allocation from the managed heap.
XEIGNORE(xe_mutex_lock(memory->heap_mutex));
uint8_t* p = (uint8_t*)mspace_malloc(memory->heap, size);
uint8_t* p = (uint8_t*)mspace_memalign(memory->heap, alignment, size);
XEIGNORE(xe_mutex_unlock(memory->heap_mutex));
if (!p) {
return 0;

View File

@ -51,7 +51,8 @@ enum {
};
uint32_t xe_memory_heap_alloc(xe_memory_ref memory, uint32_t base_address,
uint32_t size, uint32_t flags);
uint32_t size, uint32_t flags,
uint32_t alignment = 0x20);
int xe_memory_heap_free(xe_memory_ref memory, uint32_t addr, uint32_t size);
bool xe_memory_is_valid(xe_memory_ref memory, uint32_t address);

View File

@ -234,7 +234,7 @@ uint32_t xeMmAllocatePhysicalMemoryEx(
// Allocate.
uint32_t flags = 0;
uint32_t base_address = xe_memory_heap_alloc(
state->memory(), 0, adjusted_size, flags);
state->memory(), 0, adjusted_size, flags, alignment);
if (!base_address) {
// Failed - assume no memory available.
return 0;