Changed radeons memory manager to use areas instead of malloc. Now the radeon.driver should work without hacking the kernel heap bigger.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12134 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2005-03-29 21:09:05 +00:00
parent d19337ad86
commit bccfa80b9b
3 changed files with 31 additions and 11 deletions

View File

@ -26,6 +26,7 @@ typedef struct mem_block {
// memory heap
typedef struct mem_info {
mem_block *first;
area_id heap_area;
uint32 block_size;
sem_id lock;
mem_block *heap;

View File

@ -47,6 +47,7 @@ mem_info *mem_init( uint32 start, uint32 len, uint32 block_size, uint32 heap_ent
mem_block *first;
mem_info *mem;
uint i;
uint32 size;
SHOW_FLOW( 2, "start=%lx, len=%lx, block_size=%lx, heap_entries=%ld",
start, len, block_size, heap_entries );
@ -61,13 +62,21 @@ mem_info *mem_init( uint32 start, uint32 len, uint32 block_size, uint32 heap_ent
if( mem->lock < 0 )
goto err2;
mem->heap = malloc( heap_entries * sizeof( mem_block ));
if( mem->heap == NULL )
// align size to B_PAGE_SIZE
size = heap_entries * sizeof(mem_block);
if ((size / B_PAGE_SIZE) * B_PAGE_SIZE != size)
size = ((size / B_PAGE_SIZE) + 1) * B_PAGE_SIZE;
mem->heap_area = create_area("memmgr_heap_area", (void **)&mem->heap,
B_ANY_ADDRESS, size, B_FULL_LOCK,
B_READ_AREA | B_WRITE_AREA);
if (mem->heap_area < 0 || mem->heap == NULL)
goto err3;
for( i = 1; i < heap_entries; ++i )
mem->heap[i].next = &mem->heap[i+1];
mem->heap[i-1].next = &mem->heap[i];
mem->heap[heap_entries - 1].next = NULL;
mem->unused = &mem->heap[1];
@ -96,9 +105,9 @@ void mem_destroy( mem_info *mem )
{
SHOW_FLOW0( 2, "" );
free( mem->heap );
delete_sem( mem->lock );
free( mem );
delete_area(mem->heap_area);
delete_sem(mem->lock);
free(mem);
}

View File

@ -124,10 +124,12 @@ static status_t createGARTBuffer( GART_info *gart, size_t size )
// init GATT (could be used for both PCI and AGP)
static status_t initGATT( GART_info *gart )
{
area_id map_area;
uint32 map_area_size;
physical_entry *map;
physical_entry PTB_map[1];
size_t map_count;
int i;
uint32 i;
uint32 *gatt_entry;
size_t num_pages;
@ -157,7 +159,15 @@ static status_t initGATT( GART_info *gart )
memset( gart->GATT.ptr, 0, num_pages * sizeof( uint32 ));
map_count = num_pages + 1;
map = malloc( map_count * sizeof( physical_entry ) );
// align size to B_PAGE_SIZE
map_area_size = map_count * sizeof(physical_entry);
if ((map_area_size / B_PAGE_SIZE) * B_PAGE_SIZE != map_area_size)
map_area_size = ((map_area_size / B_PAGE_SIZE) + 1) * B_PAGE_SIZE;
// temporary area where we fill in the memory map (deleted below)
map_area = create_area("pci_gart_map_area", (void **)&map, B_ANY_ADDRESS, map_area_size, B_FULL_LOCK, B_READ_AREA | B_WRITE_AREA);
dprintf("pci_gart_map_area: %d\n", map_area);
get_memory_map( gart->buffer.ptr, gart->buffer.size, map, map_count );
@ -180,7 +190,7 @@ static status_t initGATT( GART_info *gart )
}
}
free( map );
delete_area(map_area);
if( i == map_count ) {
// this case should never happen