Revision acd1c812 ioport.c

b/ioport.c
174 174
    return 0;
175 175
}
176 176

  
177
static uint32_t ioport_readb_thunk(void *opaque, uint32_t addr)
178
{
179
    IORange *ioport = opaque;
180
    uint64_t data;
181

  
182
    ioport->ops->read(ioport, addr - ioport->base, 1, &data);
183
    return data;
184
}
185

  
186
static uint32_t ioport_readw_thunk(void *opaque, uint32_t addr)
187
{
188
    IORange *ioport = opaque;
189
    uint64_t data;
190

  
191
    ioport->ops->read(ioport, addr - ioport->base, 2, &data);
192
    return data;
193
}
194

  
195
static uint32_t ioport_readl_thunk(void *opaque, uint32_t addr)
196
{
197
    IORange *ioport = opaque;
198
    uint64_t data;
199

  
200
    ioport->ops->read(ioport, addr - ioport->base, 4, &data);
201
    return data;
202
}
203

  
204
static void ioport_writeb_thunk(void *opaque, uint32_t addr, uint32_t data)
205
{
206
    IORange *ioport = opaque;
207

  
208
    ioport->ops->write(ioport, addr - ioport->base, 1, data);
209
}
210

  
211
static void ioport_writew_thunk(void *opaque, uint32_t addr, uint32_t data)
212
{
213
    IORange *ioport = opaque;
214

  
215
    ioport->ops->write(ioport, addr - ioport->base, 2, data);
216
}
217

  
218
static void ioport_writel_thunk(void *opaque, uint32_t addr, uint32_t data)
219
{
220
    IORange *ioport = opaque;
221

  
222
    ioport->ops->write(ioport, addr - ioport->base, 4, data);
223
}
224

  
225
void ioport_register(IORange *ioport)
226
{
227
    register_ioport_read(ioport->base, ioport->len, 1,
228
                         ioport_readb_thunk, ioport);
229
    register_ioport_read(ioport->base, ioport->len, 2,
230
                         ioport_readw_thunk, ioport);
231
    register_ioport_read(ioport->base, ioport->len, 4,
232
                         ioport_readl_thunk, ioport);
233
    register_ioport_write(ioport->base, ioport->len, 1,
234
                          ioport_writeb_thunk, ioport);
235
    register_ioport_write(ioport->base, ioport->len, 2,
236
                          ioport_writew_thunk, ioport);
237
    register_ioport_write(ioport->base, ioport->len, 4,
238
                          ioport_writel_thunk, ioport);
239
}
240

  
177 241
void isa_unassign_ioport(pio_addr_t start, int length)
178 242
{
179 243
    int i;

Also available in: Unified diff