Kevin O'Connor | e7cc764 | 2009-10-04 10:05:16 -0400 | [diff] [blame] | 1 | #ifndef __PV_H |
| 2 | #define __PV_H |
| 3 | |
Kevin O'Connor | 02313b2 | 2013-02-07 22:42:25 -0500 | [diff] [blame] | 4 | #include "config.h" // CONFIG_* |
Kevin O'Connor | 02313b2 | 2013-02-07 22:42:25 -0500 | [diff] [blame] | 5 | #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'Connor | 7b5bc50 | 2013-02-09 13:07:23 -0500 | [diff] [blame] | 10 | #define PF_KVM (1<<2) |
Kevin O'Connor | 02313b2 | 2013-02-07 22:42:25 -0500 | [diff] [blame] | 11 | |
Marc Marí | 06316c9 | 2015-10-08 17:03:26 +0200 | [diff] [blame] | 12 | typedef struct QemuCfgDmaAccess { |
| 13 | u32 control; |
| 14 | u32 length; |
| 15 | u64 address; |
| 16 | } PACKED QemuCfgDmaAccess; |
| 17 | |
Kevin O'Connor | f85e4bc | 2013-02-19 01:33:45 -0500 | [diff] [blame] | 18 | extern u32 RamSize; |
| 19 | extern u64 RamSizeOver4G; |
Kevin O'Connor | 02313b2 | 2013-02-07 22:42:25 -0500 | [diff] [blame] | 20 | extern int PlatformRunningOn; |
| 21 | |
| 22 | static inline int runningOnQEMU(void) { |
| 23 | return CONFIG_QEMU || ( |
| 24 | CONFIG_QEMU_HARDWARE && GET_GLOBAL(PlatformRunningOn) & PF_QEMU); |
| 25 | } |
| 26 | static inline int runningOnXen(void) { |
| 27 | return CONFIG_XEN && GET_GLOBAL(PlatformRunningOn) & PF_XEN; |
| 28 | } |
Kevin O'Connor | 7b5bc50 | 2013-02-09 13:07:23 -0500 | [diff] [blame] | 29 | static inline int runningOnKVM(void) { |
| 30 | return CONFIG_QEMU && GET_GLOBAL(PlatformRunningOn) & PF_KVM; |
Kevin O'Connor | e7cc764 | 2009-10-04 10:05:16 -0400 | [diff] [blame] | 31 | } |
| 32 | |
Kevin O'Connor | 4ade523 | 2013-09-18 21:41:48 -0400 | [diff] [blame] | 33 | // Common paravirt ports. |
Marc Marí | 06316c9 | 2015-10-08 17:03:26 +0200 | [diff] [blame] | 34 | #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'Connor | 4ade523 | 2013-09-18 21:41:48 -0400 | [diff] [blame] | 40 | |
Marc Marí | 06316c9 | 2015-10-08 17:03:26 +0200 | [diff] [blame] | 41 | // 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 | |
| 50 | int qemu_cfg_dma_enabled(void); |
Kevin O'Connor | a2a86e2 | 2013-02-13 19:35:12 -0500 | [diff] [blame] | 51 | void qemu_preinit(void); |
| 52 | void qemu_platform_setup(void); |
Kevin O'Connor | b840ba9 | 2013-02-09 20:09:22 -0500 | [diff] [blame] | 53 | void qemu_cfg_init(void); |
Gerd Hoffmann | c4c9fae | 2009-12-18 12:16:04 +0100 | [diff] [blame] | 54 | |
Igor Mammedov | 023b1d0 | 2016-10-13 14:38:27 +0200 | [diff] [blame] | 55 | u16 qemu_init_present_cpus_count(void); |
| 56 | u16 qemu_get_present_cpus_count(void); |
| 57 | |
Kevin O'Connor | e7cc764 | 2009-10-04 10:05:16 -0400 | [diff] [blame] | 58 | #endif |