2013-04-26 07:24:42 +04: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 21:17:17 +03:00
|
|
|
#include "qemu/osdep.h"
|
2013-04-26 07:24:42 +04:00
|
|
|
#include "qemu/log.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2019-08-12 08:23:59 +03:00
|
|
|
#include "sysemu/runstate.h"
|
2013-04-26 07:24:42 +04:00
|
|
|
|
2013-04-26 07:24:44 +04:00
|
|
|
#include "hw/nvram/fw_cfg.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2017-10-17 19:44:23 +03:00
|
|
|
#include "hw/misc/pvpanic.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2024-06-03 15:16:55 +03:00
|
|
|
#include "standard-headers/misc/pvpanic.h"
|
2013-04-26 07:24:44 +04:00
|
|
|
|
2013-04-26 07:24:42 +04:00
|
|
|
static void handle_event(int event)
|
|
|
|
{
|
|
|
|
static bool logged;
|
|
|
|
|
2024-05-27 09:27:49 +03:00
|
|
|
if (event & ~PVPANIC_EVENTS && !logged) {
|
2013-04-26 07:24:42 +04:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", event);
|
|
|
|
logged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event & PVPANIC_PANICKED) {
|
2017-02-14 09:25:23 +03:00
|
|
|
qemu_system_guest_panicked(NULL);
|
2013-04-26 07:24:42 +04:00
|
|
|
return;
|
|
|
|
}
|
2020-01-14 05:31:02 +03:00
|
|
|
|
2022-02-21 15:27:17 +03:00
|
|
|
if (event & PVPANIC_CRASH_LOADED) {
|
2020-01-14 05:31:02 +03:00
|
|
|
qemu_system_guest_crashloaded(NULL);
|
|
|
|
return;
|
|
|
|
}
|
2024-05-27 09:27:51 +03:00
|
|
|
|
|
|
|
if (event & PVPANIC_SHUTDOWN) {
|
|
|
|
qemu_system_guest_pvshutdown();
|
|
|
|
return;
|
|
|
|
}
|
2013-04-26 07:24:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return supported events on read */
|
2021-01-27 17:59:27 +03:00
|
|
|
static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size)
|
2013-04-26 07:24:42 +04:00
|
|
|
{
|
2020-11-09 16:53:04 +03:00
|
|
|
PVPanicState *pvp = opaque;
|
|
|
|
return pvp->events;
|
2013-04-26 07:24:42 +04:00
|
|
|
}
|
|
|
|
|
2021-01-27 17:59:27 +03:00
|
|
|
static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val,
|
2013-04-26 07:24:42 +04:00
|
|
|
unsigned size)
|
|
|
|
{
|
|
|
|
handle_event(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps pvpanic_ops = {
|
2021-01-27 17:59:27 +03:00
|
|
|
.read = pvpanic_read,
|
|
|
|
.write = pvpanic_write,
|
2013-04-26 07:24:42 +04:00
|
|
|
.impl = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-27 17:59:27 +03:00
|
|
|
void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size)
|
2013-04-26 07:24:42 +04:00
|
|
|
{
|
2021-01-27 17:59:27 +03:00
|
|
|
memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size);
|
2013-04-26 07:24:42 +04:00
|
|
|
}
|