blob: d8eb7c45bacf505a72f234b07a3c2a31f1281906 [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_*
Kevin O'Connor02313b22013-02-07 22:42:25 -05005#include "biosvar.h" // GET_GLOBAL
6
7// Types of paravirtualized platforms.
8#define PF_QEMU (1<<0)
9#define PF_XEN (1<<1)
Kevin O'Connor7b5bc502013-02-09 13:07:23 -050010#define PF_KVM (1<<2)
Kevin O'Connor02313b22013-02-07 22:42:25 -050011
Marc Marí06316c92015-10-08 17:03:26 +020012typedef struct QemuCfgDmaAccess {
13 u32 control;
14 u32 length;
15 u64 address;
16} PACKED QemuCfgDmaAccess;
17
Kevin O'Connorf85e4bc2013-02-19 01:33:45 -050018extern u32 RamSize;
19extern u64 RamSizeOver4G;
Kevin O'Connor02313b22013-02-07 22:42:25 -050020extern int PlatformRunningOn;
21
22static inline int runningOnQEMU(void) {
23 return CONFIG_QEMU || (
24 CONFIG_QEMU_HARDWARE && GET_GLOBAL(PlatformRunningOn) & PF_QEMU);
25}
26static inline int runningOnXen(void) {
27 return CONFIG_XEN && GET_GLOBAL(PlatformRunningOn) & PF_XEN;
28}
Kevin O'Connor7b5bc502013-02-09 13:07:23 -050029static inline int runningOnKVM(void) {
30 return CONFIG_QEMU && GET_GLOBAL(PlatformRunningOn) & PF_KVM;
Kevin O'Connore7cc7642009-10-04 10:05:16 -040031}
32
Kevin O'Connor4ade5232013-09-18 21:41:48 -040033// Common paravirt ports.
Marc Marí06316c92015-10-08 17:03:26 +020034#define PORT_SMI_CMD 0x00b2
35#define PORT_SMI_STATUS 0x00b3
36#define PORT_QEMU_CFG_CTL 0x0510
37#define PORT_QEMU_CFG_DATA 0x0511
38#define PORT_QEMU_CFG_DMA_ADDR_HIGH 0x0514
39#define PORT_QEMU_CFG_DMA_ADDR_LOW 0x0518
Kevin O'Connor4ade5232013-09-18 21:41:48 -040040
Marc Marí06316c92015-10-08 17:03:26 +020041// QEMU_CFG_DMA_CONTROL bits
42#define QEMU_CFG_DMA_CTL_ERROR 0x01
43#define QEMU_CFG_DMA_CTL_READ 0x02
44#define QEMU_CFG_DMA_CTL_SKIP 0x04
45#define QEMU_CFG_DMA_CTL_SELECT 0x08
46
47// QEMU_CFG_DMA ID bit
48#define QEMU_CFG_VERSION_DMA 2
49
50int qemu_cfg_dma_enabled(void);
Kevin O'Connora2a86e22013-02-13 19:35:12 -050051void qemu_preinit(void);
52void qemu_platform_setup(void);
Kevin O'Connorb840ba92013-02-09 20:09:22 -050053void qemu_cfg_init(void);
Gerd Hoffmannc4c9fae2009-12-18 12:16:04 +010054
Igor Mammedov023b1d02016-10-13 14:38:27 +020055u16 qemu_get_present_cpus_count(void);
56
Kevin O'Connore7cc7642009-10-04 10:05:16 -040057#endif