iPXE
hvm.h
Go to the documentation of this file.
1 #ifndef _HVM_H
2 #define _HVM_H
3 
4 /** @file
5  *
6  * Xen HVM driver
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <ipxe/xen.h>
14 #include <xen/hvm/hvm_op.h>
15 #include <xen/hvm/params.h>
16 
17 /** Minimum CPUID base */
18 #define HVM_CPUID_MIN 0x40000000UL
19 
20 /** Maximum CPUID base */
21 #define HVM_CPUID_MAX 0x4000ff00UL
22 
23 /** Increment between CPUID bases */
24 #define HVM_CPUID_STEP 0x00000100UL
25 
26 /** Magic signature */
27 #define HVM_CPUID_MAGIC "XenVMMXenVMM"
28 
29 /** Get Xen version */
30 #define HVM_CPUID_VERSION 1
31 
32 /** Get number of hypercall pages */
33 #define HVM_CPUID_PAGES 2
34 
35 /** PCI MMIO BAR */
36 #define HVM_MMIO_BAR PCI_BASE_ADDRESS_1
37 
38 /** A Xen HVM device */
39 struct hvm_device {
40  /** Xen hypervisor */
42  /** PCI device */
43  struct pci_device *pci;
44  /** CPUID base */
46  /** Length of hypercall table */
47  size_t hypercall_len;
48  /** MMIO base address */
49  unsigned long mmio;
50  /** Current offset within MMIO address space */
51  size_t mmio_offset;
52  /** Length of MMIO address space */
53  size_t mmio_len;
54 };
55 
56 /**
57  * Get HVM parameter value
58  *
59  * @v xen Xen hypervisor
60  * @v index Parameter index
61  * @v value Value to fill in
62  * @ret xenrc Xen status code
63  */
64 static inline int xen_hvm_get_param ( struct xen_hypervisor *xen,
65  unsigned int index, uint64_t *value ) {
66  struct xen_hvm_param param;
67  int xenrc;
68 
69  param.domid = DOMID_SELF;
70  param.index = index;
71  xenrc = xen_hypercall_2 ( xen, __HYPERVISOR_hvm_op, HVMOP_get_param,
72  virt_to_phys ( &param ) );
73  *value = param.value;
74  return xenrc;
75 }
76 
77 #endif /* _HVM_H */
size_t mmio_offset
Current offset within MMIO address space.
Definition: hvm.h:51
static int xen_hvm_get_param(struct xen_hypervisor *xen, unsigned int index, uint64_t *value)
Get HVM parameter value.
Definition: hvm.h:64
struct xen_hypervisor xen
Xen hypervisor.
Definition: hvm.h:41
unsigned long long uint64_t
Definition: stdint.h:13
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A Xen hypervisor.
Definition: xen.h:51
Xen interface.
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
size_t hypercall_len
Length of hypercall table.
Definition: hvm.h:47
unsigned long mmio
MMIO base address.
Definition: hvm.h:49
A PCI device.
Definition: pci.h:206
struct hv_monitor_parameter param[4][32]
Parameters.
Definition: hyperv.h:24
#define HVMOP_get_param
Definition: hvm_op.h:17
A Xen HVM device.
Definition: hvm.h:39
unsigned int uint32_t
Definition: stdint.h:12
size_t mmio_len
Length of MMIO address space.
Definition: hvm.h:53
#define DOMID_SELF
Definition: xen.h:567
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define __HYPERVISOR_hvm_op
Definition: xen.h:110
struct pci_device * pci
PCI device.
Definition: hvm.h:43
uint32_t cpuid_base
CPUID base.
Definition: hvm.h:45