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