blob: d32ca13d9c7529c1e9ac902c497e82fa827ec2cc [file] [log] [blame]
Kevin O'Connore7cc7642009-10-04 10:05:16 -04001#ifndef __PV_H
2#define __PV_H
3
Kevin O'Connor02313b22013-02-07 22:42:25 -05004#include "config.h" // CONFIG_*
5#include "util.h" // memcpy
6#include "biosvar.h" // GET_GLOBAL
7
8// Types of paravirtualized platforms.
9#define PF_QEMU (1<<0)
10#define PF_XEN (1<<1)
11
12// misc.c
13extern int PlatformRunningOn;
14
15static inline int runningOnQEMU(void) {
16 return CONFIG_QEMU || (
17 CONFIG_QEMU_HARDWARE && GET_GLOBAL(PlatformRunningOn) & PF_QEMU);
18}
19static inline int runningOnXen(void) {
20 return CONFIG_XEN && GET_GLOBAL(PlatformRunningOn) & PF_XEN;
21}
Kevin O'Connore7cc7642009-10-04 10:05:16 -040022
23/* This CPUID returns the signature 'KVMKVMKVM' in ebx, ecx, and edx. It
24 * should be used to determine that a VM is running under KVM.
25 */
26#define KVM_CPUID_SIGNATURE 0x40000000
27
28static inline int kvm_para_available(void)
29{
Kevin O'Connor9eb21002012-01-29 13:30:56 -050030 if (CONFIG_COREBOOT)
31 return 0;
Kevin O'Connore7cc7642009-10-04 10:05:16 -040032 unsigned int eax, ebx, ecx, edx;
33 char signature[13];
34
35 cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
36 memcpy(signature + 0, &ebx, 4);
37 memcpy(signature + 4, &ecx, 4);
38 memcpy(signature + 8, &edx, 4);
39 signature[12] = 0;
40
41 if (strcmp(signature, "KVMKVMKVM") == 0)
42 return 1;
43
44 return 0;
45}
46
Kevin O'Connor7a08ae72012-03-14 21:11:39 -040047#define QEMU_CFG_SIGNATURE 0x00
48#define QEMU_CFG_ID 0x01
49#define QEMU_CFG_UUID 0x02
50#define QEMU_CFG_NUMA 0x0d
51#define QEMU_CFG_BOOT_MENU 0x0e
52#define QEMU_CFG_MAX_CPUS 0x0f
Gerd Hoffmannc4c9fae2009-12-18 12:16:04 +010053#define QEMU_CFG_FILE_DIR 0x19
Kevin O'Connor7a08ae72012-03-14 21:11:39 -040054#define QEMU_CFG_ARCH_LOCAL 0x8000
55#define QEMU_CFG_ACPI_TABLES (QEMU_CFG_ARCH_LOCAL + 0)
56#define QEMU_CFG_SMBIOS_ENTRIES (QEMU_CFG_ARCH_LOCAL + 1)
57#define QEMU_CFG_IRQ0_OVERRIDE (QEMU_CFG_ARCH_LOCAL + 2)
58#define QEMU_CFG_E820_TABLE (QEMU_CFG_ARCH_LOCAL + 3)
Kevin O'Connore7cc7642009-10-04 10:05:16 -040059
60extern int qemu_cfg_present;
61
Kevin O'Connor8ed2e532013-01-21 02:32:48 -050062void qemu_ramsize_preinit(void);
63void qemu_biostable_setup(void);
Kevin O'Connord83c87b2013-01-21 01:14:12 -050064void qemu_cfg_preinit(void);
Kevin O'Connore7cc7642009-10-04 10:05:16 -040065int qemu_cfg_show_boot_menu(void);
66void qemu_cfg_get_uuid(u8 *uuid);
Kevin O'Connor4d2b6192009-10-08 21:37:21 -040067int qemu_cfg_irq0_override(void);
Kevin O'Connorcc6dc462009-10-08 21:18:41 -040068u16 qemu_cfg_acpi_additional_tables(void);
69u16 qemu_cfg_next_acpi_table_len(void);
70void *qemu_cfg_next_acpi_table_load(void *addr, u16 len);
Kevin O'Connor4e4b4102009-10-08 21:21:59 -040071u16 qemu_cfg_smbios_entries(void);
72size_t qemu_cfg_smbios_load_field(int type, size_t offset, void *addr);
73int qemu_cfg_smbios_load_external(int type, char **p, unsigned *nr_structs,
74 unsigned *max_struct_size, char *end);
Kevin O'Connor590e5542009-10-08 22:09:02 -040075int qemu_cfg_get_numa_nodes(void);
76void qemu_cfg_get_numa_data(u64 *data, int n);
Kevin O'Connor84705852009-10-08 22:13:15 -040077u16 qemu_cfg_get_max_cpus(void);
Jes Sorensen0360e8e2010-02-16 09:46:08 +010078struct e820_reservation {
79 u64 address;
80 u64 length;
81 u32 type;
82};
Jes Sorensen0360e8e2010-02-16 09:46:08 +010083u32 qemu_cfg_e820_entries(void);
84void* qemu_cfg_e820_load_next(void *addr);
Kevin O'Connord83c87b2013-01-21 01:14:12 -050085void qemu_romfile_init(void);
Gerd Hoffmannc4c9fae2009-12-18 12:16:04 +010086
Kevin O'Connore7cc7642009-10-04 10:05:16 -040087#endif