iPXE
hyperv.h
Go to the documentation of this file.
00001 #ifndef _BITS_HYPERV_H
00002 #define _BITS_HYPERV_H
00003 
00004 /** @file
00005  *
00006  * Hyper-V interface
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stddef.h>
00013 #include <stdint.h>
00014 #include <ipxe/io.h>
00015 
00016 /**
00017  * Issue hypercall
00018  *
00019  * @v hv                Hyper-V hypervisor
00020  * @v code              Call code
00021  * @v in                Input parameters
00022  * @v out               Output parameters
00023  * @ret status          Status code
00024  */
00025 static inline __attribute__ (( always_inline )) int
00026 hv_call ( struct hv_hypervisor *hv, unsigned int code, const void *in,
00027           void *out ) {
00028         void *hypercall = hv->hypercall;
00029         uint32_t in_phys;
00030         uint32_t out_phys;
00031         uint32_t discard_ecx;
00032         uint32_t discard_edx;
00033         uint16_t result;
00034 
00035         in_phys = ( ( __builtin_constant_p ( in ) && ( in == NULL ) )
00036                        ? 0 : virt_to_phys ( in ) );
00037         out_phys = ( ( __builtin_constant_p ( out ) && ( out == NULL ) )
00038                        ? 0 : virt_to_phys ( out ) );
00039         __asm__ __volatile__ ( "call *%9"
00040                                : "=a" ( result ), "=c" ( discard_ecx ),
00041                                  "=d" ( discard_edx )
00042                                : "d" ( 0 ), "a" ( code ),
00043                                  "b" ( 0 ), "c" ( in_phys ),
00044                                  "D" ( 0 ), "S" ( out_phys ),
00045                                  "m" ( hypercall ) );
00046         return result;
00047 }
00048 
00049 #endif /* _BITS_HYPERV_H */