Home | History | Annotate | Download | only in XenBusDxe
      1 /** @file
      2   Function declaration and internal data for XenBusDxe.
      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 #ifndef __EFI_XENBUS_DXE_H__
     17 #define __EFI_XENBUS_DXE_H__
     18 
     19 #include <Uefi.h>
     20 
     21 //
     22 // Libraries
     23 //
     24 #include <Library/UefiBootServicesTableLib.h>
     25 #include <Library/MemoryAllocationLib.h>
     26 #include <Library/BaseMemoryLib.h>
     27 #include <Library/BaseLib.h>
     28 #include <Library/UefiLib.h>
     29 #include <Library/DevicePathLib.h>
     30 #include <Library/DebugLib.h>
     31 
     32 
     33 //
     34 // UEFI Driver Model Protocols
     35 //
     36 #include <Protocol/DriverBinding.h>
     37 
     38 
     39 //
     40 // Consumed Protocols
     41 //
     42 #include <Protocol/XenIo.h>
     43 
     44 
     45 //
     46 // Produced Protocols
     47 //
     48 #include <Protocol/XenBus.h>
     49 
     50 
     51 //
     52 // Driver Version
     53 //
     54 #define XENBUS_DXE_VERSION  0x00000010
     55 
     56 
     57 //
     58 // Protocol instances
     59 //
     60 extern EFI_DRIVER_BINDING_PROTOCOL  gXenBusDxeDriverBinding;
     61 extern EFI_COMPONENT_NAME2_PROTOCOL  gXenBusDxeComponentName2;
     62 extern EFI_COMPONENT_NAME_PROTOCOL  gXenBusDxeComponentName;
     63 
     64 
     65 //
     66 // Include files with function prototypes
     67 //
     68 #include "DriverBinding.h"
     69 #include "ComponentName.h"
     70 
     71 //
     72 // Other stuff
     73 //
     74 #include <IndustryStandard/Xen/xen.h>
     75 
     76 typedef struct _XENBUS_DEVICE_PATH XENBUS_DEVICE_PATH;
     77 typedef struct _XENBUS_DEVICE XENBUS_DEVICE;
     78 
     79 // Have the state of the driver.
     80 #define XENBUS_DEVICE_SIGNATURE SIGNATURE_32 ('X','B','s','t')
     81 struct _XENBUS_DEVICE {
     82   UINT32                        Signature;
     83   EFI_DRIVER_BINDING_PROTOCOL   *This;
     84   EFI_HANDLE                    ControllerHandle;
     85   XENIO_PROTOCOL                *XenIo;
     86   EFI_EVENT                     ExitBootEvent;
     87   EFI_DEVICE_PATH_PROTOCOL      *DevicePath;
     88   LIST_ENTRY                    ChildList;
     89 
     90   shared_info_t                 *SharedInfo;
     91 };
     92 
     93 // There is one of this struct allocated for every child.
     94 #define XENBUS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('X', 'B', 'p', 'd')
     95 typedef struct {
     96     UINTN Signature;
     97     LIST_ENTRY Link;
     98     EFI_HANDLE Handle;
     99     XENBUS_PROTOCOL XenBusIo;
    100     XENBUS_DEVICE *Dev;
    101     XENBUS_DEVICE_PATH *DevicePath;
    102 } XENBUS_PRIVATE_DATA;
    103 
    104 #define XENBUS_PRIVATE_DATA_FROM_THIS(a) \
    105   CR (a, XENBUS_PRIVATE_DATA, XenBusIo, XENBUS_PRIVATE_DATA_SIGNATURE)
    106 #define XENBUS_PRIVATE_DATA_FROM_LINK(a) \
    107   CR (a, XENBUS_PRIVATE_DATA, Link, XENBUS_PRIVATE_DATA_SIGNATURE)
    108 
    109 /*
    110  * Helpers
    111  */
    112 
    113 /**
    114   Atomically test and clear a bit.
    115 
    116   @param Bit      Bit index to test in *Address
    117   @param Address  The Address to the buffer that contain the bit to test.
    118 
    119   @return Value of the Bit before it was cleared.
    120 **/
    121 INT32
    122 EFIAPI
    123 TestAndClearBit (
    124   IN INT32 Bit,
    125   IN VOID  *Address
    126   );
    127 
    128 CHAR8*
    129 AsciiStrDup (
    130   IN CONST CHAR8* Str
    131   );
    132 
    133 #endif
    134