From 9182a61b9b3af5202070698095a3f0d1756b6a3f Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Mon, 23 Feb 2009 23:08:40 +0000 Subject: [PATCH] [S3C/DM9000] Removed base addresses substractions New qemu already does the bank address substraction, no need to do it in IO memory accessors --- hw/dm9000.c | 4 ++-- hw/s3c2410.c | 27 +++++---------------------- hw/s3c2410_nand.c | 2 -- hw/s3c2440_nand.c | 2 -- hw/s3c24xx_gpio.c | 2 -- hw/s3c24xx_lcd.c | 2 -- hw/s3c24xx_mmci.c | 2 -- hw/s3c24xx_rtc.c | 2 -- hw/s3c24xx_udc.c | 6 +++--- 9 files changed, 10 insertions(+), 39 deletions(-) diff --git a/hw/dm9000.c b/hw/dm9000.c index 8d8b0e1123..efc4a96ebf 100644 --- a/hw/dm9000.c +++ b/hw/dm9000.c @@ -612,8 +612,8 @@ void dm9000_init(NICInfo *nd, target_phys_addr_t base_addr, iomemtype = cpu_register_io_memory(0, dm9000_readfn, dm9000_writefn, state); cpu_register_physical_memory(base_addr, MAX(addr_offset, data_offset) + 4, iomemtype); - state->addr = base_addr + addr_offset; - state->data = base_addr + data_offset; + state->addr = /*base_addr + */addr_offset; + state->data = /*base_addr + */data_offset; state->irq = irq; memcpy(state->macaddr, nd->macaddr, 6); diff --git a/hw/s3c2410.c b/hw/s3c2410.c index 8d7298597b..833fee9477 100644 --- a/hw/s3c2410.c +++ b/hw/s3c2410.c @@ -214,7 +214,6 @@ static void s3c_pic_reset(struct s3c_pic_state_s *s) static uint32_t s3c_pic_read(void *opaque, target_phys_addr_t addr) { struct s3c_pic_state_s *s = (struct s3c_pic_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_SRCPND: @@ -244,7 +243,6 @@ static void s3c_pic_write(void *opaque, target_phys_addr_t addr, uint32_t value) { struct s3c_pic_state_s *s = (struct s3c_pic_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_SRCPND: @@ -387,7 +385,6 @@ static void s3c_mc_reset(struct s3c_state_s *s) static uint32_t s3c_mc_read(void *opaque, target_phys_addr_t addr) { struct s3c_state_s *s = (struct s3c_state_s *) opaque; - addr -= s->mc_base; switch (addr >> 2) { case S3C_BWSCON ... S3C_MRSRB7: @@ -403,7 +400,6 @@ static void s3c_mc_write(void *opaque, target_phys_addr_t addr, uint32_t value) { struct s3c_state_s *s = (struct s3c_state_s *) opaque; - addr -= s->mc_base; switch (addr >> 2) { case S3C_BWSCON ... S3C_MRSRB7: @@ -464,7 +460,6 @@ static void s3c_clkpwr_reset(struct s3c_state_s *s) static uint32_t s3c_clkpwr_read(void *opaque, target_phys_addr_t addr) { struct s3c_state_s *s = (struct s3c_state_s *) opaque; - addr -= s->clkpwr_base; switch (addr) { case S3C_LOCKTIME ... S3C_CLKDIVN: @@ -480,7 +475,6 @@ static void s3c_clkpwr_write(void *opaque, target_phys_addr_t addr, uint32_t value) { struct s3c_state_s *s = (struct s3c_state_s *) opaque; - addr -= s->clkpwr_base; switch (addr) { case S3C_LOCKTIME: @@ -675,7 +669,7 @@ static uint32_t s3c_dma_read(void *opaque, target_phys_addr_t addr) { struct s3c_dma_state_s *s = (struct s3c_dma_state_s *) opaque; struct s3c_dma_ch_state_s *ch = 0; - addr -= s->base; + if (addr >= 0 && addr <= (S3C_DMA_CH_N << 6)) { ch = &s->ch[addr >> 6]; addr &= 0x3f; @@ -712,7 +706,7 @@ static void s3c_dma_write(void *opaque, target_phys_addr_t addr, { struct s3c_dma_state_s *s = (struct s3c_dma_state_s *) opaque; struct s3c_dma_ch_state_s *ch = 0; - addr -= s->base; + if (addr >= 0 && addr <= (S3C_DMA_CH_N << 6)) { ch = &s->ch[addr >> 6]; addr &= 0x3f; @@ -961,7 +955,6 @@ static uint32_t s3c_timers_read(void *opaque, target_phys_addr_t addr) { struct s3c_timers_state_s *s = (struct s3c_timers_state_s *) opaque; int tm = 0; - addr -= s->base; switch (addr) { case S3C_TCFG0: @@ -999,7 +992,7 @@ static void s3c_timers_write(void *opaque, target_phys_addr_t addr, { struct s3c_timers_state_s *s = (struct s3c_timers_state_s *) opaque; int tm = 0; - addr -= s->base; + // s->base; switch (addr) { case S3C_TCFG0: @@ -1323,7 +1316,6 @@ static uint32_t s3c_uart_read(void *opaque, target_phys_addr_t addr) { struct s3c_uart_state_s *s = (struct s3c_uart_state_s *) opaque; uint8_t ret; - addr -= s->base; switch (addr) { case S3C_ULCON: @@ -1375,7 +1367,6 @@ static void s3c_uart_write(void *opaque, target_phys_addr_t addr, struct s3c_uart_state_s *s = (struct s3c_uart_state_s *) opaque; uint8_t ch; int i, afc; - addr -= s->base; switch (addr) { case S3C_ULCON: @@ -1596,7 +1587,6 @@ static void s3c_adc_event(void *opaque, static uint32_t s3c_adc_read(void *opaque, target_phys_addr_t addr) { struct s3c_adc_state_s *s = (struct s3c_adc_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_ADCCON: @@ -1622,7 +1612,6 @@ static void s3c_adc_write(void *opaque, target_phys_addr_t addr, uint32_t value) { struct s3c_adc_state_s *s = (struct s3c_adc_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_ADCCON: @@ -1862,7 +1851,6 @@ static void s3c_master_work(void *opaque) static uint32_t s3c_i2c_read(void *opaque, target_phys_addr_t addr) { struct s3c_i2c_state_s *s = (struct s3c_i2c_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_IICCON: @@ -1884,7 +1872,6 @@ static void s3c_i2c_write(void *opaque, target_phys_addr_t addr, uint32_t value) { struct s3c_i2c_state_s *s = (struct s3c_i2c_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_IICCON: @@ -2053,7 +2040,7 @@ static uint32_t s3c_spi_read(void *opaque, target_phys_addr_t addr) { struct s3c_spi_state_s *s = (struct s3c_spi_state_s *) opaque; int ch; - addr -= s->base; + ch = addr >> 5; switch (addr) { @@ -2096,7 +2083,7 @@ static void s3c_spi_write(void *opaque, target_phys_addr_t addr, { struct s3c_spi_state_s *s = (struct s3c_spi_state_s *) opaque; int ch; - addr -= s->base; + ch = addr >> 5; switch (addr) { @@ -2342,7 +2329,6 @@ static uint32_t s3c_i2s_read(void *opaque, target_phys_addr_t addr) { struct s3c_i2s_state_s *s = (struct s3c_i2s_state_s *) opaque; uint32_t ret; - addr -= s->base; switch (addr) { case S3C_IISCON: @@ -2377,7 +2363,6 @@ static void s3c_i2s_write(void *opaque, target_phys_addr_t addr, uint32_t value) { struct s3c_i2s_state_s *s = (struct s3c_i2s_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_IISCON: @@ -2550,7 +2535,6 @@ static void s3c_wdt_timeout(void *opaque) static uint32_t s3c_wdt_read(void *opaque, target_phys_addr_t addr) { struct s3c_wdt_state_s *s = (struct s3c_wdt_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_WTCON: @@ -2571,7 +2555,6 @@ static void s3c_wdt_write(void *opaque, target_phys_addr_t addr, uint32_t value) { struct s3c_wdt_state_s *s = (struct s3c_wdt_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_WTCON: diff --git a/hw/s3c2410_nand.c b/hw/s3c2410_nand.c index 6cd73a04e0..f693d7a30c 100644 --- a/hw/s3c2410_nand.c +++ b/hw/s3c2410_nand.c @@ -47,7 +47,6 @@ static uint32_t s3c2410_nand_read(void *opaque, target_phys_addr_t addr) int rb, shr = 0; if (!s->nand) return 0; - addr -= s->nand_base; switch (addr) { case S3C_NFCONF: @@ -88,7 +87,6 @@ static void s3c2410_nand_write(void *opaque, target_phys_addr_t addr, struct s3c2410_nand_s *s = (struct s3c2410_nand_s *) opaque; if (!s->nand) return; - addr -= s->nand_base; switch (addr) { case S3C_NFCONF: diff --git a/hw/s3c2440_nand.c b/hw/s3c2440_nand.c index bae794b98a..53d742e07c 100644 --- a/hw/s3c2440_nand.c +++ b/hw/s3c2440_nand.c @@ -47,7 +47,6 @@ static uint32_t s3c2440_nand_read(void *opaque, target_phys_addr_t addr) int rb, shr = 0; if (!s->nand) return 0; - addr -= s->nand_base; switch (addr) { case S3C_NFCONF: @@ -88,7 +87,6 @@ static void s3c2440_nand_write(void *opaque, target_phys_addr_t addr, struct s3c2440_nand_s *s = (struct s3c2440_nand_s *) opaque; if (!s->nand) return; - addr -= s->nand_base; switch (addr) { case S3C_NFCONF: diff --git a/hw/s3c24xx_gpio.c b/hw/s3c24xx_gpio.c index c7aa67e5be..33337c8f59 100644 --- a/hw/s3c24xx_gpio.c +++ b/hw/s3c24xx_gpio.c @@ -175,7 +175,6 @@ static uint32_t s3c_gpio_read(void *opaque, target_phys_addr_t addr) { struct s3c_gpio_state_s *s = (struct s3c_gpio_state_s *) opaque; int bank = 0; - addr -= s->base; if ((addr >> 4) < S3C_IO_BANKS) { bank = addr >> 4; addr &= 0xf; @@ -230,7 +229,6 @@ static void s3c_gpio_write(void *opaque, target_phys_addr_t addr, struct s3c_gpio_state_s *s = (struct s3c_gpio_state_s *) opaque; uint32_t diff; int ln, bank = 0; - addr -= s->base; if ((addr >> 4) < S3C_IO_BANKS) { bank = addr >> 4; addr &= 0xf; diff --git a/hw/s3c24xx_lcd.c b/hw/s3c24xx_lcd.c index 2142867dce..9768a3c7a9 100644 --- a/hw/s3c24xx_lcd.c +++ b/hw/s3c24xx_lcd.c @@ -106,7 +106,6 @@ void s3c_lcd_reset(struct s3c_lcd_state_s *s) static uint32_t s3c_lcd_read(void *opaque, target_phys_addr_t addr) { struct s3c_lcd_state_s *s = (struct s3c_lcd_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_LCDCON1: @@ -157,7 +156,6 @@ static void s3c_lcd_write(void *opaque, target_phys_addr_t addr, uint32_t value) { struct s3c_lcd_state_s *s = (struct s3c_lcd_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_LCDCON1: diff --git a/hw/s3c24xx_mmci.c b/hw/s3c24xx_mmci.c index 348524767a..2b9fc63eed 100644 --- a/hw/s3c24xx_mmci.c +++ b/hw/s3c24xx_mmci.c @@ -217,7 +217,6 @@ static uint32_t s3c_mmci_readw(void *opaque, target_phys_addr_t addr) { struct s3c_mmci_state_s *s = (struct s3c_mmci_state_s *) opaque; uint32_t ret; - addr -= s->base; if (addr > S3C_SDIMAX) goto bad_reg; addr = s->map[addr]; @@ -298,7 +297,6 @@ static void s3c_mmci_writew(void *opaque, target_phys_addr_t addr, uint32_t value) { struct s3c_mmci_state_s *s = (struct s3c_mmci_state_s *) opaque; - addr -= s->base; if (addr > S3C_SDIMAX) goto bad_reg; addr = s->map[addr]; diff --git a/hw/s3c24xx_rtc.c b/hw/s3c24xx_rtc.c index bae17d5823..dca2627a04 100644 --- a/hw/s3c24xx_rtc.c +++ b/hw/s3c24xx_rtc.c @@ -123,7 +123,6 @@ static inline int from_bcd(uint32_t val) static uint32_t s3c_rtc_read(void *opaque, target_phys_addr_t addr) { struct s3c_rtc_state_s *s = (struct s3c_rtc_state_s *) opaque; - addr -= s->base; switch (addr) { case S3C_RTC_CON: @@ -183,7 +182,6 @@ static void s3c_rtc_write(void *opaque, target_phys_addr_t addr, { struct s3c_rtc_state_s *s = (struct s3c_rtc_state_s *) opaque; int diff; - addr -= s->base; switch (addr) { case S3C_RTC_CON: diff --git a/hw/s3c24xx_udc.c b/hw/s3c24xx_udc.c index 7303911ad4..5e5fc8c220 100644 --- a/hw/s3c24xx_udc.c +++ b/hw/s3c24xx_udc.c @@ -219,9 +219,9 @@ static uint32_t s3c_udc_read(void *opaque, target_phys_addr_t addr) struct s3c_udc_state_s *s = (struct s3c_udc_state_s *) opaque; int ep = S3C_EPS; uint8_t ret = 0; - addr -= s->base; + while (addr < s3c_udc_ep_reg[-- ep]); - addr -= s3c_udc_ep_reg[ep]; + addr -= s3c_udc_ep_reg[ep]; switch (addr) { case S3C_FUNC_ADDR: @@ -348,7 +348,7 @@ static void s3c_udc_write(void *opaque, target_phys_addr_t addr, { struct s3c_udc_state_s *s = (struct s3c_udc_state_s *) opaque; int ep = S3C_EPS; - addr -= s->base; + while (addr < s3c_udc_ep_reg[-- ep]); addr -= s3c_udc_ep_reg[ep]; -- 2.11.4.GIT