blob: 7d4bc026acb72172a62681d4681a18617bd5ad02 [file] [log] [blame]
Kevin O'Connore7cc7642009-10-04 10:05:16 -04001#ifndef __PV_H
2#define __PV_H
3
4#include "util.h"
5
6/* This CPUID returns the signature 'KVMKVMKVM' in ebx, ecx, and edx. It
7 * should be used to determine that a VM is running under KVM.
8 */
9#define KVM_CPUID_SIGNATURE 0x40000000
10
11static inline int kvm_para_available(void)
12{
13 unsigned int eax, ebx, ecx, edx;
14 char signature[13];
15
16 cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
17 memcpy(signature + 0, &ebx, 4);
18 memcpy(signature + 4, &ecx, 4);
19 memcpy(signature + 8, &edx, 4);
20 signature[12] = 0;
21
22 if (strcmp(signature, "KVMKVMKVM") == 0)
23 return 1;
24
25 return 0;
26}
27
28#define QEMU_CFG_SIGNATURE 0x00
29#define QEMU_CFG_ID 0x01
30#define QEMU_CFG_UUID 0x02
31#define QEMU_CFG_NUMA 0x0d
32#define QEMU_CFG_BOOT_MENU 0x0e
33#define QEMU_CFG_MAX_CPUS 0x0f
Gerd Hoffmannc4c9fae2009-12-18 12:16:04 +010034#define QEMU_CFG_FILE_DIR 0x19
Kevin O'Connore7cc7642009-10-04 10:05:16 -040035#define QEMU_CFG_ARCH_LOCAL 0x8000
36#define QEMU_CFG_ACPI_TABLES (QEMU_CFG_ARCH_LOCAL + 0)
37#define QEMU_CFG_SMBIOS_ENTRIES (QEMU_CFG_ARCH_LOCAL + 1)
Kevin O'Connor812654a2009-10-12 12:02:33 -040038#define QEMU_CFG_IRQ0_OVERRIDE (QEMU_CFG_ARCH_LOCAL + 2)
Jes Sorensen0360e8e2010-02-16 09:46:08 +010039#define QEMU_CFG_E820_TABLE (QEMU_CFG_ARCH_LOCAL + 3)
Kevin O'Connore7cc7642009-10-04 10:05:16 -040040
41extern int qemu_cfg_present;
42
43void qemu_cfg_port_probe(void);
44int qemu_cfg_show_boot_menu(void);
45void qemu_cfg_get_uuid(u8 *uuid);
Kevin O'Connor4d2b6192009-10-08 21:37:21 -040046int qemu_cfg_irq0_override(void);
Kevin O'Connorcc6dc462009-10-08 21:18:41 -040047u16 qemu_cfg_acpi_additional_tables(void);
48u16 qemu_cfg_next_acpi_table_len(void);
49void *qemu_cfg_next_acpi_table_load(void *addr, u16 len);
Kevin O'Connor4e4b4102009-10-08 21:21:59 -040050u16 qemu_cfg_smbios_entries(void);
51size_t qemu_cfg_smbios_load_field(int type, size_t offset, void *addr);
52int qemu_cfg_smbios_load_external(int type, char **p, unsigned *nr_structs,
53 unsigned *max_struct_size, char *end);
Kevin O'Connor590e5542009-10-08 22:09:02 -040054int qemu_cfg_get_numa_nodes(void);
55void qemu_cfg_get_numa_data(u64 *data, int n);
Kevin O'Connor84705852009-10-08 22:13:15 -040056u16 qemu_cfg_get_max_cpus(void);
Kevin O'Connore7cc7642009-10-04 10:05:16 -040057
Gerd Hoffmannc4c9fae2009-12-18 12:16:04 +010058typedef struct QemuCfgFile {
59 u32 size; /* file size */
60 u16 select; /* write this to 0x510 to read it */
61 u16 reserved;
62 char name[56];
63} QemuCfgFile;
64
Jes Sorensen0360e8e2010-02-16 09:46:08 +010065struct e820_reservation {
66 u64 address;
67 u64 length;
68 u32 type;
69};
70
Kevin O'Connore2304262010-06-13 16:05:17 -040071u32 qemu_cfg_next_prefix_file(const char *prefix, u32 prevselect);
72u32 qemu_cfg_find_file(const char *name);
Kevin O'Connorf79a4622010-07-04 08:32:38 -040073int qemu_cfg_size_file(u32 select);
Kevin O'Connore2304262010-06-13 16:05:17 -040074int qemu_cfg_read_file(u32 select, void *dst, u32 maxlen);
75
76// Wrappers that select cbfs or qemu_cfg file interface.
77static inline u32 romfile_findprefix(const char *prefix, u32 previd) {
78 if (CONFIG_COREBOOT)
79 return (u32)cbfs_findprefix(prefix, (void*)previd);
80 return qemu_cfg_next_prefix_file(prefix, previd);
81}
82static inline u32 romfile_find(const char *name) {
83 if (CONFIG_COREBOOT)
84 return (u32)cbfs_finddatafile(name);
85 return qemu_cfg_find_file(name);
86}
Kevin O'Connorf79a4622010-07-04 08:32:38 -040087static inline u32 romfile_size(u32 fileid) {
88 if (CONFIG_COREBOOT)
89 return cbfs_datasize((void*)fileid);
90 return qemu_cfg_size_file(fileid);
91}
Kevin O'Connore2304262010-06-13 16:05:17 -040092static inline int romfile_copy(u32 fileid, void *dst, u32 maxlen) {
93 if (CONFIG_COREBOOT)
94 return cbfs_copyfile((void*)fileid, dst, maxlen);
95 return qemu_cfg_read_file(fileid, dst, maxlen);
96}
97
Jes Sorensen0360e8e2010-02-16 09:46:08 +010098u32 qemu_cfg_e820_entries(void);
99void* qemu_cfg_e820_load_next(void *addr);
Gerd Hoffmannc4c9fae2009-12-18 12:16:04 +0100100
Kevin O'Connore7cc7642009-10-04 10:05:16 -0400101#endif