2011-03-07 23:32:37 +01:00
|
|
|
/*
|
|
|
|
* QEMU model of the Milkymist SoftUSB block.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 Michael Walle <michael@walle.cc>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Specification available at:
|
|
|
|
* not available yet
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:16:57 +01:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 09:01:28 +01:00
|
|
|
#include "qapi/error.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/hw.h"
|
|
|
|
#include "hw/sysbus.h"
|
2011-03-07 23:32:37 +01:00
|
|
|
#include "trace.h"
|
2012-11-28 12:06:30 +01:00
|
|
|
#include "ui/console.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/input/hid.h"
|
2012-12-17 18:20:00 +01:00
|
|
|
#include "qemu/error-report.h"
|
2011-03-07 23:32:37 +01:00
|
|
|
|
|
|
|
enum {
|
|
|
|
R_CTRL = 0,
|
|
|
|
R_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CTRL_RESET = (1<<0),
|
|
|
|
};
|
|
|
|
|
|
|
|
#define COMLOC_DEBUG_PRODUCE 0x1000
|
|
|
|
#define COMLOC_DEBUG_BASE 0x1001
|
|
|
|
#define COMLOC_MEVT_PRODUCE 0x1101
|
|
|
|
#define COMLOC_MEVT_BASE 0x1102
|
|
|
|
#define COMLOC_KEVT_PRODUCE 0x1142
|
|
|
|
#define COMLOC_KEVT_BASE 0x1143
|
|
|
|
|
2013-07-26 18:37:02 +02:00
|
|
|
#define TYPE_MILKYMIST_SOFTUSB "milkymist-softusb"
|
|
|
|
#define MILKYMIST_SOFTUSB(obj) \
|
|
|
|
OBJECT_CHECK(MilkymistSoftUsbState, (obj), TYPE_MILKYMIST_SOFTUSB)
|
|
|
|
|
2011-03-07 23:32:37 +01:00
|
|
|
struct MilkymistSoftUsbState {
|
2013-07-26 18:37:02 +02:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
2011-08-09 23:54:55 +02:00
|
|
|
HIDState hid_kbd;
|
|
|
|
HIDState hid_mouse;
|
2011-03-07 23:32:37 +01:00
|
|
|
|
2011-08-08 20:40:35 +02:00
|
|
|
MemoryRegion regs_region;
|
|
|
|
MemoryRegion pmem;
|
|
|
|
MemoryRegion dmem;
|
2011-03-07 23:32:37 +01:00
|
|
|
qemu_irq irq;
|
|
|
|
|
2013-03-15 15:34:22 +01:00
|
|
|
void *pmem_ptr;
|
|
|
|
void *dmem_ptr;
|
|
|
|
|
2011-03-07 23:32:37 +01:00
|
|
|
/* device properties */
|
|
|
|
uint32_t pmem_size;
|
|
|
|
uint32_t dmem_size;
|
|
|
|
|
|
|
|
/* device registers */
|
|
|
|
uint32_t regs[R_MAX];
|
|
|
|
|
|
|
|
/* mouse state */
|
2011-08-09 23:54:55 +02:00
|
|
|
uint8_t mouse_hid_buffer[4];
|
2011-03-07 23:32:37 +01:00
|
|
|
|
|
|
|
/* keyboard state */
|
2011-08-09 23:54:55 +02:00
|
|
|
uint8_t kbd_hid_buffer[8];
|
2011-03-07 23:32:37 +01:00
|
|
|
};
|
|
|
|
typedef struct MilkymistSoftUsbState MilkymistSoftUsbState;
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t softusb_read(void *opaque, hwaddr addr,
|
2011-08-08 20:40:35 +02:00
|
|
|
unsigned size)
|
2011-03-07 23:32:37 +01:00
|
|
|
{
|
|
|
|
MilkymistSoftUsbState *s = opaque;
|
|
|
|
uint32_t r = 0;
|
|
|
|
|
|
|
|
addr >>= 2;
|
|
|
|
switch (addr) {
|
|
|
|
case R_CTRL:
|
|
|
|
r = s->regs[addr];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error_report("milkymist_softusb: read access to unknown register 0x"
|
|
|
|
TARGET_FMT_plx, addr << 2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
trace_milkymist_softusb_memory_read(addr << 2, r);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-23 12:30:10 +02:00
|
|
|
softusb_write(void *opaque, hwaddr addr, uint64_t value,
|
2011-08-08 20:40:35 +02:00
|
|
|
unsigned size)
|
2011-03-07 23:32:37 +01:00
|
|
|
{
|
|
|
|
MilkymistSoftUsbState *s = opaque;
|
|
|
|
|
|
|
|
trace_milkymist_softusb_memory_write(addr, value);
|
|
|
|
|
|
|
|
addr >>= 2;
|
|
|
|
switch (addr) {
|
|
|
|
case R_CTRL:
|
|
|
|
s->regs[addr] = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error_report("milkymist_softusb: write access to unknown register 0x"
|
|
|
|
TARGET_FMT_plx, addr << 2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-08 20:40:35 +02:00
|
|
|
static const MemoryRegionOps softusb_mmio_ops = {
|
|
|
|
.read = softusb_read,
|
|
|
|
.write = softusb_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 4,
|
|
|
|
.max_access_size = 4,
|
|
|
|
},
|
2011-03-07 23:32:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void softusb_read_dmem(MilkymistSoftUsbState *s,
|
|
|
|
uint32_t offset, uint8_t *buf, uint32_t len)
|
|
|
|
{
|
|
|
|
if (offset + len >= s->dmem_size) {
|
|
|
|
error_report("milkymist_softusb: read dmem out of bounds "
|
2011-06-22 14:03:54 +02:00
|
|
|
"at offset 0x%x, len %d", offset, len);
|
2013-03-28 19:43:04 +01:00
|
|
|
memset(buf, 0, len);
|
2011-03-07 23:32:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-15 15:34:22 +01:00
|
|
|
memcpy(buf, s->dmem_ptr + offset, len);
|
2011-03-07 23:32:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void softusb_write_dmem(MilkymistSoftUsbState *s,
|
|
|
|
uint32_t offset, uint8_t *buf, uint32_t len)
|
|
|
|
{
|
|
|
|
if (offset + len >= s->dmem_size) {
|
|
|
|
error_report("milkymist_softusb: write dmem out of bounds "
|
2011-06-22 14:03:54 +02:00
|
|
|
"at offset 0x%x, len %d", offset, len);
|
2011-03-07 23:32:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-15 15:34:22 +01:00
|
|
|
memcpy(s->dmem_ptr + offset, buf, len);
|
2011-03-07 23:32:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void softusb_mouse_changed(MilkymistSoftUsbState *s)
|
|
|
|
{
|
|
|
|
uint8_t m;
|
|
|
|
|
|
|
|
softusb_read_dmem(s, COMLOC_MEVT_PRODUCE, &m, 1);
|
|
|
|
trace_milkymist_softusb_mevt(m);
|
2011-08-09 23:54:55 +02:00
|
|
|
softusb_write_dmem(s, COMLOC_MEVT_BASE + 4 * m, s->mouse_hid_buffer, 4);
|
2011-03-07 23:32:37 +01:00
|
|
|
m = (m + 1) & 0xf;
|
|
|
|
softusb_write_dmem(s, COMLOC_MEVT_PRODUCE, &m, 1);
|
|
|
|
|
|
|
|
trace_milkymist_softusb_pulse_irq();
|
|
|
|
qemu_irq_pulse(s->irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void softusb_kbd_changed(MilkymistSoftUsbState *s)
|
|
|
|
{
|
|
|
|
uint8_t m;
|
|
|
|
|
|
|
|
softusb_read_dmem(s, COMLOC_KEVT_PRODUCE, &m, 1);
|
|
|
|
trace_milkymist_softusb_kevt(m);
|
2011-08-09 23:54:55 +02:00
|
|
|
softusb_write_dmem(s, COMLOC_KEVT_BASE + 8 * m, s->kbd_hid_buffer, 8);
|
2011-03-07 23:32:37 +01:00
|
|
|
m = (m + 1) & 0x7;
|
|
|
|
softusb_write_dmem(s, COMLOC_KEVT_PRODUCE, &m, 1);
|
|
|
|
|
|
|
|
trace_milkymist_softusb_pulse_irq();
|
|
|
|
qemu_irq_pulse(s->irq);
|
|
|
|
}
|
|
|
|
|
2011-08-09 23:54:55 +02:00
|
|
|
static void softusb_kbd_hid_datain(HIDState *hs)
|
2011-03-07 23:32:37 +01:00
|
|
|
{
|
2011-08-09 23:54:55 +02:00
|
|
|
MilkymistSoftUsbState *s = container_of(hs, MilkymistSoftUsbState, hid_kbd);
|
|
|
|
int len;
|
2011-03-07 23:32:37 +01:00
|
|
|
|
|
|
|
/* if device is in reset, do nothing */
|
|
|
|
if (s->regs[R_CTRL] & CTRL_RESET) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-04 20:00:07 +02:00
|
|
|
while (hid_has_events(hs)) {
|
|
|
|
len = hid_keyboard_poll(hs, s->kbd_hid_buffer,
|
|
|
|
sizeof(s->kbd_hid_buffer));
|
2011-03-07 23:32:37 +01:00
|
|
|
|
2014-10-04 20:00:07 +02:00
|
|
|
if (len == 8) {
|
|
|
|
softusb_kbd_changed(s);
|
|
|
|
}
|
2011-08-09 23:54:55 +02:00
|
|
|
}
|
2011-03-07 23:32:37 +01:00
|
|
|
}
|
|
|
|
|
2011-08-09 23:54:55 +02:00
|
|
|
static void softusb_mouse_hid_datain(HIDState *hs)
|
2011-03-07 23:32:37 +01:00
|
|
|
{
|
2011-08-09 23:54:55 +02:00
|
|
|
MilkymistSoftUsbState *s =
|
|
|
|
container_of(hs, MilkymistSoftUsbState, hid_mouse);
|
|
|
|
int len;
|
2011-03-07 23:32:37 +01:00
|
|
|
|
2011-08-09 23:54:55 +02:00
|
|
|
/* if device is in reset, do nothing */
|
|
|
|
if (s->regs[R_CTRL] & CTRL_RESET) {
|
|
|
|
return;
|
|
|
|
}
|
2011-03-07 23:32:37 +01:00
|
|
|
|
2014-10-04 20:00:07 +02:00
|
|
|
while (hid_has_events(hs)) {
|
|
|
|
len = hid_pointer_poll(hs, s->mouse_hid_buffer,
|
|
|
|
sizeof(s->mouse_hid_buffer));
|
2011-06-24 12:31:11 +02:00
|
|
|
|
2014-10-04 20:00:07 +02:00
|
|
|
if (len == 4) {
|
|
|
|
softusb_mouse_changed(s);
|
|
|
|
}
|
2011-08-09 23:54:55 +02:00
|
|
|
}
|
2011-05-23 17:37:12 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 23:32:37 +01:00
|
|
|
static void milkymist_softusb_reset(DeviceState *d)
|
|
|
|
{
|
2013-07-26 18:37:02 +02:00
|
|
|
MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(d);
|
2011-03-07 23:32:37 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < R_MAX; i++) {
|
|
|
|
s->regs[i] = 0;
|
|
|
|
}
|
2011-08-09 23:54:55 +02:00
|
|
|
memset(s->kbd_hid_buffer, 0, sizeof(s->kbd_hid_buffer));
|
|
|
|
memset(s->mouse_hid_buffer, 0, sizeof(s->mouse_hid_buffer));
|
|
|
|
|
|
|
|
hid_reset(&s->hid_kbd);
|
|
|
|
hid_reset(&s->hid_mouse);
|
2011-03-07 23:32:37 +01:00
|
|
|
|
|
|
|
/* defaults */
|
|
|
|
s->regs[R_CTRL] = CTRL_RESET;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int milkymist_softusb_init(SysBusDevice *dev)
|
|
|
|
{
|
2013-07-26 18:37:02 +02:00
|
|
|
MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(dev);
|
2011-03-07 23:32:37 +01:00
|
|
|
|
|
|
|
sysbus_init_irq(dev, &s->irq);
|
|
|
|
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&s->regs_region, OBJECT(s), &softusb_mmio_ops, s,
|
2011-08-08 20:40:35 +02:00
|
|
|
"milkymist-softusb", R_MAX * 4);
|
2011-11-27 10:38:10 +01:00
|
|
|
sysbus_init_mmio(dev, &s->regs_region);
|
2011-03-07 23:32:37 +01:00
|
|
|
|
|
|
|
/* register pmem and dmem */
|
2017-07-07 16:42:49 +02:00
|
|
|
memory_region_init_ram_nomigrate(&s->pmem, OBJECT(s), "milkymist-softusb.pmem",
|
Fix bad error handling after memory_region_init_ram()
Symptom:
$ qemu-system-x86_64 -m 10000000
Unexpected error in ram_block_add() at /work/armbru/qemu/exec.c:1456:
upstream-qemu: cannot set up guest memory 'pc.ram': Cannot allocate memory
Aborted (core dumped)
Root cause: commit ef701d7 screwed up handling of out-of-memory
conditions. Before the commit, we report the error and exit(1), in
one place, ram_block_add(). The commit lifts the error handling up
the call chain some, to three places. Fine. Except it uses
&error_abort in these places, changing the behavior from exit(1) to
abort(), and thus undoing the work of commit 3922825 "exec: Don't
abort when we can't allocate guest memory".
The three places are:
* memory_region_init_ram()
Commit 4994653 (right after commit ef701d7) lifted the error
handling further, through memory_region_init_ram(), multiplying the
incorrect use of &error_abort. Later on, imitation of existing
(bad) code may have created more.
* memory_region_init_ram_ptr()
The &error_abort is still there.
* memory_region_init_rom_device()
Doesn't need fixing, because commit 33e0eb5 (soon after commit
ef701d7) lifted the error handling further, and in the process
changed it from &error_abort to passing it up the call chain.
Correct, because the callers are realize() methods.
Fix the error handling after memory_region_init_ram() with a
Coccinelle semantic patch:
@r@
expression mr, owner, name, size, err;
position p;
@@
memory_region_init_ram(mr, owner, name, size,
(
- &error_abort
+ &error_fatal
|
err@p
)
);
@script:python@
p << r.p;
@@
print "%s:%s:%s" % (p[0].file, p[0].line, p[0].column)
When the last argument is &error_abort, it gets replaced by
&error_fatal. This is the fix.
If the last argument is anything else, its position is reported. This
lets us check the fix is complete. Four positions get reported:
* ram_backend_memory_alloc()
Error is passed up the call chain, ultimately through
user_creatable_complete(). As far as I can tell, it's callers all
handle the error sanely.
* fsl_imx25_realize(), fsl_imx31_realize(), dp8393x_realize()
DeviceClass.realize() methods, errors handled sanely further up the
call chain.
We're good. Test case again behaves:
$ qemu-system-x86_64 -m 10000000
qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory
[Exit 1 ]
The next commits will repair the rest of commit ef701d7's damage.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1441983105-26376-3-git-send-email-armbru@redhat.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
2015-09-11 16:51:43 +02:00
|
|
|
s->pmem_size, &error_fatal);
|
2011-12-20 14:59:12 +01:00
|
|
|
vmstate_register_ram_global(&s->pmem);
|
2013-03-15 15:34:22 +01:00
|
|
|
s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem);
|
|
|
|
sysbus_init_mmio(dev, &s->pmem);
|
2017-07-07 16:42:49 +02:00
|
|
|
memory_region_init_ram_nomigrate(&s->dmem, OBJECT(s), "milkymist-softusb.dmem",
|
Fix bad error handling after memory_region_init_ram()
Symptom:
$ qemu-system-x86_64 -m 10000000
Unexpected error in ram_block_add() at /work/armbru/qemu/exec.c:1456:
upstream-qemu: cannot set up guest memory 'pc.ram': Cannot allocate memory
Aborted (core dumped)
Root cause: commit ef701d7 screwed up handling of out-of-memory
conditions. Before the commit, we report the error and exit(1), in
one place, ram_block_add(). The commit lifts the error handling up
the call chain some, to three places. Fine. Except it uses
&error_abort in these places, changing the behavior from exit(1) to
abort(), and thus undoing the work of commit 3922825 "exec: Don't
abort when we can't allocate guest memory".
The three places are:
* memory_region_init_ram()
Commit 4994653 (right after commit ef701d7) lifted the error
handling further, through memory_region_init_ram(), multiplying the
incorrect use of &error_abort. Later on, imitation of existing
(bad) code may have created more.
* memory_region_init_ram_ptr()
The &error_abort is still there.
* memory_region_init_rom_device()
Doesn't need fixing, because commit 33e0eb5 (soon after commit
ef701d7) lifted the error handling further, and in the process
changed it from &error_abort to passing it up the call chain.
Correct, because the callers are realize() methods.
Fix the error handling after memory_region_init_ram() with a
Coccinelle semantic patch:
@r@
expression mr, owner, name, size, err;
position p;
@@
memory_region_init_ram(mr, owner, name, size,
(
- &error_abort
+ &error_fatal
|
err@p
)
);
@script:python@
p << r.p;
@@
print "%s:%s:%s" % (p[0].file, p[0].line, p[0].column)
When the last argument is &error_abort, it gets replaced by
&error_fatal. This is the fix.
If the last argument is anything else, its position is reported. This
lets us check the fix is complete. Four positions get reported:
* ram_backend_memory_alloc()
Error is passed up the call chain, ultimately through
user_creatable_complete(). As far as I can tell, it's callers all
handle the error sanely.
* fsl_imx25_realize(), fsl_imx31_realize(), dp8393x_realize()
DeviceClass.realize() methods, errors handled sanely further up the
call chain.
We're good. Test case again behaves:
$ qemu-system-x86_64 -m 10000000
qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory
[Exit 1 ]
The next commits will repair the rest of commit ef701d7's damage.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1441983105-26376-3-git-send-email-armbru@redhat.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
2015-09-11 16:51:43 +02:00
|
|
|
s->dmem_size, &error_fatal);
|
2011-12-20 14:59:12 +01:00
|
|
|
vmstate_register_ram_global(&s->dmem);
|
2013-03-15 15:34:22 +01:00
|
|
|
s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem);
|
|
|
|
sysbus_init_mmio(dev, &s->dmem);
|
2011-03-07 23:32:37 +01:00
|
|
|
|
2011-08-09 23:54:55 +02:00
|
|
|
hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain);
|
|
|
|
hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain);
|
2011-03-07 23:32:37 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_milkymist_softusb = {
|
|
|
|
.name = "milkymist-softusb",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2014-04-16 16:01:33 +02:00
|
|
|
.fields = (VMStateField[]) {
|
2011-03-07 23:32:37 +01:00
|
|
|
VMSTATE_UINT32_ARRAY(regs, MilkymistSoftUsbState, R_MAX),
|
2011-08-09 23:54:55 +02:00
|
|
|
VMSTATE_HID_KEYBOARD_DEVICE(hid_kbd, MilkymistSoftUsbState),
|
|
|
|
VMSTATE_HID_POINTER_DEVICE(hid_mouse, MilkymistSoftUsbState),
|
|
|
|
VMSTATE_BUFFER(kbd_hid_buffer, MilkymistSoftUsbState),
|
|
|
|
VMSTATE_BUFFER(mouse_hid_buffer, MilkymistSoftUsbState),
|
2011-03-07 23:32:37 +01:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-01-24 20:12:29 +01:00
|
|
|
static Property milkymist_softusb_properties[] = {
|
|
|
|
DEFINE_PROP_UINT32("pmem_size", MilkymistSoftUsbState, pmem_size, 0x00001000),
|
|
|
|
DEFINE_PROP_UINT32("dmem_size", MilkymistSoftUsbState, dmem_size, 0x00002000),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void milkymist_softusb_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 20:12:29 +01:00
|
|
|
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
|
|
|
|
|
|
|
|
k->init = milkymist_softusb_init;
|
2011-12-08 04:34:16 +01:00
|
|
|
dc->reset = milkymist_softusb_reset;
|
|
|
|
dc->vmsd = &vmstate_milkymist_softusb;
|
|
|
|
dc->props = milkymist_softusb_properties;
|
2012-01-24 20:12:29 +01:00
|
|
|
}
|
|
|
|
|
2013-01-10 16:19:07 +01:00
|
|
|
static const TypeInfo milkymist_softusb_info = {
|
2013-07-26 18:37:02 +02:00
|
|
|
.name = TYPE_MILKYMIST_SOFTUSB,
|
2011-12-08 04:34:16 +01:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(MilkymistSoftUsbState),
|
|
|
|
.class_init = milkymist_softusb_class_init,
|
2011-03-07 23:32:37 +01:00
|
|
|
};
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void milkymist_softusb_register_types(void)
|
2011-03-07 23:32:37 +01:00
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
type_register_static(&milkymist_softusb_info);
|
2011-03-07 23:32:37 +01:00
|
|
|
}
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
type_init(milkymist_softusb_register_types)
|