The old map_io() function can now be removed. Also fill in ofmem_arch_early_map_pages() on SPARC32 which is required for ofmem_map_io() to work correctly.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk --- openbios-devel/arch/sparc32/console.c | 4 ++-- openbios-devel/arch/sparc32/lib.c | 25 +------------------------ openbios-devel/drivers/escc.c | 4 ++-- openbios-devel/drivers/esp.c | 4 ++-- openbios-devel/drivers/fw_cfg.c | 2 +- openbios-devel/drivers/iommu.c | 2 +- openbios-devel/drivers/obio.c | 10 +++++----- openbios-devel/drivers/sbus.c | 2 +- openbios-devel/include/libopenbios/ofmem.h | 1 - 9 files changed, 15 insertions(+), 39 deletions(-)
diff --git a/openbios-devel/arch/sparc32/console.c b/openbios-devel/arch/sparc32/console.c index 52e4827..2bcdf02 100644 --- a/openbios-devel/arch/sparc32/console.c +++ b/openbios-devel/arch/sparc32/console.c @@ -46,8 +46,8 @@ static void video_cls(void)
void tcx_init(uint64_t base) { - vmem = map_io(base + VMEM_BASE, VMEM_SIZE); - dac = map_io(base + DAC_BASE, DAC_SIZE); + vmem = (unsigned char *)ofmem_map_io(base + VMEM_BASE, VMEM_SIZE); + dac = (uint32_t *)ofmem_map_io(base + DAC_BASE, DAC_SIZE);
console_init(); } diff --git a/openbios-devel/arch/sparc32/lib.c b/openbios-devel/arch/sparc32/lib.c index 6847b36..74ac5e7 100644 --- a/openbios-devel/arch/sparc32/lib.c +++ b/openbios-devel/arch/sparc32/lib.c @@ -218,29 +218,6 @@ map_pages(phys_addr_t phys, unsigned long virt, }
/* - * Create an I/O mapping to pa[size]. - * Returns va of the mapping or 0 if unsuccessful. - */ -void * -map_io(uint64_t pa, int size) -{ - unsigned long va; - unsigned int npages; - unsigned int off; - - off = pa & (PAGE_SIZE - 1); - npages = (off + size - 1) / PAGE_SIZE + 1; - pa &= ~(PAGE_SIZE - 1); - - va = (unsigned long)mem_alloc(&cio, npages * PAGE_SIZE, PAGE_SIZE); - if (va == 0) - return NULL; - - map_pages(pa, va, npages * PAGE_SIZE, ofmem_arch_io_translation_mode(pa)); - return (void *)(va + off); -} - -/* * D5.3 pgmap@ ( va -- pte ) */ static void @@ -371,7 +348,7 @@ void ofmem_arch_unmap_pages(ucell virt, ucell size)
void ofmem_arch_early_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode) { - /* Currently do nothing */ + map_pages(phys, virt, size, mode); }
char *obp_dumb_memalloc(char *va, unsigned int size) diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index e22d245..ef431b2 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -105,7 +105,7 @@ static void uart_init_line(volatile unsigned char *port, unsigned long baud) int uart_init(phys_addr_t port, unsigned long speed) { #ifdef CONFIG_DRIVER_ESCC_SUN - serial_dev = map_io(port & ~7ULL, ZS_REGS); + serial_dev = (unsigned char *)ofmem_map_io(port & ~7ULL, ZS_REGS); serial_dev += port & 7ULL; #else serial_dev = (unsigned char *)(uintptr_t)port; @@ -213,7 +213,7 @@ static volatile unsigned char *kbd_dev;
void kbd_init(phys_addr_t base) { - kbd_dev = map_io(base, 2 * 4); + kbd_dev = (unsigned char *)ofmem_map_io(base, 2 * 4); kbd_dev += 4; }
diff --git a/openbios-devel/drivers/esp.c b/openbios-devel/drivers/esp.c index 869421d..f268b6a 100644 --- a/openbios-devel/drivers/esp.c +++ b/openbios-devel/drivers/esp.c @@ -311,7 +311,7 @@ static int espdma_init(unsigned int slot, uint64_t base, unsigned long offset, struct esp_dma *espdma) { - espdma->regs = (void *)map_io(base + (uint64_t)offset, 0x10); + espdma->regs = (void *)ofmem_map_io(base + (uint64_t)offset, 0x10);
if (espdma->regs == NULL) { DPRINTF("espdma_init: cannot map registers\n"); @@ -445,7 +445,7 @@ ob_esp_init(unsigned int slot, uint64_t base, unsigned long espoffset, return -1; } /* Get the IO region */ - esp->ll = (void *)map_io(base + (uint64_t)espoffset, + esp->ll = (void *)ofmem_map_io(base + (uint64_t)espoffset, sizeof(struct esp_regs)); if (esp->ll == NULL) { DPRINTF("Can't map ESP registers\n"); diff --git a/openbios-devel/drivers/fw_cfg.c b/openbios-devel/drivers/fw_cfg.c index 0da2e72..4027570 100644 --- a/openbios-devel/drivers/fw_cfg.c +++ b/openbios-devel/drivers/fw_cfg.c @@ -65,7 +65,7 @@ void fw_cfg_init(void) { #if defined(CONFIG_SPARC32) - fw_cfg_cmd = (void *)map_io(CONFIG_FW_CFG_ADDR, 2); + fw_cfg_cmd = (void *)ofmem_map_io(CONFIG_FW_CFG_ADDR, 2); fw_cfg_data = (uint8_t *)fw_cfg_cmd + 2; #elif defined(CONFIG_SPARC64) // Nothing for the port version diff --git a/openbios-devel/drivers/iommu.c b/openbios-devel/drivers/iommu.c index 6af5b33..7d34f81 100644 --- a/openbios-devel/drivers/iommu.c +++ b/openbios-devel/drivers/iommu.c @@ -103,7 +103,7 @@ iommu_init(struct iommu *t, uint64_t base) int ret; unsigned long vasize;
- regs = map_io(base, IOMMU_REGS); + regs = (struct iommu_regs *)ofmem_map_io(base, IOMMU_REGS); if (regs == NULL) { DPRINTF("Cannot map IOMMU\n"); for (;;) { } diff --git a/openbios-devel/drivers/obio.c b/openbios-devel/drivers/obio.c index 38c5f8d..359c6c2 100644 --- a/openbios-devel/drivers/obio.c +++ b/openbios-devel/drivers/obio.c @@ -71,7 +71,7 @@ map_reg(uint64_t base, uint64_t offset, unsigned long size, int map, if (map) { unsigned long addr;
- addr = (unsigned long)map_io(base + offset, size); + addr = (unsigned long)ofmem_map_io(base + offset, size);
PUSH(addr); fword("encode-int"); @@ -251,7 +251,7 @@ ob_aux2_reset_init(uint64_t base, uint64_t offset, int intr) power_reg = (void *)ob_reg(base, offset, AUXIO2_REGS, 1);
// Not in device tree - reset_reg = map_io(base + (uint64_t)SLAVIO_RESET, RESET_REGS); + reset_reg = (unsigned int *)ofmem_map_io(base + (uint64_t)SLAVIO_RESET, RESET_REGS);
bind_func("sparc32-reset-all", sparc32_reset_all); push_str("' sparc32-reset-all to reset-all"); @@ -297,7 +297,7 @@ ob_counter_init(uint64_t base, unsigned long offset) fword("property");
- counter_regs = map_io(base + (uint64_t)offset, sizeof(*counter_regs)); + counter_regs = (struct sun4m_timer_regs *)ofmem_map_io(base + (uint64_t)offset, sizeof(*counter_regs)); counter_regs->cfg = 0xffffffff; counter_regs->l10_timer_limit = (((1000000/100) + 1) << 10); counter_regs->cpu_timers[0].l14_timer_limit = 0; @@ -352,7 +352,7 @@ ob_interrupt_init(uint64_t base, unsigned long offset) push_str("reg"); fword("property");
- intregs = map_io(base | (uint64_t)offset, sizeof(*intregs)); + intregs = (struct sun4m_intregs *)ofmem_map_io(base | (uint64_t)offset, sizeof(*intregs)); intregs->clear = ~SUN4M_INT_MASKALL; intregs->cpu_intregs[0].clear = ~0x17fff;
@@ -403,7 +403,7 @@ static void ob_smp_init(unsigned long mem_size) { // See arch/sparc32/entry.S for memory layout - smp_header = (struct smp_cfg *)map_io((uint64_t)(mem_size - 0x100), + smp_header = (struct smp_cfg *)ofmem_map_io((uint64_t)(mem_size - 0x100), sizeof(struct smp_cfg)); }
diff --git a/openbios-devel/drivers/sbus.c b/openbios-devel/drivers/sbus.c index cba1050..f4a6d66 100644 --- a/openbios-devel/drivers/sbus.c +++ b/openbios-devel/drivers/sbus.c @@ -49,7 +49,7 @@ ob_sbus_node_init(uint64_t base) push_str("reg"); fword("property");
- regs = map_io(base, SBUS_REGS); + regs = (void *)ofmem_map_io(base, SBUS_REGS); PUSH((unsigned long)regs); fword("encode-int"); push_str("address"); diff --git a/openbios-devel/include/libopenbios/ofmem.h b/openbios-devel/include/libopenbios/ofmem.h index fa37146..4588a5e 100644 --- a/openbios-devel/include/libopenbios/ofmem.h +++ b/openbios-devel/include/libopenbios/ofmem.h @@ -136,7 +136,6 @@ extern struct mem cdvmem; void mem_init(struct mem *t, char *begin, char *limit); void *mem_alloc(struct mem *t, int size, int align); void map_pages(phys_addr_t phys, unsigned long virt, unsigned long size, unsigned long mode); -void *map_io(uint64_t pa, int size); #endif
#ifdef PAGE_SHIFT