Revision 2871a3f6 hw/acpi_piix4.c

b/hw/acpi_piix4.c
52 52

  
53 53
typedef struct PIIX4PMState {
54 54
    PCIDevice dev;
55
    IORange ioport;
55 56
    uint16_t pmsts;
56 57
    uint16_t pmen;
57 58
    uint16_t pmcntrl;
......
128 129
    pm_update_sci(s);
129 130
}
130 131

  
131
static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
132
static void pm_ioport_write(IORange *ioport, uint64_t addr, unsigned width,
133
                            uint64_t val)
132 134
{
133
    PIIX4PMState *s = opaque;
134
    addr &= 0x3f;
135
    PIIX4PMState *s = container_of(ioport, PIIX4PMState, ioport);
136

  
137
    if (width != 2) {
138
        PIIX4_DPRINTF("PM write port=0x%04x width=%d val=0x%08x\n",
139
                      (unsigned)addr, width, (unsigned)val);
140
    }
141

  
135 142
    switch(addr) {
136 143
    case 0x00:
137 144
        {
......
184 191
    PIIX4_DPRINTF("PM writew port=0x%04x val=0x%04x\n", addr, val);
185 192
}
186 193

  
187
static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
194
static void pm_ioport_read(IORange *ioport, uint64_t addr, unsigned width,
195
                            uint64_t *data)
188 196
{
189
    PIIX4PMState *s = opaque;
197
    PIIX4PMState *s = container_of(ioport, PIIX4PMState, ioport);
190 198
    uint32_t val;
191 199

  
192
    addr &= 0x3f;
193 200
    switch(addr) {
194 201
    case 0x00:
195 202
        val = get_pmsts(s);
......
200 207
    case 0x04:
201 208
        val = s->pmcntrl;
202 209
        break;
203
    default:
204
        val = 0;
205
        break;
206
    }
207
    PIIX4_DPRINTF("PM readw port=0x%04x val=0x%04x\n", addr, val);
208
    return val;
209
}
210

  
211
static void pm_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
212
{
213
    //    PIIX4PMState *s = opaque;
214
    PIIX4_DPRINTF("PM writel port=0x%04x val=0x%08x\n", addr & 0x3f, val);
215
}
216

  
217
static uint32_t pm_ioport_readl(void *opaque, uint32_t addr)
218
{
219
    PIIX4PMState *s = opaque;
220
    uint32_t val;
221

  
222
    addr &= 0x3f;
223
    switch(addr) {
224 210
    case 0x08:
225 211
        val = get_pmtmr(s);
226 212
        break;
......
228 214
        val = 0;
229 215
        break;
230 216
    }
231
    PIIX4_DPRINTF("PM readl port=0x%04x val=0x%08x\n", addr, val);
232
    return val;
217
    PIIX4_DPRINTF("PM readw port=0x%04x val=0x%04x\n", addr, val);
218
    *data = val;
233 219
}
234 220

  
221
static const IORangeOps pm_iorange_ops = {
222
    .read = pm_ioport_read,
223
    .write = pm_ioport_write,
224
};
225

  
235 226
static void apm_ctrl_changed(uint32_t val, void *arg)
236 227
{
237 228
    PIIX4PMState *s = arg;
......
265 256

  
266 257
        /* XXX: need to improve memory and ioport allocation */
267 258
        PIIX4_DPRINTF("PM: mapping to 0x%x\n", pm_io_base);
268
        register_ioport_write(pm_io_base, 64, 2, pm_ioport_writew, s);
269
        register_ioport_read(pm_io_base, 64, 2, pm_ioport_readw, s);
270
        register_ioport_write(pm_io_base, 64, 4, pm_ioport_writel, s);
271
        register_ioport_read(pm_io_base, 64, 4, pm_ioport_readl, s);
259
        iorange_init(&s->ioport, &pm_iorange_ops, pm_io_base, 64);
260
        ioport_register(&s->ioport);
272 261
    }
273 262
}
274 263

  

Also available in: Unified diff