blob: a14d83e101a3df89480302c1c96935fc35717a1f [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
Ben Warrenf9918222017-02-20 19:56:15 -08006#include "romfile.h" // struct romfile_s
Kevin O'Connor02313b22013-02-07 22:42:25 -05007
8// Types of paravirtualized platforms.
9#define PF_QEMU (1<<0)
10#define PF_XEN (1<<1)
Kevin O'Connor7b5bc502013-02-09 13:07:23 -050011#define PF_KVM (1<<2)
Kevin O'Connor02313b22013-02-07 22:42:25 -050012
Marc Marí06316c92015-10-08 17:03:26 +020013typedef struct QemuCfgDmaAccess {
14 u32 control;
15 u32 length;
16 u64 address;
17} PACKED QemuCfgDmaAccess;
18
Kevin O'Connorf85e4bc2013-02-19 01:33:45 -050019extern u32 RamSize;
20extern u64 RamSizeOver4G;
Kevin O'Connor02313b22013-02-07 22:42:25 -050021extern int PlatformRunningOn;
22
23static inline int runningOnQEMU(void) {
24 return CONFIG_QEMU || (
25 CONFIG_QEMU_HARDWARE && GET_GLOBAL(PlatformRunningOn) & PF_QEMU);
26}
27static inline int runningOnXen(void) {
28 return CONFIG_XEN && GET_GLOBAL(PlatformRunningOn) & PF_XEN;
29}
Kevin O'Connor7b5bc502013-02-09 13:07:23 -050030static inline int runningOnKVM(void) {
31 return CONFIG_QEMU && GET_GLOBAL(PlatformRunningOn) & PF_KVM;
Kevin O'Connore7cc7642009-10-04 10:05:16 -040032}
33
Kevin O'Connor4ade5232013-09-18 21:41:48 -040034// Common paravirt ports.
Marc Marí06316c92015-10-08 17:03:26 +020035#define PORT_SMI_CMD 0x00b2
36#define PORT_SMI_STATUS 0x00b3
37#define PORT_QEMU_CFG_CTL 0x0510
38#define PORT_QEMU_CFG_DATA 0x0511
39#define PORT_QEMU_CFG_DMA_ADDR_HIGH 0x0514
40#define PORT_QEMU_CFG_DMA_ADDR_LOW 0x0518
Kevin O'Connor4ade5232013-09-18 21:41:48 -040041
Marc Marí06316c92015-10-08 17:03:26 +020042// QEMU_CFG_DMA_CONTROL bits
43#define QEMU_CFG_DMA_CTL_ERROR 0x01
44#define QEMU_CFG_DMA_CTL_READ 0x02
45#define QEMU_CFG_DMA_CTL_SKIP 0x04
46#define QEMU_CFG_DMA_CTL_SELECT 0x08
Ben Warrenf9918222017-02-20 19:56:15 -080047#define QEMU_CFG_DMA_CTL_WRITE 0x10
Marc Marí06316c92015-10-08 17:03:26 +020048
49// QEMU_CFG_DMA ID bit
50#define QEMU_CFG_VERSION_DMA 2
51
Petr Berky5fbf2462017-03-28 23:03:53 +020052int qemu_cfg_enabled(void);
Marc Marí06316c92015-10-08 17:03:26 +020053int qemu_cfg_dma_enabled(void);
Kevin O'Connora2a86e22013-02-13 19:35:12 -050054void qemu_preinit(void);
55void qemu_platform_setup(void);
Kevin O'Connorb840ba92013-02-09 20:09:22 -050056void qemu_cfg_init(void);
Gerd Hoffmannc4c9fae2009-12-18 12:16:04 +010057
Igor Mammedov023b1d02016-10-13 14:38:27 +020058u16 qemu_get_present_cpus_count(void);
Ben Warrenf9918222017-02-20 19:56:15 -080059int qemu_cfg_write_file(void *src, struct romfile_s *file, u32 offset, u32 len);
Ben Warren336b60b2017-02-20 19:56:18 -080060int qemu_cfg_write_file_simple(void *src, u16 key, u32 offset, u32 len);
61u16 qemu_get_romfile_key(struct romfile_s *file);
Igor Mammedov023b1d02016-10-13 14:38:27 +020062
Kevin O'Connore7cc7642009-10-04 10:05:16 -040063#endif