* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed

map_physical_memory()'s physicalAddress parameter type from void* to
  phys_addr_t. This breaks source compatibility, but -- as long as
  phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with
  BeOS.
* Adjusted all code using the affected interfaces (Oh what fun!). Added a few
  TODOs in places where the wrong types (e.g. void* for physical addresses
  are used). Looks like quite a few drivers aren't 64 bit safe and others
  will break with PAE.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36960 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-05-27 22:07:27 +00:00
parent 1716472d36
commit 64d79eff72
86 changed files with 1378 additions and 1334 deletions
+3 -3
View File
@@ -79,8 +79,8 @@ struct timer {
#define B_READ_DEVICE 0x00000002
typedef struct {
void *address; /* address in physical memory */
ulong size; /* size of block */
phys_addr_t address; /* address in physical memory */
phys_size_t size; /* size of block */
} physical_entry;
/* address specifications for mapping physical memory */
@@ -156,7 +156,7 @@ extern status_t get_memory_map_etc(team_id team, const void *address,
extern long get_memory_map(const void *buffer, ulong size,
physical_entry *table, long numEntries);
extern area_id map_physical_memory(const char *areaName,
void *physicalAddress, size_t size, uint32 flags,
phys_addr_t physicalAddress, size_t size, uint32 flags,
uint32 protection, void **_mappedAddress);
/* kernel debugging facilities */
@@ -60,8 +60,8 @@ area_id
AreaKeeper::Map(const char *name, void *physicalAddress, size_t numBytes,
uint32 spec, uint32 protection, void **_virtualAddress)
{
fArea = map_physical_memory(name, physicalAddress, numBytes, spec, protection,
_virtualAddress);
fArea = map_physical_memory(name, (addr_t)physicalAddress, numBytes, spec,
protection, _virtualAddress);
return fArea;
}
@@ -60,8 +60,8 @@ area_id
AreaKeeper::Map(const char *name, void *physicalAddress, size_t numBytes,
uint32 spec, uint32 protection, void **_virtualAddress)
{
fArea = map_physical_memory(name, physicalAddress, numBytes, spec, protection,
_virtualAddress);
fArea = map_physical_memory(name, (addr_t)physicalAddress, numBytes, spec,
protection, _virtualAddress);
return fArea;
}
@@ -584,7 +584,7 @@ prepare_sleep_state(uint8 state, void (*wakeFunc)(void), size_t size)
if (status != B_OK)
return status;
status = AcpiSetFirmwareWakingVector((addr_t)wakeVector.address);
status = AcpiSetFirmwareWakingVector(wakeVector.address);
if (status != AE_OK)
return B_ERROR;
}
@@ -439,9 +439,8 @@ AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS where, ACPI_SIZE length)
{
#ifdef _KERNEL_MODE
void *there;
area_id area = map_physical_memory("acpi_physical_mem_area", (void *)where,
length, B_ANY_KERNEL_ADDRESS,
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, &there);
area_id area = map_physical_memory("acpi_physical_mem_area", where, length,
B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, &there);
DEBUG_FUNCTION_F("addr: 0x%08lx; length: %lu; mapped: %p; area: %ld",
(addr_t)where, (size_t)length, there, area);
@@ -640,7 +640,7 @@ Aperture::BindMemory(aperture_memory *memory, addr_t address, size_t size)
TRACE("bind %ld bytes at %lx\n", size, base);
for (addr_t offset = 0; offset < size; offset += B_PAGE_SIZE) {
addr_t physicalAddress = 0;
phys_addr_t physicalAddress = 0;
status_t status;
if (!physical) {
@@ -650,7 +650,7 @@ Aperture::BindMemory(aperture_memory *memory, addr_t address, size_t size)
if (status < B_OK)
return status;
physicalAddress = (addr_t)entry.address;
physicalAddress = entry.address;
} else {
#ifdef __HAIKU__
uint32 index = offset >> PAGE_SHIFT;
@@ -1008,6 +1008,7 @@ static status_t
allocate_memory(aperture_id id, size_t size, size_t alignment, uint32 flags,
addr_t *_apertureBase, addr_t *_physicalBase)
{
// TODO: _physicalBase should be a phys_addr_t*!
if ((flags & ~APERTURE_PUBLIC_FLAGS_MASK) != 0 || _apertureBase == NULL)
return B_BAD_VALUE;
@@ -1042,7 +1043,7 @@ allocate_memory(aperture_id id, size_t size, size_t alignment, uint32 flags,
return status;
}
*_physicalBase = (addr_t)entry.address;
*_physicalBase = entry.address;
#endif
}
@@ -974,7 +974,7 @@ ATAChannel::_TransferPIOBlock(ATARequest *request, size_t length,
uint32 currentLength = MIN(entry->size - offset, length);
status_t result = _TransferPIOPhysical(request,
(addr_t)entry->address + offset, currentLength, transferred);
entry->address + offset, currentLength, transferred);
if (result != B_OK) {
request->SetSense(SCSIS_KEY_HARDWARE_ERROR,
SCSIS_ASC_INTERNAL_FAILURE);
@@ -50,11 +50,11 @@ copy_sg_data(scsi_ccb *ccb, uint offset, uint allocationLength,
bytes = MIN(bytes, sgList->size);
if (toBuffer) {
vm_memcpy_from_physical(buffer, (addr_t)sgList->address + offset,
bytes, false);
vm_memcpy_from_physical(buffer, sgList->address + offset, bytes,
false);
} else {
vm_memcpy_to_physical((addr_t)sgList->address + offset, buffer,
bytes, false);
vm_memcpy_to_physical(sgList->address + offset, buffer, bytes,
false);
}
buffer = (char *)buffer + bytes;
@@ -37,6 +37,7 @@ area_id
alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void *virtadr;
area_id area;
@@ -61,7 +62,7 @@ alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
if (virt)
*virt = virtadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
TRACE("area = %ld, size = %ld, virt = %p, phy = %p\n", area, size, virtadr,
pe.address);
return area;
@@ -83,8 +84,8 @@ map_mem(void **virt, void *phy, size_t size, uint32 protection,
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (char *)phy - offset;
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS,
protection, &mapadr);
area = map_physical_memory(name, (addr_t)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));
@@ -95,11 +95,11 @@ copy_sg_data(scsi_ccb *request, uint offset, uint allocationLength,
buffer, (void *)(sgList->address + offset), (int)bytes, toBuffer);
if (toBuffer) {
vm_memcpy_from_physical(buffer, (addr_t)sgList->address + offset,
bytes, false);
vm_memcpy_from_physical(buffer, sgList->address + offset, bytes,
false);
} else {
vm_memcpy_to_physical((addr_t)sgList->address + offset, buffer,
bytes, false);
vm_memcpy_to_physical(sgList->address + offset, buffer, bytes,
false);
}
buffer = (char *)buffer + bytes;
@@ -56,29 +56,28 @@ is_sg_list_dma_safe(scsi_ccb *request)
// argh - controller is a bit picky, so make sure he likes us
for (cur_idx = sg_count; cur_idx >= 1; --cur_idx, ++sg_list) {
addr_t max_len;
phys_addr_t max_len;
// calculate space upto next dma boundary crossing and
// verify that it isn't crossed
max_len = (dma_boundary + 1) -
((addr_t)sg_list->address & dma_boundary);
max_len = (dma_boundary + 1) - (sg_list->address & dma_boundary);
if (max_len < sg_list->size) {
SHOW_FLOW(0, "S/G-entry crosses DMA boundary @0x%x",
(int)sg_list->address + (int)max_len);
SHOW_FLOW(0, "S/G-entry crosses DMA boundary @%" B_PRIxPHYSADDR,
sg_list->address + max_len);
return false;
}
// check both begin and end of entry for alignment
if (((addr_t)sg_list->address & alignment) != 0) {
SHOW_FLOW(0, "S/G-entry has bad alignment @0x%x",
(int)sg_list->address);
if ((sg_list->address & alignment) != 0) {
SHOW_FLOW(0, "S/G-entry has bad alignment @%#" B_PRIxPHYSADDR,
sg_list->address);
return false;
}
if ((((addr_t)sg_list->address + sg_list->size) & alignment) != 0) {
SHOW_FLOW(0, "end of S/G-entry has bad alignment @0x%x",
(int)sg_list->address + (int)sg_list->size);
if (((sg_list->address + sg_list->size) & alignment) != 0) {
SHOW_FLOW(0, "end of S/G-entry has bad alignment @%" B_PRIxPHYSADDR,
sg_list->address + sg_list->size);
return false;
}
@@ -118,12 +117,10 @@ scsi_copy_dma_buffer(scsi_ccb *request, uint32 size, bool to_buffer)
bytes = min( size, sg_list->size );
if (to_buffer) {
vm_memcpy_from_physical(buffer_data, (addr_t)sg_list->address,
bytes, false);
} else {
vm_memcpy_to_physical((addr_t)sg_list->address, buffer_data,
bytes, false);
}
vm_memcpy_from_physical(buffer_data, sg_list->address, bytes,
false);
} else
vm_memcpy_to_physical(sg_list->address, buffer_data, bytes, false);
buffer_data += bytes;
}
@@ -345,7 +342,7 @@ dump_sg_table(const physical_entry *sg_list,
SHOW_FLOW(1, "count=%d", (int)sg_list_count);
for (cur_idx = sg_list_count; cur_idx >= 1; --cur_idx, ++sg_list) {
SHOW_FLOW(1, "addr=%x, size=%d", (int)sg_list->address,
SHOW_FLOW(1, "addr=%" B_PRIxPHYSADDR ", size=%d", sg_list->address,
(int)sg_list->size);
}
}
@@ -54,7 +54,8 @@ status_t
scsi_init_emulation_buffer(scsi_device_info *device, size_t buffer_size)
{
physical_entry map[1];
addr_t unaligned_phys, aligned_phys, aligned_addr, unaligned_addr;
phys_addr_t unaligned_phys, aligned_phys;
addr_t aligned_addr, unaligned_addr;
size_t total_size;
SHOW_FLOW0(3, "");
@@ -82,7 +83,7 @@ scsi_init_emulation_buffer(scsi_device_info *device, size_t buffer_size)
get_memory_map((void *)unaligned_addr, B_PAGE_SIZE, map, 1);
// get aligned part
unaligned_phys = (addr_t)map[0].address;
unaligned_phys = map[0].address;
aligned_phys = (unaligned_phys + buffer_size - 1) & ~(buffer_size - 1);
aligned_addr = unaligned_addr + (aligned_phys - unaligned_phys);
@@ -490,14 +491,14 @@ copy_sg_data(scsi_ccb *request, uint offset, uint allocation_length,
bytes = min(bytes, sg_list->size);
SHOW_FLOW(0, "buffer = %p, virt_addr = %#lx, bytes = %lu, to_buffer = %d",
buffer, (addr_t)sg_list->address + offset, bytes, to_buffer);
buffer, sg_list->address + offset, bytes, to_buffer);
if (to_buffer) {
vm_memcpy_from_physical(buffer, (addr_t)sg_list->address + offset,
bytes, false);
vm_memcpy_from_physical(buffer, sg_list->address + offset, bytes,
false);
} else {
vm_memcpy_to_physical((addr_t)sg_list->address + offset, buffer,
bytes, false);
vm_memcpy_to_physical(sg_list->address + offset, buffer, bytes,
false);
}
buffer = (char *)buffer + bytes;
@@ -59,13 +59,14 @@ fill_temp_sg(scsi_ccb *ccb)
// calculate space upto next dma boundary crossing
max_len = (dma_boundary + 1) -
((addr_t)temp_sg[cur_idx].address & dma_boundary);
(temp_sg[cur_idx].address & dma_boundary);
// restrict size per sg item
max_len = min(max_len, max_sg_block_size);
SHOW_FLOW(4, "addr=%p, size=%x, max_len=%x, idx=%d, num=%d",
temp_sg[cur_idx].address, (int)temp_sg[cur_idx].size,
(int)max_len, (int)cur_idx, (int)num_entries);
SHOW_FLOW(4, "addr=%#" B_PRIxPHYSADDR ", size=%x, max_len=%x, "
"idx=%d, num=%d", temp_sg[cur_idx].address,
(int)temp_sg[cur_idx].size, (int)max_len, (int)cur_idx,
(int)num_entries);
if (max_len < temp_sg[cur_idx].size) {
// split sg block
@@ -76,7 +77,8 @@ fill_temp_sg(scsi_ccb *ccb)
(num_entries - 1 - cur_idx) * sizeof(physical_entry));
temp_sg[cur_idx].size = max_len;
temp_sg[cur_idx + 1].address = (void *)((addr_t)temp_sg[cur_idx + 1].address + max_len);
temp_sg[cur_idx + 1].address
= temp_sg[cur_idx + 1].address + max_len;
temp_sg[cur_idx + 1].size -= max_len;
}
}
@@ -94,7 +94,8 @@ get_iovec_memory_map(iovec *vec, size_t vec_count, size_t vec_offset, size_t len
// try to combine with previous sg block
if (cur_num_entries > 0 && cur_idx > 0
&& map[cur_idx].address == (char *)map[cur_idx - 1].address + map[cur_idx - 1].size) {
&& map[cur_idx].address
== map[cur_idx - 1].address + map[cur_idx - 1].size) {
SHOW_FLOW0( 3, "combine with previous chunk" );
map[cur_idx - 1].size += map[cur_idx].size;
memcpy(&map[cur_idx], &map[cur_idx + 1], (cur_num_entries - 1) * sizeof(map[0]));
@@ -128,6 +128,7 @@ status_t
PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,
void **physicalAddress)
{
// TODO: physicalAddress should be a phys_addr_t*!
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (debug_debugger_running()) {
for (int32 i = 0; i < 64; i++) {
@@ -136,7 +137,7 @@ PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,
fDebugUseMap |= mask;
*logicalAddress = (void *)((uint8 *)fLogicalBase + fDebugBase
+ i * fDebugChunkSize);
*physicalAddress = (void *)((uint8 *)fPhysicalBase + fDebugBase
*physicalAddress = (void *)(fPhysicalBase + fDebugBase
+ i * fDebugChunkSize);
return B_OK;
}
@@ -199,7 +200,7 @@ PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,
_Unlock();
size_t offset = fBlockSize[arrayToUse] * i;
*logicalAddress = (void *)((uint8 *)fLogicalBase + offset);
*physicalAddress = (void *)((uint8 *)fPhysicalBase + offset);
*physicalAddress = (void *)(fPhysicalBase + offset);
return B_OK;
}
}
@@ -222,6 +223,7 @@ status_t
PhysicalMemoryAllocator::Deallocate(size_t size, void *logicalAddress,
void *physicalAddress)
{
// TODO: physicalAddress should be a phys_addr_t!
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (debug_debugger_running()) {
uint32 index = ((uint8 *)logicalAddress - (uint8 *)fLogicalBase
@@ -248,7 +250,7 @@ PhysicalMemoryAllocator::Deallocate(size_t size, void *logicalAddress,
if (logicalAddress)
offset = (uint32)logicalAddress - (uint32)fLogicalBase;
else if (physicalAddress)
offset = (uint32)physicalAddress - (uint32)fPhysicalBase;
offset = (addr_t)physicalAddress - fPhysicalBase;
else {
TRACE_ERROR(("PMA: no value given for either physical or logical address\n"));
return B_BAD_VALUE;
@@ -50,7 +50,7 @@ private:
mutex fLock;
area_id fArea;
void *fLogicalBase;
void *fPhysicalBase;
phys_addr_t fPhysicalBase;
int32 fArrayCount;
size_t *fBlockSize;
@@ -294,6 +294,7 @@ area_id
Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
const char *name)
{
// TODO: physicalAddress should be a phys_addr_t*!
TRACE("allocating %ld bytes for %s\n", size, name);
void *logAddress;
@@ -319,9 +320,9 @@ Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
*logicalAddress = logAddress;
if (physicalAddress)
*physicalAddress = physicalEntry.address;
*physicalAddress = (void*)(addr_t)physicalEntry.address;
TRACE("area = %ld, size = %ld, log = %p, phy = %p\n",
TRACE("area = %ld, size = %ld, log = %p, phy = %#" B_PRIxPHYSADDR "\n",
area, size, logAddress, physicalEntry.address);
return area;
}
@@ -92,7 +92,7 @@ struct intel_info {
size_t aperture_size;
size_t aperture_stolen_size;
addr_t scratch_page;
phys_addr_t scratch_page;
area_id scratch_area;
};
@@ -380,7 +380,7 @@ intel_map(intel_info &info)
return info.aperture_area;
}
info.scratch_page = (addr_t)entry.address;
info.scratch_page = entry.address;
gttMapper.Detach();
mmioMapper.Detach();
@@ -94,7 +94,7 @@ typedef struct channel_data {
area_id prd_area;
prd_entry * prdt;
void * prdt_phys;
phys_addr_t prdt_phys;
uint32 dma_active;
uint32 lost;
} channel_data;
@@ -272,9 +272,9 @@ controller_init(device_node *node, void **_controllerCookie)
FLOW("controller %p\n", controller);
mmioArea = map_physical_memory("Silicon Image SATA regs",
(void *)mmioBase, kASICData[asicIndex].mmio_bar_size,
B_ANY_KERNEL_ADDRESS, 0, (void **)&mmioAddr);
mmioArea = map_physical_memory("Silicon Image SATA regs", mmioBase,
kASICData[asicIndex].mmio_bar_size, B_ANY_KERNEL_ADDRESS, 0,
(void **)&mmioAddr);
if (mmioArea < B_OK) {
TRACE("controller_init: mapping memory failed\n");
free(controller);
@@ -683,7 +683,7 @@ dma_prepare(void *channelCookie, const physical_entry *sg_list,
for (i = sg_list_count - 1, prd = channel->prdt; i >= 0;
--i, ++prd, ++sg_list ) {
prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device,
sg_list->address));
(void*)(addr_t)sg_list->address));
// 0 means 64K - this is done automatically by discarding upper 16 bits
prd->count = B_HOST_TO_LENDIAN_INT16((uint16)sg_list->size);
@@ -695,7 +695,7 @@ dma_prepare(void *channelCookie, const physical_entry *sg_list,
// XXX move this to chan init?
temp = (*channel->bm_prdt_address) & 3;
temp |= B_HOST_TO_LENDIAN_INT32(pci->ram_address(device,
(void *)channel->prdt_phys)) & ~3;
(void *)(addr_t)channel->prdt_phys)) & ~3;
*channel->bm_prdt_address = temp;
*channel->dev_ctrl; // read altstatus to flush
@@ -103,7 +103,7 @@ typedef struct channel_data {
area_id prd_area;
prd_entry * prdt;
void * prdt_phys;
phys_addr_t prdt_phys;
uint32 dma_active;
uint32 lost;
} channel_data;
@@ -278,9 +278,9 @@ controller_init(device_node *node, void **_controllerCookie)
FLOW("controller %p\n", controller);
mmioArea = map_physical_memory("Silicon Image SATA regs",
(void *)mmioBase, kASICData[asicIndex].mmio_bar_size,
B_ANY_KERNEL_ADDRESS, 0, (void **)&mmioAddr);
mmioArea = map_physical_memory("Silicon Image SATA regs", mmioBase,
kASICData[asicIndex].mmio_bar_size, B_ANY_KERNEL_ADDRESS, 0,
(void **)&mmioAddr);
if (mmioArea < B_OK) {
TRACE("controller_init: mapping memory failed\n");
free(controller);
@@ -691,7 +691,7 @@ dma_prepare(void *channelCookie, const physical_entry *sg_list,
for (i = sg_list_count - 1, prd = channel->prdt; i >= 0;
--i, ++prd, ++sg_list ) {
prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device,
sg_list->address));
(void*)(addr_t)sg_list->address));
// 0 means 64K - this is done automatically by discarding upper 16 bits
prd->count = B_HOST_TO_LENDIAN_INT16((uint16)sg_list->size);
@@ -703,7 +703,7 @@ dma_prepare(void *channelCookie, const physical_entry *sg_list,
// XXX move this to chan init?
temp = (*channel->bm_prdt_address) & 3;
temp |= B_HOST_TO_LENDIAN_INT32(pci->ram_address(device,
(void *)channel->prdt_phys)) & ~3;
(void *)(addr_t)channel->prdt_phys)) & ~3;
*channel->bm_prdt_address = temp;
*channel->dev_ctrl; // read altstatus to flush
@@ -1088,7 +1088,7 @@ static Symbios *create_cardinfo(int num, pci_info *pi, int flags)
if(flags & symf_sram){
unsigned char *c;
s->sram_phys = pi->u.h0.base_registers[2];
if((aid=map_physical_memory(name, (void *) s->sram_phys, 4096,
if((aid=map_physical_memory(name, s->sram_phys, 4096,
B_ANY_KERNEL_ADDRESS, B_READ_AREA + B_WRITE_AREA,
(void **) &(s->script))) < 0){
free(s);
@@ -452,10 +452,11 @@ AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax,
*prdCount = 0;
while (sgCount > 0 && dataSize > 0) {
size_t size = min_c(sgTable->size, dataSize);
void *address = sgTable->address;
phys_addr_t address = sgTable->address;
T_PORT(AHCIPortPrdTable(fController, fIndex, address, size));
FLOW("FillPrdTable: sg-entry addr %p, size %lu\n", address, size);
if ((uint32)address & 1) {
FLOW("FillPrdTable: sg-entry addr %#" B_PRIxPHYSADDR ", size %lu\n",
address, size);
if (address & 1) {
TRACE("AHCIPort::FillPrdTable: data alignment error\n");
return B_ERROR;
}
@@ -475,7 +476,7 @@ AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax,
prdTable->dbc = bytes - 1;
*prdCount += 1;
prdTable++;
address = (char *)address + bytes;
address = address + bytes;
size -= bytes;
}
sgTable++;
+7 -5
View File
@@ -25,6 +25,7 @@ area_id
alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * virtadr;
area_id areaid;
@@ -48,7 +49,7 @@ alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
if (virt)
*virt = virtadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
TRACE("area = %ld, size = %ld, virt = %p, phy = %p\n", areaid, size, virtadr, pe.address);
return areaid;
}
@@ -68,8 +69,8 @@ map_mem(void **virt, void *phy, size_t size, uint32 protection,
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (char *)phy - offset;
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS,
protection, &mapadr);
area = map_physical_memory(name, (addr_t)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));
return area;
@@ -92,9 +93,10 @@ sg_memcpy(const physical_entry *sgTable, int sgCount, const void *data,
for (i = 0; i < sgCount && dataSize > 0; i++) {
size_t size = min_c(dataSize, sgTable[i].size);
TRACE("sg_memcpy phyAddr %p, size %lu\n", sgTable[i].address, size);
TRACE("sg_memcpy phyAddr %#" B_PRIxPHYSADDR ", size %lu\n",
sgTable[i].address, size);
vm_memcpy_to_physical((addr_t)sgTable[i].address, data, size, false);
vm_memcpy_to_physical(sgTable[i].address, data, size, false);
data = (char *)data + size;
dataSize -= size;
@@ -800,7 +800,7 @@ static BusLogic *create_cardinfo(int num, int iobase, int irq)
BusLogic *bl = (BusLogic *) malloc(sizeof(BusLogic));
#ifndef __INTEL__
i = map_physical_memory("bl_regs",(void*) iobase, 4096,
i = map_physical_memory("bl_regs", iobase, 4096,
B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA, &a);
iobase = (uint32) a;
if(i < 0) {
+1 -1
View File
@@ -154,7 +154,7 @@ EHCI::EHCI(pci_info *info, Stack *stack)
fPCIInfo->u.h0.base_register_sizes[0]);
fRegisterArea = map_physical_memory("EHCI memory mapped registers",
(void *)physicalAddress, mapSize, B_ANY_KERNEL_BLOCK_ADDRESS,
physicalAddress, mapSize, B_ANY_KERNEL_BLOCK_ADDRESS,
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_READ_AREA | B_WRITE_AREA,
(void **)&fCapabilityRegisters);
if (fRegisterArea < B_OK) {
+1 -1
View File
@@ -101,7 +101,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
offset &= PCI_address_memory_32_mask;
TRACE_ALWAYS("iospace offset: 0x%lx\n", offset);
fRegisterArea = map_physical_memory("OHCI memory mapped registers",
(void *)offset, B_PAGE_SIZE, B_ANY_KERNEL_BLOCK_ADDRESS,
offset, B_PAGE_SIZE, B_ANY_KERNEL_BLOCK_ADDRESS,
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_READ_AREA | B_WRITE_AREA,
(void **)&fOperationalRegisters);
if (fRegisterArea < B_OK) {
@@ -41,7 +41,7 @@ text_init(void)
return -1;
}
map_physical_memory("video_mem", (void *)SCREEN_START, SCREEN_END - SCREEN_START,
map_physical_memory("video_mem", SCREEN_START, SCREEN_END - SCREEN_START,
B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void *)&sOrigin);
dprintf("console/text: mapped vid mem to virtual address %p\n", sOrigin);
@@ -35,6 +35,7 @@ round_to_pagesize(uint32 size)
static area_id
alloc_mem(void **phy, void **log, size_t size, const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void *logadr;
area_id areaid;
@@ -57,7 +58,7 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
return areaid;
}
@@ -66,6 +66,7 @@ round_to_pagesize(uint32 size)
area_id
alloc_mem(void **phy, void **log, size_t size, const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * logadr;
area_id area;
@@ -90,7 +91,7 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n", area, size, logadr,
pe.address));
return area;
@@ -110,7 +111,8 @@ map_mem(void **log, void *phy, size_t size, const char *name)
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = phy - offset;
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_ADDRESS, 0, &mapadr);
area = map_physical_memory(name, (addr_t)phyadr, size, B_ANY_KERNEL_ADDRESS,
0, &mapadr);
*log = mapadr + offset;
LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n",
@@ -66,6 +66,7 @@ round_to_pagesize(uint32 size)
area_id
alloc_mem(void **phy, void **log, size_t size, const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * logadr;
area_id areaid;
@@ -90,7 +91,7 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n",areaid,size,logadr,pe.address));
return areaid;
}
@@ -66,6 +66,7 @@ round_to_pagesize(uint32 size)
area_id
alloc_mem(void **phy, void **log, size_t size, const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * logadr;
area_id areaid;
@@ -90,7 +91,7 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n", areaid, size,
logadr, pe.address));
return areaid;
@@ -115,8 +116,8 @@ map_mem(void **log, void *phy, size_t size, const char *name)
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = phy - offset;
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA | B_WRITE_AREA, &mapadr);
area = map_physical_memory(name, (addr_t)phyadr, size,
B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr);
*log = mapadr + offset;
LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n",
@@ -274,7 +274,7 @@ geode_stream_stop(geode_stream* stream)
status_t
geode_stream_setup_buffers(geode_stream* stream, const char* desc)
{
uint32 bufferSize, bufferPhysicalAddress, alloc;
uint32 bufferSize, alloc;
uint32 index;
physical_entry pe;
struct acc_prd* bufferDescriptors;
@@ -317,7 +317,7 @@ geode_stream_setup_buffers(geode_stream* stream, const char* desc)
return rc;
}
bufferPhysicalAddress = (uint32)pe.address;
phys_addr_t bufferPhysicalAddress = pe.address;
dprintf("%s(%s): Allocated %lu bytes for %ld buffers\n", __func__, desc,
alloc, stream->num_buffers);
@@ -349,7 +349,7 @@ geode_stream_setup_buffers(geode_stream* stream, const char* desc)
return rc;
}
stream->physical_buffer_descriptors = (uint32)pe.address;
stream->physical_buffer_descriptors = pe.address;
dprintf("%s(%s): Allocated %ld bytes for %ld BDLEs\n", __func__, desc,
alloc, stream->num_buffers);
@@ -66,6 +66,7 @@ round_to_pagesize(uint32 size)
area_id
alloc_mem(void **log, void **phy, size_t size, const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * logadr;
area_id areaid;
@@ -90,7 +91,7 @@ alloc_mem(void **log, void **phy, size_t size, const char *name)
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n",areaid,size,logadr,pe.address));
return areaid;
}
@@ -114,7 +115,8 @@ map_mem(void **log, void *phy, size_t size, const char *name)
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (char *)phy - offset;
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr);
area = map_physical_memory(name, (addr_t)phyadr, size,
B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr);
*log = (char *)mapadr + offset;
LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n",
@@ -47,6 +47,7 @@ area_id
alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * virtadr;
area_id areaid;
@@ -71,7 +72,7 @@ alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
if (virt)
*virt = virtadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
LOG(("area = %ld, size = %ld, virt = %p, phy = %p\n", areaid, size, virtadr, pe.address));
return areaid;
}
@@ -95,7 +96,8 @@ map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (char *)phy - offset;
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr);
area = map_physical_memory(name, (addr_t)phyadr, size,
B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr);
*virt = (char *)mapadr + offset;
LOG(("physical = %p, virtual = %p, offset = %ld, phyadr = %p, mapadr = %p, size = %ld, area = 0x%08lx\n",
+6 -5
View File
@@ -352,7 +352,7 @@ find_low_memory(
ddprintf(("cmedia_pci: no memory map\n"));
goto allocate;
}
if ((uint32)where.address & 0xff000000) {
if ((where.address & ~(phys_addr_t)0xffffff) != 0) {
ddprintf(("cmedia_pci: bad physical address\n"));
goto allocate;
}
@@ -360,7 +360,8 @@ find_low_memory(
ddprintf(("cmedia_pci: lock not contiguous\n"));
goto allocate;
}
dprintf("cmedia_pci: physical %p logical %p\n", where.address, ainfo.address);
dprintf("cmedia_pci: physical %#" B_PRIxPHYSADDR " logical %p\n",
where.address, ainfo.address);
goto a_o_k;
}
@@ -384,12 +385,12 @@ allocate:
goto oops;
}
ddprintf(("cmedia_pci: physical %p\n", where.address));
if ((uint32)where.address & 0xff000000) {
if ((where.address & ~(phys_addr_t)0xffffff) != 0) {
delete_area(curarea);
curarea = B_ERROR;
goto oops;
}
if ((((uint32)where.address)+low_size) & 0xff000000) {
if (((where.address + low_size) & ~(phys_addr_t)0xffffff) != 0) {
delete_area(curarea);
curarea = B_ERROR;
goto oops;
@@ -408,7 +409,7 @@ a_o_k:
ddprintf(("cmedia_pci: successfully found or created low area!\n"));
card->low_size = low_size;
card->low_mem = addr;
card->low_phys = (vuchar *)where.address;
card->low_phys = (vuchar *)(addr_t)where.address;
card->map_low = curarea;
return B_OK;
}
+4 -2
View File
@@ -66,6 +66,7 @@ round_to_pagesize(uint32 size)
area_id
alloc_mem(void **phy, void **log, size_t size, const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * logadr;
area_id area;
@@ -90,7 +91,7 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n", area, size, logadr,
pe.address));
return area;
@@ -110,7 +111,8 @@ map_mem(void **log, void *phy, size_t size, const char *name)
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (void*)((uint32)phy - offset);
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_ADDRESS, 0, &mapadr);
area = map_physical_memory(name, (addr_t)phyadr, size, B_ANY_KERNEL_ADDRESS,
0, &mapadr);
*log = (void*) ((uint32)mapadr + offset);
LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n",
@@ -66,6 +66,7 @@ round_to_pagesize(uint32 size)
area_id
alloc_mem(void **phy, void **log, size_t size, const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * logadr;
area_id areaid;
@@ -90,7 +91,7 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n",areaid,size,logadr,pe.address));
return areaid;
}
@@ -149,7 +149,7 @@ struct hda_stream {
uint32 sample_size;
uint8* buffers[STREAM_MAX_BUFFERS];
/* Virtual addresses for buffer */
uint32 physical_buffers[STREAM_MAX_BUFFERS];
phys_addr_t physical_buffers[STREAM_MAX_BUFFERS];
/* Physical addresses for buffer */
volatile bigtime_t real_time;
@@ -411,14 +411,17 @@ init_corb_rirb_pos(hda_controller* controller)
/* Program CORB/RIRB for these locations */
controller->Write32(HDAC_CORB_BASE_LOWER, (uint32)pe.address);
controller->Write32(HDAC_CORB_BASE_UPPER, 0);
controller->Write32(HDAC_CORB_BASE_UPPER,
(uint32)((uint64)pe.address >> 32));
controller->Write32(HDAC_RIRB_BASE_LOWER, (uint32)pe.address + rirbOffset);
controller->Write32(HDAC_RIRB_BASE_UPPER, 0);
controller->Write32(HDAC_RIRB_BASE_UPPER,
(uint32)(((uint64)pe.address + rirbOffset) >> 32));
/* Program DMA position update */
controller->Write32(HDAC_DMA_POSITION_BASE_LOWER,
(uint32)pe.address + posOffset);
controller->Write32(HDAC_DMA_POSITION_BASE_UPPER, 0);
controller->Write32(HDAC_DMA_POSITION_BASE_UPPER,
(uint32)(((uint64)pe.address + posOffset) >> 32));
controller->stream_positions = (uint32*)
((uint8*)controller->corb + posOffset);
@@ -567,7 +570,6 @@ status_t
hda_stream_setup_buffers(hda_audio_group* audioGroup, hda_stream* stream,
const char* desc)
{
uint32 bufferPhysicalAddress;
uint32 response[2];
physical_entry pe;
bdl_entry_t* bufferDescriptors;
@@ -635,7 +637,7 @@ hda_stream_setup_buffers(hda_audio_group* audioGroup, hda_stream* stream,
return rc;
}
bufferPhysicalAddress = (uint32)pe.address;
phys_addr_t bufferPhysicalAddress = pe.address;
dprintf("%s(%s): Allocated %lu bytes for %ld buffers\n", __func__, desc,
alloc, stream->num_buffers);
@@ -678,8 +680,9 @@ hda_stream_setup_buffers(hda_audio_group* audioGroup, hda_stream* stream,
uint32 fragments = 0;
for (uint32 index = 0; index < stream->num_buffers;
index++, bufferDescriptors++) {
bufferDescriptors->lower = stream->physical_buffers[index];
bufferDescriptors->upper = 0;
bufferDescriptors->lower = (uint32)stream->physical_buffers[index];
bufferDescriptors->upper
= (uint32)((uint64)stream->physical_buffers[index] >> 32);
fragments++;
bufferDescriptors->length = stream->buffer_size;
bufferDescriptors->ioc = 1;
@@ -780,7 +783,7 @@ hda_hw_init(hda_controller* controller)
/* Map MMIO registers */
controller->regs_area = map_physical_memory("hda_hw_regs",
(void*)controller->pci_info.u.h0.base_registers[0],
controller->pci_info.u.h0.base_registers[0],
controller->pci_info.u.h0.base_register_sizes[0], B_ANY_KERNEL_ADDRESS,
0, (void**)&controller->regs);
if (controller->regs_area < B_OK) {
@@ -48,6 +48,7 @@ round_to_pagesize(uint32 size)
area_id
alloc_mem(void **phy, void **log, size_t size, const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * logadr;
area_id areaid;
@@ -72,7 +73,7 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
TRACE("area = %d, size = %#08X, log = %#08X, phy = %#08X\n", (int)areaid, (int)size, (int)logadr, (int)pe.address);
return areaid;
}
@@ -177,7 +177,7 @@ static status_t setup_hardware( sis7018_dev * card)
{
TRACE("%s memory %lx length %lx\n", card->name, card->info.u.h0.base_registers[1], card->info.u.h0.base_register_sizes[1]);
card->regs_area = map_physical_memory("Regs sis7018",
(void *)card->info.u.h0.base_registers[1],
card->info.u.h0.base_registers[1],
card->info.u.h0.base_register_sizes[1],
B_ANY_KERNEL_ADDRESS,
B_READ_AREA + B_WRITE_AREA,
@@ -505,13 +505,13 @@ static status_t hw_find_memory(sis7018_ch *ch, size_t blocksize)
curarea = B_ERROR;
goto oops;
}
TRACE("physical %p\n", where.address);
if ((uint32)where.address & 0xff000000){
TRACE("physical %#" B_PRIxPHYSADDR "\n", where.address);
if ((where.address & ~(phys_addr_t)0xffffff) != 0){
delete_area(curarea);
curarea = B_ERROR;
goto oops;
}
if ((((uint32)where.address)+low_size) & 0xff000000){
if (((where.address + low_size) & ~(phys_addr_t)0xffffff) != 0){
delete_area(curarea);
curarea = B_ERROR;
goto oops;
@@ -530,7 +530,7 @@ oops:
ch->mem_size = low_size;
ch->mem_ptr = addr;
ch->mem_phys = (vuchar *)where.address;
ch->mem_phys = (vuchar *)(adrr_t)where.address;
ch->wr_1 = ch->mem_ptr;
ch->wr_2 = ch->wr_1+ch->mem_size/2;
@@ -51,8 +51,8 @@ map_mem(void **virt, void *phy, size_t size, uint32 protection,
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (char *)phy - offset;
size = ROUNDUP(size + offset, B_PAGE_SIZE);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS,
protection, &mapadr);
area = map_physical_memory(name, (addr_t)phyadr, size,
B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr);
if (area < B_OK) {
TRACE("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area));
return area;
@@ -71,6 +71,7 @@ area_id
alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * virtadr;
area_id areaid;
@@ -94,7 +95,7 @@ alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
if (virt)
*virt = virtadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
TRACE("area = %ld, size = %ld, virt = %p, phy = %p\n", areaid, size, virtadr, pe.address);
return areaid;
}
@@ -396,7 +396,7 @@ Mach64_GetBiosParameters(DeviceInfo& di, uint8& clockType)
uint8* romAddr;
area_id romArea = map_physical_memory("ATI Mach64 ROM",
(void*)0x000c0000,
0x000c0000,
M64_BIOS_SIZE,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -475,7 +475,7 @@ Rage128_GetBiosParameters(DeviceInfo& di)
uint8* romAddr;
area_id romArea = map_physical_memory("ATI Rage128 ROM",
(void*)0x000c0000,
0x000c0000,
R128_BIOS_SIZE,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -573,7 +573,7 @@ MapDevice(DeviceInfo& di)
si.videoMemArea = map_physical_memory(
frameBufferAreaName,
(void*)videoRamAddr,
videoRamAddr,
videoRamSize,
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA + B_WRITE_AREA,
@@ -583,7 +583,7 @@ MapDevice(DeviceInfo& di)
// Try to map this time without write combining.
si.videoMemArea = map_physical_memory(
frameBufferAreaName,
(void*)videoRamAddr,
videoRamAddr,
videoRamSize,
B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA + B_WRITE_AREA,
@@ -623,7 +623,7 @@ MapDevice(DeviceInfo& di)
}
si.regsArea = map_physical_memory("ATI mmio registers",
(void*)regsBase,
regsBase,
regAreaSize,
B_ANY_KERNEL_ADDRESS,
0, // neither read nor write, to hide it from user space apps
@@ -395,7 +395,7 @@ pci_info *pcii = &(di->pcii);
* (B_MTR_WC) and the memory mapped registers with B_MTR_UC.
*/
si->memoryArea = map_physical_memory(buffer,
(void *)di->pcii.u.h0.base_registers[0],
di->pcii.u.h0.base_registers[0],
di->pcii.u.h0.base_register_sizes[0],
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_UC,
B_READ_AREA + B_WRITE_AREA,
@@ -360,7 +360,7 @@ static status_t map_device(device_info *di)
/* get a virtual memory address for the registers*/
si->regs_area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[registers],
di->pcii.u.h0.base_registers[registers],
di->pcii.u.h0.base_register_sizes[registers],
B_ANY_KERNEL_ADDRESS,
B_USER_CLONEABLE_AREA | (si->use_clone_bugfix ? B_READ_AREA|B_WRITE_AREA : 0),
@@ -382,7 +382,7 @@ static status_t map_device(device_info *di)
rom_area = map_physical_memory(
buffer,
(void *)di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_registers[frame_buffer],
32768,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -451,7 +451,7 @@ static status_t map_device(device_info *di)
/* map the pseudo dma into vmem (write-only)*/
si->pseudo_dma_area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[pseudo_dma],
di->pcii.u.h0.base_registers[pseudo_dma],
di->pcii.u.h0.base_register_sizes[pseudo_dma],
B_ANY_KERNEL_ADDRESS,
B_WRITE_AREA,
@@ -500,7 +500,7 @@ static status_t map_device(device_info *di)
/* map the framebuffer into vmem, using Write Combining*/
si->fb_area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA | B_WRITE_AREA,
@@ -510,7 +510,7 @@ static status_t map_device(device_info *di)
if (si->fb_area < 0) {
si->fb_area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA | B_WRITE_AREA,
@@ -603,7 +603,7 @@ static void copy_rom(device_info *di)
rom_area = map_physical_memory(
buffer,
(void *)di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_registers[frame_buffer],
32768,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -374,7 +374,7 @@ static status_t map_device(device_info *di)
/* get a virtual memory address for the registers*/
si->regs_area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[registers],
di->pcii.u.h0.base_registers[registers],
di->pcii.u.h0.base_register_sizes[registers],
B_ANY_KERNEL_ADDRESS,
(si->use_clone_bugfix ? B_READ_AREA|B_WRITE_AREA : 0),
@@ -391,7 +391,7 @@ static status_t map_device(device_info *di)
si->regs2_area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[registers2],
di->pcii.u.h0.base_registers[registers2],
di->pcii.u.h0.base_register_sizes[registers2],
B_ANY_KERNEL_ADDRESS,
(si->use_clone_bugfix ? B_READ_AREA|B_WRITE_AREA : 0),
@@ -424,7 +424,7 @@ static status_t map_device(device_info *di)
rom_area = map_physical_memory(
buffer,
(void *)di->pcii.u.h0.rom_base_pci,
di->pcii.u.h0.rom_base_pci,
di->pcii.u.h0.rom_size,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -447,7 +447,7 @@ static status_t map_device(device_info *di)
/* ROM was not assigned an adress, fetch it from ISA legacy memory map! */
rom_area = map_physical_memory(
buffer,
(void *)0x000c0000,
0x000c0000,
65536,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -490,7 +490,7 @@ static status_t map_device(device_info *di)
/* map the framebuffer into vmem, using Write Combining*/
si->fb_area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA + B_WRITE_AREA,
@@ -500,7 +500,7 @@ static status_t map_device(device_info *di)
if (si->fb_area < 0) {
si->fb_area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_registers[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA + B_WRITE_AREA,
@@ -557,7 +557,7 @@ map_device(device_info *di)
si->regs_area = map_physical_memory(
buffer,
/* WARNING: Nvidia needs to map regs as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[registers],
di->pcii.u.h0.base_registers_pci[registers],
di->pcii.u.h0.base_register_sizes[registers],
B_ANY_KERNEL_ADDRESS,
B_USER_CLONEABLE_AREA | (si->use_clone_bugfix ? B_READ_AREA|B_WRITE_AREA : 0),
@@ -595,7 +595,7 @@ map_device(device_info *di)
rom_area = map_physical_memory(
buffer,
(void *)di->pcii.u.h0.rom_base_pci,
di->pcii.u.h0.rom_base_pci,
di->pcii.u.h0.rom_size,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -619,7 +619,7 @@ map_device(device_info *di)
if (!tmpUlong) {
/* ROM was not assigned an adress, fetch it from ISA legacy memory map! */
rom_area = map_physical_memory(buffer, (void *)0x000c0000,
rom_area = map_physical_memory(buffer, 0x000c0000,
65536, B_ANY_KERNEL_ADDRESS, B_READ_AREA, (void **)&(rom_temp));
}
@@ -655,7 +655,7 @@ map_device(device_info *di)
/* map the framebuffer into vmem, using Write Combining*/
si->fb_area = map_physical_memory(buffer,
/* WARNING: Nvidia needs to map framebuffer as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA | B_WRITE_AREA,
@@ -665,7 +665,7 @@ map_device(device_info *di)
if (si->fb_area < 0) {
si->fb_area = map_physical_memory(buffer,
/* WARNING: Nvidia needs to map framebuffer as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA | B_WRITE_AREA,
@@ -917,17 +917,17 @@ open_hook(const char* name, uint32 flags, void** cookie)
* even on older CPU's. */
get_memory_map(unaligned_dma_buffer, B_PAGE_SIZE, map, 1);
si->dma_buffer_pci = (void*)
((((uint32)(map[0].address)) + net_buf_size - 1) & ~(net_buf_size - 1));
((map[0].address + net_buf_size - 1) & ~(net_buf_size - 1));
/* map the net DMA command buffer into vmem, using Write Combining */
si->dma_area = map_physical_memory(
"NV aligned DMA cmd buffer", si->dma_buffer_pci, net_buf_size,
"NV aligned DMA cmd buffer", (addr_t)si->dma_buffer_pci, net_buf_size,
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA | B_WRITE_AREA, &(si->dma_buffer));
/* if failed with write combining try again without */
if (si->dma_area < 0) {
si->dma_area = map_physical_memory(
"NV aligned DMA cmd buffer", si->dma_buffer_pci, net_buf_size,
si->dma_area = map_physical_memory("NV aligned DMA cmd buffer",
(addr_t)si->dma_buffer_pci, net_buf_size,
B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA | B_WRITE_AREA, &(si->dma_buffer));
}
@@ -321,7 +321,7 @@ map_device(device_info *di)
si->regs_area = map_physical_memory(
buffer,
/* WARNING: Nvidia needs to map regs as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[registers],
di->pcii.u.h0.base_registers_pci[registers],
di->pcii.u.h0.base_register_sizes[registers],
B_ANY_KERNEL_ADDRESS,
B_USER_CLONEABLE_AREA | (si->use_clone_bugfix ? B_READ_AREA|B_WRITE_AREA : 0),
@@ -359,7 +359,7 @@ map_device(device_info *di)
rom_area = map_physical_memory(
buffer,
(void *)di->pcii.u.h0.rom_base_pci,
di->pcii.u.h0.rom_base_pci,
di->pcii.u.h0.rom_size,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -383,7 +383,7 @@ map_device(device_info *di)
if (!tmpUlong) {
/* ROM was not assigned an adress, fetch it from ISA legacy memory map! */
rom_area = map_physical_memory(buffer, (void *)0x000c0000,
rom_area = map_physical_memory(buffer, 0x000c0000,
65536, B_ANY_KERNEL_ADDRESS, B_READ_AREA, (void **)&(rom_temp));
}
@@ -419,7 +419,7 @@ map_device(device_info *di)
/* map the framebuffer into vmem, using Write Combining*/
si->fb_area = map_physical_memory(buffer,
/* WARNING: Nvidia needs to map framebuffer as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA | B_WRITE_AREA,
@@ -429,7 +429,7 @@ map_device(device_info *di)
if (si->fb_area < 0) {
si->fb_area = map_physical_memory(buffer,
/* WARNING: Nvidia needs to map framebuffer as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA | B_WRITE_AREA,
@@ -676,18 +676,18 @@ open_hook(const char* name, uint32 flags, void** cookie)
* even on older CPU's. */
get_memory_map(unaligned_dma_buffer, B_PAGE_SIZE, map, 1);
si->dma_buffer_pci = (void*)
((((uint32)(map[0].address)) + net_buf_size - 1) & ~(net_buf_size - 1));
((map[0].address + net_buf_size - 1) & ~(net_buf_size - 1));
/* map the net DMA command buffer into vmem, using Write Combining */
si->dma_area = map_physical_memory(
"NV aligned DMA cmd buffer", si->dma_buffer_pci, net_buf_size,
"NV aligned DMA cmd buffer", (addr_t)si->dma_buffer_pci, net_buf_size,
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA | B_WRITE_AREA, &(si->dma_buffer));
/* if failed with write combining try again without */
if (si->dma_area < 0) {
si->dma_area = map_physical_memory(
"NV aligned DMA cmd buffer", si->dma_buffer_pci, net_buf_size,
B_ANY_KERNEL_BLOCK_ADDRESS,
"NV aligned DMA cmd buffer", (addr_t)si->dma_buffer_pci,
net_buf_size, B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA | B_WRITE_AREA, &(si->dma_buffer));
}
/* if there was an error, delete our other areas and pass on error*/
@@ -82,7 +82,7 @@ static status_t Radeon_PrepareDMA(
}
for( i = 0; i < 16; ++i ) {
uint32 address = (uint32)map[i].address;
phys_addr_t address = map[i].address;
size_t contig_size = map[i].size;
if( contig_size == 0 )
@@ -99,19 +99,19 @@ static status_t createGARTBuffer( GART_info *gart, size_t size )
get_memory_map( unaligned_addr, B_PAGE_SIZE, map, 1 );
aligned_phys =
(void **)(((uint32)map[0].address + size - 1) & ~(size - 1));
(void **)((map[0].address + size - 1) & ~(size - 1));
SHOW_FLOW( 3, "aligned_phys=%p", aligned_phys );
gart->buffer.area = map_physical_memory( "Radeon aligned PCI GART buffer",
aligned_phys,
(addr_t)aligned_phys,
size, B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA | B_WRITE_AREA, &gart->buffer.ptr );
if( gart->buffer.area < 0 ) {
SHOW_ERROR0( 3, "cannot map buffer with WC" );
gart->buffer.area = map_physical_memory( "Radeon aligned PCI GART buffer",
aligned_phys,
(addr_t)aligned_phys,
size, B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA | B_WRITE_AREA, &gart->buffer.ptr );
}
@@ -166,7 +166,7 @@ static status_t initGATT( GART_info *gart )
}
get_memory_map(gart->GATT.ptr, B_PAGE_SIZE, PTB_map, 1);
gart->GATT.phys = (uint32)PTB_map[0].address;
gart->GATT.phys = PTB_map[0].address;
SHOW_INFO(3, "GATT_ptr=%p, GATT_phys=%p", gart->GATT.ptr,
(void *)gart->GATT.phys);
@@ -192,7 +192,7 @@ static status_t initGATT( GART_info *gart )
gatt_entry = gart->GATT.ptr;
for( i = 0; i < map_count; ++i ) {
uint32 addr = (uint32)map[i].address;
phys_addr_t addr = map[i].address;
size_t size = map[i].size;
if( size == 0 )
@@ -1039,7 +1039,7 @@ status_t Radeon_MapBIOS( pci_info *pcii, rom_info *ri )
ri->phys_address = 0xc0000;
ri->size = 0x40000;
ri->bios_area = map_physical_memory( buffer, (void *)ri->phys_address,
ri->bios_area = map_physical_memory( buffer, ri->phys_address,
ri->size, B_ANY_KERNEL_ADDRESS, B_READ_AREA, (void **)&ri->bios_ptr );
if( ri->bios_area < 0 )
return ri->bios_area;
@@ -70,7 +70,7 @@ status_t Radeon_MapDevice( device_info *di, bool mmio_only )
si->regs_area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[regs],
di->pcii.u.h0.base_registers[regs],
di->pcii.u.h0.base_register_sizes[regs],
B_ANY_KERNEL_ADDRESS,
/*// for "poke" debugging
@@ -96,7 +96,7 @@ status_t Radeon_MapDevice( device_info *di, bool mmio_only )
si->ROM_area = map_physical_memory(
buffer,
(void *) di->rom.phys_address,
di->rom.phys_address,
di->rom.size,
B_ANY_KERNEL_ADDRESS,
0,
@@ -131,7 +131,7 @@ status_t Radeon_MapDevice( device_info *di, bool mmio_only )
si->memory[mt_local].area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[fb],
di->pcii.u.h0.base_registers[fb],
di->pcii.u.h0.base_register_sizes[fb],
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA + B_WRITE_AREA,
@@ -141,7 +141,7 @@ status_t Radeon_MapDevice( device_info *di, bool mmio_only )
SHOW_FLOW0( 3, "couldn't enable WC for frame buffer" );
si->memory[mt_local].area = map_physical_memory(
buffer,
(void *) di->pcii.u.h0.base_registers[fb],
di->pcii.u.h0.base_registers[fb],
di->pcii.u.h0.base_register_sizes[fb],
B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA + B_WRITE_AREA,
@@ -243,7 +243,7 @@ MapDevice(DeviceInfo& di)
pciInfo.vendor_id, pciInfo.device_id,
pciInfo.bus, pciInfo.device, pciInfo.function);
si.regsArea = map_physical_memory(areaName, (void*)regsBase, regAreaSize,
si.regsArea = map_physical_memory(areaName, regsBase, regAreaSize,
B_ANY_KERNEL_ADDRESS,
0, // neither read nor write, to hide it from user space apps
(void**)(&(di.regs)));
@@ -259,7 +259,7 @@ MapDevice(DeviceInfo& di)
si.videoMemArea = map_physical_memory(
areaName,
(void*)videoRamAddr,
videoRamAddr,
videoRamSize,
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA + B_WRITE_AREA,
@@ -269,7 +269,7 @@ MapDevice(DeviceInfo& di)
// Try to map this time without write combining.
si.videoMemArea = map_physical_memory(
areaName,
(void*)videoRamAddr,
videoRamAddr,
videoRamSize,
B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA + B_WRITE_AREA,
@@ -374,7 +374,7 @@ static status_t map_device(device_info *di)
si->regs_area = map_physical_memory(
buffer,
/* WARNING: Nvidia needs to map regs as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[registers],
di->pcii.u.h0.base_registers_pci[registers],
di->pcii.u.h0.base_register_sizes[registers],
B_ANY_KERNEL_ADDRESS,
(si->use_clone_bugfix ? B_READ_AREA|B_WRITE_AREA : 0),
@@ -407,7 +407,7 @@ static status_t map_device(device_info *di)
rom_area = map_physical_memory(
buffer,
(void *)di->pcii.u.h0.rom_base_pci,
di->pcii.u.h0.rom_base_pci,
di->pcii.u.h0.rom_size,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -430,7 +430,7 @@ static status_t map_device(device_info *di)
/* ROM was not assigned an adress, fetch it from ISA legacy memory map! */
rom_area = map_physical_memory(
buffer,
(void *)0x000c0000,
0x000c0000,
65536,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
@@ -466,7 +466,7 @@ static status_t map_device(device_info *di)
si->fb_area = map_physical_memory(
buffer,
/* WARNING: Nvidia needs to map framebuffer as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA + B_WRITE_AREA,
@@ -477,7 +477,7 @@ static status_t map_device(device_info *di)
si->fb_area = map_physical_memory(
buffer,
/* WARNING: Nvidia needs to map framebuffer as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_registers_pci[frame_buffer],
di->pcii.u.h0.base_register_sizes[frame_buffer],
B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA + B_WRITE_AREA,
@@ -335,7 +335,7 @@ static status_t map_device(device_info *di)
di->pcii.bus, di->pcii.device, di->pcii.function);
si->regs_area = map_physical_memory(
buffer,
(void *)_regs,
_regs,
_regs_size,
B_ANY_KERNEL_ADDRESS,
0, /* B_READ_AREA + B_WRITE_AREA, */ /* neither read nor write, to hide it from user space apps */
@@ -257,7 +257,7 @@ remap_frame_buffer(vesa_info& info, addr_t physicalBase, uint32 width,
}
if (remap) {
area_id area = map_physical_memory("vesa frame buffer", (void*)base,
area_id area = map_physical_memory("vesa frame buffer", base,
size, B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA,
(void**)&frameBuffer);
if (area < 0)
@@ -383,7 +383,7 @@ static status_t map_device(device_info *di)
si->regs_area = map_physical_memory(
buffer,
/* WARNING: Nvidia needs to map regs as viewed from PCI space! */
(void *) di->pcii.u.h0.base_registers_pci[registers],
di->pcii.u.h0.base_registers_pci[registers],
di->pcii.u.h0.base_register_sizes[registers],
B_ANY_KERNEL_ADDRESS,
(si->use_clone_bugfix ? B_READ_AREA|B_WRITE_AREA : 0),
@@ -95,13 +95,13 @@ MapDevice()
/* Map the frame buffer */
si->fbArea = map_physical_memory("VMware frame buffer",
si->fbDma, si->fbSize, B_ANY_KERNEL_BLOCK_ADDRESS|B_MTR_WC,
(addr_t)si->fbDma, si->fbSize, B_ANY_KERNEL_BLOCK_ADDRESS|B_MTR_WC,
B_READ_AREA|B_WRITE_AREA, (void **)&si->fb);
if (si->fbArea < 0) {
/* Try again without write combining */
writeCombined = 0;
si->fbArea = map_physical_memory("VMware frame buffer",
si->fbDma, si->fbSize, B_ANY_KERNEL_BLOCK_ADDRESS,
(addr_t)si->fbDma, si->fbSize, B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA|B_WRITE_AREA, (void **)&si->fb);
}
if (si->fbArea < 0) {
@@ -114,7 +114,7 @@ MapDevice()
/* Map the fifo */
si->fifoArea = map_physical_memory("VMware fifo",
si->fifoDma, si->fifoSize, B_ANY_KERNEL_BLOCK_ADDRESS,
(addr_t)si->fifoDma, si->fifoSize, B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA|B_WRITE_AREA, (void **)&si->fifo);
if (si->fifoArea < 0) {
TRACE("failed to map fifo\n");
+3 -3
View File
@@ -155,7 +155,7 @@ mem_map_target(off_t position, size_t length, uint32 protection,
void **virtualAddress)
{
area_id area;
void *physicalAddress;
phys_addr_t physicalAddress;
size_t offset;
size_t size;
@@ -164,10 +164,10 @@ mem_map_target(off_t position, size_t length, uint32 protection,
return EINVAL;
/* the first page address */
physicalAddress = (void *)(addr_t)(position & ~((off_t)B_PAGE_SIZE - 1));
physicalAddress = (phys_addr_t)position & ~((off_t)B_PAGE_SIZE - 1);
/* offset of target into it */
offset = position - (off_t)(addr_t)physicalAddress;
offset = position - (off_t)physicalAddress;
/* size of the whole mapping (page rounded) */
size = (offset + length + B_PAGE_SIZE - 1) & ~((size_t)B_PAGE_SIZE - 1);
+3 -2
View File
@@ -245,7 +245,8 @@ poke_control(void* cookie, uint32 op, void* arg, size_t length)
return B_BAD_VALUE;
result = get_memory_map(ioctl->address, ioctl->size, &table, 1);
ioctl->physical_address = table.address;
ioctl->physical_address = (void*)(addr_t)table.address;
// TODO: mem_map_args::physical_address should be phys_addr_t!
ioctl->size = table.size;
return result;
}
@@ -257,7 +258,7 @@ poke_control(void* cookie, uint32 op, void* arg, size_t length)
return B_BAD_VALUE;
ioctl->area = map_physical_memory(ioctl->name,
ioctl->physical_address, ioctl->size, ioctl->flags,
(addr_t)ioctl->physical_address, ioctl->size, ioctl->flags,
ioctl->protection, (void**)&ioctl->address);
return ioctl->area;
}
@@ -111,7 +111,7 @@ static inline void b44_MM_MapRxDma(PLM_DEVICE_BLOCK pDevice,
physical_entry entry;
get_memory_map(pPacket->u.Rx.pRxBufferVirt,pPacket->u.Rx.RxBufferSize,&entry,1);
*paddr = (LM_UINT32) entry.address;
*paddr = entry.address;
}
static inline void b44_MM_MapTxDma(PLM_DEVICE_BLOCK pDevice,
@@ -122,7 +122,7 @@ static inline void b44_MM_MapTxDma(PLM_DEVICE_BLOCK pDevice,
physical_entry entry;
get_memory_map(pkt->data,pkt->size,&entry,1);
*paddr = (LM_UINT32) entry.address;
*paddr = entry.address;
*len = pPacket->PacketSize;
}
@@ -484,7 +484,10 @@ b44_MM_MapMemBase(PLM_DEVICE_BLOCK pDevice)
get_module(B_PCI_MODULE_NAME,(module_info **)&pci);
size = ROUNDUP(size,B_PAGE_SIZE);
pUmDevice->mem_base = map_physical_memory("bcm440x_regs",(void *)(pUmDevice->pci_data.u.h0.base_registers[0]),size,B_ANY_KERNEL_BLOCK_ADDRESS,B_READ_AREA | B_WRITE_AREA,(void **)(&pDevice->pMappedMemBase));
pUmDevice->mem_base = map_physical_memory("bcm440x_regs",
pUmDevice->pci_data.u.h0.base_registers[0], size,
B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA,
(void **)(&pDevice->pMappedMemBase));
return LM_STATUS_SUCCESS;
}
@@ -604,7 +607,7 @@ b44_MM_AllocateSharedMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
*pMemoryBlockVirt = (PLM_VOID) pvirt;
get_memory_map(pvirt,BlockSize,&entry,1);
*pMemoryBlockPhy = (LM_PHYSICAL_ADDRESS) entry.address;
*pMemoryBlockPhy = entry.address;
return LM_STATUS_SUCCESS;
}
@@ -780,7 +780,7 @@ MM_MapMemBase(PLM_DEVICE_BLOCK pDevice)
size = ROUND_UP_TO_PAGE(size);
pUmDevice->mem_base = map_physical_memory("broadcom_regs",
(void *)(pUmDevice->pci_data.u.h0.base_registers[0]), size,
pUmDevice->pci_data.u.h0.base_registers[0], size,
B_ANY_KERNEL_BLOCK_ADDRESS, 0,
(void **)(&pDevice->pMappedMemBase));
@@ -897,8 +897,8 @@ MM_AllocateSharedMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
*pMemoryBlockVirt = (PLM_VOID) pvirt;
get_memory_map(pvirt,BlockSize,&entry,1);
pMemoryBlockPhy->Low = (uint32)(entry.address);
pMemoryBlockPhy->High = 0;
pMemoryBlockPhy->Low = (uint32)entry.address;
pMemoryBlockPhy->High = (uint32)(entry.address >> 32);
/* We only support 32 bit */
return LM_STATUS_SUCCESS;
@@ -114,8 +114,8 @@ static inline void MM_MapRxDma(PLM_DEVICE_BLOCK pDevice,
struct B_UM_PACKET *bpkt = (struct B_UM_PACKET *)(pPacket);
get_memory_map(bpkt->data,pPacket->u.Rx.RxBufferSize,&entry,1);
paddr->Low = (LM_UINT32) entry.address;
paddr->High = 0L;
paddr->Low = (LM_UINT32)entry.address;
paddr->High = (LM_UINT32)(entry.address >> 32);
}
static inline void MM_MapTxDma(PLM_DEVICE_BLOCK pDevice,
@@ -126,8 +126,8 @@ static inline void MM_MapTxDma(PLM_DEVICE_BLOCK pDevice,
physical_entry entry;
get_memory_map(pkt->data,pkt->size,&entry,1);
paddr->Low = (LM_UINT32) entry.address;
paddr->High = 0L;
paddr->Low = (LM_UINT32)entry.address;
paddr->High = (LM_UINT32)(entry.address >> 32);
*len = pPacket->PacketSize;
}
@@ -162,7 +162,9 @@ static status_t close_hook( void * );
TRACE(( kDevName " _open_hook(): PCI base=%lx size=%lx offset=%lx\n", base, size, offset));
data->ioarea = map_physical_memory(kDevName " Regs", (void *)base, size, B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA, (void **)&data->reg_base);
data->ioarea = map_physical_memory(kDevName " Regs", base, size,
B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA,
(void **)&data->reg_base);
data->reg_base = data->reg_base + offset;
}
@@ -654,10 +656,10 @@ static status_t init_ring_buffers(dp83815_properties_t *data)
get_area_info(data->mem_area, &info);
get_memory_map(info.address, info.size, map, 4);
desc_base_phys_addr = (int)map[0].address + NUM_BUFFS*BUFFER_SIZE;
desc_base_virt_addr = (info.address + NUM_BUFFS*BUFFER_SIZE);
desc_base_phys_addr = map[0].address + NUM_BUFFS*BUFFER_SIZE;
desc_base_virt_addr = info.address + NUM_BUFFS*BUFFER_SIZE;
buff_base_phys_addr = (int)map[0].address;
buff_base_phys_addr = map[0].address;
buff_base_virt_addr = info.address;
RxDescRing = desc_base_virt_addr;
@@ -63,6 +63,7 @@ round_to_pagesize(uint32 size)
area_id
alloc_mem(void **log, void **phy, size_t size, const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * logadr;
area_id areaid;
@@ -87,7 +88,7 @@ alloc_mem(void **log, void **phy, size_t size, const char *name)
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
dprintf("area = %ld, size = %ld, log = %p, phy = %p\n",areaid,size,logadr,pe.address);
return areaid;
}
@@ -111,7 +112,8 @@ map_mem(void **log, void *phy, size_t size, const char *name)
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (void *) ( (uint32)phy - offset );
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr);
area = map_physical_memory(name, (addr_t)phyadr, size,
B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr);
*log = (void *) ( (uint32)mapadr + offset );
dprintf("physical = %p, logical = %p, offset = %#lx, phyadr = %p, mapadr = %p, size = %#lx, area = %#lx\n",
@@ -1198,8 +1198,11 @@ enable_addressing(etherpci_private_t *data)
dprintf(kDevName ": PCI base=%x size=%x offset=%x\n", base, size, offset);
if ((data->ioarea = map_physical_memory(kDevName "_regs", (void *)base, size, B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA, (void **)&data->reg_base)) < 0)
if ((data->ioarea = map_physical_memory(kDevName "_regs", base, size,
B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA,
(void **)&data->reg_base)) < 0) {
return B_ERROR;
}
data->reg_base = data->reg_base + offset;
@@ -125,7 +125,7 @@ static inline unsigned long vtophys(unsigned long virtual_addr)
err = get_memory_map((void *)virtual_addr, 2046, &pe, 1);
if (err < 0)
panic("ipro1000: get_memory_map failed for %p, error %08lx\n", (void *)virtual_addr, err);
return (unsigned long) pe.address;
return pe.address;
}
#define M_DEVBUF 1
@@ -36,7 +36,8 @@ map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (char *)phy - offset;
size = ROUNDUP(size + offset, B_PAGE_SIZE);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr);
area = map_physical_memory(name, (addr_t)phyadr, size,
B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr);
if (area < B_OK) {
ERROROUT3("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area));
return area;
@@ -37,6 +37,7 @@ area_id
alloc_contiguous(void **virt, void **phy, size_t size, uint32 protection,
const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * virtadr;
area_id areaid;
@@ -61,7 +62,7 @@ alloc_contiguous(void **virt, void **phy, size_t size, uint32 protection,
if (virt)
*virt = virtadr;
if (phy)
*phy = pe.address;
*phy = (void*)(addr_t)pe.address;
TRACE("area = %ld, size = %ld, virt = %p, phy = %p\n", areaid, size, virtadr, pe.address);
return areaid;
}
@@ -81,7 +82,7 @@ map_mem(void **virt, void *phy, size_t size, uint32 protection,
offset = (uint32)phy & (B_PAGE_SIZE - 1);
phyadr = (char *)phy - offset;
size = round_to_pagesize(size + offset);
area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_ADDRESS,
area = map_physical_memory(name, (addr_t)phyadr, size, B_ANY_KERNEL_ADDRESS,
protection, &mapadr);
if (area < B_OK) {
ERROR("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area));
@@ -71,13 +71,13 @@ const static struct mii_chip_info {
/***************************** helper functions *****************************/
static uint32
static phys_addr_t
physicalAddress(volatile void *address, uint32 length)
{
physical_entry table;
get_memory_map((void *)address, length, &table, 1);
return (uint32)table.address;
return table.address;
}
@@ -261,7 +261,7 @@ alloc_buffers(dev_info_t *device)
/* get physical address of Initialization Block */
size = RNDUP(sizeof(dev_info_t), B_PAGE_SIZE);
get_memory_map(&(device->init_blk), size, &entry, 1);
device->phys_init_blk = (uint32)entry.address;
device->phys_init_blk = entry.address;
TRACE((DEVICE_NAME " init block va=%p pa=%p, size %lx\n",
&(device->init_blk), (void *)device->phys_init_blk, size));
@@ -279,7 +279,7 @@ alloc_buffers(dev_info_t *device)
}
/* get physical address of tx descriptor */
get_memory_map(device->tx_desc[0], size, &entry, 1);
device->phys_tx_desc = (uint32)(entry.address);
device->phys_tx_desc = entry.address;
TRACE((DEVICE_NAME " create tx desc area va=%p pa=%p sz=%lx\n",
device->tx_desc[0], (void *)device->phys_tx_desc, size));
@@ -300,7 +300,7 @@ alloc_buffers(dev_info_t *device)
/* get physical address of tx buffer */
get_memory_map(device->tx_buf[0], size, &entry, 1);
device->phys_tx_buf = (uint32)(entry.address);
device->phys_tx_buf = entry.address;
TRACE((DEVICE_NAME " create tx buf area va=%p pa=%08lx sz=%lx\n",
device->tx_buf[0], device->tx_desc[0]->s.tbadr, size));
@@ -321,7 +321,7 @@ alloc_buffers(dev_info_t *device)
}
/* get physical address of rx descriptor */
get_memory_map(device->rx_desc[0], size, &entry, 1);
device->phys_rx_desc = (uint32)entry.address;
device->phys_rx_desc = entry.address;
TRACE((DEVICE_NAME " create rx desc area va=%p pa=%p sz=%lx\n",
device->rx_desc[0], (void *)device->phys_rx_desc, size));
@@ -342,7 +342,7 @@ alloc_buffers(dev_info_t *device)
}
/* get physical address of rx buffer */
get_memory_map(device->rx_buf[0], size, &entry, 1);
device->phys_rx_buf = (uint32)(entry.address);
device->phys_rx_buf = entry.address;
TRACE((DEVICE_NAME " create rx buf area va=%p pa=%08lx sz=%lx\n",
device->rx_buf[0], device->rx_desc[0]->s.rbadr, size));
@@ -53,14 +53,14 @@ mii_readstatus(wb_device *device)
}
static uint32
static phys_addr_t
physicalAddress(volatile void *addr, uint32 length)
{
physical_entry table;
get_memory_map((void*)addr, length, &table, 1);
return (uint32)table.address;
return table.address;
}
@@ -897,7 +897,7 @@ IPW2100::MapPhysicalMemory(const char *name, uint32 physicalAddress,
size = (size + offset + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
void *virtualAddress;
area_id area = map_physical_memory(name, (void *)physicalAddress, size,
area_id area = map_physical_memory(name, physicalAddress, size,
B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA, &virtualAddress);
if (area < B_OK) {
TRACE_ALWAYS(("IPW2100: mapping physical address failed\n"));
@@ -918,6 +918,7 @@ area_id
IPW2100::AllocateContiguous(const char *name, void **logicalAddress,
uint32 *physicalAddress, size_t size)
{
// TODO: physicalAddress should be phys_addr_t*!
size = (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
void *virtualAddress = NULL;
area_id area = create_area(name, &virtualAddress, B_ANY_KERNEL_ADDRESS,
@@ -933,7 +934,7 @@ IPW2100::AllocateContiguous(const char *name, void **logicalAddress,
if (physicalAddress) {
physical_entry physicalEntry;
get_memory_map(virtualAddress, size, &physicalEntry, 1);
*physicalAddress = (uint32)physicalEntry.address;
*physicalAddress = physicalEntry.address;
}
return area;
@@ -249,12 +249,13 @@ ata_adapter_prepare_dma(ata_adapter_channel_info *channel,
writeToDevice ? "write" : "read", sgListCount);
for (i = sgListCount - 1, prd = channel->prdt; i >= 0; --i, ++prd, ++sgList) {
prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device, sgList->address));
prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device,
(void*)(addr_t)sgList->address));
// 0 means 64K - this is done automatically be discarding upper 16 bits
prd->count = B_HOST_TO_LENDIAN_INT16((uint16)sgList->size);
prd->EOT = i == 0;
TRACE_DMA("ata_adapter: %p, %ld => 0x%08x, %d, %d\n",
TRACE_DMA("ata_adapter: %#" B_PRIxPHYSADDR ", %ld => 0x%08x, %d, %d\n",
sgList->address, sgList->size, prd->address, prd->count, prd->EOT);
SHOW_FLOW( 4, "%x, %x, %d", (int)prd->address, prd->count, prd->EOT);
}
@@ -413,7 +414,7 @@ ata_adapter_init_channel(device_node *node,
}
get_memory_map(channel->prdt, prdt_size, pe, 1);
channel->prdt_phys = (uint32)pe[0].address;
channel->prdt_phys = pe[0].address;
SHOW_FLOW(3, "virt=%p, phys=%x", channel->prdt, (int)channel->prdt_phys);
@@ -227,7 +227,8 @@ ide_adapter_prepare_dma(ide_adapter_channel_info *channel,
int i;
for (i = sgListCount - 1, prd = channel->prdt; i >= 0; --i, ++prd, ++sgList) {
prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device, sgList->address));
prd->address = B_HOST_TO_LENDIAN_INT32(pci->ram_address(device,
(void*)(addr_t)sgList->address));
// 0 means 64K - this is done automatically be discarding upper 16 bits
prd->count = B_HOST_TO_LENDIAN_INT16((uint16)sgList->size);
prd->EOT = i == 0;
@@ -405,7 +405,7 @@ openpic_init_driver(device_node *node, void **cookie)
// map register space
void *virtualRegisterBase = NULL;
area_id registerArea = map_physical_memory("openpic registers",
(void*)physicalRegisterBase, registerSpaceSize, B_ANY_KERNEL_ADDRESS,
physicalRegisterBase, registerSpaceSize, B_ANY_KERNEL_ADDRESS,
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, &virtualRegisterBase);
if (registerArea < 0)
return info->register_area;
+1 -1
View File
@@ -649,7 +649,7 @@ arch_vm_init_post_area(kernel_args *args)
vm_mark_page_range_inuse(0x0, 0xa0000 / B_PAGE_SIZE);
// map 0 - 0xa0000 directly
id = map_physical_memory("dma_region", (void *)0x0, 0xa0000,
id = map_physical_memory("dma_region", 0x0, 0xa0000,
B_ANY_KERNEL_ADDRESS | B_MTR_WB,
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, &gDmaAddress);
if (id < 0) {
+1 -1
View File
@@ -120,7 +120,7 @@ extern "C" status_t
bios_init(void)
{
// map BIOS area 0xe0000 - 0xfffff
area_id biosArea = map_physical_memory("pc bios", (void *)0xe0000, 0x20000,
area_id biosArea = map_physical_memory("pc bios", 0xe0000, 0x20000,
B_ANY_KERNEL_ADDRESS | B_MTR_WB,
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void **)&gBiosBase);
if (biosArea < 0)
+1 -1
View File
@@ -556,7 +556,7 @@ vm86_prepare(struct vm86_state *state, unsigned int ramSize)
}
// copy int vectors and BIOS data area
vectors = map_physical_memory("int vectors", (void *)0, 0x502,
vectors = map_physical_memory("int vectors", 0, 0x502,
B_ANY_KERNEL_BLOCK_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA,
&address);
if (vectors < B_OK) {
@@ -414,7 +414,7 @@ frame_buffer_console_init(kernel_args* args)
void* frameBuffer;
sConsole.area = map_physical_memory("vesa frame buffer",
(void*)args->frame_buffer.physical_buffer.start,
args->frame_buffer.physical_buffer.start,
args->frame_buffer.physical_buffer.size, B_ANY_KERNEL_ADDRESS,
B_READ_AREA | B_WRITE_AREA | B_USER_CLONEABLE_AREA, &frameBuffer);
if (sConsole.area < 0)
+3 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@@ -106,7 +106,7 @@ private:
uint32 fEntriesEver;
spinlock fLock;
char* fTraceOutputBuffer;
addr_t fPhysicalAddress;
phys_addr_t fPhysicalAddress;
uint32 fMagic3;
};
@@ -380,7 +380,7 @@ TracingMetaData::Create(TracingMetaData*& _metaData)
physical_entry physicalEntry;
if (get_memory_map(metaData->fTraceOutputBuffer, B_PAGE_SIZE,
&physicalEntry, 1) == B_OK) {
metaData->fPhysicalAddress = (addr_t)physicalEntry.address;
metaData->fPhysicalAddress = physicalEntry.address;
} else {
dprintf("TracingMetaData::Create(): failed to get physical address "
"of tracing buffer\n");
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2008, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@@ -1219,6 +1219,7 @@ IORequest::_CopySimple(void* bounceBuffer, void* external, size_t size,
IORequest::_CopyPhysical(void* bounceBuffer, void* external, size_t size,
team_id team, bool copyIn)
{
// TODO: The physical address must be phys_addr_t!
if (copyIn) {
return vm_memcpy_from_physical(bounceBuffer, (addr_t)external, size,
false);
@@ -1250,7 +1251,7 @@ IORequest::_CopyUser(void* _bounceBuffer, void* _external, size_t size,
for (uint32 i = 0; i < count; i++) {
const physical_entry& entry = entries[i];
error = _CopyPhysical(bounceBuffer, entry.address,
error = _CopyPhysical(bounceBuffer, (void*)entry.address,
entry.size, team, copyIn);
if (error != B_OK)
return error;
@@ -1,5 +1,5 @@
/*
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2008, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@@ -241,7 +241,7 @@ DMAResource::CreateBounceBuffer(DMABounceBuffer** _buffer)
return B_ERROR;
}
physicalBase = (addr_t)entry.address;
physicalBase = entry.address;
if (fRestrictions.high_address < physicalBase + size) {
delete_area(area);
@@ -440,7 +440,7 @@ DMAResource::TranslateNext(IORequest* request, IOOperation* operation,
get_memory_map_etc(request->Team(), (void*)base, size,
&entry, &count);
vecs[segmentCount].iov_base = entry.address;
vecs[segmentCount].iov_base = (void*)(addr_t)entry.address;
vecs[segmentCount].iov_len = entry.size;
transferLeft -= entry.size;
+8 -7
View File
@@ -5388,13 +5388,13 @@ get_memory_map_etc(team_id team, const void* address, size_t numBytes,
}
// need to switch to the next physical_entry?
if (index < 0 || (phys_addr_t)table[index].address
if (index < 0 || table[index].address
!= physicalAddress - table[index].size) {
if ((uint32)++index + 1 > numEntries) {
// table to small
break;
}
table[index].address = (void*)physicalAddress;
table[index].address = physicalAddress;
table[index].size = bytes;
} else {
// page does fit in current entry
@@ -5442,7 +5442,7 @@ get_memory_map(const void* address, ulong numBytes, physical_entry* table,
if (entriesRead + 1 > (uint32)numEntries)
return B_BUFFER_OVERFLOW;
table[entriesRead].address = NULL;
table[entriesRead].address = 0;
table[entriesRead].size = 0;
return B_OK;
@@ -5567,8 +5567,9 @@ transfer_area(area_id id, void** _address, uint32 addressSpec, team_id target,
area_id
map_physical_memory(const char* name, void* physicalAddress, size_t numBytes,
uint32 addressSpec, uint32 protection, void** _virtualAddress)
map_physical_memory(const char* name, phys_addr_t physicalAddress,
size_t numBytes, uint32 addressSpec, uint32 protection,
void** _virtualAddress)
{
if (!arch_vm_supports_protection(protection))
return B_NOT_SUPPORTED;
@@ -5576,8 +5577,8 @@ map_physical_memory(const char* name, void* physicalAddress, size_t numBytes,
fix_protection(&protection);
return vm_map_physical_memory(VMAddressSpace::KernelID(), name,
_virtualAddress, addressSpec, numBytes, protection,
(phys_addr_t)physicalAddress, false);
_virtualAddress, addressSpec, numBytes, protection, physicalAddress,
false);
}