* [Qemu-devel] [PATCH] isa: configure serial+parallel by index.
@ 2009-10-13 11:38 Gerd Hoffmann
2009-10-13 19:08 ` Markus Armbruster
0 siblings, 1 reply; 8+ messages in thread
From: Gerd Hoffmann @ 2009-10-13 11:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
This patch adds a 'index' property to the isa-parallel and isa-serial
devices. This can be used to create devices with the default isa irqs
and ioports by simply specifying the index, i.e.
-device isa-serial,index=1
instead of
-device isa-serial,iobase=0x2f8,irq=3
for ttyS1 aka com2. Likewise for parallel ports.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/parallel.c | 23 +++++++++++++++++------
hw/serial.c | 26 +++++++++++++++++++-------
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/hw/parallel.c b/hw/parallel.c
index 92eecb1..79fa8f6 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -80,6 +80,7 @@ struct ParallelState {
typedef struct ISAParallelState {
ISADevice dev;
+ uint32_t index;
uint32_t iobase;
uint32_t isairq;
ParallelState state;
@@ -445,11 +446,14 @@ static void parallel_reset(void *opaque)
s->last_read_offset = ~0U;
}
+static const int isa_parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
+
static int parallel_isa_initfn(ISADevice *dev)
{
+ static int index;
ISAParallelState *isa = DO_UPCAST(ISAParallelState, dev, dev);
ParallelState *s = &isa->state;
- int base = isa->iobase;
+ int base;
uint8_t dummy;
if (!s->chr) {
@@ -457,6 +461,15 @@ static int parallel_isa_initfn(ISADevice *dev)
exit(1);
}
+ if (isa->index == -1)
+ isa->index = index;
+ if (isa->index >= MAX_PARALLEL_PORTS)
+ return -1;
+ if (isa->iobase == -1)
+ isa->iobase = isa_parallel_io[isa->index];
+ index++;
+
+ base = isa->iobase;
isa_init_irq(dev, &s->irq, isa->isairq);
parallel_reset(s);
qemu_register_reset(parallel_reset, s);
@@ -483,15 +496,12 @@ static int parallel_isa_initfn(ISADevice *dev)
return 0;
}
-static const int isa_parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
-
ParallelState *parallel_init(int index, CharDriverState *chr)
{
ISADevice *dev;
dev = isa_create("isa-parallel");
- qdev_prop_set_uint32(&dev->qdev, "iobase", isa_parallel_io[index]);
- qdev_prop_set_uint32(&dev->qdev, "irq", 7);
+ qdev_prop_set_uint32(&dev->qdev, "index", index);
qdev_prop_set_chr(&dev->qdev, "chardev", chr);
if (qdev_init(&dev->qdev) < 0)
return NULL;
@@ -579,7 +589,8 @@ static ISADeviceInfo parallel_isa_info = {
.qdev.size = sizeof(ISAParallelState),
.init = parallel_isa_initfn,
.qdev.props = (Property[]) {
- DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, 0x378),
+ DEFINE_PROP_HEX32("index", ISAParallelState, index, -1),
+ DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, -1),
DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7),
DEFINE_PROP_CHR("chardev", ISAParallelState, state.chr),
DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/serial.c b/hw/serial.c
index eb14f11..869063c 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -148,6 +148,7 @@ struct SerialState {
typedef struct ISASerialState {
ISADevice dev;
+ uint32_t index;
uint32_t iobase;
uint32_t isairq;
SerialState state;
@@ -733,11 +734,25 @@ static void serial_init_core(SerialState *s)
serial_event, s);
}
+static const int isa_serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
+static const int isa_serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
+
static int serial_isa_initfn(ISADevice *dev)
{
+ static int index;
ISASerialState *isa = DO_UPCAST(ISASerialState, dev, dev);
SerialState *s = &isa->state;
+ if (isa->index == -1)
+ isa->index = index;
+ if (isa->index >= MAX_SERIAL_PORTS)
+ return -1;
+ if (isa->iobase == -1)
+ isa->iobase = isa_serial_io[isa->index];
+ if (isa->isairq == -1)
+ isa->isairq = isa_serial_irq[isa->index];
+ index++;
+
s->baudbase = 115200;
isa_init_irq(dev, &s->irq, isa->isairq);
serial_init_core(s);
@@ -748,16 +763,12 @@ static int serial_isa_initfn(ISADevice *dev)
return 0;
}
-static const int isa_serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
-static const int isa_serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
-
SerialState *serial_isa_init(int index, CharDriverState *chr)
{
ISADevice *dev;
dev = isa_create("isa-serial");
- qdev_prop_set_uint32(&dev->qdev, "iobase", isa_serial_io[index]);
- qdev_prop_set_uint32(&dev->qdev, "irq", isa_serial_irq[index]);
+ qdev_prop_set_uint32(&dev->qdev, "index", index);
qdev_prop_set_chr(&dev->qdev, "chardev", chr);
if (qdev_init(&dev->qdev) < 0)
return NULL;
@@ -886,8 +897,9 @@ static ISADeviceInfo serial_isa_info = {
.qdev.size = sizeof(ISASerialState),
.init = serial_isa_initfn,
.qdev.props = (Property[]) {
- DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, 0x3f8),
- DEFINE_PROP_UINT32("irq", ISASerialState, isairq, 4),
+ DEFINE_PROP_HEX32("index", ISASerialState, index, -1),
+ DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, -1),
+ DEFINE_PROP_UINT32("irq", ISASerialState, isairq, -1),
DEFINE_PROP_CHR("chardev", ISASerialState, state.chr),
DEFINE_PROP_END_OF_LIST(),
},
--
1.6.2.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] isa: configure serial+parallel by index.
2009-10-13 11:38 Gerd Hoffmann
@ 2009-10-13 19:08 ` Markus Armbruster
2009-10-26 8:56 ` Markus Armbruster
0 siblings, 1 reply; 8+ messages in thread
From: Markus Armbruster @ 2009-10-13 19:08 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Gerd Hoffmann <kraxel@redhat.com> writes:
> This patch adds a 'index' property to the isa-parallel and isa-serial
> devices. This can be used to create devices with the default isa irqs
> and ioports by simply specifying the index, i.e.
>
> -device isa-serial,index=1
>
> instead of
>
> -device isa-serial,iobase=0x2f8,irq=3
>
> for ttyS1 aka com2. Likewise for parallel ports.
Not mentioned here, only in the code:
* index defaults to 0 for the first device to initialize, 1 for the
second, and so forth.
* It is okay to overwrite the defaults provided by index, e.g.
-device isa-serial,index=1,irq=4
Looks fine to me. A similar solution could do for default mac address.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] isa: configure serial+parallel by index.
2009-10-13 19:08 ` Markus Armbruster
@ 2009-10-26 8:56 ` Markus Armbruster
2009-10-26 9:13 ` Gerd Hoffmann
0 siblings, 1 reply; 8+ messages in thread
From: Markus Armbruster @ 2009-10-26 8:56 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Markus Armbruster <armbru@redhat.com> writes:
> Gerd Hoffmann <kraxel@redhat.com> writes:
>
>> This patch adds a 'index' property to the isa-parallel and isa-serial
>> devices. This can be used to create devices with the default isa irqs
>> and ioports by simply specifying the index, i.e.
>>
>> -device isa-serial,index=1
>>
>> instead of
>>
>> -device isa-serial,iobase=0x2f8,irq=3
>>
>> for ttyS1 aka com2. Likewise for parallel ports.
>
> Not mentioned here, only in the code:
>
> * index defaults to 0 for the first device to initialize, 1 for the
> second, and so forth.
>
> * It is okay to overwrite the defaults provided by index, e.g.
>
> -device isa-serial,index=1,irq=4
>
> Looks fine to me. A similar solution could do for default mac address.
One little thing I missed on first reading: making an index property
hexadecimal is weird. I'd really expect decimal there.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] isa: configure serial+parallel by index.
2009-10-26 8:56 ` Markus Armbruster
@ 2009-10-26 9:13 ` Gerd Hoffmann
0 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2009-10-26 9:13 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
>> Looks fine to me. A similar solution could do for default mac address.
>
> One little thing I missed on first reading: making an index property
> hexadecimal is weird. I'd really expect decimal there.
Indeed. Wasn't intentional, cut+paste bug. Will fix.
cheers,
Gerd
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH] isa: configure serial+parallel by index.
@ 2009-10-26 11:19 Gerd Hoffmann
0 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2009-10-26 11:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
This patch adds a 'index' property to the isa-parallel and isa-serial
devices. This can be used to create devices with the default isa irqs
and ioports by simply specifying the index, i.e.
-device isa-serial,index=1
instead of
-device isa-serial,iobase=0x2f8,irq=3
for ttyS1 aka com2. Likewise for parallel ports.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/parallel.c | 23 +++++++++++++++++------
hw/serial.c | 26 +++++++++++++++++++-------
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/hw/parallel.c b/hw/parallel.c
index 92eecb1..263b5bf 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -80,6 +80,7 @@ struct ParallelState {
typedef struct ISAParallelState {
ISADevice dev;
+ uint32_t index;
uint32_t iobase;
uint32_t isairq;
ParallelState state;
@@ -445,11 +446,14 @@ static void parallel_reset(void *opaque)
s->last_read_offset = ~0U;
}
+static const int isa_parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
+
static int parallel_isa_initfn(ISADevice *dev)
{
+ static int index;
ISAParallelState *isa = DO_UPCAST(ISAParallelState, dev, dev);
ParallelState *s = &isa->state;
- int base = isa->iobase;
+ int base;
uint8_t dummy;
if (!s->chr) {
@@ -457,6 +461,15 @@ static int parallel_isa_initfn(ISADevice *dev)
exit(1);
}
+ if (isa->index == -1)
+ isa->index = index;
+ if (isa->index >= MAX_PARALLEL_PORTS)
+ return -1;
+ if (isa->iobase == -1)
+ isa->iobase = isa_parallel_io[isa->index];
+ index++;
+
+ base = isa->iobase;
isa_init_irq(dev, &s->irq, isa->isairq);
parallel_reset(s);
qemu_register_reset(parallel_reset, s);
@@ -483,15 +496,12 @@ static int parallel_isa_initfn(ISADevice *dev)
return 0;
}
-static const int isa_parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
-
ParallelState *parallel_init(int index, CharDriverState *chr)
{
ISADevice *dev;
dev = isa_create("isa-parallel");
- qdev_prop_set_uint32(&dev->qdev, "iobase", isa_parallel_io[index]);
- qdev_prop_set_uint32(&dev->qdev, "irq", 7);
+ qdev_prop_set_uint32(&dev->qdev, "index", index);
qdev_prop_set_chr(&dev->qdev, "chardev", chr);
if (qdev_init(&dev->qdev) < 0)
return NULL;
@@ -579,7 +589,8 @@ static ISADeviceInfo parallel_isa_info = {
.qdev.size = sizeof(ISAParallelState),
.init = parallel_isa_initfn,
.qdev.props = (Property[]) {
- DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, 0x378),
+ DEFINE_PROP_UINT32("index", ISAParallelState, index, -1),
+ DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, -1),
DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7),
DEFINE_PROP_CHR("chardev", ISAParallelState, state.chr),
DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/serial.c b/hw/serial.c
index eb14f11..381b027 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -148,6 +148,7 @@ struct SerialState {
typedef struct ISASerialState {
ISADevice dev;
+ uint32_t index;
uint32_t iobase;
uint32_t isairq;
SerialState state;
@@ -733,11 +734,25 @@ static void serial_init_core(SerialState *s)
serial_event, s);
}
+static const int isa_serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
+static const int isa_serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
+
static int serial_isa_initfn(ISADevice *dev)
{
+ static int index;
ISASerialState *isa = DO_UPCAST(ISASerialState, dev, dev);
SerialState *s = &isa->state;
+ if (isa->index == -1)
+ isa->index = index;
+ if (isa->index >= MAX_SERIAL_PORTS)
+ return -1;
+ if (isa->iobase == -1)
+ isa->iobase = isa_serial_io[isa->index];
+ if (isa->isairq == -1)
+ isa->isairq = isa_serial_irq[isa->index];
+ index++;
+
s->baudbase = 115200;
isa_init_irq(dev, &s->irq, isa->isairq);
serial_init_core(s);
@@ -748,16 +763,12 @@ static int serial_isa_initfn(ISADevice *dev)
return 0;
}
-static const int isa_serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
-static const int isa_serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
-
SerialState *serial_isa_init(int index, CharDriverState *chr)
{
ISADevice *dev;
dev = isa_create("isa-serial");
- qdev_prop_set_uint32(&dev->qdev, "iobase", isa_serial_io[index]);
- qdev_prop_set_uint32(&dev->qdev, "irq", isa_serial_irq[index]);
+ qdev_prop_set_uint32(&dev->qdev, "index", index);
qdev_prop_set_chr(&dev->qdev, "chardev", chr);
if (qdev_init(&dev->qdev) < 0)
return NULL;
@@ -886,8 +897,9 @@ static ISADeviceInfo serial_isa_info = {
.qdev.size = sizeof(ISASerialState),
.init = serial_isa_initfn,
.qdev.props = (Property[]) {
- DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, 0x3f8),
- DEFINE_PROP_UINT32("irq", ISASerialState, isairq, 4),
+ DEFINE_PROP_UINT32("index", ISASerialState, index, -1),
+ DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, -1),
+ DEFINE_PROP_UINT32("irq", ISASerialState, isairq, -1),
DEFINE_PROP_CHR("chardev", ISASerialState, state.chr),
DEFINE_PROP_END_OF_LIST(),
},
--
1.6.2.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH] isa: configure serial+parallel by index.
@ 2009-11-17 10:28 Gerd Hoffmann
2009-11-20 15:01 ` Markus Armbruster
0 siblings, 1 reply; 8+ messages in thread
From: Gerd Hoffmann @ 2009-11-17 10:28 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
This patch adds a 'index' property to the isa-parallel and isa-serial
devices. This can be used to create devices with the default isa irqs
and ioports by simply specifying the index, i.e.
-device isa-serial,index=1
instead of
-device isa-serial,iobase=0x2f8,irq=3
for ttyS1 aka com2. Likewise for parallel ports.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/parallel.c | 2 +-
hw/serial.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/parallel.c b/hw/parallel.c
index 5ae8348..12693d4 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -587,7 +587,7 @@ static ISADeviceInfo parallel_isa_info = {
.qdev.size = sizeof(ISAParallelState),
.init = parallel_isa_initfn,
.qdev.props = (Property[]) {
- DEFINE_PROP_HEX32("index", ISAParallelState, index, -1),
+ DEFINE_PROP_UINT32("index", ISAParallelState, index, -1),
DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, -1),
DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7),
DEFINE_PROP_CHR("chardev", ISAParallelState, state.chr),
diff --git a/hw/serial.c b/hw/serial.c
index 0063260..e7538ac 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -900,7 +900,7 @@ static ISADeviceInfo serial_isa_info = {
.qdev.size = sizeof(ISASerialState),
.init = serial_isa_initfn,
.qdev.props = (Property[]) {
- DEFINE_PROP_HEX32("index", ISASerialState, index, -1),
+ DEFINE_PROP_UINT32("index", ISASerialState, index, -1),
DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, -1),
DEFINE_PROP_UINT32("irq", ISASerialState, isairq, -1),
DEFINE_PROP_CHR("chardev", ISASerialState, state.chr),
--
1.6.2.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] isa: configure serial+parallel by index.
2009-11-17 10:28 [Qemu-devel] [PATCH] isa: configure serial+parallel by index Gerd Hoffmann
@ 2009-11-20 15:01 ` Markus Armbruster
2009-12-02 14:59 ` Anthony Liguori
0 siblings, 1 reply; 8+ messages in thread
From: Markus Armbruster @ 2009-11-20 15:01 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Gerd Hoffmann <kraxel@redhat.com> writes:
> This patch adds a 'index' property to the isa-parallel and isa-serial
> devices. This can be used to create devices with the default isa irqs
> and ioports by simply specifying the index, i.e.
>
> -device isa-serial,index=1
>
> instead of
>
> -device isa-serial,iobase=0x2f8,irq=3
>
> for ttyS1 aka com2. Likewise for parallel ports.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/parallel.c | 2 +-
> hw/serial.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/parallel.c b/hw/parallel.c
> index 5ae8348..12693d4 100644
> --- a/hw/parallel.c
> +++ b/hw/parallel.c
> @@ -587,7 +587,7 @@ static ISADeviceInfo parallel_isa_info = {
> .qdev.size = sizeof(ISAParallelState),
> .init = parallel_isa_initfn,
> .qdev.props = (Property[]) {
> - DEFINE_PROP_HEX32("index", ISAParallelState, index, -1),
> + DEFINE_PROP_UINT32("index", ISAParallelState, index, -1),
> DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, -1),
> DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7),
> DEFINE_PROP_CHR("chardev", ISAParallelState, state.chr),
> diff --git a/hw/serial.c b/hw/serial.c
> index 0063260..e7538ac 100644
> --- a/hw/serial.c
> +++ b/hw/serial.c
> @@ -900,7 +900,7 @@ static ISADeviceInfo serial_isa_info = {
> .qdev.size = sizeof(ISASerialState),
> .init = serial_isa_initfn,
> .qdev.props = (Property[]) {
> - DEFINE_PROP_HEX32("index", ISASerialState, index, -1),
> + DEFINE_PROP_UINT32("index", ISASerialState, index, -1),
> DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, -1),
> DEFINE_PROP_UINT32("irq", ISASerialState, isairq, -1),
> DEFINE_PROP_CHR("chardev", ISASerialState, state.chr),
The commit message is bogus. The patch is a minor fix of commit
e8ee28fb, and the message is a copy of that commit's message.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] isa: configure serial+parallel by index.
2009-11-20 15:01 ` Markus Armbruster
@ 2009-12-02 14:59 ` Anthony Liguori
0 siblings, 0 replies; 8+ messages in thread
From: Anthony Liguori @ 2009-12-02 14:59 UTC (permalink / raw)
To: Markus Armbruster; +Cc: Gerd Hoffmann, qemu-devel
Markus Armbruster wrote:
> The commit message is bogus. The patch is a minor fix of commit
> e8ee28fb, and the message is a copy of that commit's message.
>
Thanks, I've updated the commit message appropriately.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-12-02 14:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-17 10:28 [Qemu-devel] [PATCH] isa: configure serial+parallel by index Gerd Hoffmann
2009-11-20 15:01 ` Markus Armbruster
2009-12-02 14:59 ` Anthony Liguori
-- strict thread matches above, loose matches on Subject: below --
2009-10-26 11:19 Gerd Hoffmann
2009-10-13 11:38 Gerd Hoffmann
2009-10-13 19:08 ` Markus Armbruster
2009-10-26 8:56 ` Markus Armbruster
2009-10-26 9:13 ` Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).