2 * QEMU simulated pvpanic device.
4 * Copyright Fujitsu, Corp. 2013
7 * Wen Congyang <wency@cn.fujitsu.com>
8 * Hu Tao <hutao@cn.fujitsu.com>
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
15 #include "qemu/osdep.h"
17 #include "qemu/module.h"
18 #include "sysemu/runstate.h"
20 #include "hw/nvram/fw_cfg.h"
21 #include "hw/qdev-properties.h"
22 #include "hw/misc/pvpanic.h"
23 #include "qom/object.h"
24 #include "standard-headers/linux/pvpanic.h"
26 static void handle_event(int event
)
30 if (event
& ~(PVPANIC_PANICKED
| PVPANIC_CRASH_LOADED
) && !logged
) {
31 qemu_log_mask(LOG_GUEST_ERROR
, "pvpanic: unknown event %#x.\n", event
);
35 if (event
& PVPANIC_PANICKED
) {
36 qemu_system_guest_panicked(NULL
);
40 if (event
& PVPANIC_CRASH_LOADED
) {
41 qemu_system_guest_crashloaded(NULL
);
46 /* return supported events on read */
47 static uint64_t pvpanic_read(void *opaque
, hwaddr addr
, unsigned size
)
49 PVPanicState
*pvp
= opaque
;
53 static void pvpanic_write(void *opaque
, hwaddr addr
, uint64_t val
,
59 static const MemoryRegionOps pvpanic_ops
= {
61 .write
= pvpanic_write
,
68 void pvpanic_setup_io(PVPanicState
*s
, DeviceState
*dev
, unsigned size
)
70 memory_region_init_io(&s
->mr
, OBJECT(dev
), &pvpanic_ops
, s
, "pvpanic", size
);