Read max number of cpus from VM.
[seabios.git] / src / paravirt.h
1 #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
11 static 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
34 #define QEMU_CFG_ARCH_LOCAL             0x8000
35 #define QEMU_CFG_ACPI_TABLES            (QEMU_CFG_ARCH_LOCAL + 0)
36 #define QEMU_CFG_SMBIOS_ENTRIES         (QEMU_CFG_ARCH_LOCAL + 1)
37 #define QEMU_CFG_IRQ0_OVERRIDE          (QEMU_CFG_ARCH_LOCAL + 1)
38
39 extern int qemu_cfg_present;
40
41 void qemu_cfg_port_probe(void);
42 int qemu_cfg_show_boot_menu(void);
43 void qemu_cfg_get_uuid(u8 *uuid);
44 int qemu_cfg_irq0_override(void);
45 u16 qemu_cfg_acpi_additional_tables(void);
46 u16 qemu_cfg_next_acpi_table_len(void);
47 void *qemu_cfg_next_acpi_table_load(void *addr, u16 len);
48 u16 qemu_cfg_smbios_entries(void);
49 size_t qemu_cfg_smbios_load_field(int type, size_t offset, void *addr);
50 int qemu_cfg_smbios_load_external(int type, char **p, unsigned *nr_structs,
51                                   unsigned *max_struct_size, char *end);
52 int qemu_cfg_get_numa_nodes(void);
53 void qemu_cfg_get_numa_data(u64 *data, int n);
54 u16 qemu_cfg_get_max_cpus(void);
55
56 #endif