xref: /openbmc/qemu/include/hw/misc/vmcoreinfo.h (revision c39f95dc)
1 /*
2  * Virtual Machine coreinfo device
3  *
4  * Copyright (C) 2017 Red Hat, Inc.
5  *
6  * Authors: Marc-André Lureau <marcandre.lureau@redhat.com>
7  *
8  * This work is licensed under the terms of the GNU GPL, version 2 or later.
9  * See the COPYING file in the top-level directory.
10  *
11  */
12 #ifndef VMCOREINFO_H
13 #define VMCOREINFO_H
14 
15 #include "hw/qdev.h"
16 
17 #define VMCOREINFO_DEVICE "vmcoreinfo"
18 #define VMCOREINFO(obj) OBJECT_CHECK(VMCoreInfoState, (obj), VMCOREINFO_DEVICE)
19 
20 #define VMCOREINFO_FORMAT_NONE 0x0
21 #define VMCOREINFO_FORMAT_ELF 0x1
22 
23 /* all fields are little-endian */
24 typedef struct FWCfgVMCoreInfo {
25     uint16_t host_format; /* set on reset */
26     uint16_t guest_format;
27     uint32_t size;
28     uint64_t paddr;
29 } QEMU_PACKED FWCfgVMCoreInfo;
30 
31 typedef struct VMCoreInfoState {
32     DeviceClass parent_obj;
33 
34     bool has_vmcoreinfo;
35     FWCfgVMCoreInfo vmcoreinfo;
36 } VMCoreInfoState;
37 
38 /* returns NULL unless there is exactly one device */
39 static inline VMCoreInfoState *vmcoreinfo_find(void)
40 {
41     Object *o = object_resolve_path_type("", VMCOREINFO_DEVICE, NULL);
42 
43     return o ? VMCOREINFO(o) : NULL;
44 }
45 
46 #endif
47