pc-testdev.c (47b5264eb3e1cd2825e48d28fd0d1b239ed53974) | pc-testdev.c (db895a1e6a97e919f9b86d60c969377357b05066) |
---|---|
1/* 2 * QEMU x86 ISA testdev 3 * 4 * Copyright (c) 2012 Avi Kivity, Gerd Hoffmann, Marcelo Tosatti 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 128 unchanged lines hidden (view full) --- 137} 138 139static const MemoryRegionOps test_iomem_ops = { 140 .read = test_iomem_read, 141 .write = test_iomem_write, 142 .endianness = DEVICE_LITTLE_ENDIAN, 143}; 144 | 1/* 2 * QEMU x86 ISA testdev 3 * 4 * Copyright (c) 2012 Avi Kivity, Gerd Hoffmann, Marcelo Tosatti 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 128 unchanged lines hidden (view full) --- 137} 138 139static const MemoryRegionOps test_iomem_ops = { 140 .read = test_iomem_read, 141 .write = test_iomem_write, 142 .endianness = DEVICE_LITTLE_ENDIAN, 143}; 144 |
145static int init_test_device(ISADevice *isa) | 145static void testdev_realizefn(DeviceState *d, Error **errp) |
146{ | 146{ |
147 PCTestdev *dev = TESTDEV(isa); | 147 ISADevice *isa = ISA_DEVICE(d); 148 PCTestdev *dev = TESTDEV(d); |
148 MemoryRegion *mem = isa_address_space(isa); 149 MemoryRegion *io = isa_address_space_io(isa); 150 151 memory_region_init_io(&dev->ioport, &test_ioport_ops, dev, 152 "pc-testdev-ioport", 4); 153 memory_region_init_io(&dev->flush, &test_flush_ops, dev, 154 "pc-testdev-flush-page", 4); 155 memory_region_init_io(&dev->irq, &test_irq_ops, dev, 156 "pc-testdev-irq-line", 24); 157 memory_region_init_io(&dev->iomem, &test_iomem_ops, dev, 158 "pc-testdev-iomem", IOMEM_LEN); 159 160 memory_region_add_subregion(io, 0xe0, &dev->ioport); 161 memory_region_add_subregion(io, 0xe4, &dev->flush); 162 memory_region_add_subregion(io, 0x2000, &dev->irq); 163 memory_region_add_subregion(mem, 0xff000000, &dev->iomem); | 149 MemoryRegion *mem = isa_address_space(isa); 150 MemoryRegion *io = isa_address_space_io(isa); 151 152 memory_region_init_io(&dev->ioport, &test_ioport_ops, dev, 153 "pc-testdev-ioport", 4); 154 memory_region_init_io(&dev->flush, &test_flush_ops, dev, 155 "pc-testdev-flush-page", 4); 156 memory_region_init_io(&dev->irq, &test_irq_ops, dev, 157 "pc-testdev-irq-line", 24); 158 memory_region_init_io(&dev->iomem, &test_iomem_ops, dev, 159 "pc-testdev-iomem", IOMEM_LEN); 160 161 memory_region_add_subregion(io, 0xe0, &dev->ioport); 162 memory_region_add_subregion(io, 0xe4, &dev->flush); 163 memory_region_add_subregion(io, 0x2000, &dev->irq); 164 memory_region_add_subregion(mem, 0xff000000, &dev->iomem); |
164 165 return 0; | |
166} 167 168static void testdev_class_init(ObjectClass *klass, void *data) 169{ | 165} 166 167static void testdev_class_init(ObjectClass *klass, void *data) 168{ |
170 ISADeviceClass *k = ISA_DEVICE_CLASS(klass); | 169 DeviceClass *dc = DEVICE_CLASS(klass); |
171 | 170 |
172 k->init = init_test_device; | 171 dc->realize = testdev_realizefn; |
173} 174 175static const TypeInfo testdev_info = { 176 .name = TYPE_TESTDEV, 177 .parent = TYPE_ISA_DEVICE, 178 .instance_size = sizeof(PCTestdev), 179 .class_init = testdev_class_init, 180}; 181 182static void testdev_register_types(void) 183{ 184 type_register_static(&testdev_info); 185} 186 187type_init(testdev_register_types) | 172} 173 174static const TypeInfo testdev_info = { 175 .name = TYPE_TESTDEV, 176 .parent = TYPE_ISA_DEVICE, 177 .instance_size = sizeof(PCTestdev), 178 .class_init = testdev_class_init, 179}; 180 181static void testdev_register_types(void) 182{ 183 type_register_static(&testdev_info); 184} 185 186type_init(testdev_register_types) |