27#include <IndustryStandard/Xen/io/xenbus.h>
76 Child = XENBUS_PRIVATE_DATA_FROM_LINK (Entry);
88XenBusReadDriverState (
94 XENSTORE_STATUS Status;
97 if (Status != XENSTORE_STATUS_SUCCESS) {
98 State = XenbusStateClosed;
121 CHAR8 DevicePath[XENSTORE_ABS_PATH_MAX];
122 XENSTORE_STATUS StatusXenStore;
138 enum xenbus_state State;
150 State = XenBusReadDriverState (DevicePath);
151 if (State != XenbusStateInitialising) {
159 "XenBus: Device %a ignored. "
173 (VOID **)&BackendPath
175 if (StatusXenStore != XENSTORE_STATUS_SUCCESS) {
176 DEBUG ((DEBUG_ERROR,
"xenbus: %a no backend path.\n", DevicePath));
177 Status = EFI_NOT_FOUND;
182 Private->XenBusIo.Type = AsciiStrDup (Type);
183 Private->XenBusIo.Node = AsciiStrDup (DevicePath);
184 Private->XenBusIo.Backend = BackendPath;
190 &gXenBusDevicePathTemplate
192 if (!
AsciiStrCmp (Private->XenBusIo.Type,
"vbd")) {
193 TempXenBusPath->Type = XENBUS_DEVICE_PATH_TYPE_VBD;
196 TempXenBusPath->DeviceId = Private->XenBusIo.DeviceId;
199 &TempXenBusPath->Vendor.Header
205 Status =
gBS->InstallMultipleProtocolInterfaces (
207 &gEfiDevicePathProtocolGuid,
209 &gXenBusProtocolGuid,
213 if (EFI_ERROR (Status)) {
214 goto ErrorInstallProtocol;
217 Status =
gBS->OpenProtocol (
218 Dev->ControllerHandle,
223 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
225 if (EFI_ERROR (Status)) {
228 "open by child controller fail (%r)\n",
231 goto ErrorOpenProtocolByChild;
234 DEBUG ((DEBUG_ERROR,
"XenBus: does not exist: %a\n", DevicePath));
235 Status = EFI_NOT_FOUND;
240ErrorOpenProtocolByChild:
241 gBS->UninstallMultipleProtocolInterfaces (
243 &gEfiDevicePathProtocolGuid,
245 &gXenBusProtocolGuid,
252 FreePool ((VOID *)Private->XenBusIo.Backend);
253 FreePool ((VOID *)Private->XenBusIo.Node);
254 FreePool ((VOID *)Private->XenBusIo.Type);
278 CONST CHAR8 **Directory;
281 XENSTORE_STATUS Status;
290 if (Status != XENSTORE_STATUS_SUCCESS) {
294 for (Index = 0; Index < Count; Index++) {
295 XenBusAddDevice (Dev, Type, Directory[Index]);
320 XENSTORE_STATUS Status;
329 if (Status != XENSTORE_STATUS_SUCCESS) {
333 for (Index = 0; Index < Count; Index++) {
339 return XENSTORE_STATUS_SUCCESS;
348 IN enum xenbus_state NewState
351 enum xenbus_state CurrentState;
352 XENSTORE_STATUS Status;
355 DEBUG ((DEBUG_INFO,
"XenBus: Set state to %d\n", NewState));
358 if (Status != XENSTORE_STATUS_SUCCESS) {
364 if (CurrentState == NewState) {
370 }
while (Status == XENSTORE_STATUS_EAGAIN);
372 if (Status != XENSTORE_STATUS_SUCCESS) {
373 DEBUG ((DEBUG_ERROR,
"XenBus: failed to write new state\n"));
377 DEBUG ((DEBUG_INFO,
"XenBus: Set state to %d, done\n", NewState));
384 XENBUS_PRIVATE_DATA_SIGNATURE,
389 XenBusXenStoreBackendRead,
390 XenBusXenStoreSPrint,
391 XenBusXenStoreRemove,
392 XenBusXenStoreTransactionStart,
393 XenBusXenStoreTransactionEnd,
401 XenBusRegisterWatchBackend,
402 XenBusUnregisterWatch,
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
BOOLEAN EFIAPI IsNodeAtEnd(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
UINTN EFIAPI AsciiStrDecimalToUintn(IN CONST CHAR8 *String)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
NODE Child(IN NODE LoopVar6, IN UINT8 LoopVar5)
#define HARDWARE_DEVICE_PATH
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
UINT32 EFIAPI XenBusEventChannelNotify(IN XENBUS_PROTOCOL *This, IN evtchn_port_t Port)
UINT32 EFIAPI XenBusEventChannelClose(IN XENBUS_PROTOCOL *This, IN evtchn_port_t Port)
UINT32 EFIAPI XenBusEventChannelAllocate(IN XENBUS_PROTOCOL *This, IN domid_t DomainId, OUT evtchn_port_t *Port)
EFI_STATUS EFIAPI XenBusGrantEndAccess(IN XENBUS_PROTOCOL *This, IN grant_ref_t Ref)
EFI_STATUS EFIAPI XenBusGrantAccess(IN XENBUS_PROTOCOL *This, IN domid_t DomainId, IN UINTN Frame, IN BOOLEAN ReadOnly, OUT grant_ref_t *RefPtr)
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
#define DEBUG(Expression)
EFI_STATUS EFIAPI Transaction(IN CONST EFI_SPI_IO_PROTOCOL *This, IN EFI_SPI_TRANSACTION_TYPE TransactionType, IN BOOLEAN DebugTransaction, IN UINT32 ClockHz OPTIONAL, IN UINT32 BusWidth, IN UINT32 FrameSize, IN UINT32 WriteBytes, IN UINT8 *WriteBuffer, IN UINT32 ReadBytes, OUT UINT8 *ReadBuffer)
STATIC VOID XenBusEnumerateDeviceType(XENBUS_DEVICE *Dev, CONST CHAR8 *Type)
XENSTORE_STATUS XenBusEnumerateBus(XENBUS_DEVICE *Dev)
STATIC XENBUS_PRIVATE_DATA * XenBusDeviceInitialized(IN XENBUS_DEVICE *Dev, IN CONST CHAR8 *Node)
XENSTORE_STATUS EFIAPI XenStoreSPrint(IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, IN CONST CHAR8 *FormatString,...)
XENSTORE_STATUS XenStoreListDirectory(IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, OUT UINT32 *DirectoryCountPtr, OUT CONST CHAR8 ***DirectoryListPtr)
BOOLEAN XenStorePathExists(IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *Directory, IN CONST CHAR8 *Node)
XENSTORE_STATUS XenStoreRead(IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, OUT UINT32 *LenPtr OPTIONAL, OUT VOID **Result)
EFI_HANDLE DriverBindingHandle