summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/XenBusDxe
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/XenBusDxe')
-rw-r--r--OvmfPkg/XenBusDxe/ComponentName.c10
-rw-r--r--OvmfPkg/XenBusDxe/EventChannel.c42
-rw-r--r--OvmfPkg/XenBusDxe/EventChannel.h19
-rw-r--r--OvmfPkg/XenBusDxe/GrantTable.c98
-rw-r--r--OvmfPkg/XenBusDxe/GrantTable.h11
-rw-r--r--OvmfPkg/XenBusDxe/Helpers.c4
-rw-r--r--OvmfPkg/XenBusDxe/TestAndClearBit.c15
-rw-r--r--OvmfPkg/XenBusDxe/XenBus.c225
-rw-r--r--OvmfPkg/XenBusDxe/XenBus.h12
-rw-r--r--OvmfPkg/XenBusDxe/XenBusDxe.c194
-rw-r--r--OvmfPkg/XenBusDxe/XenBusDxe.h56
-rw-r--r--OvmfPkg/XenBusDxe/XenStore.c736
-rw-r--r--OvmfPkg/XenBusDxe/XenStore.h132
13 files changed, 857 insertions, 697 deletions
diff --git a/OvmfPkg/XenBusDxe/ComponentName.c b/OvmfPkg/XenBusDxe/ComponentName.c
index 83e7628a2c..9141e9264f 100644
--- a/OvmfPkg/XenBusDxe/ComponentName.c
+++ b/OvmfPkg/XenBusDxe/ComponentName.c
@@ -14,7 +14,7 @@
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME_PROTOCOL gXenBusDxeComponentName = {
- (EFI_COMPONENT_NAME_GET_DRIVER_NAME) XenBusDxeComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME_GET_DRIVER_NAME)XenBusDxeComponentNameGetDriverName,
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)XenBusDxeComponentNameGetControllerName,
"eng"
};
@@ -33,18 +33,18 @@ EFI_COMPONENT_NAME2_PROTOCOL gXenBusDxeComponentName2 = {
/// Table of driver names
///
GLOBAL_REMOVE_IF_UNREFERENCED
-EFI_UNICODE_STRING_TABLE mXenBusDxeDriverNameTable[] = {
+EFI_UNICODE_STRING_TABLE mXenBusDxeDriverNameTable[] = {
{ "eng;en", (CHAR16 *)L"XenBus Bus Driver" },
- { NULL, NULL }
+ { NULL, NULL }
};
///
/// Table of controller names
///
GLOBAL_REMOVE_IF_UNREFERENCED
-EFI_UNICODE_STRING_TABLE mXenBusDxeControllerNameTable[] = {
+EFI_UNICODE_STRING_TABLE mXenBusDxeControllerNameTable[] = {
{ "eng;en", (CHAR16 *)L"XenBus Controller" },
- { NULL, NULL }
+ { NULL, NULL }
};
/**
diff --git a/OvmfPkg/XenBusDxe/EventChannel.c b/OvmfPkg/XenBusDxe/EventChannel.c
index 6c905b511f..810c9bdb7f 100644
--- a/OvmfPkg/XenBusDxe/EventChannel.c
+++ b/OvmfPkg/XenBusDxe/EventChannel.c
@@ -15,14 +15,14 @@
UINT32
XenEventChannelNotify (
- IN XENBUS_DEVICE *Dev,
- IN evtchn_port_t Port
+ IN XENBUS_DEVICE *Dev,
+ IN evtchn_port_t Port
)
{
- INTN ReturnCode;
- evtchn_send_t Send;
+ INTN ReturnCode;
+ evtchn_send_t Send;
- Send.port = Port;
+ Send.port = Port;
ReturnCode = XenHypercallEventChannelOp (EVTCHNOP_send, &Send);
return (UINT32)ReturnCode;
}
@@ -30,23 +30,25 @@ XenEventChannelNotify (
UINT32
EFIAPI
XenBusEventChannelAllocate (
- IN XENBUS_PROTOCOL *This,
- IN domid_t DomainId,
- OUT evtchn_port_t *Port
+ IN XENBUS_PROTOCOL *This,
+ IN domid_t DomainId,
+ OUT evtchn_port_t *Port
)
{
- evtchn_alloc_unbound_t Parameter;
- UINT32 ReturnCode;
+ evtchn_alloc_unbound_t Parameter;
+ UINT32 ReturnCode;
- Parameter.dom = DOMID_SELF;
+ Parameter.dom = DOMID_SELF;
Parameter.remote_dom = DomainId;
- ReturnCode = (UINT32)XenHypercallEventChannelOp (
+ ReturnCode = (UINT32)XenHypercallEventChannelOp (
EVTCHNOP_alloc_unbound,
- &Parameter);
+ &Parameter
+ );
if (ReturnCode != 0) {
DEBUG ((DEBUG_ERROR, "ERROR: alloc_unbound failed with rc=%d", ReturnCode));
return ReturnCode;
}
+
*Port = Parameter.port;
return ReturnCode;
}
@@ -54,24 +56,24 @@ XenBusEventChannelAllocate (
UINT32
EFIAPI
XenBusEventChannelNotify (
- IN XENBUS_PROTOCOL *This,
- IN evtchn_port_t Port
+ IN XENBUS_PROTOCOL *This,
+ IN evtchn_port_t Port
)
{
- XENBUS_PRIVATE_DATA *Private;
+ XENBUS_PRIVATE_DATA *Private;
- Private = XENBUS_PRIVATE_DATA_FROM_THIS(This);
+ Private = XENBUS_PRIVATE_DATA_FROM_THIS (This);
return XenEventChannelNotify (Private->Dev, Port);
}
UINT32
EFIAPI
XenBusEventChannelClose (
- IN XENBUS_PROTOCOL *This,
- IN evtchn_port_t Port
+ IN XENBUS_PROTOCOL *This,
+ IN evtchn_port_t Port
)
{
- evtchn_close_t Close;
+ evtchn_close_t Close;
Close.port = Port;
return (UINT32)XenHypercallEventChannelOp (EVTCHNOP_close, &Close);
diff --git a/OvmfPkg/XenBusDxe/EventChannel.h b/OvmfPkg/XenBusDxe/EventChannel.h
index 793571fab6..1e748825dd 100644
--- a/OvmfPkg/XenBusDxe/EventChannel.h
+++ b/OvmfPkg/XenBusDxe/EventChannel.h
@@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef __XENBUS_EVENT_CHANNEL_H
#define __XENBUS_EVENT_CHANNEL_H
@@ -23,8 +24,8 @@
**/
UINT32
XenEventChannelNotify (
- IN XENBUS_DEVICE *Dev,
- IN evtchn_port_t Port
+ IN XENBUS_DEVICE *Dev,
+ IN evtchn_port_t Port
);
/*
@@ -44,9 +45,9 @@ XenEventChannelNotify (
UINT32
EFIAPI
XenBusEventChannelAllocate (
- IN XENBUS_PROTOCOL *This,
- IN domid_t DomainId,
- OUT evtchn_port_t *Port
+ IN XENBUS_PROTOCOL *This,
+ IN domid_t DomainId,
+ OUT evtchn_port_t *Port
);
/**
@@ -60,8 +61,8 @@ XenBusEventChannelAllocate (
UINT32
EFIAPI
XenBusEventChannelNotify (
- IN XENBUS_PROTOCOL *This,
- IN evtchn_port_t Port
+ IN XENBUS_PROTOCOL *This,
+ IN evtchn_port_t Port
);
/**
@@ -75,8 +76,8 @@ XenBusEventChannelNotify (
UINT32
EFIAPI
XenBusEventChannelClose (
- IN XENBUS_PROTOCOL *This,
- IN evtchn_port_t Port
+ IN XENBUS_PROTOCOL *This,
+ IN evtchn_port_t Port
);
#endif
diff --git a/OvmfPkg/XenBusDxe/GrantTable.c b/OvmfPkg/XenBusDxe/GrantTable.c
index 58d687abad..76e0e8f17f 100644
--- a/OvmfPkg/XenBusDxe/GrantTable.c
+++ b/OvmfPkg/XenBusDxe/GrantTable.c
@@ -20,31 +20,31 @@
#include "GrantTable.h"
-#define NR_RESERVED_ENTRIES 8
+#define NR_RESERVED_ENTRIES 8
-#define NR_GRANT_FRAMES (FixedPcdGet32 (PcdXenGrantFrames))
-#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * EFI_PAGE_SIZE / sizeof(grant_entry_v1_t))
+#define NR_GRANT_FRAMES (FixedPcdGet32 (PcdXenGrantFrames))
+#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * EFI_PAGE_SIZE / sizeof(grant_entry_v1_t))
-STATIC grant_entry_v1_t *GrantTable = NULL;
-STATIC grant_ref_t GrantList[NR_GRANT_ENTRIES];
-STATIC EFI_LOCK mGrantListLock;
+STATIC grant_entry_v1_t *GrantTable = NULL;
+STATIC grant_ref_t GrantList[NR_GRANT_ENTRIES];
+STATIC EFI_LOCK mGrantListLock;
#ifdef GNT_DEBUG
-STATIC BOOLEAN GrantInUseList[NR_GRANT_ENTRIES];
+STATIC BOOLEAN GrantInUseList[NR_GRANT_ENTRIES];
#endif
STATIC
VOID
XenGrantTablePutFreeEntry (
- grant_ref_t Ref
+ grant_ref_t Ref
)
{
EfiAcquireLock (&mGrantListLock);
-#ifdef GNT_DEBUG
+ #ifdef GNT_DEBUG
ASSERT (GrantInUseList[Ref]);
GrantInUseList[Ref] = FALSE;
-#endif
+ #endif
GrantList[Ref] = GrantList[0];
- GrantList[0] = Ref;
+ GrantList[0] = Ref;
EfiReleaseLock (&mGrantListLock);
}
@@ -54,16 +54,16 @@ XenGrantTableGetFreeEntry (
VOID
)
{
- grant_ref_t Ref;
+ grant_ref_t Ref;
EfiAcquireLock (&mGrantListLock);
Ref = GrantList[0];
ASSERT (Ref >= NR_RESERVED_ENTRIES && Ref < NR_GRANT_ENTRIES);
GrantList[0] = GrantList[Ref];
-#ifdef GNT_DEBUG
+ #ifdef GNT_DEBUG
ASSERT (!GrantInUseList[Ref]);
GrantInUseList[Ref] = TRUE;
-#endif
+ #endif
EfiReleaseLock (&mGrantListLock);
return Ref;
}
@@ -76,11 +76,11 @@ XenGrantTableGrantAccess (
IN BOOLEAN ReadOnly
)
{
- grant_ref_t Ref;
- UINT16 Flags;
+ grant_ref_t Ref;
+ UINT16 Flags;
ASSERT (GrantTable != NULL);
- Ref = XenGrantTableGetFreeEntry ();
+ Ref = XenGrantTableGetFreeEntry ();
GrantTable[Ref].frame = (UINT32)Frame;
GrantTable[Ref].domid = DomainId;
MemoryFence ();
@@ -88,6 +88,7 @@ XenGrantTableGrantAccess (
if (ReadOnly) {
Flags |= GTF_readonly;
}
+
GrantTable[Ref].flags = Flags;
return Ref;
@@ -96,10 +97,10 @@ XenGrantTableGrantAccess (
STATIC
EFI_STATUS
XenGrantTableEndAccess (
- grant_ref_t Ref
+ grant_ref_t Ref
)
{
- UINT16 Flags, OldFlags;
+ UINT16 Flags, OldFlags;
ASSERT (GrantTable != NULL);
ASSERT (Ref >= NR_RESERVED_ENTRIES && Ref < NR_GRANT_ENTRIES);
@@ -110,6 +111,7 @@ XenGrantTableEndAccess (
DEBUG ((DEBUG_WARN, "WARNING: g.e. still in use! (%x)\n", Flags));
return EFI_NOT_READY;
}
+
OldFlags = InterlockedCompareExchange16 (&GrantTable[Ref].flags, Flags, 0);
} while (OldFlags != Flags);
@@ -122,40 +124,42 @@ XenGrantTableInit (
IN XENBUS_DEVICE *Dev
)
{
- xen_add_to_physmap_t Parameters;
- INTN Index;
- INTN ReturnCode;
+ xen_add_to_physmap_t Parameters;
+ INTN Index;
+ INTN ReturnCode;
-#ifdef GNT_DEBUG
- SetMem(GrantInUseList, sizeof (GrantInUseList), 1);
-#endif
+ #ifdef GNT_DEBUG
+ SetMem (GrantInUseList, sizeof (GrantInUseList), 1);
+ #endif
EfiInitializeLock (&mGrantListLock, TPL_NOTIFY);
for (Index = NR_RESERVED_ENTRIES; Index < NR_GRANT_ENTRIES; Index++) {
XenGrantTablePutFreeEntry ((grant_ref_t)Index);
}
- GrantTable = (VOID*)(UINTN) Dev->XenIo->GrantTableAddress;
+ GrantTable = (VOID *)(UINTN)Dev->XenIo->GrantTableAddress;
for (Index = 0; Index < NR_GRANT_FRAMES; Index++) {
Parameters.domid = DOMID_SELF;
- Parameters.idx = Index;
+ Parameters.idx = Index;
Parameters.space = XENMAPSPACE_grant_table;
- Parameters.gpfn = (xen_pfn_t) ((UINTN) GrantTable >> EFI_PAGE_SHIFT) + Index;
- ReturnCode = XenHypercallMemoryOp (XENMEM_add_to_physmap, &Parameters);
+ Parameters.gpfn = (xen_pfn_t)((UINTN)GrantTable >> EFI_PAGE_SHIFT) + Index;
+ ReturnCode = XenHypercallMemoryOp (XENMEM_add_to_physmap, &Parameters);
if (ReturnCode != 0) {
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"Xen GrantTable, add_to_physmap hypercall error: %Ld\n",
- (INT64)ReturnCode));
+ (INT64)ReturnCode
+ ));
}
}
}
VOID
XenGrantTableDeinit (
- XENBUS_DEVICE *Dev
+ XENBUS_DEVICE *Dev
)
{
- INTN ReturnCode, Index;
- xen_remove_from_physmap_t Parameters;
+ INTN ReturnCode, Index;
+ xen_remove_from_physmap_t Parameters;
if (GrantTable == NULL) {
return;
@@ -163,27 +167,33 @@ XenGrantTableDeinit (
for (Index = NR_GRANT_FRAMES - 1; Index >= 0; Index--) {
Parameters.domid = DOMID_SELF;
- Parameters.gpfn = (xen_pfn_t) ((UINTN) GrantTable >> EFI_PAGE_SHIFT) + Index;
- DEBUG ((DEBUG_INFO, "Xen GrantTable, removing %Lx\n",
- (UINT64)Parameters.gpfn));
+ Parameters.gpfn = (xen_pfn_t)((UINTN)GrantTable >> EFI_PAGE_SHIFT) + Index;
+ DEBUG ((
+ DEBUG_INFO,
+ "Xen GrantTable, removing %Lx\n",
+ (UINT64)Parameters.gpfn
+ ));
ReturnCode = XenHypercallMemoryOp (XENMEM_remove_from_physmap, &Parameters);
if (ReturnCode != 0) {
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"Xen GrantTable, remove_from_physmap hypercall error: %Ld\n",
- (INT64)ReturnCode));
+ (INT64)ReturnCode
+ ));
}
}
+
GrantTable = NULL;
}
EFI_STATUS
EFIAPI
XenBusGrantAccess (
- IN XENBUS_PROTOCOL *This,
- IN domid_t DomainId,
- IN UINTN Frame, // MFN
- IN BOOLEAN ReadOnly,
- OUT grant_ref_t *RefPtr
+ IN XENBUS_PROTOCOL *This,
+ IN domid_t DomainId,
+ IN UINTN Frame, // MFN
+ IN BOOLEAN ReadOnly,
+ OUT grant_ref_t *RefPtr
)
{
*RefPtr = XenGrantTableGrantAccess (DomainId, Frame, ReadOnly);
diff --git a/OvmfPkg/XenBusDxe/GrantTable.h b/OvmfPkg/XenBusDxe/GrantTable.h
index 0c1e076337..3d5c98e85d 100644
--- a/OvmfPkg/XenBusDxe/GrantTable.h
+++ b/OvmfPkg/XenBusDxe/GrantTable.h
@@ -9,6 +9,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef __GNTTAB_H__
#define __GNTTAB_H__
@@ -46,11 +47,11 @@ XenGrantTableDeinit (
EFI_STATUS
EFIAPI
XenBusGrantAccess (
- IN XENBUS_PROTOCOL *This,
- IN domid_t DomainId,
- IN UINTN Frame, // MFN
- IN BOOLEAN ReadOnly,
- OUT grant_ref_t *RefPtr
+ IN XENBUS_PROTOCOL *This,
+ IN domid_t DomainId,
+ IN UINTN Frame, // MFN
+ IN BOOLEAN ReadOnly,
+ OUT grant_ref_t *RefPtr
);
/**
diff --git a/OvmfPkg/XenBusDxe/Helpers.c b/OvmfPkg/XenBusDxe/Helpers.c
index b22f9c5b0d..753ac107fa 100644
--- a/OvmfPkg/XenBusDxe/Helpers.c
+++ b/OvmfPkg/XenBusDxe/Helpers.c
@@ -1,8 +1,8 @@
#include "XenBusDxe.h"
-CHAR8*
+CHAR8 *
AsciiStrDup (
- IN CONST CHAR8* Str
+ IN CONST CHAR8 *Str
)
{
return AllocateCopyPool (AsciiStrSize (Str), Str);
diff --git a/OvmfPkg/XenBusDxe/TestAndClearBit.c b/OvmfPkg/XenBusDxe/TestAndClearBit.c
index 989ab70358..4d51064718 100644
--- a/OvmfPkg/XenBusDxe/TestAndClearBit.c
+++ b/OvmfPkg/XenBusDxe/TestAndClearBit.c
@@ -14,12 +14,12 @@
INT32
EFIAPI
TestAndClearBit (
- IN INT32 Bit,
- IN VOID *Address
+ IN INT32 Bit,
+ IN VOID *Address
)
{
- UINT16 Word, Read;
- UINT16 Mask;
+ UINT16 Word, Read;
+ UINT16 Mask;
//
// Calculate the effective address relative to 'Address' based on the
@@ -27,14 +27,15 @@ TestAndClearBit (
// ensure we round towards -Inf, and end up with a positive shift in
// 'Bit', even if 'Bit' itself is negative.
//
- Address = (VOID*)((UINT8*) Address + ((Bit >> 4) * sizeof(UINT16)));
- Mask = 1U << (Bit & 15);
+ Address = (VOID *)((UINT8 *)Address + ((Bit >> 4) * sizeof (UINT16)));
+ Mask = 1U << (Bit & 15);
- for (Word = *(UINT16 *) Address; Word & Mask; Word = Read) {
+ for (Word = *(UINT16 *)Address; Word &Mask; Word = Read) {
Read = InterlockedCompareExchange16 (Address, Word, Word & ~Mask);
if (Read == Word) {
return 1;
}
}
+
return 0;
}
diff --git a/OvmfPkg/XenBusDxe/XenBus.c b/OvmfPkg/XenBusDxe/XenBus.c
index f8a41b6d36..7b67670ccb 100644
--- a/OvmfPkg/XenBusDxe/XenBus.c
+++ b/OvmfPkg/XenBusDxe/XenBus.c
@@ -26,16 +26,16 @@
#include <IndustryStandard/Xen/io/xenbus.h>
-STATIC XENBUS_PRIVATE_DATA gXenBusPrivateData;
+STATIC XENBUS_PRIVATE_DATA gXenBusPrivateData;
-STATIC XENBUS_DEVICE_PATH gXenBusDevicePathTemplate = {
+STATIC XENBUS_DEVICE_PATH gXenBusDevicePathTemplate = {
{ // Vendor
{ // Vendor.Header
HARDWARE_DEVICE_PATH, // Vendor.Header.Type
HW_VENDOR_DP, // Vendor.Header.SubType
{
- (UINT8) (sizeof (XENBUS_DEVICE_PATH)), // Vendor.Header.Length[0]
- (UINT8) (sizeof (XENBUS_DEVICE_PATH) >> 8), // Vendor.Header.Length[1]
+ (UINT8)(sizeof (XENBUS_DEVICE_PATH)), // Vendor.Header.Length[0]
+ (UINT8)(sizeof (XENBUS_DEVICE_PATH) >> 8), // Vendor.Header.Length[1]
}
},
XENBUS_PROTOCOL_GUID, // Vendor.Guid
@@ -44,7 +44,6 @@ STATIC XENBUS_DEVICE_PATH gXenBusDevicePathTemplate = {
0 // DeviceId
};
-
/**
Search our internal record of configured devices (not the XenStore) to
determine if the XenBus device indicated by Node is known to the system.
@@ -57,13 +56,13 @@ STATIC XENBUS_DEVICE_PATH gXenBusDevicePathTemplate = {
STATIC
XENBUS_PRIVATE_DATA *
XenBusDeviceInitialized (
- IN XENBUS_DEVICE *Dev,
- IN CONST CHAR8 *Node
+ IN XENBUS_DEVICE *Dev,
+ IN CONST CHAR8 *Node
)
{
- LIST_ENTRY *Entry;
- XENBUS_PRIVATE_DATA *Child;
- XENBUS_PRIVATE_DATA *Result;
+ LIST_ENTRY *Entry;
+ XENBUS_PRIVATE_DATA *Child;
+ XENBUS_PRIVATE_DATA *Result;
if (IsListEmpty (&Dev->ChildList)) {
return NULL;
@@ -72,7 +71,8 @@ XenBusDeviceInitialized (
Result = NULL;
for (Entry = GetFirstNode (&Dev->ChildList);
!IsNodeAtEnd (&Dev->ChildList, Entry);
- Entry = GetNextNode (&Dev->ChildList, Entry)) {
+ Entry = GetNextNode (&Dev->ChildList, Entry))
+ {
Child = XENBUS_PRIVATE_DATA_FROM_LINK (Entry);
if (!AsciiStrCmp (Child->XenBusIo.Node, Node)) {
Result = Child;
@@ -86,12 +86,12 @@ XenBusDeviceInitialized (
STATIC
XenbusState
XenBusReadDriverState (
- IN CONST CHAR8 *Path
+ IN CONST CHAR8 *Path
)
{
- XenbusState State;
- CHAR8 *Ptr = NULL;
- XENSTORE_STATUS Status;
+ XenbusState State;
+ CHAR8 *Ptr = NULL;
+ XENSTORE_STATUS Status;
Status = XenStoreRead (XST_NIL, Path, "state", NULL, (VOID **)&Ptr);
if (Status != XENSTORE_STATUS_SUCCESS) {
@@ -113,24 +113,30 @@ XenBusReadDriverState (
STATIC
EFI_STATUS
XenBusAddDevice (
- XENBUS_DEVICE *Dev,
- CONST CHAR8 *Type,
- CONST CHAR8 *Id)
+ XENBUS_DEVICE *Dev,
+ CONST CHAR8 *Type,
+ CONST CHAR8 *Id
+ )
{
- CHAR8 DevicePath[XENSTORE_ABS_PATH_MAX];
- XENSTORE_STATUS StatusXenStore;
- XENBUS_PRIVATE_DATA *Private;
- EFI_STATUS Status;
- XENBUS_DEVICE_PATH *TempXenBusPath;
- VOID *ChildXenIo;
-
- AsciiSPrint (DevicePath, sizeof (DevicePath),
- "device/%a/%a", Type, Id);
+ CHAR8 DevicePath[XENSTORE_ABS_PATH_MAX];
+ XENSTORE_STATUS StatusXenStore;
+ XENBUS_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ XENBUS_DEVICE_PATH *TempXenBusPath;
+ VOID *ChildXenIo;
+
+ AsciiSPrint (
+ DevicePath,
+ sizeof (DevicePath),
+ "device/%a/%a",
+ Type,
+ Id
+ );
if (XenStorePathExists (XST_NIL, DevicePath, "")) {
- XENBUS_PRIVATE_DATA *Child;
- enum xenbus_state State;
- CHAR8 *BackendPath;
+ XENBUS_PRIVATE_DATA *Child;
+ enum xenbus_state State;
+ CHAR8 *BackendPath;
Child = XenBusDeviceInitialized (Dev, DevicePath);
if (Child != NULL) {
@@ -148,57 +154,80 @@ XenBusAddDevice (
* happen if a device is going away after
* switching to Closed.
*/
- DEBUG ((DEBUG_INFO, "XenBus: Device %a ignored. "
- "State %d\n", DevicePath, State));
+ DEBUG ((
+ DEBUG_INFO,
+ "XenBus: Device %a ignored. "
+ "State %d\n",
+ DevicePath,
+ State
+ ));
Status = EFI_SUCCESS;
goto out;
}
- StatusXenStore = XenStoreRead (XST_NIL, DevicePath, "backend",
- NULL, (VOID **) &BackendPath);
+ StatusXenStore = XenStoreRead (
+ XST_NIL,
+ DevicePath,
+ "backend",
+ NULL,
+ (VOID **)&BackendPath
+ );
if (StatusXenStore != XENSTORE_STATUS_SUCCESS) {
DEBUG ((DEBUG_ERROR, "xenbus: %a no backend path.\n", DevicePath));
Status = EFI_NOT_FOUND;
goto out;
}
- Private = AllocateCopyPool (sizeof (*Private), &gXenBusPrivateData);
- Private->XenBusIo.Type = AsciiStrDup (Type);
- Private->XenBusIo.Node = AsciiStrDup (DevicePath);
- Private->XenBusIo.Backend = BackendPath;
+ Private = AllocateCopyPool (sizeof (*Private), &gXenBusPrivateData);
+ Private->XenBusIo.Type = AsciiStrDup (Type);
+ Private->XenBusIo.Node = AsciiStrDup (DevicePath);
+ Private->XenBusIo.Backend = BackendPath;
Private->XenBusIo.DeviceId = (UINT16)AsciiStrDecimalToUintn (Id);
- Private->Dev = Dev;
+ Private->Dev = Dev;
- TempXenBusPath = AllocateCopyPool (sizeof (XENBUS_DEVICE_PATH),
- &gXenBusDevicePathTemplate);
+ TempXenBusPath = AllocateCopyPool (
+ sizeof (XENBUS_DEVICE_PATH),
+ &gXenBusDevicePathTemplate
+ );
if (!AsciiStrCmp (Private->XenBusIo.Type, "vbd")) {
TempXenBusPath->Type = XENBUS_DEVICE_PATH_TYPE_VBD;
}
+
TempXenBusPath->DeviceId = Private->XenBusIo.DeviceId;
- Private->DevicePath = (XENBUS_DEVICE_PATH *)AppendDevicePathNode (
- Dev->DevicePath,
- &TempXenBusPath->Vendor.Header);
+ Private->DevicePath = (XENBUS_DEVICE_PATH *)AppendDevicePathNode (
+ Dev->DevicePath,
+ &TempXenBusPath->Vendor.Header
+ );
FreePool (TempXenBusPath);
InsertTailList (&Dev->ChildList, &Private->Link);
Status = gBS->InstallMultipleProtocolInterfaces (
- &Private->Handle,
- &gEfiDevicePathProtocolGuid, Private->DevicePath,
- &gXenBusProtocolGuid, &Private->XenBusIo,
- NULL);
+ &Private->Handle,
+ &gEfiDevicePathProtocolGuid,
+ Private->DevicePath,
+ &gXenBusProtocolGuid,
+ &Private->XenBusIo,
+ NULL
+ );
if (EFI_ERROR (Status)) {
goto ErrorInstallProtocol;
}
- Status = gBS->OpenProtocol (Dev->ControllerHandle,
- &gXenIoProtocolGuid,
- &ChildXenIo, Dev->This->DriverBindingHandle,
- Private->Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER);
+ Status = gBS->OpenProtocol (
+ Dev->ControllerHandle,
+ &gXenIoProtocolGuid,
+ &ChildXenIo,
+ Dev->This->DriverBindingHandle,
+ Private->Handle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "open by child controller fail (%r)\n",
- Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "open by child controller fail (%r)\n",
+ Status
+ ));
goto ErrorOpenProtocolByChild;
}
} else {
@@ -210,16 +239,19 @@ XenBusAddDevice (
ErrorOpenProtocolByChild:
gBS->UninstallMultipleProtocolInterfaces (
- Private->Handle,
- &gEfiDevicePathProtocolGuid, Private->DevicePath,
- &gXenBusProtocolGuid, &Private->XenBusIo,
- NULL);
+ Private->Handle,
+ &gEfiDevicePathProtocolGuid,
+ Private->DevicePath,
+ &gXenBusProtocolGuid,
+ &Private->XenBusIo,
+ NULL
+ );
ErrorInstallProtocol:
RemoveEntryList (&Private->Link);
FreePool (Private->DevicePath);
- FreePool ((VOID *) Private->XenBusIo.Backend);
- FreePool ((VOID *) Private->XenBusIo.Node);
- FreePool ((VOID *) Private->XenBusIo.Type);
+ FreePool ((VOID *)Private->XenBusIo.Backend);
+ FreePool ((VOID *)Private->XenBusIo.Node);
+ FreePool ((VOID *)Private->XenBusIo.Type);
FreePool (Private);
out:
return Status;
@@ -239,29 +271,33 @@ out:
STATIC
VOID
XenBusEnumerateDeviceType (
- XENBUS_DEVICE *Dev,
- CONST CHAR8 *Type
+ XENBUS_DEVICE *Dev,
+ CONST CHAR8 *Type
)
{
- CONST CHAR8 **Directory;
- UINTN Index;
- UINT32 Count;
- XENSTORE_STATUS Status;
-
- Status = XenStoreListDirectory (XST_NIL,
- "device", Type,
- &Count, &Directory);
+ CONST CHAR8 **Directory;
+ UINTN Index;
+ UINT32 Count;
+ XENSTORE_STATUS Status;
+
+ Status = XenStoreListDirectory (
+ XST_NIL,
+ "device",
+ Type,
+ &Count,
+ &Directory
+ );
if (Status != XENSTORE_STATUS_SUCCESS) {
return;
}
+
for (Index = 0; Index < Count; Index++) {
XenBusAddDevice (Dev, Type, Directory[Index]);
}
- FreePool ((VOID*)Directory);
+ FreePool ((VOID *)Directory);
}
-
/**
Enumerate the devices on a XenBus bus and install a XenBus Protocol instance.
@@ -275,17 +311,21 @@ XenBusEnumerateDeviceType (
*/
XENSTORE_STATUS
XenBusEnumerateBus (
- XENBUS_DEVICE *Dev
+ XENBUS_DEVICE *Dev
)
{
- CONST CHAR8 **Types;
- UINTN Index;
- UINT32 Count;
- XENSTORE_STATUS Status;
-
- Status = XenStoreListDirectory (XST_NIL,
- "device", "",
- &Count, &Types);
+ CONST CHAR8 **Types;
+ UINTN Index;
+ UINT32 Count;
+ XENSTORE_STATUS Status;
+
+ Status = XenStoreListDirectory (
+ XST_NIL,
+ "device",
+ "",
+ &Count,
+ &Types
+ );
if (Status != XENSTORE_STATUS_SUCCESS) {
return Status;
}
@@ -294,7 +334,7 @@ XenBusEnumerateBus (
XenBusEnumerateDeviceType (Dev, Types[Index]);
}
- FreePool ((VOID*)Types);
+ FreePool ((VOID *)Types);
return XENSTORE_STATUS_SUCCESS;
}
@@ -303,14 +343,14 @@ STATIC
XENSTORE_STATUS
EFIAPI
XenBusSetState (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN enum xenbus_state NewState
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN enum xenbus_state NewState
)
{
- enum xenbus_state CurrentState;
- XENSTORE_STATUS Status;
- CHAR8 *Temp;
+ enum xenbus_state CurrentState;
+ XENSTORE_STATUS Status;
+ CHAR8 *Temp;
DEBUG ((DEBUG_INFO, "XenBus: Set state to %d\n", NewState));
@@ -318,6 +358,7 @@ XenBusSetState (
if (Status != XENSTORE_STATUS_SUCCESS) {
goto Out;
}
+
CurrentState = AsciiStrDecimalToUintn (Temp);
FreePool (Temp);
if (CurrentState == NewState) {
@@ -327,17 +368,19 @@ XenBusSetState (
do {
Status = XenStoreSPrint (Transaction, This->Node, "state", "%d", NewState);
} while (Status == XENSTORE_STATUS_EAGAIN);
+
if (Status != XENSTORE_STATUS_SUCCESS) {
DEBUG ((DEBUG_ERROR, "XenBus: failed to write new state\n"));
goto Out;
}
+
DEBUG ((DEBUG_INFO, "XenBus: Set state to %d, done\n", NewState));
Out:
return Status;
}
-STATIC XENBUS_PRIVATE_DATA gXenBusPrivateData = {
+STATIC XENBUS_PRIVATE_DATA gXenBusPrivateData = {
XENBUS_PRIVATE_DATA_SIGNATURE, // Signature
{ NULL, NULL }, // Link
NULL, // Handle
diff --git a/OvmfPkg/XenBusDxe/XenBus.h b/OvmfPkg/XenBusDxe/XenBus.h
index c85ca99465..36aff47019 100644
--- a/OvmfPkg/XenBusDxe/XenBus.h
+++ b/OvmfPkg/XenBusDxe/XenBus.h
@@ -6,19 +6,19 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef _XEN_XENBUS_XENBUSB_H
#define _XEN_XENBUS_XENBUSB_H
#include "XenBusDxe.h"
-#define XENBUS_DEVICE_PATH_TYPE_VBD 0x1
+#define XENBUS_DEVICE_PATH_TYPE_VBD 0x1
struct _XENBUS_DEVICE_PATH {
- VENDOR_DEVICE_PATH Vendor;
- UINT8 Type;
- UINT16 DeviceId;
+ VENDOR_DEVICE_PATH Vendor;
+ UINT8 Type;
+ UINT16 DeviceId;
};
-
/**
Perform XenBus bus enumeration and install protocol for children.
@@ -32,7 +32,7 @@ struct _XENBUS_DEVICE_PATH {
**/
XENSTORE_STATUS
XenBusEnumerateBus (
- XENBUS_DEVICE *Dev
+ XENBUS_DEVICE *Dev
);
#endif /* _XEN_XENBUS_XENBUSB_H */
diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c
index 1f5628ad83..132f43a72b 100644
--- a/OvmfPkg/XenBusDxe/XenBusDxe.c
+++ b/OvmfPkg/XenBusDxe/XenBusDxe.c
@@ -32,7 +32,7 @@
///
/// Driver Binding Protocol instance
///
-EFI_DRIVER_BINDING_PROTOCOL gXenBusDxeDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gXenBusDxeDriverBinding = {
XenBusDxeDriverBindingSupported,
XenBusDxeDriverBindingStart,
XenBusDxeDriverBindingStop,
@@ -41,9 +41,8 @@ EFI_DRIVER_BINDING_PROTOCOL gXenBusDxeDriverBinding = {
NULL
};
-
STATIC EFI_LOCK mMyDeviceLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_CALLBACK);
-STATIC XENBUS_DEVICE *mMyDevice = NULL;
+STATIC XENBUS_DEVICE *mMyDevice = NULL;
/**
Map the shared_info_t page into memory.
@@ -58,16 +57,16 @@ STATIC XENBUS_DEVICE *mMyDevice = NULL;
STATIC
EFI_STATUS
XenGetSharedInfoPage (
- IN OUT XENBUS_DEVICE *Dev
+ IN OUT XENBUS_DEVICE *Dev
)
{
- xen_add_to_physmap_t Parameter;
+ xen_add_to_physmap_t Parameter;
ASSERT (Dev->SharedInfo == NULL);
Parameter.domid = DOMID_SELF;
Parameter.space = XENMAPSPACE_shared_info;
- Parameter.idx = 0;
+ Parameter.idx = 0;
//
// using reserved page because the page is not released when Linux is
@@ -75,7 +74,7 @@ XenGetSharedInfoPage (
// page, and fail because it have no right to do so (segv).
//
Dev->SharedInfo = AllocateReservedPages (1);
- Parameter.gpfn = (UINTN) Dev->SharedInfo >> EFI_PAGE_SHIFT;
+ Parameter.gpfn = (UINTN)Dev->SharedInfo >> EFI_PAGE_SHIFT;
if (XenHypercallMemoryOp (XENMEM_add_to_physmap, &Parameter) != 0) {
FreePages (Dev->SharedInfo, 1);
Dev->SharedInfo = NULL;
@@ -132,15 +131,17 @@ XenBusDxeUnload (
//
FreePool (HandleBuffer);
-
//
// Uninstall protocols installed in the driver entry point
//
Status = gBS->UninstallMultipleProtocolInterfaces (
ImageHandle,
- &gEfiDriverBindingProtocolGuid, &gXenBusDxeDriverBinding,
- &gEfiComponentNameProtocolGuid, &gXenBusDxeComponentName,
- &gEfiComponentName2ProtocolGuid, &gXenBusDxeComponentName2,
+ &gEfiDriverBindingProtocolGuid,
+ &gXenBusDxeDriverBinding,
+ &gEfiComponentNameProtocolGuid,
+ &gXenBusDxeComponentName,
+ &gEfiComponentName2ProtocolGuid,
+ &gXenBusDxeComponentName2,
NULL
);
if (EFI_ERROR (Status)) {
@@ -171,7 +172,7 @@ XenBusDxeDriverEntryPoint (
{
EFI_STATUS Status;
- if (! XenHypercallIsAvailable ()) {
+ if (!XenHypercallIsAvailable ()) {
return EFI_ABORTED;
}
@@ -188,11 +189,9 @@ XenBusDxeDriverEntryPoint (
);
ASSERT_EFI_ERROR (Status);
-
return Status;
}
-
/**
Tests to see if this driver supports a given controller. If a child device is provided,
it further tests to see if this driver supports creating a handle for the specified child device.
@@ -229,24 +228,28 @@ XenBusDxeDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- XENIO_PROTOCOL *XenIo;
+ EFI_STATUS Status;
+ XENIO_PROTOCOL *XenIo;
Status = gBS->OpenProtocol (
- ControllerHandle,
- &gXenIoProtocolGuid,
- (VOID **)&XenIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
+ ControllerHandle,
+ &gXenIoProtocolGuid,
+ (VOID **)&XenIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- gBS->CloseProtocol (ControllerHandle, &gXenIoProtocolGuid,
- This->DriverBindingHandle, ControllerHandle);
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gXenIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
return Status;
}
@@ -254,14 +257,17 @@ XenBusDxeDriverBindingSupported (
VOID
EFIAPI
NotifyExitBoot (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- XENBUS_DEVICE *Dev = Context;
+ XENBUS_DEVICE *Dev = Context;
- gBS->DisconnectController(Dev->ControllerHandle,
- Dev->This->DriverBindingHandle, NULL);
+ gBS->DisconnectController (
+ Dev->ControllerHandle,
+ Dev->This->DriverBindingHandle,
+ NULL
+ );
}
/**
@@ -309,19 +315,19 @@ XenBusDxeDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- XENBUS_DEVICE *Dev;
- XENIO_PROTOCOL *XenIo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ XENBUS_DEVICE *Dev;
+ XENIO_PROTOCOL *XenIo;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
Status = gBS->OpenProtocol (
- ControllerHandle,
- &gXenIoProtocolGuid,
- (VOID**)&XenIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
+ ControllerHandle,
+ &gXenIoProtocolGuid,
+ (VOID **)&XenIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
return Status;
@@ -330,7 +336,7 @@ XenBusDxeDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath,
+ (VOID **)&DevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -340,12 +346,12 @@ XenBusDxeDriverBindingStart (
goto ErrorOpenningProtocol;
}
- Dev = AllocateZeroPool (sizeof (*Dev));
- Dev->Signature = XENBUS_DEVICE_SIGNATURE;
- Dev->This = This;
+ Dev = AllocateZeroPool (sizeof (*Dev));
+ Dev->Signature = XENBUS_DEVICE_SIGNATURE;
+ Dev->This = This;
Dev->ControllerHandle = ControllerHandle;
- Dev->XenIo = XenIo;
- Dev->DevicePath = DevicePath;
+ Dev->XenIo = XenIo;
+ Dev->DevicePath = DevicePath;
InitializeListHead (&Dev->ChildList);
EfiAcquireLock (&mMyDeviceLock);
@@ -357,6 +363,7 @@ XenBusDxeDriverBindingStart (
Status = EFI_ALREADY_STARTED;
goto ErrorAllocated;
}
+
mMyDevice = Dev;
EfiReleaseLock (&mMyDeviceLock);
@@ -374,21 +381,32 @@ XenBusDxeDriverBindingStart (
XenBusEnumerateBus (Dev);
- Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,
- NotifyExitBoot,
- (VOID*) Dev,
- &Dev->ExitBootEvent);
+ Status = gBS->CreateEvent (
+ EVT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_CALLBACK,
+ NotifyExitBoot,
+ (VOID *)Dev,
+ &Dev->ExitBootEvent
+ );
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
ErrorAllocated:
FreePool (Dev);
- gBS->CloseProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle, ControllerHandle);
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
ErrorOpenningProtocol:
- gBS->CloseProtocol (ControllerHandle, &gXenIoProtocolGuid,
- This->DriverBindingHandle, ControllerHandle);
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gXenIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
return Status;
}
@@ -427,44 +445,54 @@ XenBusDxeDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
- UINTN Index;
- XENBUS_PROTOCOL *XenBusIo;
- XENBUS_PRIVATE_DATA *ChildData;
- EFI_STATUS Status;
- XENBUS_DEVICE *Dev = mMyDevice;
+ UINTN Index;
+ XENBUS_PROTOCOL *XenBusIo;
+ XENBUS_PRIVATE_DATA *ChildData;
+ EFI_STATUS Status;
+ XENBUS_DEVICE *Dev = mMyDevice;
for (Index = 0; Index < NumberOfChildren; Index++) {
Status = gBS->OpenProtocol (
- ChildHandleBuffer[Index],
- &gXenBusProtocolGuid,
- (VOID **) &XenBusIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ ChildHandleBuffer[Index],
+ &gXenBusProtocolGuid,
+ (VOID **)&XenBusIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "XenBusDxe: get children protocol failed: %r\n", Status));
continue;
}
+
ChildData = XENBUS_PRIVATE_DATA_FROM_THIS (XenBusIo);
- Status = gBS->CloseProtocol (Dev->ControllerHandle, &gXenIoProtocolGuid,
- Dev->This->DriverBindingHandle, ChildData->Handle);
+ Status = gBS->CloseProtocol (
+ Dev->ControllerHandle,
+ &gXenIoProtocolGuid,
+ Dev->This->DriverBindingHandle,
+ ChildData->Handle
+ );
ASSERT_EFI_ERROR (Status);
Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildData->Handle,
- &gEfiDevicePathProtocolGuid, ChildData->DevicePath,
- &gXenBusProtocolGuid, &ChildData->XenBusIo,
- NULL);
+ ChildData->Handle,
+ &gEfiDevicePathProtocolGuid,
+ ChildData->DevicePath,
+ &gXenBusProtocolGuid,
+ &ChildData->XenBusIo,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
- FreePool ((VOID*)ChildData->XenBusIo.Type);
- FreePool ((VOID*)ChildData->XenBusIo.Node);
- FreePool ((VOID*)ChildData->XenBusIo.Backend);
+ FreePool ((VOID *)ChildData->XenBusIo.Type);
+ FreePool ((VOID *)ChildData->XenBusIo.Node);
+ FreePool ((VOID *)ChildData->XenBusIo.Backend);
FreePool (ChildData->DevicePath);
RemoveEntryList (&ChildData->Link);
FreePool (ChildData);
}
+
if (NumberOfChildren > 0) {
return EFI_SUCCESS;
}
@@ -473,10 +501,18 @@ XenBusDxeDriverBindingStop (
XenStoreDeinit (Dev);
XenGrantTableDeinit (Dev);
- gBS->CloseProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle, ControllerHandle);
- gBS->CloseProtocol (ControllerHandle, &gXenIoProtocolGuid,
- This->DriverBindingHandle, ControllerHandle);
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gXenIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
mMyDevice = NULL;
FreePool (Dev);
diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.h b/OvmfPkg/XenBusDxe/XenBusDxe.h
index b1dcc3549c..8b32505cb0 100644
--- a/OvmfPkg/XenBusDxe/XenBusDxe.h
+++ b/OvmfPkg/XenBusDxe/XenBusDxe.h
@@ -24,38 +24,32 @@
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
-
//
// UEFI Driver Model Protocols
//
#include <Protocol/DriverBinding.h>
-
//
// Consumed Protocols
//
#include <Protocol/XenIo.h>
-
//
// Produced Protocols
//
#include <Protocol/XenBus.h>
-
//
// Driver Version
//
#define XENBUS_DXE_VERSION 0x00000010
-
//
// Protocol instances
//
-extern EFI_DRIVER_BINDING_PROTOCOL gXenBusDxeDriverBinding;
+extern EFI_DRIVER_BINDING_PROTOCOL gXenBusDxeDriverBinding;
extern EFI_COMPONENT_NAME2_PROTOCOL gXenBusDxeComponentName2;
-extern EFI_COMPONENT_NAME_PROTOCOL gXenBusDxeComponentName;
-
+extern EFI_COMPONENT_NAME_PROTOCOL gXenBusDxeComponentName;
//
// Include files with function prototypes
@@ -68,32 +62,32 @@ extern EFI_COMPONENT_NAME_PROTOCOL gXenBusDxeComponentName;
//
#include <IndustryStandard/Xen/xen.h>
-typedef struct _XENBUS_DEVICE_PATH XENBUS_DEVICE_PATH;
-typedef struct _XENBUS_DEVICE XENBUS_DEVICE;
+typedef struct _XENBUS_DEVICE_PATH XENBUS_DEVICE_PATH;
+typedef struct _XENBUS_DEVICE XENBUS_DEVICE;
// Have the state of the driver.
-#define XENBUS_DEVICE_SIGNATURE SIGNATURE_32 ('X','B','s','t')
+#define XENBUS_DEVICE_SIGNATURE SIGNATURE_32 ('X','B','s','t')
struct _XENBUS_DEVICE {
- UINT32 Signature;
- EFI_DRIVER_BINDING_PROTOCOL *This;
- EFI_HANDLE ControllerHandle;
- XENIO_PROTOCOL *XenIo;
- EFI_EVENT ExitBootEvent;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- LIST_ENTRY ChildList;
-
- shared_info_t *SharedInfo;
+ UINT32 Signature;
+ EFI_DRIVER_BINDING_PROTOCOL *This;
+ EFI_HANDLE ControllerHandle;
+ XENIO_PROTOCOL *XenIo;
+ EFI_EVENT ExitBootEvent;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ LIST_ENTRY ChildList;
+
+ shared_info_t *SharedInfo;
};
// There is one of this struct allocated for every child.
-#define XENBUS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('X', 'B', 'p', 'd')
+#define XENBUS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('X', 'B', 'p', 'd')
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link;
- EFI_HANDLE Handle;
- XENBUS_PROTOCOL XenBusIo;
- XENBUS_DEVICE *Dev;
- XENBUS_DEVICE_PATH *DevicePath;
+ UINTN Signature;
+ LIST_ENTRY Link;
+ EFI_HANDLE Handle;
+ XENBUS_PROTOCOL XenBusIo;
+ XENBUS_DEVICE *Dev;
+ XENBUS_DEVICE_PATH *DevicePath;
} XENBUS_PRIVATE_DATA;
#define XENBUS_PRIVATE_DATA_FROM_THIS(a) \
@@ -116,13 +110,13 @@ typedef struct {
INT32
EFIAPI
TestAndClearBit (
- IN INT32 Bit,
- IN VOID *Address
+ IN INT32 Bit,
+ IN VOID *Address
);
-CHAR8*
+CHAR8 *
AsciiStrDup (
- IN CONST CHAR8* Str
+ IN CONST CHAR8 *Str
);
#endif
diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c
index e5cca108e0..0241cfda48 100644
--- a/OvmfPkg/XenBusDxe/XenStore.c
+++ b/OvmfPkg/XenBusDxe/XenStore.c
@@ -52,46 +52,44 @@
//
typedef struct {
- CONST VOID *Data;
- UINT32 Len;
+ CONST VOID *Data;
+ UINT32 Len;
} WRITE_REQUEST;
/* Register callback to watch subtree (node) in the XenStore. */
-#define XENSTORE_WATCH_SIGNATURE SIGNATURE_32 ('X','S','w','a')
-struct _XENSTORE_WATCH
-{
- UINT32 Signature;
- LIST_ENTRY Link;
+#define XENSTORE_WATCH_SIGNATURE SIGNATURE_32 ('X','S','w','a')
+struct _XENSTORE_WATCH {
+ UINT32 Signature;
+ LIST_ENTRY Link;
/* Path being watched. */
- CHAR8 *Node;
+ CHAR8 *Node;
};
#define XENSTORE_WATCH_FROM_LINK(l) \
CR (l, XENSTORE_WATCH, Link, XENSTORE_WATCH_SIGNATURE)
-
/**
* Structure capturing messages received from the XenStore service.
*/
-#define XENSTORE_MESSAGE_SIGNATURE SIGNATURE_32 ('X', 'S', 's', 'm')
+#define XENSTORE_MESSAGE_SIGNATURE SIGNATURE_32 ('X', 'S', 's', 'm')
typedef struct {
- UINT32 Signature;
- LIST_ENTRY Link;
+ UINT32 Signature;
+ LIST_ENTRY Link;
- struct xsd_sockmsg Header;
+ struct xsd_sockmsg Header;
union {
/* Queued replies. */
struct {
- CHAR8 *Body;
+ CHAR8 *Body;
} Reply;
/* Queued watch events. */
struct {
- XENSTORE_WATCH *Handle;
- CONST CHAR8 **Vector;
- UINT32 VectorSize;
+ XENSTORE_WATCH *Handle;
+ CONST CHAR8 **Vector;
+ UINT32 VectorSize;
} Watch;
} u;
} XENSTORE_MESSAGE;
@@ -106,9 +104,9 @@ typedef struct {
* Pointer to shared memory communication structures allowing us
* to communicate with the XenStore service.
*/
- struct xenstore_domain_interface *XenStore;
+ struct xenstore_domain_interface *XenStore;
- XENBUS_DEVICE *Dev;
+ XENBUS_DEVICE *Dev;
/**
* A list of replies to our requests.
@@ -120,42 +118,41 @@ typedef struct {
*
* /note Only one requesting context can be active at a time.
*/
- LIST_ENTRY ReplyList;
+ LIST_ENTRY ReplyList;
/** Lock protecting the reply list. */
- EFI_LOCK ReplyLock;
+ EFI_LOCK ReplyLock;
/**
* List of registered watches.
*/
- LIST_ENTRY RegisteredWatches;
+ LIST_ENTRY RegisteredWatches;
/** Lock protecting the registered watches list. */
- EFI_LOCK RegisteredWatchesLock;
+ EFI_LOCK RegisteredWatchesLock;
/**
* List of pending watch callback events.
*/
- LIST_ENTRY WatchEvents;
+ LIST_ENTRY WatchEvents;
/** Lock protecting the watch callback list. */
- EFI_LOCK WatchEventsLock;
+ EFI_LOCK WatchEventsLock;
/**
* The event channel for communicating with the
* XenStore service.
*/
- evtchn_port_t EventChannel;
+ evtchn_port_t EventChannel;
/** Handle for XenStore events. */
- EFI_EVENT EventChannelEvent;
+ EFI_EVENT EventChannelEvent;
} XENSTORE_PRIVATE;
//
// Global Data
//
-static XENSTORE_PRIVATE xs;
-
+static XENSTORE_PRIVATE xs;
//
// Private Utility Functions
@@ -174,18 +171,19 @@ static XENSTORE_PRIVATE xs;
STATIC
UINT32
ExtractStrings (
- IN CONST CHAR8 *Strings,
- IN UINTN Len,
- OUT CONST CHAR8 **Dst OPTIONAL
+ IN CONST CHAR8 *Strings,
+ IN UINTN Len,
+ OUT CONST CHAR8 **Dst OPTIONAL
)
{
- UINT32 Num = 0;
- CONST CHAR8 *Ptr;
+ UINT32 Num = 0;
+ CONST CHAR8 *Ptr;
for (Ptr = Strings; Ptr < Strings + Len; Ptr += AsciiStrSize (Ptr)) {
if (Dst != NULL) {
*Dst++ = Ptr;
}
+
Num++;
}
@@ -217,10 +215,10 @@ Split (
OUT UINT32 *NumPtr
)
{
- CONST CHAR8 **Dst;
+ CONST CHAR8 **Dst;
- ASSERT(NumPtr != NULL);
- ASSERT(Strings != NULL);
+ ASSERT (NumPtr != NULL);
+ ASSERT (Strings != NULL);
/* Protect against unterminated buffers. */
if (Len > 0) {
@@ -232,11 +230,11 @@ Split (
/* Transfer to one big alloc for easy freeing by the caller. */
Dst = AllocatePool (*NumPtr * sizeof (CHAR8 *) + Len);
- CopyMem ((VOID*)&Dst[*NumPtr], Strings, Len);
+ CopyMem ((VOID *)&Dst[*NumPtr], Strings, Len);
FreePool (Strings);
/* Extract pointers to newly allocated array. */
- Strings = (CHAR8 *) &Dst[*NumPtr];
+ Strings = (CHAR8 *)&Dst[*NumPtr];
ExtractStrings (Strings, Len, Dst);
return (Dst);
@@ -253,23 +251,26 @@ Split (
STATIC
XENSTORE_WATCH *
XenStoreFindWatch (
- IN CONST CHAR8 *Token
+ IN CONST CHAR8 *Token
)
{
- XENSTORE_WATCH *Watch, *WantedWatch;
- LIST_ENTRY *Entry;
+ XENSTORE_WATCH *Watch, *WantedWatch;
+ LIST_ENTRY *Entry;
- WantedWatch = (VOID *) AsciiStrHexToUintn (Token);
+ WantedWatch = (VOID *)AsciiStrHexToUintn (Token);
if (IsListEmpty (&xs.RegisteredWatches)) {
return NULL;
}
+
for (Entry = GetFirstNode (&xs.RegisteredWatches);
!IsNull (&xs.RegisteredWatches, Entry);
- Entry = GetNextNode (&xs.RegisteredWatches, Entry)) {
+ Entry = GetNextNode (&xs.RegisteredWatches, Entry))
+ {
Watch = XENSTORE_WATCH_FROM_LINK (Entry);
- if (Watch == WantedWatch)
+ if (Watch == WantedWatch) {
return Watch;
+ }
}
return NULL;
@@ -282,16 +283,16 @@ XenStoreFindWatch (
CHAR8 *
XenStoreJoin (
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node
)
{
- CHAR8 *Buf;
- UINTN BufSize;
+ CHAR8 *Buf;
+ UINTN BufSize;
/* +1 for '/' and +1 for '\0' */
BufSize = AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2;
- Buf = AllocatePool (BufSize);
+ Buf = AllocatePool (BufSize);
ASSERT (Buf != NULL);
if (Node[0] == '\0') {
@@ -322,8 +323,8 @@ XenStoreJoin (
STATIC
BOOLEAN
XenStoreCheckIndexes (
- XENSTORE_RING_IDX Cons,
- XENSTORE_RING_IDX Prod
+ XENSTORE_RING_IDX Cons,
+ XENSTORE_RING_IDX Prod
)
{
return ((Prod - Cons) <= XENSTORE_RING_SIZE);
@@ -343,17 +344,19 @@ XenStoreCheckIndexes (
STATIC
VOID *
XenStoreGetOutputChunk (
- IN XENSTORE_RING_IDX Cons,
- IN XENSTORE_RING_IDX Prod,
- IN CHAR8 *Buffer,
- OUT UINT32 *LenPtr
+ IN XENSTORE_RING_IDX Cons,
+ IN XENSTORE_RING_IDX Prod,
+ IN CHAR8 *Buffer,
+ OUT UINT32 *LenPtr
)
{
- UINT32 Len;
+ UINT32 Len;
+
Len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX (Prod);
if ((XENSTORE_RING_SIZE - (Prod - Cons)) < Len) {
Len = XENSTORE_RING_SIZE - (Prod - Cons);
}
+
*LenPtr = Len;
return (Buffer + MASK_XENSTORE_IDX (Prod));
}
@@ -372,18 +375,19 @@ XenStoreGetOutputChunk (
STATIC
CONST VOID *
XenStoreGetInputChunk (
- IN XENSTORE_RING_IDX Cons,
- IN XENSTORE_RING_IDX Prod,
- IN CONST CHAR8 *Buffer,
- OUT UINT32 *LenPtr
+ IN XENSTORE_RING_IDX Cons,
+ IN XENSTORE_RING_IDX Prod,
+ IN CONST CHAR8 *Buffer,
+ OUT UINT32 *LenPtr
)
{
- UINT32 Len;
+ UINT32 Len;
Len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX (Cons);
if ((Prod - Cons) < Len) {
Len = Prod - Cons;
}
+
*LenPtr = Len;
return (Buffer + MASK_XENSTORE_IDX (Cons));
}
@@ -401,26 +405,27 @@ XenStoreGetInputChunk (
STATIC
EFI_STATUS
XenStoreWaitForEvent (
- IN EFI_EVENT Event,
- IN UINT64 Timeout
+ IN EFI_EVENT Event,
+ IN UINT64 Timeout
)
{
- UINTN Index;
- EFI_STATUS Status;
- EFI_EVENT TimerEvent;
- EFI_EVENT WaitList[2];
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_EVENT TimerEvent;
+ EFI_EVENT WaitList[2];
gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);
gBS->SetTimer (TimerEvent, TimerRelative, Timeout);
WaitList[0] = xs.EventChannelEvent;
WaitList[1] = TimerEvent;
- Status = gBS->WaitForEvent (2, WaitList, &Index);
+ Status = gBS->WaitForEvent (2, WaitList, &Index);
ASSERT (Status != EFI_INVALID_PARAMETER);
gBS->CloseEvent (TimerEvent);
if (Status == EFI_UNSUPPORTED) {
return EFI_SUCCESS;
}
+
if (Index == 1) {
return EFI_TIMEOUT;
} else {
@@ -442,16 +447,16 @@ XenStoreWaitForEvent (
STATIC
XENSTORE_STATUS
XenStoreWriteStore (
- IN CONST VOID *DataPtr,
- IN UINT32 Len
+ IN CONST VOID *DataPtr,
+ IN UINT32 Len
)
{
- XENSTORE_RING_IDX Cons, Prod;
- CONST CHAR8 *Data = (CONST CHAR8 *)DataPtr;
+ XENSTORE_RING_IDX Cons, Prod;
+ CONST CHAR8 *Data = (CONST CHAR8 *)DataPtr;
while (Len != 0) {
- void *Dest;
- UINT32 Available;
+ void *Dest;
+ UINT32 Available;
Cons = xs.XenStore->req_cons;
Prod = xs.XenStore->req_prod;
@@ -462,13 +467,16 @@ XenStoreWriteStore (
* Note that the events from both queues are combined, so being woken
* does not guarantee that data exist in the read ring.
*/
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = XenStoreWaitForEvent (xs.EventChannelEvent,
- EFI_TIMER_PERIOD_SECONDS (1));
+ Status = XenStoreWaitForEvent (
+ xs.EventChannelEvent,
+ EFI_TIMER_PERIOD_SECONDS (1)
+ );
if (Status == EFI_TIMEOUT) {
DEBUG ((DEBUG_WARN, "XenStore Write, waiting for a ring event.\n"));
}
+
continue;
}
@@ -485,7 +493,7 @@ XenStoreWriteStore (
CopyMem (Dest, Data, Available);
Data += Available;
- Len -= Available;
+ Len -= Available;
/*
* The store to the producer index, which indicates
@@ -521,16 +529,16 @@ XenStoreWriteStore (
STATIC
XENSTORE_STATUS
XenStoreReadStore (
- OUT VOID *DataPtr,
- IN UINT32 Len
+ OUT VOID *DataPtr,
+ IN UINT32 Len
)
{
- XENSTORE_RING_IDX Cons, Prod;
- CHAR8 *Data = (CHAR8 *) DataPtr;
+ XENSTORE_RING_IDX Cons, Prod;
+ CHAR8 *Data = (CHAR8 *)DataPtr;
while (Len != 0) {
- UINT32 Available;
- CONST CHAR8 *Src;
+ UINT32 Available;
+ CONST CHAR8 *Src;
Cons = xs.XenStore->rsp_cons;
Prod = xs.XenStore->rsp_prod;
@@ -541,13 +549,16 @@ XenStoreReadStore (
* Note that the events from both queues are combined, so being woken
* does not guarantee that data exist in the read ring.
*/
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = XenStoreWaitForEvent (xs.EventChannelEvent,
- EFI_TIMER_PERIOD_SECONDS (1));
+ Status = XenStoreWaitForEvent (
+ xs.EventChannelEvent,
+ EFI_TIMER_PERIOD_SECONDS (1)
+ );
if (Status == EFI_TIMEOUT) {
DEBUG ((DEBUG_WARN, "XenStore Read, waiting for a ring event.\n"));
}
+
continue;
}
@@ -570,7 +581,7 @@ XenStoreReadStore (
CopyMem (Data, Src, Available);
Data += Available;
- Len -= Available;
+ Len -= Available;
/*
* Insure that the producer of this ring does not see
@@ -608,20 +619,20 @@ XenStoreProcessMessage (
VOID
)
{
- XENSTORE_MESSAGE *Message;
- CHAR8 *Body;
- XENSTORE_STATUS Status;
+ XENSTORE_MESSAGE *Message;
+ CHAR8 *Body;
+ XENSTORE_STATUS Status;
- Message = AllocateZeroPool (sizeof (XENSTORE_MESSAGE));
+ Message = AllocateZeroPool (sizeof (XENSTORE_MESSAGE));
Message->Signature = XENSTORE_MESSAGE_SIGNATURE;
- Status = XenStoreReadStore (&Message->Header, sizeof (Message->Header));
+ Status = XenStoreReadStore (&Message->Header, sizeof (Message->Header));
if (Status != XENSTORE_STATUS_SUCCESS) {
FreePool (Message);
DEBUG ((DEBUG_ERROR, "XenStore: Error read store (%d)\n", Status));
return Status;
}
- Body = AllocatePool (Message->Header.len + 1);
+ Body = AllocatePool (Message->Header.len + 1);
Status = XenStoreReadStore (Body, Message->Header.len);
if (Status != XENSTORE_STATUS_SUCCESS) {
FreePool (Body);
@@ -629,27 +640,38 @@ XenStoreProcessMessage (
DEBUG ((DEBUG_ERROR, "XenStore: Error read store (%d)\n", Status));
return Status;
}
+
Body[Message->Header.len] = '\0';
if (Message->Header.type == XS_WATCH_EVENT) {
- Message->u.Watch.Vector = Split(Body, Message->Header.len,
- &Message->u.Watch.VectorSize);
+ Message->u.Watch.Vector = Split (
+ Body,
+ Message->Header.len,
+ &Message->u.Watch.VectorSize
+ );
EfiAcquireLock (&xs.RegisteredWatchesLock);
Message->u.Watch.Handle =
XenStoreFindWatch (Message->u.Watch.Vector[XS_WATCH_TOKEN]);
- DEBUG ((DEBUG_INFO, "XenStore: Watch event %a\n",
- Message->u.Watch.Vector[XS_WATCH_TOKEN]));
+ DEBUG ((
+ DEBUG_INFO,
+ "XenStore: Watch event %a\n",
+ Message->u.Watch.Vector[XS_WATCH_TOKEN]
+ ));
if (Message->u.Watch.Handle != NULL) {
EfiAcquireLock (&xs.WatchEventsLock);
InsertHeadList (&xs.WatchEvents, &Message->Link);
EfiReleaseLock (&xs.WatchEventsLock);
} else {
- DEBUG ((DEBUG_WARN, "XenStore: Watch handle %a not found\n",
- Message->u.Watch.Vector[XS_WATCH_TOKEN]));
- FreePool((VOID*)Message->u.Watch.Vector);
- FreePool(Message);
+ DEBUG ((
+ DEBUG_WARN,
+ "XenStore: Watch handle %a not found\n",
+ Message->u.Watch.Vector[XS_WATCH_TOKEN]
+ ));
+ FreePool ((VOID *)Message->u.Watch.Vector);
+ FreePool (Message);
}
+
EfiReleaseLock (&xs.RegisteredWatchesLock);
} else {
Message->u.Reply.Body = Body;
@@ -676,41 +698,42 @@ XenStoreProcessMessage (
**/
typedef struct {
- XENSTORE_STATUS Status;
- CONST CHAR8 *ErrorStr;
+ XENSTORE_STATUS Status;
+ CONST CHAR8 *ErrorStr;
} XenStoreErrors;
-static XenStoreErrors gXenStoreErrors[] = {
- { XENSTORE_STATUS_EINVAL, "EINVAL" },
- { XENSTORE_STATUS_EACCES, "EACCES" },
- { XENSTORE_STATUS_EEXIST, "EEXIST" },
- { XENSTORE_STATUS_EISDIR, "EISDIR" },
- { XENSTORE_STATUS_ENOENT, "ENOENT" },
- { XENSTORE_STATUS_ENOMEM, "ENOMEM" },
- { XENSTORE_STATUS_ENOSPC, "ENOSPC" },
- { XENSTORE_STATUS_EIO, "EIO" },
+static XenStoreErrors gXenStoreErrors[] = {
+ { XENSTORE_STATUS_EINVAL, "EINVAL" },
+ { XENSTORE_STATUS_EACCES, "EACCES" },
+ { XENSTORE_STATUS_EEXIST, "EEXIST" },
+ { XENSTORE_STATUS_EISDIR, "EISDIR" },
+ { XENSTORE_STATUS_ENOENT, "ENOENT" },
+ { XENSTORE_STATUS_ENOMEM, "ENOMEM" },
+ { XENSTORE_STATUS_ENOSPC, "ENOSPC" },
+ { XENSTORE_STATUS_EIO, "EIO" },
{ XENSTORE_STATUS_ENOTEMPTY, "ENOTEMPTY" },
- { XENSTORE_STATUS_ENOSYS, "ENOSYS" },
- { XENSTORE_STATUS_EROFS, "EROFS" },
- { XENSTORE_STATUS_EBUSY, "EBUSY" },
- { XENSTORE_STATUS_EAGAIN, "EAGAIN" },
- { XENSTORE_STATUS_EISCONN, "EISCONN" },
- { XENSTORE_STATUS_E2BIG, "E2BIG" }
+ { XENSTORE_STATUS_ENOSYS, "ENOSYS" },
+ { XENSTORE_STATUS_EROFS, "EROFS" },
+ { XENSTORE_STATUS_EBUSY, "EBUSY" },
+ { XENSTORE_STATUS_EAGAIN, "EAGAIN" },
+ { XENSTORE_STATUS_EISCONN, "EISCONN" },
+ { XENSTORE_STATUS_E2BIG, "E2BIG" }
};
STATIC
XENSTORE_STATUS
XenStoreGetError (
- CONST CHAR8 *ErrorStr
+ CONST CHAR8 *ErrorStr
)
{
- UINT32 Index;
+ UINT32 Index;
- for (Index = 0; Index < ARRAY_SIZE(gXenStoreErrors); Index++) {
+ for (Index = 0; Index < ARRAY_SIZE (gXenStoreErrors); Index++) {
if (!AsciiStrCmp (ErrorStr, gXenStoreErrors[Index].ErrorStr)) {
return gXenStoreErrors[Index].Status;
}
}
+
DEBUG ((DEBUG_WARN, "XenStore gave unknown error %a\n", ErrorStr));
return XENSTORE_STATUS_EINVAL;
}
@@ -725,26 +748,30 @@ XenStoreGetError (
STATIC
XENSTORE_STATUS
XenStoreReadReply (
- OUT enum xsd_sockmsg_type *TypePtr,
- OUT UINT32 *LenPtr OPTIONAL,
- OUT VOID **Result
+ OUT enum xsd_sockmsg_type *TypePtr,
+ OUT UINT32 *LenPtr OPTIONAL,
+ OUT VOID **Result
)
{
- XENSTORE_MESSAGE *Message;
- LIST_ENTRY *Entry;
- CHAR8 *Body;
+ XENSTORE_MESSAGE *Message;
+ LIST_ENTRY *Entry;
+ CHAR8 *Body;
while (IsListEmpty (&xs.ReplyList)) {
- XENSTORE_STATUS Status;
+ XENSTORE_STATUS Status;
Status = XenStoreProcessMessage ();
- if (Status != XENSTORE_STATUS_SUCCESS && Status != XENSTORE_STATUS_EAGAIN) {
- DEBUG ((DEBUG_ERROR, "XenStore, error while reading the ring (%d).",
- Status));
+ if ((Status != XENSTORE_STATUS_SUCCESS) && (Status != XENSTORE_STATUS_EAGAIN)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "XenStore, error while reading the ring (%d).",
+ Status
+ ));
return Status;
}
}
+
EfiAcquireLock (&xs.ReplyLock);
- Entry = GetFirstNode (&xs.ReplyList);
+ Entry = GetFirstNode (&xs.ReplyList);
Message = XENSTORE_MESSAGE_FROM_LINK (Entry);
RemoveEntryList (Entry);
EfiReleaseLock (&xs.ReplyLock);
@@ -753,6 +780,7 @@ XenStoreReadReply (
if (LenPtr != NULL) {
*LenPtr = Message->Header.len;
}
+
Body = Message->u.Reply.Body;
FreePool (Message);
@@ -776,27 +804,28 @@ XenStoreReadReply (
STATIC
XENSTORE_STATUS
XenStoreTalkv (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN enum xsd_sockmsg_type RequestType,
- IN CONST WRITE_REQUEST *WriteRequest,
- IN UINT32 NumRequests,
- OUT UINT32 *LenPtr OPTIONAL,
- OUT VOID **ResultPtr OPTIONAL
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN enum xsd_sockmsg_type RequestType,
+ IN CONST WRITE_REQUEST *WriteRequest,
+ IN UINT32 NumRequests,
+ OUT UINT32 *LenPtr OPTIONAL,
+ OUT VOID **ResultPtr OPTIONAL
)
{
- struct xsd_sockmsg Message;
- void *Return = NULL;
- UINT32 Index;
- XENSTORE_STATUS Status;
+ struct xsd_sockmsg Message;
+ void *Return = NULL;
+ UINT32 Index;
+ XENSTORE_STATUS Status;
if (Transaction == XST_NIL) {
Message.tx_id = 0;
} else {
Message.tx_id = Transaction->Id;
}
+
Message.req_id = 0;
- Message.type = RequestType;
- Message.len = 0;
+ Message.type = RequestType;
+ Message.len = 0;
for (Index = 0; Index < NumRequests; Index++) {
Message.len += WriteRequest[Index].Len;
}
@@ -859,20 +888,26 @@ Error:
STATIC
XENSTORE_STATUS
XenStoreSingle (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN enum xsd_sockmsg_type RequestType,
- IN CONST CHAR8 *Body,
- OUT UINT32 *LenPtr OPTIONAL,
- OUT VOID **Result OPTIONAL
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN enum xsd_sockmsg_type RequestType,
+ IN CONST CHAR8 *Body,
+ OUT UINT32 *LenPtr OPTIONAL,
+ OUT VOID **Result OPTIONAL
)
{
- WRITE_REQUEST WriteRequest;
-
- WriteRequest.Data = (VOID *) Body;
- WriteRequest.Len = (UINT32)AsciiStrSize (Body);
-
- return XenStoreTalkv (Transaction, RequestType, &WriteRequest, 1,
- LenPtr, Result);
+ WRITE_REQUEST WriteRequest;
+
+ WriteRequest.Data = (VOID *)Body;
+ WriteRequest.Len = (UINT32)AsciiStrSize (Body);
+
+ return XenStoreTalkv (
+ Transaction,
+ RequestType,
+ &WriteRequest,
+ 1,
+ LenPtr,
+ Result
+ );
}
//
@@ -891,16 +926,16 @@ XenStoreSingle (
STATIC
XENSTORE_STATUS
XenStoreWatch (
- CONST CHAR8 *Path,
- CONST CHAR8 *Token
+ CONST CHAR8 *Path,
+ CONST CHAR8 *Token
)
{
- WRITE_REQUEST WriteRequest[2];
+ WRITE_REQUEST WriteRequest[2];
- WriteRequest[0].Data = (VOID *) Path;
- WriteRequest[0].Len = (UINT32)AsciiStrSize (Path);
- WriteRequest[1].Data = (VOID *) Token;
- WriteRequest[1].Len = (UINT32)AsciiStrSize (Token);
+ WriteRequest[0].Data = (VOID *)Path;
+ WriteRequest[0].Len = (UINT32)AsciiStrSize (Path);
+ WriteRequest[1].Data = (VOID *)Token;
+ WriteRequest[1].Len = (UINT32)AsciiStrSize (Token);
return XenStoreTalkv (XST_NIL, XS_WATCH, WriteRequest, 2, NULL, NULL);
}
@@ -917,16 +952,16 @@ XenStoreWatch (
STATIC
XENSTORE_STATUS
XenStoreUnwatch (
- CONST CHAR8 *Path,
- CONST CHAR8 *Token
+ CONST CHAR8 *Path,
+ CONST CHAR8 *Token
)
{
- WRITE_REQUEST WriteRequest[2];
+ WRITE_REQUEST WriteRequest[2];
- WriteRequest[0].Data = (VOID *) Path;
- WriteRequest[0].Len = (UINT32)AsciiStrSize (Path);
- WriteRequest[1].Data = (VOID *) Token;
- WriteRequest[1].Len = (UINT32)AsciiStrSize (Token);
+ WriteRequest[0].Data = (VOID *)Path;
+ WriteRequest[0].Len = (UINT32)AsciiStrSize (Path);
+ WriteRequest[1].Data = (VOID *)Token;
+ WriteRequest[1].Len = (UINT32)AsciiStrSize (Token);
return XenStoreTalkv (XST_NIL, XS_UNWATCH, WriteRequest, 2, NULL, NULL);
}
@@ -934,38 +969,42 @@ XenStoreUnwatch (
STATIC
XENSTORE_STATUS
XenStoreWaitWatch (
- VOID *Token
+ VOID *Token
)
{
- XENSTORE_MESSAGE *Message;
- LIST_ENTRY *Entry = NULL;
- LIST_ENTRY *Last = NULL;
- XENSTORE_STATUS Status;
+ XENSTORE_MESSAGE *Message;
+ LIST_ENTRY *Entry = NULL;
+ LIST_ENTRY *Last = NULL;
+ XENSTORE_STATUS Status;
while (TRUE) {
EfiAcquireLock (&xs.WatchEventsLock);
if (IsListEmpty (&xs.WatchEvents) ||
- Last == GetFirstNode (&xs.WatchEvents)) {
+ (Last == GetFirstNode (&xs.WatchEvents)))
+ {
EfiReleaseLock (&xs.WatchEventsLock);
Status = XenStoreProcessMessage ();
- if (Status != XENSTORE_STATUS_SUCCESS && Status != XENSTORE_STATUS_EAGAIN) {
+ if ((Status != XENSTORE_STATUS_SUCCESS) && (Status != XENSTORE_STATUS_EAGAIN)) {
return Status;
}
+
continue;
}
for (Entry = GetFirstNode (&xs.WatchEvents);
Entry != Last && !IsNull (&xs.WatchEvents, Entry);
- Entry = GetNextNode (&xs.WatchEvents, Entry)) {
+ Entry = GetNextNode (&xs.WatchEvents, Entry))
+ {
Message = XENSTORE_MESSAGE_FROM_LINK (Entry);
if (Message->u.Watch.Handle == Token) {
RemoveEntryList (Entry);
EfiReleaseLock (&xs.WatchEventsLock);
- FreePool((VOID*)Message->u.Watch.Vector);
- FreePool(Message);
+ FreePool ((VOID *)Message->u.Watch.Vector);
+ FreePool (Message);
return XENSTORE_STATUS_SUCCESS;
}
}
+
Last = GetFirstNode (&xs.WatchEvents);
EfiReleaseLock (&xs.WatchEventsLock);
}
@@ -974,11 +1013,12 @@ XenStoreWaitWatch (
VOID
EFIAPI
NotifyEventChannelCheckForEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- XENSTORE_PRIVATE *xsp;
+ XENSTORE_PRIVATE *xsp;
+
xsp = (XENSTORE_PRIVATE *)Context;
if (TestAndClearBit (xsp->EventChannel, xsp->Dev->SharedInfo->evtchn_pending)) {
gBS->SignalEvent (Event);
@@ -993,30 +1033,42 @@ NotifyEventChannelCheckForEvent (
STATIC
EFI_STATUS
XenStoreInitComms (
- XENSTORE_PRIVATE *xsp
+ XENSTORE_PRIVATE *xsp
)
{
- EFI_STATUS Status;
- EFI_EVENT TimerEvent;
- struct xenstore_domain_interface *XenStore = xsp->XenStore;
+ EFI_STATUS Status;
+ EFI_EVENT TimerEvent;
+ struct xenstore_domain_interface *XenStore = xsp->XenStore;
Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);
- Status = gBS->SetTimer (TimerEvent, TimerRelative,
- EFI_TIMER_PERIOD_SECONDS (5));
+ Status = gBS->SetTimer (
+ TimerEvent,
+ TimerRelative,
+ EFI_TIMER_PERIOD_SECONDS (5)
+ );
while (XenStore->rsp_prod != XenStore->rsp_cons) {
Status = gBS->CheckEvent (TimerEvent);
if (!EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN, "XENSTORE response ring is not quiescent "
- "(%08x:%08x): fixing up\n",
- XenStore->rsp_cons, XenStore->rsp_prod));
+ DEBUG ((
+ DEBUG_WARN,
+ "XENSTORE response ring is not quiescent "
+ "(%08x:%08x): fixing up\n",
+ XenStore->rsp_cons,
+ XenStore->rsp_prod
+ ));
XenStore->rsp_cons = XenStore->rsp_prod;
}
}
+
gBS->CloseEvent (TimerEvent);
- Status = gBS->CreateEvent (EVT_NOTIFY_WAIT, TPL_NOTIFY,
- NotifyEventChannelCheckForEvent, xsp,
- &xsp->EventChannelEvent);
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_WAIT,
+ TPL_NOTIFY,
+ NotifyEventChannelCheckForEvent,
+ xsp,
+ &xsp->EventChannelEvent
+ );
ASSERT_EFI_ERROR (Status);
return Status;
@@ -1031,23 +1083,28 @@ XenStoreInitComms (
**/
EFI_STATUS
XenStoreInit (
- XENBUS_DEVICE *Dev
+ XENBUS_DEVICE *Dev
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
/**
* The HVM guest pseudo-physical frame number. This is Xen's mapping
* of the true machine frame number into our "physical address space".
*/
- UINTN XenStoreGpfn;
+ UINTN XenStoreGpfn;
xs.Dev = Dev;
xs.EventChannel = (evtchn_port_t)XenHypercallHvmGetParam (HVM_PARAM_STORE_EVTCHN);
- XenStoreGpfn = (UINTN)XenHypercallHvmGetParam (HVM_PARAM_STORE_PFN);
- xs.XenStore = (VOID *) (XenStoreGpfn << EFI_PAGE_SHIFT);
- DEBUG ((DEBUG_INFO, "XenBusInit: XenBus rings @%p, event channel %x\n",
- xs.XenStore, xs.EventChannel));
+ XenStoreGpfn = (UINTN)XenHypercallHvmGetParam (HVM_PARAM_STORE_PFN);
+ xs.XenStore = (VOID *)(XenStoreGpfn << EFI_PAGE_SHIFT);
+ DEBUG ((
+ DEBUG_INFO,
+ "XenBusInit: XenBus rings @%p, event channel %x\n",
+ xs.XenStore,
+ xs.EventChannel
+ ));
InitializeListHead (&xs.ReplyList);
InitializeListHead (&xs.WatchEvents);
@@ -1065,7 +1122,7 @@ XenStoreInit (
VOID
XenStoreDeinit (
- IN XENBUS_DEVICE *Dev
+ IN XENBUS_DEVICE *Dev
)
{
//
@@ -1074,8 +1131,8 @@ XenStoreDeinit (
// it is stopped.
//
if (!IsListEmpty (&xs.RegisteredWatches)) {
- XENSTORE_WATCH *Watch;
- LIST_ENTRY *Entry;
+ XENSTORE_WATCH *Watch;
+ LIST_ENTRY *Entry;
DEBUG ((DEBUG_WARN, "XenStore: RegisteredWatches is not empty, cleaning up..."));
Entry = GetFirstNode (&xs.RegisteredWatches);
while (!IsNull (&xs.RegisteredWatches, Entry)) {
@@ -1091,25 +1148,25 @@ XenStoreDeinit (
// having cleanup the list RegisteredWatches.
//
if (!IsListEmpty (&xs.WatchEvents)) {
- LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry;
DEBUG ((DEBUG_WARN, "XenStore: WatchEvents is not empty, cleaning up..."));
Entry = GetFirstNode (&xs.WatchEvents);
while (!IsNull (&xs.WatchEvents, Entry)) {
- XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry);
+ XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry);
Entry = GetNextNode (&xs.WatchEvents, Entry);
RemoveEntryList (&Message->Link);
- FreePool ((VOID*)Message->u.Watch.Vector);
+ FreePool ((VOID *)Message->u.Watch.Vector);
FreePool (Message);
}
}
if (!IsListEmpty (&xs.ReplyList)) {
- XENSTORE_MESSAGE *Message;
- LIST_ENTRY *Entry;
+ XENSTORE_MESSAGE *Message;
+ LIST_ENTRY *Entry;
Entry = GetFirstNode (&xs.ReplyList);
while (!IsNull (&xs.ReplyList, Entry)) {
Message = XENSTORE_MESSAGE_FROM_LINK (Entry);
- Entry = GetNextNode (&xs.ReplyList, Entry);
+ Entry = GetNextNode (&xs.ReplyList, Entry);
RemoveEntryList (&Message->Link);
FreePool (Message->u.Reply.Body);
FreePool (Message);
@@ -1121,7 +1178,7 @@ XenStoreDeinit (
if (xs.XenStore->server_features & XENSTORE_SERVER_FEATURE_RECONNECTION) {
xs.XenStore->connection = XENSTORE_RECONNECT;
XenEventChannelNotify (xs.Dev, xs.EventChannel);
- while (*(volatile UINT32*)&xs.XenStore->connection == XENSTORE_RECONNECT) {
+ while (*(volatile UINT32 *)&xs.XenStore->connection == XENSTORE_RECONNECT) {
XenStoreWaitForEvent (xs.EventChannelEvent, EFI_TIMER_PERIOD_MILLISECONDS (100));
}
} else {
@@ -1134,6 +1191,7 @@ XenStoreDeinit (
xs.XenStore->req_cons = xs.XenStore->req_prod = 0;
xs.XenStore->rsp_cons = xs.XenStore->rsp_prod = 0;
}
+
xs.XenStore = NULL;
}
@@ -1144,21 +1202,26 @@ XenStoreDeinit (
XENSTORE_STATUS
XenStoreListDirectory (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- OUT UINT32 *DirectoryCountPtr,
- OUT CONST CHAR8 ***DirectoryListPtr
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ OUT UINT32 *DirectoryCountPtr,
+ OUT CONST CHAR8 ***DirectoryListPtr
)
{
- CHAR8 *Path;
- CHAR8 *TempStr;
- UINT32 Len = 0;
- XENSTORE_STATUS Status;
-
- Path = XenStoreJoin (DirectoryPath, Node);
- Status = XenStoreSingle (Transaction, XS_DIRECTORY, Path, &Len,
- (VOID **) &TempStr);
+ CHAR8 *Path;
+ CHAR8 *TempStr;
+ UINT32 Len = 0;
+ XENSTORE_STATUS Status;
+
+ Path = XenStoreJoin (DirectoryPath, Node);
+ Status = XenStoreSingle (
+ Transaction,
+ XS_DIRECTORY,
+ Path,
+ &Len,
+ (VOID **)&TempStr
+ );
FreePool (Path);
if (Status != XENSTORE_STATUS_SUCCESS) {
return Status;
@@ -1171,38 +1234,44 @@ XenStoreListDirectory (
BOOLEAN
XenStorePathExists (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *Directory,
- IN CONST CHAR8 *Node
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *Directory,
+ IN CONST CHAR8 *Node
)
{
- CONST CHAR8 **TempStr;
- XENSTORE_STATUS Status;
- UINT32 TempNum;
-
- Status = XenStoreListDirectory (Transaction, Directory, Node,
- &TempNum, &TempStr);
+ CONST CHAR8 **TempStr;
+ XENSTORE_STATUS Status;
+ UINT32 TempNum;
+
+ Status = XenStoreListDirectory (
+ Transaction,
+ Directory,
+ Node,
+ &TempNum,
+ &TempStr
+ );
if (Status != XENSTORE_STATUS_SUCCESS) {
return FALSE;
}
- FreePool ((VOID*)TempStr);
+
+ FreePool ((VOID *)TempStr);
return TRUE;
}
XENSTORE_STATUS
XenStoreRead (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- OUT UINT32 *LenPtr OPTIONAL,
- OUT VOID **Result
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ OUT UINT32 *LenPtr OPTIONAL,
+ OUT VOID **Result
)
{
- CHAR8 *Path;
- VOID *Value;
- XENSTORE_STATUS Status;
+ CHAR8 *Path;
+ VOID *Value;
+ XENSTORE_STATUS Status;
- Path = XenStoreJoin (DirectoryPath, Node);
+ Path = XenStoreJoin (DirectoryPath, Node);
Status = XenStoreSingle (Transaction, XS_READ, Path, LenPtr, &Value);
FreePool (Path);
if (Status != XENSTORE_STATUS_SUCCESS) {
@@ -1215,22 +1284,22 @@ XenStoreRead (
XENSTORE_STATUS
XenStoreWrite (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- IN CONST CHAR8 *Str
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ IN CONST CHAR8 *Str
)
{
- CHAR8 *Path;
- WRITE_REQUEST WriteRequest[2];
- XENSTORE_STATUS Status;
+ CHAR8 *Path;
+ WRITE_REQUEST WriteRequest[2];
+ XENSTORE_STATUS Status;
Path = XenStoreJoin (DirectoryPath, Node);
- WriteRequest[0].Data = (VOID *) Path;
- WriteRequest[0].Len = (UINT32)AsciiStrSize (Path);
- WriteRequest[1].Data = (VOID *) Str;
- WriteRequest[1].Len = (UINT32)AsciiStrLen (Str);
+ WriteRequest[0].Data = (VOID *)Path;
+ WriteRequest[0].Len = (UINT32)AsciiStrSize (Path);
+ WriteRequest[1].Data = (VOID *)Str;
+ WriteRequest[1].Len = (UINT32)AsciiStrLen (Str);
Status = XenStoreTalkv (Transaction, XS_WRITE, WriteRequest, 2, NULL, NULL);
FreePool (Path);
@@ -1240,15 +1309,15 @@ XenStoreWrite (
XENSTORE_STATUS
XenStoreRemove (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node
)
{
- CHAR8 *Path;
- XENSTORE_STATUS Status;
+ CHAR8 *Path;
+ XENSTORE_STATUS Status;
- Path = XenStoreJoin (DirectoryPath, Node);
+ Path = XenStoreJoin (DirectoryPath, Node);
Status = XenStoreSingle (Transaction, XS_RM, Path, NULL, NULL);
FreePool (Path);
@@ -1260,11 +1329,16 @@ XenStoreTransactionStart (
OUT XENSTORE_TRANSACTION *Transaction
)
{
- CHAR8 *IdStr;
- XENSTORE_STATUS Status;
-
- Status = XenStoreSingle (XST_NIL, XS_TRANSACTION_START, "", NULL,
- (VOID **) &IdStr);
+ CHAR8 *IdStr;
+ XENSTORE_STATUS Status;
+
+ Status = XenStoreSingle (
+ XST_NIL,
+ XS_TRANSACTION_START,
+ "",
+ NULL,
+ (VOID **)&IdStr
+ );
if (Status == XENSTORE_STATUS_SUCCESS) {
Transaction->Id = (UINT32)AsciiStrDecimalToUintn (IdStr);
FreePool (IdStr);
@@ -1275,11 +1349,11 @@ XenStoreTransactionStart (
XENSTORE_STATUS
XenStoreTransactionEnd (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN BOOLEAN Abort
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN BOOLEAN Abort
)
{
- CHAR8 AbortStr[2];
+ CHAR8 AbortStr[2];
AbortStr[0] = Abort ? 'F' : 'T';
AbortStr[1] = '\0';
@@ -1290,17 +1364,17 @@ XenStoreTransactionEnd (
XENSTORE_STATUS
EFIAPI
XenStoreVSPrint (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- IN CONST CHAR8 *FormatString,
- IN VA_LIST Marker
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
)
{
- CHAR8 *Buf;
- XENSTORE_STATUS Status;
- UINTN BufSize;
- VA_LIST Marker2;
+ CHAR8 *Buf;
+ XENSTORE_STATUS Status;
+ UINTN BufSize;
+ VA_LIST Marker2;
VA_COPY (Marker2, Marker);
BufSize = SPrintLengthAsciiFormat (FormatString, Marker2) + 1;
@@ -1316,15 +1390,15 @@ XenStoreVSPrint (
XENSTORE_STATUS
EFIAPI
XenStoreSPrint (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- IN CONST CHAR8 *FormatString,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ IN CONST CHAR8 *FormatString,
...
)
{
- VA_LIST Marker;
- XENSTORE_STATUS Status;
+ VA_LIST Marker;
+ XENSTORE_STATUS Status;
VA_START (Marker, FormatString);
Status = XenStoreVSPrint (Transaction, DirectoryPath, Node, FormatString, Marker);
@@ -1341,19 +1415,19 @@ XenStoreRegisterWatch (
)
{
/* Pointer in ascii is the token. */
- CHAR8 Token[sizeof (XENSTORE_WATCH) * 2 + 1];
- XENSTORE_STATUS Status;
- XENSTORE_WATCH *Watch;
+ CHAR8 Token[sizeof (XENSTORE_WATCH) * 2 + 1];
+ XENSTORE_STATUS Status;
+ XENSTORE_WATCH *Watch;
- Watch = AllocateZeroPool (sizeof (XENSTORE_WATCH));
+ Watch = AllocateZeroPool (sizeof (XENSTORE_WATCH));
Watch->Signature = XENSTORE_WATCH_SIGNATURE;
- Watch->Node = XenStoreJoin (DirectoryPath, Node);
+ Watch->Node = XenStoreJoin (DirectoryPath, Node);
EfiAcquireLock (&xs.RegisteredWatchesLock);
InsertTailList (&xs.RegisteredWatches, &Watch->Link);
EfiReleaseLock (&xs.RegisteredWatchesLock);
- AsciiSPrint (Token, sizeof (Token), "%p", (VOID*) Watch);
+ AsciiSPrint (Token, sizeof (Token), "%p", (VOID *)Watch);
Status = XenStoreWatch (Watch->Node, Token);
/* Ignore errors due to multiple registration. */
@@ -1376,15 +1450,15 @@ XenStoreRegisterWatch (
VOID
XenStoreUnregisterWatch (
- IN XENSTORE_WATCH *Watch
+ IN XENSTORE_WATCH *Watch
)
{
- CHAR8 Token[sizeof (Watch) * 2 + 1];
- LIST_ENTRY *Entry;
+ CHAR8 Token[sizeof (Watch) * 2 + 1];
+ LIST_ENTRY *Entry;
ASSERT (Watch->Signature == XENSTORE_WATCH_SIGNATURE);
- AsciiSPrint (Token, sizeof (Token), "%p", (VOID *) Watch);
+ AsciiSPrint (Token, sizeof (Token), "%p", (VOID *)Watch);
if (XenStoreFindWatch (Token) == NULL) {
return;
}
@@ -1399,21 +1473,21 @@ XenStoreUnregisterWatch (
EfiAcquireLock (&xs.WatchEventsLock);
Entry = GetFirstNode (&xs.WatchEvents);
while (!IsNull (&xs.WatchEvents, Entry)) {
- XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry);
+ XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry);
Entry = GetNextNode (&xs.WatchEvents, Entry);
if (Message->u.Watch.Handle == Watch) {
RemoveEntryList (&Message->Link);
- FreePool ((VOID*)Message->u.Watch.Vector);
+ FreePool ((VOID *)Message->u.Watch.Vector);
FreePool (Message);
}
}
+
EfiReleaseLock (&xs.WatchEventsLock);
FreePool (Watch->Node);
FreePool (Watch);
}
-
//
// XENBUS protocol
//
@@ -1421,8 +1495,8 @@ XenStoreUnregisterWatch (
XENSTORE_STATUS
EFIAPI
XenBusWaitForWatch (
- IN XENBUS_PROTOCOL *This,
- IN VOID *Token
+ IN XENBUS_PROTOCOL *This,
+ IN VOID *Token
)
{
return XenStoreWaitWatch (Token);
@@ -1431,10 +1505,10 @@ XenBusWaitForWatch (
XENSTORE_STATUS
EFIAPI
XenBusXenStoreRead (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *Node,
- OUT VOID **Value
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *Node,
+ OUT VOID **Value
)
{
return XenStoreRead (Transaction, This->Node, Node, NULL, Value);
@@ -1443,10 +1517,10 @@ XenBusXenStoreRead (
XENSTORE_STATUS
EFIAPI
XenBusXenStoreBackendRead (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *Node,
- OUT VOID **Value
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *Node,
+ OUT VOID **Value
)
{
return XenStoreRead (Transaction, This->Backend, Node, NULL, Value);
@@ -1455,9 +1529,9 @@ XenBusXenStoreBackendRead (
XENSTORE_STATUS
EFIAPI
XenBusXenStoreRemove (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN const char *Node
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN const char *Node
)
{
return XenStoreRemove (Transaction, This->Node, Node);
@@ -1476,9 +1550,9 @@ XenBusXenStoreTransactionStart (
XENSTORE_STATUS
EFIAPI
XenBusXenStoreTransactionEnd (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN BOOLEAN Abort
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN BOOLEAN Abort
)
{
return XenStoreTransactionEnd (Transaction, Abort);
@@ -1487,16 +1561,16 @@ XenBusXenStoreTransactionEnd (
XENSTORE_STATUS
EFIAPI
XenBusXenStoreSPrint (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- IN CONST CHAR8 *FormatString,
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ IN CONST CHAR8 *FormatString,
...
)
{
- VA_LIST Marker;
- XENSTORE_STATUS Status;
+ VA_LIST Marker;
+ XENSTORE_STATUS Status;
VA_START (Marker, FormatString);
Status = XenStoreVSPrint (Transaction, DirectoryPath, Node, FormatString, Marker);
@@ -1508,23 +1582,23 @@ XenBusXenStoreSPrint (
XENSTORE_STATUS
EFIAPI
XenBusRegisterWatch (
- IN XENBUS_PROTOCOL *This,
- IN CONST CHAR8 *Node,
- OUT VOID **Token
+ IN XENBUS_PROTOCOL *This,
+ IN CONST CHAR8 *Node,
+ OUT VOID **Token
)
{
- return XenStoreRegisterWatch (This->Node, Node, (XENSTORE_WATCH **) Token);
+ return XenStoreRegisterWatch (This->Node, Node, (XENSTORE_WATCH **)Token);
}
XENSTORE_STATUS
EFIAPI
XenBusRegisterWatchBackend (
- IN XENBUS_PROTOCOL *This,
- IN CONST CHAR8 *Node,
- OUT VOID **Token
+ IN XENBUS_PROTOCOL *This,
+ IN CONST CHAR8 *Node,
+ OUT VOID **Token
)
{
- return XenStoreRegisterWatch (This->Backend, Node, (XENSTORE_WATCH **) Token);
+ return XenStoreRegisterWatch (This->Backend, Node, (XENSTORE_WATCH **)Token);
}
VOID
@@ -1534,5 +1608,5 @@ XenBusUnregisterWatch (
IN VOID *Token
)
{
- XenStoreUnregisterWatch ((XENSTORE_WATCH *) Token);
+ XenStoreUnregisterWatch ((XENSTORE_WATCH *)Token);
}
diff --git a/OvmfPkg/XenBusDxe/XenStore.h b/OvmfPkg/XenBusDxe/XenStore.h
index effaad7336..b2ae805524 100644
--- a/OvmfPkg/XenBusDxe/XenStore.h
+++ b/OvmfPkg/XenBusDxe/XenStore.h
@@ -38,11 +38,11 @@ typedef struct _XENSTORE_WATCH XENSTORE_WATCH;
**/
XENSTORE_STATUS
XenStoreListDirectory (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- OUT UINT32 *DirectoryCountPtr,
- OUT CONST CHAR8 ***DirectoryListPtr
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ OUT UINT32 *DirectoryCountPtr,
+ OUT CONST CHAR8 ***DirectoryListPtr
);
/**
@@ -58,9 +58,9 @@ XenStoreListDirectory (
**/
BOOLEAN
XenStorePathExists (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *Directory,
- IN CONST CHAR8 *Node
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *Directory,
+ IN CONST CHAR8 *Node
);
/**
@@ -82,11 +82,11 @@ XenStorePathExists (
**/
XENSTORE_STATUS
XenStoreRead (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- OUT UINT32 *LenPtr OPTIONAL,
- OUT VOID **Result
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ OUT UINT32 *LenPtr OPTIONAL,
+ OUT VOID **Result
);
/**
@@ -102,10 +102,10 @@ XenStoreRead (
**/
XENSTORE_STATUS
XenStoreWrite (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- IN CONST CHAR8 *Str
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ IN CONST CHAR8 *Str
);
/**
@@ -120,9 +120,9 @@ XenStoreWrite (
**/
XENSTORE_STATUS
XenStoreRemove (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node
);
/**
@@ -139,7 +139,7 @@ XenStoreRemove (
**/
XENSTORE_STATUS
XenStoreTransactionStart (
- OUT XENSTORE_TRANSACTION *Transaction
+ OUT XENSTORE_TRANSACTION *Transaction
);
/**
@@ -154,8 +154,8 @@ XenStoreTransactionStart (
**/
XENSTORE_STATUS
XenStoreTransactionEnd (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN BOOLEAN Abort
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN BOOLEAN Abort
);
/**
@@ -173,10 +173,10 @@ XenStoreTransactionEnd (
XENSTORE_STATUS
EFIAPI
XenStoreSPrint (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- IN CONST CHAR8 *FormatString,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ IN CONST CHAR8 *FormatString,
...
);
@@ -195,11 +195,11 @@ XenStoreSPrint (
XENSTORE_STATUS
EFIAPI
XenStoreVSPrint (
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- IN CONST CHAR8 *FormatString,
- IN VA_LIST Marker
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
);
/**
@@ -232,7 +232,7 @@ XenStoreRegisterWatch (
**/
VOID
XenStoreUnregisterWatch (
- IN XENSTORE_WATCH *Watch
+ IN XENSTORE_WATCH *Watch
);
/**
@@ -240,18 +240,17 @@ XenStoreUnregisterWatch (
is the NUL string, the returned value contains the path string
<DirectoryPath>.
- @param DirectoryPath The NUL terminated directory prefix for new path.
+ @param DirectoryPath The NUL terminated directory prefix for new path.
@param Node The NUL terminated basename for the new path.
@return A buffer containing the joined path.
*/
CHAR8 *
XenStoreJoin (
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node
);
-
/**
Initialize the XenStore states and rings.
@@ -261,7 +260,7 @@ XenStoreJoin (
**/
EFI_STATUS
XenStoreInit (
- XENBUS_DEVICE *Dev
+ XENBUS_DEVICE *Dev
);
/**
@@ -271,10 +270,9 @@ XenStoreInit (
**/
VOID
XenStoreDeinit (
- IN XENBUS_DEVICE *Dev
+ IN XENBUS_DEVICE *Dev
);
-
//
// XENBUS protocol
//
@@ -282,34 +280,34 @@ XenStoreDeinit (
XENSTORE_STATUS
EFIAPI
XenBusWaitForWatch (
- IN XENBUS_PROTOCOL *This,
- IN VOID *Token
+ IN XENBUS_PROTOCOL *This,
+ IN VOID *Token
);
XENSTORE_STATUS
EFIAPI
XenBusXenStoreRead (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *Node,
- OUT VOID **Value
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *Node,
+ OUT VOID **Value
);
XENSTORE_STATUS
EFIAPI
XenBusXenStoreBackendRead (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *Node,
- OUT VOID **Value
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *Node,
+ OUT VOID **Value
);
XENSTORE_STATUS
EFIAPI
XenBusXenStoreRemove (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *Node
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *Node
);
XENSTORE_STATUS
@@ -322,36 +320,36 @@ XenBusXenStoreTransactionStart (
XENSTORE_STATUS
EFIAPI
XenBusXenStoreTransactionEnd (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN BOOLEAN Abort
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN BOOLEAN Abort
);
XENSTORE_STATUS
EFIAPI
XenBusXenStoreSPrint (
- IN XENBUS_PROTOCOL *This,
- IN CONST XENSTORE_TRANSACTION *Transaction,
- IN CONST CHAR8 *DirectoryPath,
- IN CONST CHAR8 *Node,
- IN CONST CHAR8 *FormatString,
+ IN XENBUS_PROTOCOL *This,
+ IN CONST XENSTORE_TRANSACTION *Transaction,
+ IN CONST CHAR8 *DirectoryPath,
+ IN CONST CHAR8 *Node,
+ IN CONST CHAR8 *FormatString,
...
);
XENSTORE_STATUS
EFIAPI
XenBusRegisterWatch (
- IN XENBUS_PROTOCOL *This,
- IN CONST CHAR8 *Node,
- OUT VOID **Token
+ IN XENBUS_PROTOCOL *This,
+ IN CONST CHAR8 *Node,
+ OUT VOID **Token
);
XENSTORE_STATUS
EFIAPI
XenBusRegisterWatchBackend (
- IN XENBUS_PROTOCOL *This,
- IN CONST CHAR8 *Node,
- OUT VOID **Token
+ IN XENBUS_PROTOCOL *This,
+ IN CONST CHAR8 *Node,
+ OUT VOID **Token
);
VOID