2013-04-26 05:24:42 +02:00
|
|
|
/*
|
|
|
|
* QEMU simulated pvpanic device.
|
|
|
|
*
|
|
|
|
* Copyright Fujitsu, Corp. 2013
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Wen Congyang <wency@cn.fujitsu.com>
|
|
|
|
* Hu Tao <hutao@cn.fujitsu.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:17 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-04-26 05:24:42 +02:00
|
|
|
#include "qemu/log.h"
|
2019-05-23 16:35:07 +02:00
|
|
|
#include "qemu/module.h"
|
2019-08-12 07:23:59 +02:00
|
|
|
#include "sysemu/runstate.h"
|
2013-04-26 05:24:42 +02:00
|
|
|
|
2013-04-26 05:24:44 +02:00
|
|
|
#include "hw/nvram/fw_cfg.h"
|
2019-08-12 07:23:51 +02:00
|
|
|
#include "hw/qdev-properties.h"
|
2017-10-17 18:44:23 +02:00
|
|
|
#include "hw/misc/pvpanic.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2013-04-26 05:24:44 +02:00
|
|
|
|
2013-04-26 05:24:42 +02:00
|
|
|
static void handle_event(int event)
|
|
|
|
{
|
|
|
|
static bool logged;
|
|
|
|
|
2020-01-14 03:31:02 +01:00
|
|
|
if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASHLOADED) && !logged) {
|
2013-04-26 05:24:42 +02:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", event);
|
|
|
|
logged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event & PVPANIC_PANICKED) {
|
2017-02-14 07:25:23 +01:00
|
|
|
qemu_system_guest_panicked(NULL);
|
2013-04-26 05:24:42 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-01-14 03:31:02 +01:00
|
|
|
|
|
|
|
if (event & PVPANIC_CRASHLOADED) {
|
|
|
|
qemu_system_guest_crashloaded(NULL);
|
|
|
|
return;
|
|
|
|
}
|
2013-04-26 05:24:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return supported events on read */
|
2021-01-27 15:59:27 +01:00
|
|
|
static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size)
|
2013-04-26 05:24:42 +02:00
|
|
|
{
|
2020-11-09 14:53:04 +01:00
|
|
|
PVPanicState *pvp = opaque;
|
|
|
|
return pvp->events;
|
2013-04-26 05:24:42 +02:00
|
|
|
}
|
|
|
|
|
2021-01-27 15:59:27 +01:00
|
|
|
static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val,
|
2013-04-26 05:24:42 +02:00
|
|
|
unsigned size)
|
|
|
|
{
|
|
|
|
handle_event(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps pvpanic_ops = {
|
2021-01-27 15:59:27 +01:00
|
|
|
.read = pvpanic_read,
|
|
|
|
.write = pvpanic_write,
|
2013-04-26 05:24:42 +02:00
|
|
|
.impl = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-27 15:59:27 +01:00
|
|
|
void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size)
|
2013-04-26 05:24:42 +02:00
|
|
|
{
|
2021-01-27 15:59:27 +01:00
|
|
|
memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size);
|
2013-04-26 05:24:42 +02:00
|
|
|
}
|