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"
25 static void handle_event(int event
)
29 if (event
& ~(PVPANIC_PANICKED
| PVPANIC_CRASHLOADED
) && !logged
) {
30 qemu_log_mask(LOG_GUEST_ERROR
, "pvpanic: unknown event %#x.\n", event
);
34 if (event
& PVPANIC_PANICKED
) {
35 qemu_system_guest_panicked(NULL
);
39 if (event
& PVPANIC_CRASHLOADED
) {
40 qemu_system_guest_crashloaded(NULL
);
45 /* return supported events on read */
46 static uint64_t pvpanic_read(void *opaque
, hwaddr addr
, unsigned size
)
48 PVPanicState
*pvp
= opaque
;
52 static void pvpanic_write(void *opaque
, hwaddr addr
, uint64_t val
,
58 static const MemoryRegionOps pvpanic_ops
= {
60 .write
= pvpanic_write
,
67 void pvpanic_setup_io(PVPanicState
*s
, DeviceState
*dev
, unsigned size
)
69 memory_region_init_io(&s
->mr
, OBJECT(dev
), &pvpanic_ops
, s
, "pvpanic", size
);