Copyright (C) 2014, Citrix Ltd.\r
Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
\r
- Redistribution and use in source and binary forms, with or without\r
- modification, are permitted provided that the following conditions\r
- are met:\r
- 1. Redistributions of source code must retain the above copyright\r
- notice, this list of conditions and the following disclaimer.\r
- 2. Redistributions in binary form must reproduce the above copyright\r
- notice, this list of conditions and the following disclaimer in the\r
- documentation and/or other materials provided with the distribution.\r
-\r
- THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\r
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- SUCH DAMAGE.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
**/\r
\r
#include <Library/PrintLib.h>\r
XEN_BLOCK_FRONT_DEVICE *Dev;\r
XenbusState State;\r
UINT64 Value;\r
+ CHAR8 *Params;\r
\r
ASSERT (NodeName != NULL);\r
\r
}\r
FreePool (DeviceType);\r
\r
+ if (Dev->MediaInfo.CdRom) {\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
+ goto Error;\r
+ }\r
+ if (AsciiStrLen (Params) == 0 || AsciiStrCmp (Params, "aio:") == 0) {\r
+ FreePool (Params);\r
+ DEBUG ((EFI_D_INFO, "%a: Empty cdrom\n", __FUNCTION__));\r
+ goto Error;\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
goto Error;\r
}\r
- Dev->DomainId = Value;\r
+ Dev->DomainId = (domid_t)Value;\r
XenBusIo->EventChannelAllocate (XenBusIo, Dev->DomainId, &Dev->EventChannel);\r
\r
SharedRing = (blkif_sring_t*) AllocatePages (1);\r
if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {\r
goto Error2;\r
}\r
- Dev->MediaInfo.VDiskInfo = Value;\r
+ Dev->MediaInfo.VDiskInfo = (UINT32)Value;\r
if (Dev->MediaInfo.VDiskInfo & VDISK_READONLY) {\r
Dev->MediaInfo.ReadWrite = FALSE;\r
} else {\r
if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {\r
goto Error2;\r
}\r
- if (Value % 512 != 0) {\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 %d, "\r
+ DEBUG ((EFI_D_ERROR, "XenPvBlk: Unsupported sector-size value %Lu, "\r
"it must be a multiple of 512\n", Value));\r
goto Error2;\r
}\r
- Dev->MediaInfo.SectorSize = Value;\r
+ Dev->MediaInfo.SectorSize = (UINT32)Value;\r
\r
// Default value\r
Value = 0;\r
break;\r
}\r
DEBUG ((EFI_D_INFO,\r
- "XenPvBlk: waiting backend state %d, current: %d\n",\r
+ "XenPvBlk: waiting backend state %d, current: %Lu\n",\r
XenbusStateInitWait, Value));\r
XenBusIo->WaitForWatch (XenBusIo, Dev->StateWatchToken);\r
}\r
\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 = (End - Start) / EFI_PAGE_SIZE;\r
+ IoData->NumRef = NumSegments = (INT32)((End - Start) / EFI_PAGE_SIZE);\r
\r
ASSERT (NumSegments <= BLKIF_MAX_SEGMENTS_PER_REQUEST);\r
\r
Request = RING_GET_REQUEST (&Dev->Ring, RingIndex);\r
\r
Request->operation = IsWrite ? BLKIF_OP_WRITE : BLKIF_OP_READ;\r
- Request->nr_segments = NumSegments;\r
+ Request->nr_segments = (UINT8)NumSegments;\r
Request->handle = Dev->DeviceId;\r
Request->id = (UINTN) IoData;\r
Request->sector_number = IoData->Sector;\r
Request->seg[Index].first_sect = 0;\r
Request->seg[Index].last_sect = EFI_PAGE_SIZE / 512 - 1;\r
}\r
- Request->seg[0].first_sect = ((UINTN) IoData->Buffer & EFI_PAGE_MASK) / 512;\r
+ Request->seg[0].first_sect = (UINT8)(((UINTN) IoData->Buffer & EFI_PAGE_MASK) / 512);\r
Request->seg[NumSegments - 1].last_sect =\r
- (((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
if (Status != BLKIF_RSP_OKAY) {\r
DEBUG ((EFI_D_ERROR,\r
"XenPvBlk: "\r
- "%a error %d on %a at sector %p, num bytes %p\n",\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
- IoData->Sector,\r
- IoData->Size));\r
+ (UINT64)IoData->Sector,\r
+ (UINT64)IoData->Size));\r
}\r
\r
for (Index = 0; Index < IoData->NumRef; Index++) {\r