X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=OvmfPkg%2FXenPvBlkDxe%2FBlockFront.c;h=d07e980990562ed56c39b901abdeee2594373433;hb=147fd35c3e389ecd025dbfd243312bf5b22da7c9;hp=3c039e7add2d1d6f163f69754c9b88b52b217c44;hpb=5cce85240450b4f878cc45b2eb16b7b4be74e511;p=mirror_edk2.git
diff --git a/OvmfPkg/XenPvBlkDxe/BlockFront.c b/OvmfPkg/XenPvBlkDxe/BlockFront.c
index 3c039e7add..d07e980990 100644
--- a/OvmfPkg/XenPvBlkDxe/BlockFront.c
+++ b/OvmfPkg/XenPvBlkDxe/BlockFront.c
@@ -3,6 +3,7 @@
Copyright (c) 2007-2008 Samuel Thibault.
Copyright (C) 2014, Citrix Ltd.
+ Copyright (c) 2014, Intel Corporation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -34,11 +35,6 @@
#include
#include
-//
-// Header used for UINT32_MAX and UINT16_MAX
-//
-#include "inttypes.h"
-
/**
Helper to read an integer from XenStore.
@@ -166,13 +162,14 @@ XenPvBlockFrontInitialization (
OUT XEN_BLOCK_FRONT_DEVICE **DevPtr
)
{
- XENSTORE_TRANSACTION xbt;
+ XENSTORE_TRANSACTION Transaction;
CHAR8 *DeviceType;
blkif_sring_t *SharedRing;
XENSTORE_STATUS Status;
XEN_BLOCK_FRONT_DEVICE *Dev;
XenbusState State;
UINT64 Value;
+ CHAR8 *Params;
ASSERT (NodeName != NULL);
@@ -190,13 +187,27 @@ XenPvBlockFrontInitialization (
}
FreePool (DeviceType);
+ if (Dev->MediaInfo.CdRom) {
+ Status = XenBusIo->XsBackendRead (XenBusIo, XST_NIL, "params", (VOID**)&Params);
+ if (Status != XENSTORE_STATUS_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "%a: Failed to read params (%d)\n", __FUNCTION__, Status));
+ goto Error;
+ }
+ if (AsciiStrLen (Params) == 0 || AsciiStrCmp (Params, "aio:") == 0) {
+ FreePool (Params);
+ DEBUG ((EFI_D_INFO, "%a: Empty cdrom\n", __FUNCTION__));
+ goto Error;
+ }
+ FreePool (Params);
+ }
+
Status = XenBusReadUint64 (XenBusIo, "backend-id", FALSE, &Value);
- if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT16_MAX) {
+ if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT16) {
DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to get backend-id (%d)\n",
Status));
goto Error;
}
- Dev->DomainId = Value;
+ Dev->DomainId = (domid_t)Value;
XenBusIo->EventChannelAllocate (XenBusIo, Dev->DomainId, &Dev->EventChannel);
SharedRing = (blkif_sring_t*) AllocatePages (1);
@@ -209,38 +220,38 @@ XenPvBlockFrontInitialization (
&Dev->RingRef);
Again:
- Status = XenBusIo->XsTransactionStart (XenBusIo, &xbt);
+ Status = XenBusIo->XsTransactionStart (XenBusIo, &Transaction);
if (Status != XENSTORE_STATUS_SUCCESS) {
DEBUG ((EFI_D_WARN, "XenPvBlk: Failed to start transaction, %d\n", Status));
goto Error;
}
- Status = XenBusIo->XsPrintf (XenBusIo, xbt, NodeName, "ring-ref", "%d",
+ Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName, "ring-ref", "%d",
Dev->RingRef);
if (Status != XENSTORE_STATUS_SUCCESS) {
DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write ring-ref.\n"));
goto AbortTransaction;
}
- Status = XenBusIo->XsPrintf (XenBusIo, xbt, NodeName,
+ Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName,
"event-channel", "%d", Dev->EventChannel);
if (Status != XENSTORE_STATUS_SUCCESS) {
DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write event-channel.\n"));
goto AbortTransaction;
}
- Status = XenBusIo->XsPrintf (XenBusIo, xbt, NodeName,
+ Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName,
"protocol", "%a", XEN_IO_PROTO_ABI_NATIVE);
if (Status != XENSTORE_STATUS_SUCCESS) {
DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write protocol.\n"));
goto AbortTransaction;
}
- Status = XenBusIo->SetState (XenBusIo, xbt, XenbusStateConnected);
+ Status = XenBusIo->SetState (XenBusIo, &Transaction, XenbusStateConnected);
if (Status != XENSTORE_STATUS_SUCCESS) {
DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to switch state.\n"));
goto AbortTransaction;
}
- Status = XenBusIo->XsTransactionEnd (XenBusIo, xbt, FALSE);
+ Status = XenBusIo->XsTransactionEnd (XenBusIo, &Transaction, FALSE);
if (Status == XENSTORE_STATUS_EAGAIN) {
goto Again;
}
@@ -259,10 +270,10 @@ Again:
}
Status = XenBusReadUint64 (XenBusIo, "info", TRUE, &Value);
- if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT32_MAX) {
+ if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {
goto Error2;
}
- Dev->MediaInfo.VDiskInfo = Value;
+ Dev->MediaInfo.VDiskInfo = (UINT32)Value;
if (Dev->MediaInfo.VDiskInfo & VDISK_READONLY) {
Dev->MediaInfo.ReadWrite = FALSE;
} else {
@@ -275,18 +286,18 @@ Again:
}
Status = XenBusReadUint64 (XenBusIo, "sector-size", TRUE, &Value);
- if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT32_MAX) {
+ if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {
goto Error2;
}
- if (Value % 512 != 0) {
+ if ((UINT32)Value % 512 != 0) {
//
// This is not supported by the driver.
//
- DEBUG ((EFI_D_ERROR, "XenPvBlk: Unsupported sector-size value %d, "
+ DEBUG ((EFI_D_ERROR, "XenPvBlk: Unsupported sector-size value %Lu, "
"it must be a multiple of 512\n", Value));
goto Error2;
}
- Dev->MediaInfo.SectorSize = Value;
+ Dev->MediaInfo.SectorSize = (UINT32)Value;
// Default value
Value = 0;
@@ -319,7 +330,7 @@ Error2:
XenBusIo->XsRemove (XenBusIo, XST_NIL, "protocol");
goto Error;
AbortTransaction:
- XenBusIo->XsTransactionEnd (XenBusIo, xbt, TRUE);
+ XenBusIo->XsTransactionEnd (XenBusIo, &Transaction, TRUE);
Error:
XenPvBlockFree (Dev);
return EFI_DEVICE_ERROR;
@@ -388,7 +399,7 @@ XenPvBlockFrontShutdown (
break;
}
DEBUG ((EFI_D_INFO,
- "XenPvBlk: waiting backend state %d, current: %d\n",
+ "XenPvBlk: waiting backend state %d, current: %Lu\n",
XenbusStateInitWait, Value));
XenBusIo->WaitForWatch (XenBusIo, Dev->StateWatchToken);
}
@@ -443,7 +454,7 @@ XenPvBlockAsyncIo (
Start = (UINTN) IoData->Buffer & ~EFI_PAGE_MASK;
End = ((UINTN) IoData->Buffer + IoData->Size + EFI_PAGE_SIZE - 1) & ~EFI_PAGE_MASK;
- IoData->NumRef = NumSegments = (End - Start) / EFI_PAGE_SIZE;
+ IoData->NumRef = NumSegments = (INT32)((End - Start) / EFI_PAGE_SIZE);
ASSERT (NumSegments <= BLKIF_MAX_SEGMENTS_PER_REQUEST);
@@ -452,7 +463,7 @@ XenPvBlockAsyncIo (
Request = RING_GET_REQUEST (&Dev->Ring, RingIndex);
Request->operation = IsWrite ? BLKIF_OP_WRITE : BLKIF_OP_READ;
- Request->nr_segments = NumSegments;
+ Request->nr_segments = (UINT8)NumSegments;
Request->handle = Dev->DeviceId;
Request->id = (UINTN) IoData;
Request->sector_number = IoData->Sector;
@@ -461,9 +472,9 @@ XenPvBlockAsyncIo (
Request->seg[Index].first_sect = 0;
Request->seg[Index].last_sect = EFI_PAGE_SIZE / 512 - 1;
}
- Request->seg[0].first_sect = ((UINTN) IoData->Buffer & EFI_PAGE_MASK) / 512;
+ Request->seg[0].first_sect = (UINT8)(((UINTN) IoData->Buffer & EFI_PAGE_MASK) / 512);
Request->seg[NumSegments - 1].last_sect =
- (((UINTN) IoData->Buffer + IoData->Size - 1) & EFI_PAGE_MASK) / 512;
+ (UINT8)((((UINTN) IoData->Buffer + IoData->Size - 1) & EFI_PAGE_MASK) / 512);
for (Index = 0; Index < NumSegments; Index++) {
UINTN Data = Start + Index * EFI_PAGE_SIZE;
XenBusIo->GrantAccess (XenBusIo, Dev->DomainId,
@@ -600,11 +611,11 @@ XenPvBlockAsyncIoPoll (
if (Status != BLKIF_RSP_OKAY) {
DEBUG ((EFI_D_ERROR,
"XenPvBlk: "
- "%a error %d on %a at sector %p, num bytes %p\n",
+ "%a error %d on %a at sector %Lx, num bytes %Lx\n",
Response->operation == BLKIF_OP_READ ? "read" : "write",
Status, IoData->Dev->NodeName,
- IoData->Sector,
- IoData->Size));
+ (UINT64)IoData->Sector,
+ (UINT64)IoData->Size));
}
for (Index = 0; Index < IoData->NumRef; Index++) {