]> git.proxmox.com Git - mirror_qemu.git/blame - hw/misc/pvpanic.c
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
[mirror_qemu.git] / hw / misc / pvpanic.c
CommitLineData
eec3d2ad
HT
1/*
2 * QEMU simulated pvpanic device.
3 *
4 * Copyright Fujitsu, Corp. 2013
5 *
6 * Authors:
7 * Wen Congyang <wency@cn.fujitsu.com>
8 * Hu Tao <hutao@cn.fujitsu.com>
9 *
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.
12 *
13 */
14
0d1c9782 15#include "qemu/osdep.h"
eec3d2ad 16#include "qemu/log.h"
0b8fa32f 17#include "qemu/module.h"
54d31236 18#include "sysemu/runstate.h"
eec3d2ad 19
10a584b2 20#include "hw/nvram/fw_cfg.h"
a27bd6c7 21#include "hw/qdev-properties.h"
0d5d8a3a 22#include "hw/misc/pvpanic.h"
db1015e9 23#include "qom/object.h"
45d8c052 24#include "standard-headers/linux/pvpanic.h"
10a584b2 25
eec3d2ad
HT
26static void handle_event(int event)
27{
28 static bool logged;
29
45d8c052 30 if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) && !logged) {
eec3d2ad
HT
31 qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", event);
32 logged = true;
33 }
34
35 if (event & PVPANIC_PANICKED) {
c86f106b 36 qemu_system_guest_panicked(NULL);
eec3d2ad
HT
37 return;
38 }
7dc58dee 39
45d8c052 40 if (event & PVPANIC_CRASH_LOADED) {
7dc58dee
ZP
41 qemu_system_guest_crashloaded(NULL);
42 return;
43 }
eec3d2ad
HT
44}
45
eec3d2ad 46/* return supported events on read */
677726ef 47static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size)
eec3d2ad 48{
b1b0393c
PB
49 PVPanicState *pvp = opaque;
50 return pvp->events;
eec3d2ad
HT
51}
52
677726ef 53static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val,
eec3d2ad
HT
54 unsigned size)
55{
56 handle_event(val);
57}
58
59static const MemoryRegionOps pvpanic_ops = {
677726ef
MC
60 .read = pvpanic_read,
61 .write = pvpanic_write,
eec3d2ad
HT
62 .impl = {
63 .min_access_size = 1,
64 .max_access_size = 1,
65 },
66};
67
677726ef 68void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size)
eec3d2ad 69{
677726ef 70 memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size);
eec3d2ad 71}