]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/XenPvBlkDxe/BlockFront.c
OvmfPkg/XenPvBlkDxe: fix VS2010 build failures
[mirror_edk2.git] / OvmfPkg / XenPvBlkDxe / BlockFront.c
index 3c039e7add2d1d6f163f69754c9b88b52b217c44..afaa95983b5d48837bea6ab1dd060833c2edcd49 100644 (file)
@@ -3,6 +3,7 @@
 \r
   Copyright (c) 2007-2008 Samuel Thibault.\r
   Copyright (C) 2014, Citrix Ltd.\r
 \r
   Copyright (c) 2007-2008 Samuel Thibault.\r
   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
 \r
   Redistribution and use in source and binary forms, with or without\r
   modification, are permitted provided that the following conditions\r
 #include <IndustryStandard/Xen/io/protocols.h>\r
 #include <IndustryStandard/Xen/io/xenbus.h>\r
 \r
 #include <IndustryStandard/Xen/io/protocols.h>\r
 #include <IndustryStandard/Xen/io/xenbus.h>\r
 \r
-//\r
-// Header used for UINT32_MAX and UINT16_MAX\r
-//\r
-#include "inttypes.h"\r
-\r
 /**\r
   Helper to read an integer from XenStore.\r
 \r
 /**\r
   Helper to read an integer from XenStore.\r
 \r
@@ -166,7 +162,7 @@ XenPvBlockFrontInitialization (
   OUT XEN_BLOCK_FRONT_DEVICE  **DevPtr\r
   )\r
 {\r
   OUT XEN_BLOCK_FRONT_DEVICE  **DevPtr\r
   )\r
 {\r
-  XENSTORE_TRANSACTION xbt;\r
+  XENSTORE_TRANSACTION Transaction;\r
   CHAR8 *DeviceType;\r
   blkif_sring_t *SharedRing;\r
   XENSTORE_STATUS Status;\r
   CHAR8 *DeviceType;\r
   blkif_sring_t *SharedRing;\r
   XENSTORE_STATUS Status;\r
@@ -191,12 +187,12 @@ XenPvBlockFrontInitialization (
   FreePool (DeviceType);\r
 \r
   Status = XenBusReadUint64 (XenBusIo, "backend-id", FALSE, &Value);\r
   FreePool (DeviceType);\r
 \r
   Status = XenBusReadUint64 (XenBusIo, "backend-id", FALSE, &Value);\r
-  if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT16_MAX) {\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
     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
   XenBusIo->EventChannelAllocate (XenBusIo, Dev->DomainId, &Dev->EventChannel);\r
 \r
   SharedRing = (blkif_sring_t*) AllocatePages (1);\r
@@ -209,38 +205,38 @@ XenPvBlockFrontInitialization (
                          &Dev->RingRef);\r
 \r
 Again:\r
                          &Dev->RingRef);\r
 \r
 Again:\r
-  Status = XenBusIo->XsTransactionStart (XenBusIo, &xbt);\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
     goto Error;\r
   }\r
 \r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
     DEBUG ((EFI_D_WARN, "XenPvBlk: Failed to start transaction, %d\n", Status));\r
     goto Error;\r
   }\r
 \r
-  Status = XenBusIo->XsPrintf (XenBusIo, xbt, NodeName, "ring-ref", "%d",\r
+  Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName, "ring-ref", "%d",\r
                                Dev->RingRef);\r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
     DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write ring-ref.\n"));\r
     goto AbortTransaction;\r
   }\r
                                Dev->RingRef);\r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
     DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write ring-ref.\n"));\r
     goto AbortTransaction;\r
   }\r
-  Status = XenBusIo->XsPrintf (XenBusIo, xbt, NodeName,\r
+  Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName,\r
                                "event-channel", "%d", Dev->EventChannel);\r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
     DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write event-channel.\n"));\r
     goto AbortTransaction;\r
   }\r
                                "event-channel", "%d", Dev->EventChannel);\r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
     DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write event-channel.\n"));\r
     goto AbortTransaction;\r
   }\r
-  Status = XenBusIo->XsPrintf (XenBusIo, xbt, NodeName,\r
+  Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName,\r
                                "protocol", "%a", XEN_IO_PROTO_ABI_NATIVE);\r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
     DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write protocol.\n"));\r
     goto AbortTransaction;\r
   }\r
 \r
                                "protocol", "%a", XEN_IO_PROTO_ABI_NATIVE);\r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
     DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write protocol.\n"));\r
     goto AbortTransaction;\r
   }\r
 \r
-  Status = XenBusIo->SetState (XenBusIo, xbt, XenbusStateConnected);\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
     goto AbortTransaction;\r
   }\r
 \r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
     DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to switch state.\n"));\r
     goto AbortTransaction;\r
   }\r
 \r
-  Status = XenBusIo->XsTransactionEnd (XenBusIo, xbt, FALSE);\r
+  Status = XenBusIo->XsTransactionEnd (XenBusIo, &Transaction, FALSE);\r
   if (Status == XENSTORE_STATUS_EAGAIN) {\r
     goto Again;\r
   }\r
   if (Status == XENSTORE_STATUS_EAGAIN) {\r
     goto Again;\r
   }\r
@@ -259,10 +255,10 @@ Again:
   }\r
 \r
   Status = XenBusReadUint64 (XenBusIo, "info", TRUE, &Value);\r
   }\r
 \r
   Status = XenBusReadUint64 (XenBusIo, "info", TRUE, &Value);\r
-  if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT32_MAX) {\r
+  if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {\r
     goto Error2;\r
   }\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 (Dev->MediaInfo.VDiskInfo & VDISK_READONLY) {\r
     Dev->MediaInfo.ReadWrite = FALSE;\r
   } else {\r
@@ -275,10 +271,10 @@ Again:
   }\r
 \r
   Status = XenBusReadUint64 (XenBusIo, "sector-size", TRUE, &Value);\r
   }\r
 \r
   Status = XenBusReadUint64 (XenBusIo, "sector-size", TRUE, &Value);\r
-  if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT32_MAX) {\r
+  if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {\r
     goto Error2;\r
   }\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
     //\r
     // This is not supported by the driver.\r
     //\r
@@ -286,7 +282,7 @@ Again:
             "it must be a multiple of 512\n", Value));\r
     goto Error2;\r
   }\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
 \r
   // Default value\r
   Value = 0;\r
@@ -319,7 +315,7 @@ Error2:
   XenBusIo->XsRemove (XenBusIo, XST_NIL, "protocol");\r
   goto Error;\r
 AbortTransaction:\r
   XenBusIo->XsRemove (XenBusIo, XST_NIL, "protocol");\r
   goto Error;\r
 AbortTransaction:\r
-  XenBusIo->XsTransactionEnd (XenBusIo, xbt, TRUE);\r
+  XenBusIo->XsTransactionEnd (XenBusIo, &Transaction, TRUE);\r
 Error:\r
   XenPvBlockFree (Dev);\r
   return EFI_DEVICE_ERROR;\r
 Error:\r
   XenPvBlockFree (Dev);\r
   return EFI_DEVICE_ERROR;\r
@@ -443,7 +439,7 @@ XenPvBlockAsyncIo (
 \r
   Start = (UINTN) IoData->Buffer & ~EFI_PAGE_MASK;\r
   End = ((UINTN) IoData->Buffer + IoData->Size + EFI_PAGE_SIZE - 1) & ~EFI_PAGE_MASK;\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
 \r
   ASSERT (NumSegments <= BLKIF_MAX_SEGMENTS_PER_REQUEST);\r
 \r
@@ -452,7 +448,7 @@ XenPvBlockAsyncIo (
   Request = RING_GET_REQUEST (&Dev->Ring, RingIndex);\r
 \r
   Request->operation = IsWrite ? BLKIF_OP_WRITE : BLKIF_OP_READ;\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->handle = Dev->DeviceId;\r
   Request->id = (UINTN) IoData;\r
   Request->sector_number = IoData->Sector;\r
@@ -461,9 +457,9 @@ XenPvBlockAsyncIo (
     Request->seg[Index].first_sect = 0;\r
     Request->seg[Index].last_sect = EFI_PAGE_SIZE / 512 - 1;\r
   }\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
   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
   for (Index = 0; Index < NumSegments; Index++) {\r
     UINTN Data = Start + Index * EFI_PAGE_SIZE;\r
     XenBusIo->GrantAccess (XenBusIo, Dev->DomainId,\r