X-Git-Url: http://git.maemo.org/git/?p=qemu;a=blobdiff_plain;f=hw%2Fpl080.c;fp=hw%2Fpl080.c;h=e43b11df7a11641fbdff80f3394a96adbd4318c7;hp=e4d7e170e54e992706e8ad8b9a2c3ead1afd3932;hb=759b334a9739814df2883aa4c41b1c0f5670e90a;hpb=7e2198fc87e878b8ce5df965477e21713ebf7834 diff --git a/hw/pl080.c b/hw/pl080.c index e4d7e17..e43b11d 100644 --- a/hw/pl080.c +++ b/hw/pl080.c @@ -7,8 +7,7 @@ * This code is licenced under the GPL. */ -#include "hw.h" -#include "primecell.h" +#include "sysbus.h" #define PL080_MAX_CHANNELS 8 #define PL080_CONF_E 0x1 @@ -37,6 +36,7 @@ typedef struct { } pl080_channel; typedef struct { + SysBusDevice busdev; uint8_t tc_int; uint8_t tc_mask; uint8_t err_int; @@ -93,7 +93,7 @@ static void pl080_run(pl080_state *s) if ((s->conf & PL080_CONF_E) == 0) return; -cpu_abort(cpu_single_env, "DMA active\n"); +hw_error("DMA active\n"); /* If we are already in the middle of a DMA operation then indicate that there may be new DMA requests and return immediately. */ if (s->running) { @@ -111,7 +111,7 @@ again: continue; flow = (ch->conf >> 11) & 7; if (flow >= 4) { - cpu_abort(cpu_single_env, + hw_error( "pl080_run: Peripheral flow control not implemented\n"); } src_id = (ch->conf >> 1) & 0x1f; @@ -242,7 +242,7 @@ static uint32_t pl080_read(void *opaque, target_phys_addr_t offset) return s->sync; default: bad_offset: - cpu_abort(cpu_single_env, "pl080_read: Bad offset %x\n", (int)offset); + hw_error("pl080_read: Bad offset %x\n", (int)offset); return 0; } } @@ -288,13 +288,12 @@ static void pl080_write(void *opaque, target_phys_addr_t offset, case 10: /* SoftLBReq */ case 11: /* SoftLSReq */ /* ??? Implement these. */ - cpu_abort(cpu_single_env, "pl080_write: Soft DMA not implemented\n"); + hw_error("pl080_write: Soft DMA not implemented\n"); break; case 12: /* Configuration */ s->conf = value; if (s->conf & (PL080_CONF_M1 | PL080_CONF_M1)) { - cpu_abort(cpu_single_env, - "pl080_write: Big-endian DMA not implemented\n"); + hw_error("pl080_write: Big-endian DMA not implemented\n"); } pl080_run(s); break; @@ -303,7 +302,7 @@ static void pl080_write(void *opaque, target_phys_addr_t offset, break; default: bad_offset: - cpu_abort(cpu_single_env, "pl080_write: Bad offset %x\n", (int)offset); + hw_error("pl080_write: Bad offset %x\n", (int)offset); } pl080_update(s); } @@ -320,19 +319,35 @@ static CPUWriteMemoryFunc *pl080_writefn[] = { pl080_write }; -/* The PL080 and PL081 are the same except for the number of channels - they implement (8 and 2 respectively). */ -void *pl080_init(uint32_t base, qemu_irq irq, int nchannels) +static void pl08x_init(SysBusDevice *dev, int nchannels) { int iomemtype; - pl080_state *s; + pl080_state *s = FROM_SYSBUS(pl080_state, dev); - s = (pl080_state *)qemu_mallocz(sizeof(pl080_state)); iomemtype = cpu_register_io_memory(0, pl080_readfn, pl080_writefn, s); - cpu_register_physical_memory(base, 0x00001000, iomemtype); - s->irq = irq; + sysbus_init_mmio(dev, 0x1000, iomemtype); + sysbus_init_irq(dev, &s->irq); s->nchannels = nchannels; /* ??? Save/restore. */ - return s; } + +static void pl080_init(SysBusDevice *dev) +{ + pl08x_init(dev, 8); +} + +static void pl081_init(SysBusDevice *dev) +{ + pl08x_init(dev, 2); +} + +/* The PL080 and PL081 are the same except for the number of channels + they implement (8 and 2 respectively). */ +static void pl080_register_devices(void) +{ + sysbus_register_dev("pl080", sizeof(pl080_state), pl080_init); + sysbus_register_dev("pl081", sizeof(pl080_state), pl081_init); +} + +device_init(pl080_register_devices)