aspeed: Introduce a create_pca9552() helper
[qemu.git] / hw / misc / pvpanic.c
blobe2cb4a5d28a29d90c3a646f7102d4c85005ccf69
1 /*
2 * QEMU simulated pvpanic device.
4 * Copyright Fujitsu, Corp. 2013
6 * Authors:
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"
16 #include "qemu/log.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)
27 static bool logged;
29 if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASHLOADED) && !logged) {
30 qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", event);
31 logged = true;
34 if (event & PVPANIC_PANICKED) {
35 qemu_system_guest_panicked(NULL);
36 return;
39 if (event & PVPANIC_CRASHLOADED) {
40 qemu_system_guest_crashloaded(NULL);
41 return;
45 /* return supported events on read */
46 static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size)
48 PVPanicState *pvp = opaque;
49 return pvp->events;
52 static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val,
53 unsigned size)
55 handle_event(val);
58 static const MemoryRegionOps pvpanic_ops = {
59 .read = pvpanic_read,
60 .write = pvpanic_write,
61 .impl = {
62 .min_access_size = 1,
63 .max_access_size = 1,
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);