PL080 qdev conversion

Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
Paul Brook 2009-05-14 22:35:08 +01:00
parent 82634c2d74
commit b4496b13bb
3 changed files with 28 additions and 12 deletions

View File

@ -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;
@ -319,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)

View File

@ -89,7 +89,7 @@ static void realview_init(ram_addr_t ram_size,
sysbus_create_simple("pl011", 0x1000c000, pic[15]);
/* DMA controller is optional, apparently. */
pl080_init(0x10030000, pic[24], 2);
sysbus_create_simple("pl081", 0x10030000, pic[24]);
sysbus_create_simple("sp804", 0x10011000, pic[4]);
sysbus_create_simple("sp804", 0x10012000, pic[5]);

View File

@ -226,7 +226,7 @@ static void versatile_init(ram_addr_t ram_size,
sysbus_create_simple("pl011", 0x101f3000, pic[14]);
sysbus_create_simple("pl011", 0x10009000, sic[6]);
pl080_init(0x10130000, pic[17], 8);
sysbus_create_simple("pl080", 0x10130000, pic[17]);
sysbus_create_simple("sp804", 0x101e2000, pic[4]);
sysbus_create_simple("sp804", 0x101e3000, pic[5]);