mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-11 07:53:47 +00:00
isa: Tidy support code for isabus_get_fw_dev_path
The only user of ISADevice.ioports is isabus_get_fw_dev_path, and it only looks at the first entry of the array. Which suggests that this entire array+sort operation can be replaced by a simple minimum. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
febbd7c29a
commit
ebf47c24b0
25
hw/isa-bus.c
25
hw/isa-bus.c
@ -83,24 +83,11 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
|
|||||||
dev->nirqs++;
|
dev->nirqs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void isa_init_ioport_one(ISADevice *dev, uint16_t ioport)
|
|
||||||
{
|
|
||||||
assert(dev->nioports < ARRAY_SIZE(dev->ioports));
|
|
||||||
dev->ioports[dev->nioports++] = ioport;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int isa_cmp_ports(const void *p1, const void *p2)
|
|
||||||
{
|
|
||||||
return *(uint16_t*)p1 - *(uint16_t*)p2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length)
|
void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length)
|
||||||
{
|
{
|
||||||
int i;
|
if (dev->ioport_id == 0 || start < dev->ioport_id) {
|
||||||
for (i = start; i < start + length; i++) {
|
dev->ioport_id = start;
|
||||||
isa_init_ioport_one(dev, i);
|
|
||||||
}
|
}
|
||||||
qsort(dev->ioports, dev->nioports, sizeof(dev->ioports[0]), isa_cmp_ports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void isa_init_ioport(ISADevice *dev, uint16_t ioport)
|
void isa_init_ioport(ISADevice *dev, uint16_t ioport)
|
||||||
@ -112,9 +99,7 @@ void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start)
|
|||||||
{
|
{
|
||||||
memory_region_add_subregion(isabus->address_space_io, start, io);
|
memory_region_add_subregion(isabus->address_space_io, start, io);
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
assert(dev->nio < ARRAY_SIZE(dev->io));
|
isa_init_ioport(dev, start);
|
||||||
dev->io[dev->nio++] = io;
|
|
||||||
isa_init_ioport_range(dev, start, memory_region_size(io));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +193,8 @@ static char *isabus_get_fw_dev_path(DeviceState *dev)
|
|||||||
int off;
|
int off;
|
||||||
|
|
||||||
off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev));
|
off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev));
|
||||||
if (d->nioports) {
|
if (d->ioport_id) {
|
||||||
snprintf(path + off, sizeof(path) - off, "@%04x", d->ioports[0]);
|
snprintf(path + off, sizeof(path) - off, "@%04x", d->ioport_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return strdup(path);
|
return strdup(path);
|
||||||
|
5
hw/isa.h
5
hw/isa.h
@ -13,12 +13,9 @@ typedef struct ISADeviceInfo ISADeviceInfo;
|
|||||||
|
|
||||||
struct ISADevice {
|
struct ISADevice {
|
||||||
DeviceState qdev;
|
DeviceState qdev;
|
||||||
MemoryRegion *io[32];
|
|
||||||
uint32_t isairq[2];
|
uint32_t isairq[2];
|
||||||
uint16_t ioports[32];
|
|
||||||
int nirqs;
|
int nirqs;
|
||||||
int nioports;
|
int ioport_id;
|
||||||
int nio;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*isa_qdev_initfn)(ISADevice *dev);
|
typedef int (*isa_qdev_initfn)(ISADevice *dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user