Home | History | Annotate | Download | only in XenHypercallLib
      1 /** @file
      2   Functions to make Xen hypercalls.
      3 
      4   Copyright (C) 2014, Citrix Ltd.
      5 
      6   This program and the accompanying materials
      7   are licensed and made available under the terms and conditions of the BSD License
      8   which accompanies this distribution.  The full text of the license may be found at
      9   http://opensource.org/licenses/bsd-license.php
     10 
     11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 
     14 **/
     15 
     16 #include <PiDxe.h>
     17 
     18 #include <IndustryStandard/Xen/hvm/params.h>
     19 #include <IndustryStandard/Xen/memory.h>
     20 
     21 #include <Library/DebugLib.h>
     22 #include <Library/XenHypercallLib.h>
     23 
     24 UINT64
     25 EFIAPI
     26 XenHypercallHvmGetParam (
     27   IN UINT32        Index
     28   )
     29 {
     30   xen_hvm_param_t     Parameter;
     31   INTN                Error;
     32 
     33   Parameter.domid = DOMID_SELF;
     34   Parameter.index = Index;
     35   Error = XenHypercall2 (__HYPERVISOR_hvm_op,
     36                          HVMOP_get_param, (INTN) &Parameter);
     37   if (Error != 0) {
     38     DEBUG ((EFI_D_ERROR,
     39             "XenHypercall: Error %Ld trying to get HVM parameter %d\n",
     40             (INT64)Error, Index));
     41     return 0;
     42   }
     43   return Parameter.value;
     44 }
     45 
     46 INTN
     47 EFIAPI
     48 XenHypercallMemoryOp (
     49   IN     UINTN Operation,
     50   IN OUT VOID *Arguments
     51   )
     52 {
     53   return XenHypercall2 (__HYPERVISOR_memory_op,
     54                         Operation, (INTN) Arguments);
     55 }
     56 
     57 INTN
     58 EFIAPI
     59 XenHypercallEventChannelOp (
     60   IN     INTN Operation,
     61   IN OUT VOID *Arguments
     62   )
     63 {
     64   return XenHypercall2 (__HYPERVISOR_event_channel_op,
     65                         Operation, (INTN) Arguments);
     66 }
     67