diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-02-20 13:05:47 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-02-20 13:05:48 +0000 |
commit | 61e8a923646903d76a6d952019716b417d42eedc (patch) | |
tree | 038e4c1921d45b2fe5d650a8fb476bb8169a1544 /hw/timer/ds1338.c | |
parent | 4c0c9bbe78901a706497a8fa1a27935bafc20cf7 (diff) | |
parent | 91f32b0c92fb18a403e48d3c8ffc14422a0c1ca5 (diff) | |
download | hqemu-61e8a923646903d76a6d952019716b417d42eedc.zip hqemu-61e8a923646903d76a6d952019716b417d42eedc.tar.gz |
Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging
QOM infrastructure fixes and device conversions
* QTest cleanups and test cases for PCI NICs
* NAND fix for "info qtree"
* Cleanup and extension of QOM machine tests
* IndustryPack test cases and conversion to QOM realize
* I2C cleanups
* Cleanups of legacy qdev properties
# gpg: Signature made Mon 17 Feb 2014 22:15:37 GMT using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg: aka "Andreas Färber <afaerber@suse.com>"
* remotes/afaerber/tags/qom-devices-for-peter: (49 commits)
qtest: Include system headers before user headers
qapi: Refine human printing of sizes
qdev: Use QAPI type names for properties
qdev: Add enum property types to QAPI schema
block: Handle "rechs" and "large" translation options
qdev: Remove hex8/32/64 property types
qdev: Remove most legacy printers
qdev: Use human mode in "info qtree"
qapi: Add human mode to StringOutputVisitor
qdev: Inline qdev_prop_parse()
qdev: Legacy properties are just strings
qdev: Legacy properties are now read-only
qdev: Remove legacy parsers for hex8/32/64
qdev: Sizes are now parsed by StringInputVisitor
qapi: Add size parser to StringInputVisitor
qtest: Don't segfault with invalid -qtest option
ipack: Move IndustryPack out of hw/char/
ipoctal232: QOM parent field cleanup
ipack: QOM parent field cleanup for IPackDevice
ipack: QOM parent field cleanup for IPackBus
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/timer/ds1338.c')
-rw-r--r-- | hw/timer/ds1338.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c index 8987cdc..bb2f8ee 100644 --- a/hw/timer/ds1338.c +++ b/hw/timer/ds1338.c @@ -23,8 +23,12 @@ #define HOURS_PM 0x20 #define CTRL_OSF 0x20 -typedef struct { - I2CSlave i2c; +#define TYPE_DS1338 "ds1338" +#define DS1338(obj) OBJECT_CHECK(DS1338State, (obj), TYPE_DS1338) + +typedef struct DS1338State { + I2CSlave parent_obj; + int64_t offset; uint8_t wday_offset; uint8_t nvram[NVRAM_SIZE]; @@ -38,7 +42,7 @@ static const VMStateDescription vmstate_ds1338 = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField[]) { - VMSTATE_I2C_SLAVE(i2c, DS1338State), + VMSTATE_I2C_SLAVE(parent_obj, DS1338State), VMSTATE_INT64(offset, DS1338State), VMSTATE_UINT8_V(wday_offset, DS1338State, 2), VMSTATE_UINT8_ARRAY(nvram, DS1338State, NVRAM_SIZE), @@ -90,7 +94,7 @@ static void inc_regptr(DS1338State *s) static void ds1338_event(I2CSlave *i2c, enum i2c_event event) { - DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c); + DS1338State *s = DS1338(i2c); switch (event) { case I2C_START_RECV: @@ -111,7 +115,7 @@ static void ds1338_event(I2CSlave *i2c, enum i2c_event event) static int ds1338_recv(I2CSlave *i2c) { - DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c); + DS1338State *s = DS1338(i2c); uint8_t res; res = s->nvram[s->ptr]; @@ -121,7 +125,8 @@ static int ds1338_recv(I2CSlave *i2c) static int ds1338_send(I2CSlave *i2c, uint8_t data) { - DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c); + DS1338State *s = DS1338(i2c); + if (s->addr_byte) { s->ptr = data & (NVRAM_SIZE - 1); s->addr_byte = false; @@ -198,7 +203,7 @@ static int ds1338_init(I2CSlave *i2c) static void ds1338_reset(DeviceState *dev) { - DS1338State *s = FROM_I2C_SLAVE(DS1338State, I2C_SLAVE(dev)); + DS1338State *s = DS1338(dev); /* The clock is running and synchronized with the host */ s->offset = 0; @@ -222,7 +227,7 @@ static void ds1338_class_init(ObjectClass *klass, void *data) } static const TypeInfo ds1338_info = { - .name = "ds1338", + .name = TYPE_DS1338, .parent = TYPE_I2C_SLAVE, .instance_size = sizeof(DS1338State), .class_init = ds1338_class_init, |