STATIC\r
XENSTORE_STATUS\r
XenBusReadUint64 (\r
- IN XENBUS_PROTOCOL *This,\r
- IN CONST CHAR8 *Node,\r
- IN BOOLEAN FromBackend,\r
- OUT UINT64 *ValuePtr\r
+ IN XENBUS_PROTOCOL *This,\r
+ IN CONST CHAR8 *Node,\r
+ IN BOOLEAN FromBackend,\r
+ OUT UINT64 *ValuePtr\r
)\r
{\r
- XENSTORE_STATUS Status;\r
- CHAR8 *Ptr;\r
+ XENSTORE_STATUS Status;\r
+ CHAR8 *Ptr;\r
\r
if (!FromBackend) {\r
- Status = This->XsRead (This, XST_NIL, Node, (VOID**)&Ptr);\r
+ Status = This->XsRead (This, XST_NIL, Node, (VOID **)&Ptr);\r
} else {\r
- Status = This->XsBackendRead (This, XST_NIL, Node, (VOID**)&Ptr);\r
+ Status = This->XsBackendRead (This, XST_NIL, Node, (VOID **)&Ptr);\r
}\r
+\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
return Status;\r
}\r
+\r
// AsciiStrDecimalToUint64 will ASSERT if Ptr overflow UINT64.\r
*ValuePtr = AsciiStrDecimalToUint64 (Ptr);\r
FreePool (Ptr);\r
STATIC\r
VOID\r
XenPvBlockFree (\r
- IN XEN_BLOCK_FRONT_DEVICE *Dev\r
+ IN XEN_BLOCK_FRONT_DEVICE *Dev\r
)\r
{\r
- XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
+ XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
\r
if (Dev->RingRef != 0) {\r
XenBusIo->GrantEndAccess (XenBusIo, Dev->RingRef);\r
}\r
+\r
if (Dev->Ring.sring != NULL) {\r
FreePages (Dev->Ring.sring, 1);\r
}\r
+\r
if (Dev->EventChannel != 0) {\r
XenBusIo->EventChannelClose (XenBusIo, Dev->EventChannel);\r
}\r
+\r
FreePool (Dev);\r
}\r
\r
STATIC\r
XENSTORE_STATUS\r
XenPvBlkWaitForBackendState (\r
- IN XEN_BLOCK_FRONT_DEVICE *Dev,\r
- IN XenbusState ExpectedState,\r
- OUT XenbusState *LastStatePtr OPTIONAL\r
+ IN XEN_BLOCK_FRONT_DEVICE *Dev,\r
+ IN XenbusState ExpectedState,\r
+ OUT XenbusState *LastStatePtr OPTIONAL\r
)\r
{\r
- XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
- XenbusState State;\r
- UINT64 Value;\r
- XENSTORE_STATUS Status = XENSTORE_STATUS_SUCCESS;\r
+ XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
+ XenbusState State;\r
+ UINT64 Value;\r
+ XENSTORE_STATUS Status = XENSTORE_STATUS_SUCCESS;\r
\r
while (TRUE) {\r
Status = XenBusReadUint64 (XenBusIo, "state", TRUE, &Value);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
return Status;\r
}\r
+\r
if (Value > XenbusStateReconfigured) {\r
//\r
// Value is not a State value.\r
//\r
return XENSTORE_STATUS_EIO;\r
}\r
+\r
State = Value;\r
if (State == ExpectedState) {\r
break;\r
Status = XENSTORE_STATUS_FAIL;\r
break;\r
}\r
- DEBUG ((EFI_D_INFO,\r
- "XenPvBlk: waiting backend state %d, current: %d\n",\r
- ExpectedState, State));\r
+\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "XenPvBlk: waiting backend state %d, current: %d\n",\r
+ ExpectedState,\r
+ State\r
+ ));\r
XenBusIo->WaitForWatch (XenBusIo, Dev->StateWatchToken);\r
}\r
\r
OUT XEN_BLOCK_FRONT_DEVICE **DevPtr\r
)\r
{\r
- XENSTORE_TRANSACTION Transaction;\r
- CHAR8 *DeviceType;\r
- blkif_sring_t *SharedRing;\r
- XENSTORE_STATUS Status;\r
- XEN_BLOCK_FRONT_DEVICE *Dev;\r
- XenbusState State;\r
- UINT64 Value;\r
- CHAR8 *Params;\r
+ XENSTORE_TRANSACTION Transaction;\r
+ CHAR8 *DeviceType;\r
+ blkif_sring_t *SharedRing;\r
+ XENSTORE_STATUS Status;\r
+ XEN_BLOCK_FRONT_DEVICE *Dev;\r
+ XenbusState State;\r
+ UINT64 Value;\r
+ CHAR8 *Params;\r
\r
ASSERT (NodeName != NULL);\r
\r
Dev = AllocateZeroPool (sizeof (XEN_BLOCK_FRONT_DEVICE));\r
+ if (Dev == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
Dev->Signature = XEN_BLOCK_FRONT_SIGNATURE;\r
- Dev->NodeName = NodeName;\r
- Dev->XenBusIo = XenBusIo;\r
- Dev->DeviceId = XenBusIo->DeviceId;\r
+ Dev->NodeName = NodeName;\r
+ Dev->XenBusIo = XenBusIo;\r
+ Dev->DeviceId = XenBusIo->DeviceId;\r
\r
- XenBusIo->XsRead (XenBusIo, XST_NIL, "device-type", (VOID**)&DeviceType);\r
+ XenBusIo->XsRead (XenBusIo, XST_NIL, "device-type", (VOID **)&DeviceType);\r
if (AsciiStrCmp (DeviceType, "cdrom") == 0) {\r
Dev->MediaInfo.CdRom = TRUE;\r
} else {\r
Dev->MediaInfo.CdRom = FALSE;\r
}\r
+\r
FreePool (DeviceType);\r
\r
if (Dev->MediaInfo.CdRom) {\r
- Status = XenBusIo->XsBackendRead (XenBusIo, XST_NIL, "params", (VOID**)&Params);\r
+ Status = XenBusIo->XsBackendRead (XenBusIo, XST_NIL, "params", (VOID **)&Params);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR, "%a: Failed to read params (%d)\n", __FUNCTION__, Status));\r
+ DEBUG ((DEBUG_ERROR, "%a: Failed to read params (%d)\n", __FUNCTION__, Status));\r
goto Error;\r
}\r
- if (AsciiStrLen (Params) == 0 || AsciiStrCmp (Params, "aio:") == 0) {\r
+\r
+ if ((AsciiStrLen (Params) == 0) || (AsciiStrCmp (Params, "aio:") == 0)) {\r
FreePool (Params);\r
- DEBUG ((EFI_D_INFO, "%a: Empty cdrom\n", __FUNCTION__));\r
+ DEBUG ((DEBUG_INFO, "%a: Empty cdrom\n", __FUNCTION__));\r
goto Error;\r
}\r
+\r
FreePool (Params);\r
}\r
\r
Status = XenBusReadUint64 (XenBusIo, "backend-id", FALSE, &Value);\r
- if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT16) {\r
- DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to get backend-id (%d)\n",\r
- Status));\r
+ if ((Status != XENSTORE_STATUS_SUCCESS) || (Value > MAX_UINT16)) {\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: Failed to get backend-id (%d)\n",\r
+ Status\r
+ ));\r
goto Error;\r
}\r
+\r
Dev->DomainId = (domid_t)Value;\r
XenBusIo->EventChannelAllocate (XenBusIo, Dev->DomainId, &Dev->EventChannel);\r
\r
- SharedRing = (blkif_sring_t*) AllocatePages (1);\r
+ SharedRing = (blkif_sring_t *)AllocatePages (1);\r
SHARED_RING_INIT (SharedRing);\r
FRONT_RING_INIT (&Dev->Ring, SharedRing, EFI_PAGE_SIZE);\r
- XenBusIo->GrantAccess (XenBusIo,\r
- Dev->DomainId,\r
- (INTN) SharedRing >> EFI_PAGE_SHIFT,\r
- FALSE,\r
- &Dev->RingRef);\r
+ XenBusIo->GrantAccess (\r
+ XenBusIo,\r
+ Dev->DomainId,\r
+ (INTN)SharedRing >> EFI_PAGE_SHIFT,\r
+ FALSE,\r
+ &Dev->RingRef\r
+ );\r
\r
Again:\r
Status = XenBusIo->XsTransactionStart (XenBusIo, &Transaction);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_WARN, "XenPvBlk: Failed to start transaction, %d\n", Status));\r
+ DEBUG ((DEBUG_WARN, "XenPvBlk: Failed to start transaction, %d\n", Status));\r
goto Error;\r
}\r
\r
- Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName, "ring-ref", "%d",\r
- Dev->RingRef);\r
+ Status = XenBusIo->XsPrintf (\r
+ XenBusIo,\r
+ &Transaction,\r
+ NodeName,\r
+ "ring-ref",\r
+ "%d",\r
+ Dev->RingRef\r
+ );\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write ring-ref.\n"));\r
+ DEBUG ((DEBUG_ERROR, "XenPvBlk: Failed to write ring-ref.\n"));\r
goto AbortTransaction;\r
}\r
- Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName,\r
- "event-channel", "%d", Dev->EventChannel);\r
+\r
+ Status = XenBusIo->XsPrintf (\r
+ XenBusIo,\r
+ &Transaction,\r
+ NodeName,\r
+ "event-channel",\r
+ "%d",\r
+ Dev->EventChannel\r
+ );\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write event-channel.\n"));\r
+ DEBUG ((DEBUG_ERROR, "XenPvBlk: Failed to write event-channel.\n"));\r
goto AbortTransaction;\r
}\r
- Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName,\r
- "protocol", "%a", XEN_IO_PROTO_ABI_NATIVE);\r
+\r
+ Status = XenBusIo->XsPrintf (\r
+ XenBusIo,\r
+ &Transaction,\r
+ NodeName,\r
+ "protocol",\r
+ "%a",\r
+ XEN_IO_PROTO_ABI_NATIVE\r
+ );\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write protocol.\n"));\r
+ DEBUG ((DEBUG_ERROR, "XenPvBlk: Failed to write protocol.\n"));\r
goto AbortTransaction;\r
}\r
\r
Status = XenBusIo->SetState (XenBusIo, &Transaction, XenbusStateConnected);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to switch state.\n"));\r
+ DEBUG ((DEBUG_ERROR, "XenPvBlk: Failed to switch state.\n"));\r
goto AbortTransaction;\r
}\r
\r
//\r
Status = XenPvBlkWaitForBackendState (Dev, XenbusStateConnected, &State);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: backend for %a/%d not available, rc=%d state=%d\n",\r
- XenBusIo->Type, XenBusIo->DeviceId, Status, State));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: backend for %a/%d not available, rc=%d state=%d\n",\r
+ XenBusIo->Type,\r
+ XenBusIo->DeviceId,\r
+ Status,\r
+ State\r
+ ));\r
goto Error2;\r
}\r
\r
Status = XenBusReadUint64 (XenBusIo, "info", TRUE, &Value);\r
- if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {\r
+ if ((Status != XENSTORE_STATUS_SUCCESS) || (Value > MAX_UINT32)) {\r
goto Error2;\r
}\r
+\r
Dev->MediaInfo.VDiskInfo = (UINT32)Value;\r
if (Dev->MediaInfo.VDiskInfo & VDISK_READONLY) {\r
Dev->MediaInfo.ReadWrite = FALSE;\r
}\r
\r
Status = XenBusReadUint64 (XenBusIo, "sector-size", TRUE, &Value);\r
- if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {\r
+ if ((Status != XENSTORE_STATUS_SUCCESS) || (Value > MAX_UINT32)) {\r
goto Error2;\r
}\r
+\r
if ((UINT32)Value % 512 != 0) {\r
//\r
// This is not supported by the driver.\r
//\r
- DEBUG ((EFI_D_ERROR, "XenPvBlk: Unsupported sector-size value %Lu, "\r
- "it must be a multiple of 512\n", Value));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: Unsupported sector-size value %Lu, "\r
+ "it must be a multiple of 512\n",\r
+ Value\r
+ ));\r
goto Error2;\r
}\r
+\r
Dev->MediaInfo.SectorSize = (UINT32)Value;\r
\r
// Default value\r
Dev->MediaInfo.FeatureFlushCache = FALSE;\r
}\r
\r
- DEBUG ((EFI_D_INFO, "XenPvBlk: New disk with %ld sectors of %d bytes\n",\r
- Dev->MediaInfo.Sectors, Dev->MediaInfo.SectorSize));\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "XenPvBlk: New disk with %ld sectors of %d bytes\n",\r
+ Dev->MediaInfo.Sectors,\r
+ Dev->MediaInfo.SectorSize\r
+ ));\r
\r
*DevPtr = Dev;\r
return EFI_SUCCESS;\r
\r
VOID\r
XenPvBlockFrontShutdown (\r
- IN XEN_BLOCK_FRONT_DEVICE *Dev\r
+ IN XEN_BLOCK_FRONT_DEVICE *Dev\r
)\r
{\r
- XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
- XENSTORE_STATUS Status;\r
- UINT64 Value;\r
+ XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
+ XENSTORE_STATUS Status;\r
+ UINT64 Value;\r
\r
XenPvBlockSync (Dev);\r
\r
Status = XenBusIo->SetState (XenBusIo, XST_NIL, XenbusStateClosing);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: error while changing state to Closing: %d\n",\r
- Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: error while changing state to Closing: %d\n",\r
+ Status\r
+ ));\r
goto Close;\r
}\r
\r
Status = XenPvBlkWaitForBackendState (Dev, XenbusStateClosing, NULL);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: error while waiting for closing backend state: %d\n",\r
- Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: error while waiting for closing backend state: %d\n",\r
+ Status\r
+ ));\r
goto Close;\r
}\r
\r
Status = XenBusIo->SetState (XenBusIo, XST_NIL, XenbusStateClosed);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: error while changing state to Closed: %d\n",\r
- Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: error while changing state to Closed: %d\n",\r
+ Status\r
+ ));\r
goto Close;\r
}\r
\r
Status = XenPvBlkWaitForBackendState (Dev, XenbusStateClosed, NULL);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: error while waiting for closed backend state: %d\n",\r
- Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: error while waiting for closed backend state: %d\n",\r
+ Status\r
+ ));\r
goto Close;\r
}\r
\r
Status = XenBusIo->SetState (XenBusIo, XST_NIL, XenbusStateInitialising);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: error while changing state to initialising: %d\n",\r
- Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: error while changing state to initialising: %d\n",\r
+ Status\r
+ ));\r
goto Close;\r
}\r
\r
while (TRUE) {\r
Status = XenBusReadUint64 (XenBusIo, "state", TRUE, &Value);\r
if (Status != XENSTORE_STATUS_SUCCESS) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: error while waiting for new backend state: %d\n",\r
- Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: error while waiting for new backend state: %d\n",\r
+ Status\r
+ ));\r
goto Close;\r
}\r
- if (Value <= XenbusStateInitWait || Value >= XenbusStateClosed) {\r
+\r
+ if ((Value <= XenbusStateInitWait) || (Value >= XenbusStateClosed)) {\r
break;\r
}\r
- DEBUG ((EFI_D_INFO,\r
- "XenPvBlk: waiting backend state %d, current: %Lu\n",\r
- XenbusStateInitWait, Value));\r
+\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "XenPvBlk: waiting backend state %d, current: %Lu\n",\r
+ XenbusStateInitWait,\r
+ Value\r
+ ));\r
XenBusIo->WaitForWatch (XenBusIo, Dev->StateWatchToken);\r
}\r
\r
STATIC\r
VOID\r
XenPvBlockWaitSlot (\r
- IN XEN_BLOCK_FRONT_DEVICE *Dev\r
+ IN XEN_BLOCK_FRONT_DEVICE *Dev\r
)\r
{\r
/* Wait for a slot */\r
if (!RING_FULL (&Dev->Ring)) {\r
break;\r
}\r
+\r
/* Really no slot, could wait for an event on Dev->EventChannel. */\r
}\r
}\r
\r
VOID\r
XenPvBlockAsyncIo (\r
- IN OUT XEN_BLOCK_FRONT_IO *IoData,\r
- IN BOOLEAN IsWrite\r
+ IN OUT XEN_BLOCK_FRONT_IO *IoData,\r
+ IN BOOLEAN IsWrite\r
)\r
{\r
- XEN_BLOCK_FRONT_DEVICE *Dev = IoData->Dev;\r
- XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
- blkif_request_t *Request;\r
- RING_IDX RingIndex;\r
- BOOLEAN Notify;\r
- INT32 NumSegments, Index;\r
- UINTN Start, End;\r
+ XEN_BLOCK_FRONT_DEVICE *Dev = IoData->Dev;\r
+ XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
+ blkif_request_t *Request;\r
+ RING_IDX RingIndex;\r
+ BOOLEAN Notify;\r
+ INT32 NumSegments, Index;\r
+ UINTN Start, End;\r
\r
// Can't io at non-sector-aligned location\r
- ASSERT(!(IoData->Sector & ((Dev->MediaInfo.SectorSize / 512) - 1)));\r
+ ASSERT (!(IoData->Sector & ((Dev->MediaInfo.SectorSize / 512) - 1)));\r
// Can't io non-sector-sized amounts\r
- ASSERT(!(IoData->Size & (Dev->MediaInfo.SectorSize - 1)));\r
+ ASSERT (!(IoData->Size & (Dev->MediaInfo.SectorSize - 1)));\r
// Can't io non-sector-aligned buffer\r
- ASSERT(!((UINTN) IoData->Buffer & (Dev->MediaInfo.SectorSize - 1)));\r
+ ASSERT (!((UINTN)IoData->Buffer & (Dev->MediaInfo.SectorSize - 1)));\r
\r
- Start = (UINTN) IoData->Buffer & ~EFI_PAGE_MASK;\r
- End = ((UINTN) IoData->Buffer + IoData->Size + EFI_PAGE_SIZE - 1) & ~EFI_PAGE_MASK;\r
+ Start = (UINTN)IoData->Buffer & ~EFI_PAGE_MASK;\r
+ End = ((UINTN)IoData->Buffer + IoData->Size + EFI_PAGE_SIZE - 1) & ~EFI_PAGE_MASK;\r
IoData->NumRef = NumSegments = (INT32)((End - Start) / EFI_PAGE_SIZE);\r
\r
ASSERT (NumSegments <= BLKIF_MAX_SEGMENTS_PER_REQUEST);\r
\r
XenPvBlockWaitSlot (Dev);\r
RingIndex = Dev->Ring.req_prod_pvt;\r
- Request = RING_GET_REQUEST (&Dev->Ring, RingIndex);\r
+ Request = RING_GET_REQUEST (&Dev->Ring, RingIndex);\r
\r
- Request->operation = IsWrite ? BLKIF_OP_WRITE : BLKIF_OP_READ;\r
- Request->nr_segments = (UINT8)NumSegments;\r
- Request->handle = Dev->DeviceId;\r
- Request->id = (UINTN) IoData;\r
+ Request->operation = IsWrite ? BLKIF_OP_WRITE : BLKIF_OP_READ;\r
+ Request->nr_segments = (UINT8)NumSegments;\r
+ Request->handle = Dev->DeviceId;\r
+ Request->id = (UINTN)IoData;\r
Request->sector_number = IoData->Sector;\r
\r
for (Index = 0; Index < NumSegments; Index++) {\r
Request->seg[Index].first_sect = 0;\r
- Request->seg[Index].last_sect = EFI_PAGE_SIZE / 512 - 1;\r
+ Request->seg[Index].last_sect = EFI_PAGE_SIZE / 512 - 1;\r
}\r
- Request->seg[0].first_sect = (UINT8)(((UINTN) IoData->Buffer & EFI_PAGE_MASK) / 512);\r
+\r
+ Request->seg[0].first_sect = (UINT8)(((UINTN)IoData->Buffer & EFI_PAGE_MASK) / 512);\r
Request->seg[NumSegments - 1].last_sect =\r
- (UINT8)((((UINTN) IoData->Buffer + IoData->Size - 1) & EFI_PAGE_MASK) / 512);\r
+ (UINT8)((((UINTN)IoData->Buffer + IoData->Size - 1) & EFI_PAGE_MASK) / 512);\r
for (Index = 0; Index < NumSegments; Index++) {\r
- UINTN Data = Start + Index * EFI_PAGE_SIZE;\r
- XenBusIo->GrantAccess (XenBusIo, Dev->DomainId,\r
- Data >> EFI_PAGE_SHIFT, IsWrite,\r
- &Request->seg[Index].gref);\r
+ UINTN Data = Start + Index * EFI_PAGE_SIZE;\r
+ XenBusIo->GrantAccess (\r
+ XenBusIo,\r
+ Dev->DomainId,\r
+ Data >> EFI_PAGE_SHIFT,\r
+ IsWrite,\r
+ &Request->seg[Index].gref\r
+ );\r
IoData->GrantRef[Index] = Request->seg[Index].gref;\r
}\r
\r
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (&Dev->Ring, Notify);\r
\r
if (Notify) {\r
- UINT32 ReturnCode;\r
+ UINT32 ReturnCode;\r
ReturnCode = XenBusIo->EventChannelNotify (XenBusIo, Dev->EventChannel);\r
if (ReturnCode != 0) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: Unexpected return value from EventChannelNotify: %d\n",\r
- ReturnCode));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: Unexpected return value from EventChannelNotify: %d\n",\r
+ ReturnCode\r
+ ));\r
}\r
}\r
}\r
\r
EFI_STATUS\r
XenPvBlockIo (\r
- IN OUT XEN_BLOCK_FRONT_IO *IoData,\r
- IN BOOLEAN IsWrite\r
+ IN OUT XEN_BLOCK_FRONT_IO *IoData,\r
+ IN BOOLEAN IsWrite\r
)\r
{\r
//\r
STATIC\r
VOID\r
XenPvBlockPushOperation (\r
- IN XEN_BLOCK_FRONT_DEVICE *Dev,\r
- IN UINT8 Operation,\r
- IN UINT64 Id\r
+ IN XEN_BLOCK_FRONT_DEVICE *Dev,\r
+ IN UINT8 Operation,\r
+ IN UINT64 Id\r
)\r
{\r
- INT32 Index;\r
- blkif_request_t *Request;\r
- BOOLEAN Notify;\r
+ INT32 Index;\r
+ blkif_request_t *Request;\r
+ BOOLEAN Notify;\r
\r
XenPvBlockWaitSlot (Dev);\r
- Index = Dev->Ring.req_prod_pvt;\r
- Request = RING_GET_REQUEST(&Dev->Ring, Index);\r
- Request->operation = Operation;\r
+ Index = Dev->Ring.req_prod_pvt;\r
+ Request = RING_GET_REQUEST (&Dev->Ring, Index);\r
+ Request->operation = Operation;\r
Request->nr_segments = 0;\r
- Request->handle = Dev->DeviceId;\r
- Request->id = Id;\r
+ Request->handle = Dev->DeviceId;\r
+ Request->id = Id;\r
/* Not needed anyway, but the backend will check it */\r
Request->sector_number = 0;\r
Dev->Ring.req_prod_pvt = Index + 1;\r
MemoryFence ();\r
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (&Dev->Ring, Notify);\r
if (Notify) {\r
- XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
- UINT32 ReturnCode;\r
+ XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;\r
+ UINT32 ReturnCode;\r
ReturnCode = XenBusIo->EventChannelNotify (XenBusIo, Dev->EventChannel);\r
if (ReturnCode != 0) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: Unexpected return value from EventChannelNotify: %d\n",\r
- ReturnCode));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: Unexpected return value from EventChannelNotify: %d\n",\r
+ ReturnCode\r
+ ));\r
}\r
}\r
}\r
\r
VOID\r
XenPvBlockSync (\r
- IN XEN_BLOCK_FRONT_DEVICE *Dev\r
+ IN XEN_BLOCK_FRONT_DEVICE *Dev\r
)\r
{\r
if (Dev->MediaInfo.ReadWrite) {\r
\r
VOID\r
XenPvBlockAsyncIoPoll (\r
- IN XEN_BLOCK_FRONT_DEVICE *Dev\r
+ IN XEN_BLOCK_FRONT_DEVICE *Dev\r
)\r
{\r
- RING_IDX ProducerIndex, ConsumerIndex;\r
- blkif_response_t *Response;\r
- INT32 More;\r
+ RING_IDX ProducerIndex, ConsumerIndex;\r
+ blkif_response_t *Response;\r
+ INT32 More;\r
\r
do {\r
ProducerIndex = Dev->Ring.sring->rsp_prod;\r
ConsumerIndex = Dev->Ring.rsp_cons;\r
\r
while (ConsumerIndex != ProducerIndex) {\r
- XEN_BLOCK_FRONT_IO *IoData = NULL;\r
- INT16 Status;\r
+ XEN_BLOCK_FRONT_IO *IoData = NULL;\r
+ INT16 Status;\r
\r
Response = RING_GET_RESPONSE (&Dev->Ring, ConsumerIndex);\r
\r
- IoData = (VOID *) (UINTN) Response->id;\r
+ IoData = (VOID *)(UINTN)Response->id;\r
Status = Response->status;\r
\r
switch (Response->operation) {\r
- case BLKIF_OP_READ:\r
- case BLKIF_OP_WRITE:\r
+ case BLKIF_OP_READ:\r
+ case BLKIF_OP_WRITE:\r
{\r
- INT32 Index;\r
+ INT32 Index;\r
\r
if (Status != BLKIF_RSP_OKAY) {\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: "\r
- "%a error %d on %a at sector %Lx, num bytes %Lx\n",\r
- Response->operation == BLKIF_OP_READ ? "read" : "write",\r
- Status, IoData->Dev->NodeName,\r
- (UINT64)IoData->Sector,\r
- (UINT64)IoData->Size));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: "\r
+ "%a error %d on %a at sector %Lx, num bytes %Lx\n",\r
+ Response->operation == BLKIF_OP_READ ? "read" : "write",\r
+ Status,\r
+ IoData->Dev->NodeName,\r
+ (UINT64)IoData->Sector,\r
+ (UINT64)IoData->Size\r
+ ));\r
}\r
\r
for (Index = 0; Index < IoData->NumRef; Index++) {\r
break;\r
}\r
\r
- case BLKIF_OP_WRITE_BARRIER:\r
- if (Status != BLKIF_RSP_OKAY) {\r
- DEBUG ((EFI_D_ERROR, "XenPvBlk: write barrier error %d\n", Status));\r
- }\r
- break;\r
- case BLKIF_OP_FLUSH_DISKCACHE:\r
- if (Status != BLKIF_RSP_OKAY) {\r
- DEBUG ((EFI_D_ERROR, "XenPvBlk: flush error %d\n", Status));\r
- }\r
- break;\r
+ case BLKIF_OP_WRITE_BARRIER:\r
+ if (Status != BLKIF_RSP_OKAY) {\r
+ DEBUG ((DEBUG_ERROR, "XenPvBlk: write barrier error %d\n", Status));\r
+ }\r
\r
- default:\r
- DEBUG ((EFI_D_ERROR,\r
- "XenPvBlk: unrecognized block operation %d response (status %d)\n",\r
- Response->operation, Status));\r
- break;\r
+ break;\r
+ case BLKIF_OP_FLUSH_DISKCACHE:\r
+ if (Status != BLKIF_RSP_OKAY) {\r
+ DEBUG ((DEBUG_ERROR, "XenPvBlk: flush error %d\n", Status));\r
+ }\r
+\r
+ break;\r
+\r
+ default:\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "XenPvBlk: unrecognized block operation %d response (status %d)\n",\r
+ Response->operation,\r
+ Status\r
+ ));\r
+ break;\r
}\r
\r
Dev->Ring.rsp_cons = ++ConsumerIndex;\r
if (IoData != NULL) {\r
IoData->Status = Status ? EFI_DEVICE_ERROR : EFI_SUCCESS;\r
}\r
+\r
if (Dev->Ring.rsp_cons != ConsumerIndex) {\r
/* We reentered, we must not continue here */\r
break;\r