iPXE
hvm.h
Go to the documentation of this file.
00001 #ifndef _HVM_H
00002 #define _HVM_H
00003 
00004 /** @file
00005  *
00006  * Xen HVM driver
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/xen.h>
00014 #include <xen/hvm/hvm_op.h>
00015 #include <xen/hvm/params.h>
00016 
00017 /** Minimum CPUID base */
00018 #define HVM_CPUID_MIN 0x40000000UL
00019 
00020 /** Maximum CPUID base */
00021 #define HVM_CPUID_MAX 0x4000ff00UL
00022 
00023 /** Increment between CPUID bases */
00024 #define HVM_CPUID_STEP 0x00000100UL
00025 
00026 /** Magic signature */
00027 #define HVM_CPUID_MAGIC "XenVMMXenVMM"
00028 
00029 /** Get Xen version */
00030 #define HVM_CPUID_VERSION 1
00031 
00032 /** Get number of hypercall pages */
00033 #define HVM_CPUID_PAGES 2
00034 
00035 /** PCI MMIO BAR */
00036 #define HVM_MMIO_BAR PCI_BASE_ADDRESS_1
00037 
00038 /** A Xen HVM device */
00039 struct hvm_device {
00040         /** Xen hypervisor */
00041         struct xen_hypervisor xen;
00042         /** CPUID base */
00043         uint32_t cpuid_base;
00044         /** Length of hypercall table */
00045         size_t hypercall_len;
00046         /** MMIO base address */
00047         unsigned long mmio;
00048         /** Current offset within MMIO address space */
00049         size_t mmio_offset;
00050         /** Length of MMIO address space */
00051         size_t mmio_len;
00052 };
00053 
00054 /**
00055  * Get HVM parameter value
00056  *
00057  * @v xen               Xen hypervisor
00058  * @v index             Parameter index
00059  * @v value             Value to fill in
00060  * @ret xenrc           Xen status code
00061  */
00062 static inline int xen_hvm_get_param ( struct xen_hypervisor *xen,
00063                                       unsigned int index, uint64_t *value ) {
00064         struct xen_hvm_param param;
00065         int xenrc;
00066 
00067         param.domid = DOMID_SELF;
00068         param.index = index;
00069         xenrc = xen_hypercall_2 ( xen, __HYPERVISOR_hvm_op, HVMOP_get_param,
00070                                   virt_to_phys ( &param ) );
00071         *value = param.value;
00072         return xenrc;
00073 }
00074 
00075 #endif /* _HVM_H */