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 XenHypercallHvmGetParam (
     26   IN UINT32        Index
     27   )
     28 {
     29   xen_hvm_param_t     Parameter;
     30   INTN                Error;
     31 
     32   Parameter.domid = DOMID_SELF;
     33   Parameter.index = Index;
     34   Error = XenHypercall2 (__HYPERVISOR_hvm_op,
     35                          HVMOP_get_param, (INTN) &Parameter);
     36   if (Error != 0) {
     37     DEBUG ((EFI_D_ERROR,
     38             "XenHypercall: Error %Ld trying to get HVM parameter %d\n",
     39             (INT64)Error, Index));
     40     return 0;
     41   }
     42   return Parameter.value;
     43 }
     44 
     45 INTN
     46 XenHypercallMemoryOp (
     47   IN     UINTN Operation,
     48   IN OUT VOID *Arguments
     49   )
     50 {
     51   return XenHypercall2 (__HYPERVISOR_memory_op,
     52                         Operation, (INTN) Arguments);
     53 }
     54 
     55 INTN
     56 XenHypercallEventChannelOp (
     57   IN     INTN Operation,
     58   IN OUT VOID *Arguments
     59   )
     60 {
     61   return XenHypercall2 (__HYPERVISOR_event_channel_op,
     62                         Operation, (INTN) Arguments);
     63 }
     64