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