Use the correct type for physical addresses.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37219 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-06-21 23:22:19 +00:00
parent 6a76b51960
commit 3553f1894d
4 changed files with 22 additions and 18 deletions

View File

@ -105,11 +105,12 @@ AHCIController::Init()
return B_ERROR;
}
void *addr = (void *)pciInfo.u.h0.base_registers[5];
phys_addr_t addr = pciInfo.u.h0.base_registers[5];
size_t size = pciInfo.u.h0.base_register_sizes[5];
TRACE("registers at %p, size %#lx\n", addr, size);
if (!addr) {
TRACE("registers at %#" B_PRIxPHYSADDR ", size %#" B_PRIxSIZE "\n", addr,
size);
if (addr == 0) {
TRACE("PCI base address register 5 not assigned\n");
return B_ERROR;
}

View File

@ -75,9 +75,9 @@ AHCIPort::Init1()
+ sizeof(prd) * PRD_TABLE_ENTRY_COUNT;
char *virtAddr;
char *physAddr;
phys_addr_t physAddr;
fArea = alloc_mem((void **)&virtAddr, (void **)&physAddr, size, 0,
fArea = alloc_mem((void **)&virtAddr, &physAddr, size, 0,
"some AHCI port");
if (fArea < B_OK) {
TRACE("failed allocating memory for port %d\n", fIndex);

View File

@ -22,10 +22,9 @@ round_to_pagesize(uint32 size)
area_id
alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
alloc_mem(void **virt, phys_addr_t *phy, size_t size, uint32 protection,
const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * virtadr;
area_id areaid;
@ -49,7 +48,7 @@ alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
if (virt)
*virt = virtadr;
if (phy)
*phy = (void*)(addr_t)pe.address;
*phy = pe.address;
TRACE("area = %ld, size = %ld, virt = %p, phy = %#" B_PRIxPHYSADDR "\n",
areaid, size, virtadr, pe.address);
return areaid;
@ -57,20 +56,21 @@ alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
area_id
map_mem(void **virt, void *phy, size_t size, uint32 protection,
map_mem(void **virt, phys_addr_t phy, size_t size, uint32 protection,
const char *name)
{
uint32 offset;
void *phyadr;
phys_addr_t phyadr;
void *mapadr;
area_id area;
TRACE("mapping physical address %p with %ld bytes for %s\n", phy, size, name);
TRACE("mapping physical address %#" B_PRIxPHYSADDR " with %" B_PRIuSIZE
" bytes for %s\n", phy, size, name);
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (char *)phy - offset;
offset = phy & (B_PAGE_SIZE - 1);
phyadr = phy - offset;
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, (addr_t)phyadr, size,
area = map_physical_memory(name, phyadr, size,
B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr);
if (area < B_OK) {
ERROR("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area));
@ -79,8 +79,9 @@ map_mem(void **virt, void *phy, size_t size, uint32 protection,
*virt = (char *)mapadr + offset;
TRACE("physical = %p, virtual = %p, offset = %ld, phyadr = %p, mapadr = %p, size = %ld, area = 0x%08lx\n",
phy, *virt, offset, phyadr, mapadr, size, area);
TRACE("physical = %#" B_PRIxPHYSADDR ", virtual = %p, offset = %ld, "
"phyadr = %#" B_PRIxPHYSADDR ", mapadr = %p, size = %ld, area = "
"0x%08lx\n", phy, *virt, offset, phyadr, mapadr, size, area);
return area;
}

View File

@ -11,8 +11,10 @@
extern "C" {
#endif
area_id alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name);
area_id map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name);
area_id alloc_mem(void **virt, phys_addr_t *phy, size_t size, uint32 protection,
const char *name);
area_id map_mem(void **virt, phys_addr_t phy, size_t size, uint32 protection,
const char *name);
status_t sg_memcpy(const physical_entry *sgTable, int sgCount, const void *data, size_t dataSize);