提交 e8ba1ce9 编写于 作者: G Gerd Hoffmann

switch debugcon to memory api

Also some QOM glue while being at it.
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
上级 25bbf61e
...@@ -29,20 +29,27 @@ ...@@ -29,20 +29,27 @@
#include "isa.h" #include "isa.h"
#include "pc.h" #include "pc.h"
#define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon"
#define ISA_DEBUGCON_DEVICE(obj) \
OBJECT_CHECK(ISADebugconState, (obj), TYPE_ISA_DEBUGCON_DEVICE)
//#define DEBUG_DEBUGCON //#define DEBUG_DEBUGCON
typedef struct DebugconState { typedef struct DebugconState {
MemoryRegion io;
CharDriverState *chr; CharDriverState *chr;
uint32_t readback; uint32_t readback;
} DebugconState; } DebugconState;
typedef struct ISADebugconState { typedef struct ISADebugconState {
ISADevice dev; ISADevice parent_obj;
uint32_t iobase; uint32_t iobase;
DebugconState state; DebugconState state;
} ISADebugconState; } ISADebugconState;
static void debugcon_ioport_write(void *opaque, uint32_t addr, uint32_t val) static void debugcon_ioport_write(void *opaque, hwaddr addr, uint64_t val,
unsigned width)
{ {
DebugconState *s = opaque; DebugconState *s = opaque;
unsigned char ch = val; unsigned char ch = val;
...@@ -55,7 +62,7 @@ static void debugcon_ioport_write(void *opaque, uint32_t addr, uint32_t val) ...@@ -55,7 +62,7 @@ static void debugcon_ioport_write(void *opaque, uint32_t addr, uint32_t val)
} }
static uint32_t debugcon_ioport_read(void *opaque, uint32_t addr) static uint64_t debugcon_ioport_read(void *opaque, hwaddr addr, unsigned width)
{ {
DebugconState *s = opaque; DebugconState *s = opaque;
...@@ -66,6 +73,14 @@ static uint32_t debugcon_ioport_read(void *opaque, uint32_t addr) ...@@ -66,6 +73,14 @@ static uint32_t debugcon_ioport_read(void *opaque, uint32_t addr)
return s->readback; return s->readback;
} }
static const MemoryRegionOps debugcon_ops = {
.read = debugcon_ioport_read,
.write = debugcon_ioport_write,
.valid.min_access_size = 1,
.valid.max_access_size = 1,
.endianness = DEVICE_LITTLE_ENDIAN,
};
static void debugcon_init_core(DebugconState *s) static void debugcon_init_core(DebugconState *s)
{ {
if (!s->chr) { if (!s->chr) {
...@@ -78,12 +93,14 @@ static void debugcon_init_core(DebugconState *s) ...@@ -78,12 +93,14 @@ static void debugcon_init_core(DebugconState *s)
static int debugcon_isa_initfn(ISADevice *dev) static int debugcon_isa_initfn(ISADevice *dev)
{ {
ISADebugconState *isa = DO_UPCAST(ISADebugconState, dev, dev); ISADebugconState *isa = ISA_DEBUGCON_DEVICE(dev);
DebugconState *s = &isa->state; DebugconState *s = &isa->state;
debugcon_init_core(s); debugcon_init_core(s);
register_ioport_write(isa->iobase, 1, 1, debugcon_ioport_write, s); memory_region_init_io(&s->io, &debugcon_ops, s,
register_ioport_read(isa->iobase, 1, 1, debugcon_ioport_read, s); TYPE_ISA_DEBUGCON_DEVICE, 1);
memory_region_add_subregion(isa_address_space_io(dev),
isa->iobase, &s->io);
return 0; return 0;
} }
...@@ -103,7 +120,7 @@ static void debugcon_isa_class_initfn(ObjectClass *klass, void *data) ...@@ -103,7 +120,7 @@ static void debugcon_isa_class_initfn(ObjectClass *klass, void *data)
} }
static TypeInfo debugcon_isa_info = { static TypeInfo debugcon_isa_info = {
.name = "isa-debugcon", .name = TYPE_ISA_DEBUGCON_DEVICE,
.parent = TYPE_ISA_DEVICE, .parent = TYPE_ISA_DEVICE,
.instance_size = sizeof(ISADebugconState), .instance_size = sizeof(ISADebugconState),
.class_init = debugcon_isa_class_initfn, .class_init = debugcon_isa_class_initfn,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册