Revision 3812ed0b

b/hw/apb_pci.c
31 31
#include "pci_host.h"
32 32
#include "pci_bridge.h"
33 33
#include "pci_internals.h"
34
#include "rwhandler.h"
35 34
#include "apb_pci.h"
36 35
#include "sysemu.h"
37 36
#include "exec-memory.h"
......
70 69
typedef struct APBState {
71 70
    SysBusDevice busdev;
72 71
    PCIBus      *bus;
73
    ReadWriteHandler pci_config_handler;
72
    MemoryRegion apb_config;
73
    MemoryRegion pci_config;
74
    MemoryRegion pci_ioport;
74 75
    uint32_t iommu[4];
75 76
    uint32_t pci_control[16];
76 77
    uint32_t pci_irq_map[8];
......
81 82
} APBState;
82 83

  
83 84
static void apb_config_writel (void *opaque, target_phys_addr_t addr,
84
                               uint32_t val)
85
                               uint64_t val, unsigned size)
85 86
{
86 87
    APBState *s = opaque;
87 88

  
......
128 129
    }
129 130
}
130 131

  
131
static uint32_t apb_config_readl (void *opaque,
132
                                  target_phys_addr_t addr)
132
static uint64_t apb_config_readl (void *opaque,
133
                                  target_phys_addr_t addr, unsigned size)
133 134
{
134 135
    APBState *s = opaque;
135 136
    uint32_t val;
......
176 177
    return val;
177 178
}
178 179

  
179
static CPUWriteMemoryFunc * const apb_config_write[] = {
180
    &apb_config_writel,
181
    &apb_config_writel,
182
    &apb_config_writel,
180
static const MemoryRegionOps apb_config_ops = {
181
    .read = apb_config_readl,
182
    .write = apb_config_writel,
183
    .endianness = DEVICE_NATIVE_ENDIAN,
183 184
};
184 185

  
185
static CPUReadMemoryFunc * const apb_config_read[] = {
186
    &apb_config_readl,
187
    &apb_config_readl,
188
    &apb_config_readl,
189
};
190

  
191
static void apb_pci_config_write(ReadWriteHandler *h, pcibus_t addr,
192
                                 uint32_t val, int size)
186
static void apb_pci_config_write(void *opaque, target_phys_addr_t addr,
187
                                 uint64_t val, unsigned size)
193 188
{
194
    APBState *s = container_of(h, APBState, pci_config_handler);
189
    APBState *s = opaque;
195 190

  
196 191
    val = qemu_bswap_len(val, size);
197 192
    APB_DPRINTF("%s: addr " TARGET_FMT_lx " val %x\n", __func__, addr, val);
198 193
    pci_data_write(s->bus, addr, val, size);
199 194
}
200 195

  
201
static uint32_t apb_pci_config_read(ReadWriteHandler *h, pcibus_t addr,
202
                                    int size)
196
static uint64_t apb_pci_config_read(void *opaque, target_phys_addr_t addr,
197
                                    unsigned size)
203 198
{
204 199
    uint32_t ret;
205
    APBState *s = container_of(h, APBState, pci_config_handler);
200
    APBState *s = opaque;
206 201

  
207 202
    ret = pci_data_read(s->bus, addr, size);
208 203
    ret = qemu_bswap_len(ret, size);
......
252 247
    return val;
253 248
}
254 249

  
255
static CPUWriteMemoryFunc * const pci_apb_iowrite[] = {
256
    &pci_apb_iowriteb,
257
    &pci_apb_iowritew,
258
    &pci_apb_iowritel,
259
};
260

  
261
static CPUReadMemoryFunc * const pci_apb_ioread[] = {
262
    &pci_apb_ioreadb,
263
    &pci_apb_ioreadw,
264
    &pci_apb_ioreadl,
250
static const MemoryRegionOps pci_ioport_ops = {
251
    .old_mmio = {
252
        .read = { pci_apb_ioreadb, pci_apb_ioreadw, pci_apb_ioreadl },
253
        .write = { pci_apb_iowriteb, pci_apb_iowritew, pci_apb_iowritel, },
254
    },
255
    .endianness = DEVICE_NATIVE_ENDIAN,
265 256
};
266 257

  
267 258
/* The APB host has an IRQ line for each IRQ line of each slot.  */
......
393 384
    }
394 385
}
395 386

  
387
static const MemoryRegionOps pci_config_ops = {
388
    .read = apb_pci_config_read,
389
    .write = apb_pci_config_write,
390
    .endianness = DEVICE_NATIVE_ENDIAN,
391
};
392

  
396 393
static int pci_pbm_init_device(SysBusDevice *dev)
397 394
{
398 395
    APBState *s;
399
    int pci_config, apb_config, pci_ioport;
400 396
    unsigned int i;
401 397

  
402 398
    s = FROM_SYSBUS(APBState, dev);
......
408 404
    }
409 405

  
410 406
    /* apb_config */
411
    apb_config = cpu_register_io_memory(apb_config_read,
412
                                        apb_config_write, s,
413
                                        DEVICE_NATIVE_ENDIAN);
407
    memory_region_init_io(&s->apb_config, &apb_config_ops, s, "apb-config",
408
                          0x10000);
414 409
    /* at region 0 */
415
    sysbus_init_mmio(dev, 0x10000ULL, apb_config);
410
    sysbus_init_mmio_region(dev, &s->apb_config);
416 411

  
417
    /* PCI configuration space */
418
    s->pci_config_handler.read = apb_pci_config_read;
419
    s->pci_config_handler.write = apb_pci_config_write;
420
    pci_config = cpu_register_io_memory_simple(&s->pci_config_handler,
421
                                               DEVICE_NATIVE_ENDIAN);
422
    assert(pci_config >= 0);
412
    memory_region_init_io(&s->pci_config, &pci_config_ops, s, "apb-pci-config",
413
                          0x1000000);
423 414
    /* at region 1 */
424
    sysbus_init_mmio(dev, 0x1000000ULL, pci_config);
415
    sysbus_init_mmio_region(dev, &s->pci_config);
425 416

  
426 417
    /* pci_ioport */
427
    pci_ioport = cpu_register_io_memory(pci_apb_ioread,
428
                                        pci_apb_iowrite, s,
429
                                        DEVICE_NATIVE_ENDIAN);
418
    memory_region_init_io(&s->pci_ioport, &pci_ioport_ops, s,
419
                          "apb-pci-ioport", 0x10000);
430 420
    /* at region 2 */
431
    sysbus_init_mmio(dev, 0x10000ULL, pci_ioport);
421
    sysbus_init_mmio_region(dev, &s->pci_ioport);
432 422

  
433 423
    return 0;
434 424
}

Also available in: Unified diff