* Renamed GART's deallocate_memory() to free_memory().
* Removed "physical" parameter of GART's bind_aperture() - I don't think this be of use to anyone. * Fixed binding/unbinding pages in the Intel GART driver; I accidently shifted the page offset twice. * Actually forgot handling of allocated memory in Aperture::BindMemory(). * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23796 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -60,13 +60,13 @@ typedef struct agp_gart_module_info {
|
|||||||
status_t (*allocate_memory)(aperture_id id, size_t size,
|
status_t (*allocate_memory)(aperture_id id, size_t size,
|
||||||
size_t alignment, uint32 flags, addr_t *_apertureBase,
|
size_t alignment, uint32 flags, addr_t *_apertureBase,
|
||||||
addr_t *_physicalBase);
|
addr_t *_physicalBase);
|
||||||
status_t (*deallocate_memory)(aperture_id id, addr_t apertureBase);
|
status_t (*free_memory)(aperture_id id, addr_t apertureBase);
|
||||||
status_t (*reserve_aperture)(aperture_id id, size_t size,
|
status_t (*reserve_aperture)(aperture_id id, size_t size,
|
||||||
addr_t *_apertureBase);
|
addr_t *_apertureBase);
|
||||||
status_t (*unreserve_aperture)(aperture_id id, addr_t apertureBase);
|
status_t (*unreserve_aperture)(aperture_id id, addr_t apertureBase);
|
||||||
status_t (*bind_aperture)(aperture_id id, area_id area, addr_t base,
|
status_t (*bind_aperture)(aperture_id id, area_id area, addr_t base,
|
||||||
size_t size, size_t alignment, bool physical,
|
size_t size, size_t alignment, addr_t reservedBase,
|
||||||
addr_t reservedBase, addr_t *_apertureBase);
|
addr_t *_apertureBase);
|
||||||
status_t (*unbind_aperture)(aperture_id id, addr_t apertureBase);
|
status_t (*unbind_aperture)(aperture_id id, addr_t apertureBase);
|
||||||
} agp_gart_module_info;
|
} agp_gart_module_info;
|
||||||
|
|
||||||
|
|||||||
@@ -132,8 +132,7 @@ public:
|
|||||||
status_t AllocateMemory(aperture_memory *memory, uint32 flags);
|
status_t AllocateMemory(aperture_memory *memory, uint32 flags);
|
||||||
|
|
||||||
status_t UnbindMemory(aperture_memory *memory);
|
status_t UnbindMemory(aperture_memory *memory);
|
||||||
status_t BindMemory(aperture_memory *memory, addr_t base, size_t size,
|
status_t BindMemory(aperture_memory *memory, addr_t base, size_t size);
|
||||||
bool physical);
|
|
||||||
|
|
||||||
status_t GetInfo(aperture_info *info);
|
status_t GetInfo(aperture_info *info);
|
||||||
|
|
||||||
@@ -387,6 +386,20 @@ set_pci_mode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
get_area_base_and_size(area_id area, addr_t base, size_t size)
|
||||||
|
{
|
||||||
|
area_info info;
|
||||||
|
status_t status = get_area_info(area, &info);
|
||||||
|
if (status < B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
base = (addr_t)info.address;
|
||||||
|
size = info.size;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Aperture *
|
Aperture *
|
||||||
get_aperture(aperture_id id)
|
get_aperture(aperture_id id)
|
||||||
{
|
{
|
||||||
@@ -568,6 +581,7 @@ Aperture::UnbindMemory(aperture_memory *memory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
addr_t start = base - Base();
|
addr_t start = base - Base();
|
||||||
|
TRACE("unbind %ld bytes at %lx\n", size, start);
|
||||||
|
|
||||||
for (addr_t offset = 0; offset < memory->size; offset += B_PAGE_SIZE) {
|
for (addr_t offset = 0; offset < memory->size; offset += B_PAGE_SIZE) {
|
||||||
status_t status = fModule->unbind_page(fPrivateAperture, start + offset);
|
status_t status = fModule->unbind_page(fPrivateAperture, start + offset);
|
||||||
@@ -582,9 +596,21 @@ Aperture::UnbindMemory(aperture_memory *memory)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Aperture::BindMemory(aperture_memory *memory, addr_t address, size_t size,
|
Aperture::BindMemory(aperture_memory *memory, addr_t address, size_t size)
|
||||||
bool physical)
|
|
||||||
{
|
{
|
||||||
|
bool physical = false;
|
||||||
|
|
||||||
|
if ((memory->flags & ALLOCATED_APERTURE) != 0) {
|
||||||
|
// We allocated this memory, get the base and size from there
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
physical = true;
|
||||||
|
#else
|
||||||
|
status_t status = get_area_base_and_size(memory->area, address, size);
|
||||||
|
if (status < B_OK)
|
||||||
|
return status;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// We don't need to bind reserved memory
|
// We don't need to bind reserved memory
|
||||||
addr_t base = memory->base;
|
addr_t base = memory->base;
|
||||||
int32 offset;
|
int32 offset;
|
||||||
@@ -613,8 +639,18 @@ Aperture::BindMemory(aperture_memory *memory, addr_t address, size_t size,
|
|||||||
return status;
|
return status;
|
||||||
|
|
||||||
physicalAddress = (addr_t)entry.address;
|
physicalAddress = (addr_t)entry.address;
|
||||||
} else
|
} else {
|
||||||
physicalAddress = address + offset;
|
#ifdef __HAIKU__
|
||||||
|
uint32 index = offset >> PAGE_SHIFT;
|
||||||
|
vm_page *page;
|
||||||
|
if ((memory->flags & B_APERTURE_NEED_PHYSICAL) != 0)
|
||||||
|
page = memory->page + index;
|
||||||
|
else
|
||||||
|
page = memory->pages[index];
|
||||||
|
|
||||||
|
physicalAddress = page->physical_page_number << PAGE_SHIFT;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
status = fModule->bind_page(fPrivateAperture, start + offset,
|
status = fModule->bind_page(fPrivateAperture, start + offset,
|
||||||
physicalAddress);
|
physicalAddress);
|
||||||
@@ -971,7 +1007,7 @@ allocate_memory(aperture_id id, size_t size, size_t alignment, uint32 flags,
|
|||||||
|
|
||||||
status_t status = aperture->AllocateMemory(memory, flags);
|
status_t status = aperture->AllocateMemory(memory, flags);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
status = aperture->BindMemory(memory, memory->base, memory->size, false);
|
status = aperture->BindMemory(memory, 0, 0);
|
||||||
if (status < B_OK) {
|
if (status < B_OK) {
|
||||||
aperture->DeleteMemory(memory);
|
aperture->DeleteMemory(memory);
|
||||||
return status;
|
return status;
|
||||||
@@ -998,7 +1034,7 @@ allocate_memory(aperture_id id, size_t size, size_t alignment, uint32 flags,
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
deallocate_memory(aperture_id id, addr_t base)
|
free_memory(aperture_id id, addr_t base)
|
||||||
{
|
{
|
||||||
Aperture *aperture = get_aperture(id);
|
Aperture *aperture = get_aperture(id);
|
||||||
if (aperture == NULL)
|
if (aperture == NULL)
|
||||||
@@ -1038,7 +1074,7 @@ unreserve_aperture(aperture_id id, addr_t apertureBase)
|
|||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
bind_aperture(aperture_id id, area_id area, addr_t base, size_t size,
|
bind_aperture(aperture_id id, area_id area, addr_t base, size_t size,
|
||||||
size_t alignment, bool physical, addr_t reservedBase, addr_t *_apertureBase)
|
size_t alignment, addr_t reservedBase, addr_t *_apertureBase)
|
||||||
{
|
{
|
||||||
Aperture *aperture = get_aperture(id);
|
Aperture *aperture = get_aperture(id);
|
||||||
if (aperture == NULL)
|
if (aperture == NULL)
|
||||||
@@ -1054,15 +1090,9 @@ bind_aperture(aperture_id id, area_id area, addr_t base, size_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (area >= 0) {
|
if (area >= 0) {
|
||||||
// get base and size from area
|
status_t status = get_area_base_and_size(area, base, size);
|
||||||
area_info info;
|
|
||||||
status_t status = get_area_info(area, &info);
|
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
base = (addr_t)info.address;
|
|
||||||
size = info.size;
|
|
||||||
physical = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Autolock _(aperture->Lock());
|
Autolock _(aperture->Lock());
|
||||||
@@ -1082,7 +1112,7 @@ bind_aperture(aperture_id id, area_id area, addr_t base, size_t size,
|
|||||||
|
|
||||||
// just bind the physical pages backing the memory into the GART
|
// just bind the physical pages backing the memory into the GART
|
||||||
|
|
||||||
status_t status = aperture->BindMemory(memory, base, size, physical);
|
status_t status = aperture->BindMemory(memory, base, size);
|
||||||
if (status < B_OK) {
|
if (status < B_OK) {
|
||||||
if (reservedBase < 0)
|
if (reservedBase < 0)
|
||||||
aperture->DeleteMemory(memory);
|
aperture->DeleteMemory(memory);
|
||||||
@@ -1202,7 +1232,7 @@ static struct agp_gart_module_info sAGPModuleInfo = {
|
|||||||
unmap_aperture,
|
unmap_aperture,
|
||||||
get_aperture_info,
|
get_aperture_info,
|
||||||
allocate_memory,
|
allocate_memory,
|
||||||
deallocate_memory,
|
free_memory,
|
||||||
reserve_aperture,
|
reserve_aperture,
|
||||||
unreserve_aperture,
|
unreserve_aperture,
|
||||||
bind_aperture,
|
bind_aperture,
|
||||||
|
|||||||
@@ -222,7 +222,8 @@ intel_map(intel_info &info)
|
|||||||
|
|
||||||
info.gtt_entries = gttSize / 4096;
|
info.gtt_entries = gttSize / 4096;
|
||||||
info.gtt_stolen_entries = stolenSize / 4096;
|
info.gtt_stolen_entries = stolenSize / 4096;
|
||||||
dprintf("GTT base %lx, size %lu, entries %lu, stolen %lu\n", info.gtt_physical_base,
|
|
||||||
|
TRACE("GTT base %lx, size %lu, entries %lu, stolen %lu\n", info.gtt_physical_base,
|
||||||
gttSize, info.gtt_entries, stolenSize);
|
gttSize, info.gtt_entries, stolenSize);
|
||||||
|
|
||||||
int fbIndex = 0;
|
int fbIndex = 0;
|
||||||
@@ -379,7 +380,9 @@ intel_set_aperture_size(void *aperture, size_t size)
|
|||||||
static status_t
|
static status_t
|
||||||
intel_bind_page(void *aperture, uint32 offset, addr_t physicalAddress)
|
intel_bind_page(void *aperture, uint32 offset, addr_t physicalAddress)
|
||||||
{
|
{
|
||||||
set_gtt_entry(sInfo, offset << GTT_PAGE_SHIFT, physicalAddress);
|
TRACE("bind_page(offset %lx, physical %lx)\n", offset, physicalAddress);
|
||||||
|
|
||||||
|
set_gtt_entry(sInfo, offset, physicalAddress);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,8 +390,10 @@ intel_bind_page(void *aperture, uint32 offset, addr_t physicalAddress)
|
|||||||
static status_t
|
static status_t
|
||||||
intel_unbind_page(void *aperture, uint32 offset)
|
intel_unbind_page(void *aperture, uint32 offset)
|
||||||
{
|
{
|
||||||
|
TRACE("unbind_page(offset %lx)\n", offset);
|
||||||
|
|
||||||
if (sInfo.scratch_page != 0)
|
if (sInfo.scratch_page != 0)
|
||||||
set_gtt_entry(sInfo, offset << GTT_PAGE_SHIFT, sInfo.scratch_page);
|
set_gtt_entry(sInfo, offset, sInfo.scratch_page);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user