Changeset View
Changeset View
Standalone View
Standalone View
head/sys/powerpc/ofw/ofw_real.c
Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | ofw_real_bounce_alloc(void *junk) | ||||
of_bounce_phys = vtophys(of_bounce_virt); | of_bounce_phys = vtophys(of_bounce_virt); | ||||
of_bounce_size = 4 * PAGE_SIZE; | of_bounce_size = 4 * PAGE_SIZE; | ||||
/* | /* | ||||
* For virtual-mode OF, direct map this physical address so that | * For virtual-mode OF, direct map this physical address so that | ||||
* we have a 32-bit virtual address to give OF. | * we have a 32-bit virtual address to give OF. | ||||
*/ | */ | ||||
if (!ofw_real_mode && !hw_direct_map) | if (!ofw_real_mode && (!hw_direct_map || DMAP_BASE_ADDRESS != 0)) | ||||
pmap_kenter(of_bounce_phys, of_bounce_phys); | pmap_kenter(of_bounce_phys, of_bounce_phys); | ||||
mtx_unlock(&of_bounce_mtx); | mtx_unlock(&of_bounce_mtx); | ||||
} | } | ||||
static cell_t | static cell_t | ||||
ofw_real_map(const void *buf, size_t len) | ofw_real_map(const void *buf, size_t len) | ||||
{ | { | ||||
static char emergency_buffer[255]; | static char emergency_buffer[255]; | ||||
cell_t phys; | cell_t phys; | ||||
mtx_assert(&of_bounce_mtx, MA_OWNED); | mtx_assert(&of_bounce_mtx, MA_OWNED); | ||||
if (of_bounce_virt == NULL) { | if (of_bounce_virt == NULL) { | ||||
/* | /* | ||||
* If we haven't set up the MMU, then buf is guaranteed | * If we haven't set up the MMU, then buf is guaranteed | ||||
* to be accessible to OF, because the only memory we | * to be accessible to OF, because the only memory we | ||||
* can use right now is memory mapped by firmware. | * can use right now is memory mapped by firmware. | ||||
*/ | */ | ||||
if (!pmap_bootstrapped) | if (!pmap_bootstrapped) | ||||
return (cell_t)(uintptr_t)buf; | return (cell_t)((uintptr_t)buf & ~DMAP_BASE_ADDRESS); | ||||
/* | /* | ||||
* XXX: It is possible for us to get called before the VM has | * XXX: It is possible for us to get called before the VM has | ||||
* come online, but after the MMU is up. We don't have the | * come online, but after the MMU is up. We don't have the | ||||
* bounce buffer yet, but can no longer presume a 1:1 mapping. | * bounce buffer yet, but can no longer presume a 1:1 mapping. | ||||
* Copy into the emergency buffer, and reset at the end. | * Copy into the emergency buffer, and reset at the end. | ||||
*/ | */ | ||||
of_bounce_virt = emergency_buffer; | of_bounce_virt = emergency_buffer; | ||||
of_bounce_phys = (vm_offset_t)of_bounce_virt; | of_bounce_phys = (vm_offset_t)of_bounce_virt & | ||||
~DMAP_BASE_ADDRESS; | |||||
of_bounce_size = sizeof(emergency_buffer); | of_bounce_size = sizeof(emergency_buffer); | ||||
} | } | ||||
/* | /* | ||||
* Make sure the bounce page offset satisfies any reasonable | * Make sure the bounce page offset satisfies any reasonable | ||||
* alignment constraint. | * alignment constraint. | ||||
*/ | */ | ||||
of_bounce_offset += sizeof(register_t) - (of_bounce_offset % sizeof(register_t)); | of_bounce_offset += sizeof(register_t) - | ||||
(of_bounce_offset % sizeof(register_t)); | |||||
if (of_bounce_offset + len > of_bounce_size) { | if (of_bounce_offset + len > of_bounce_size) { | ||||
panic("Oversize Open Firmware call!"); | panic("Oversize Open Firmware call!"); | ||||
return 0; | return 0; | ||||
} | } | ||||
if (buf != NULL) | if (buf != NULL) | ||||
memcpy(of_bounce_virt + of_bounce_offset, buf, len); | memcpy(of_bounce_virt + of_bounce_offset, buf, len); | ||||
▲ Show 20 Lines • Show All 831 Lines • Show Last 20 Lines |