Laszlo Ersek [mailto:ler...@redhat.com] wrote:
]Apparently I wasn't quick enough to answer (which is not a surprise ]these days), but I do have some points to raise... ] ]On 11/11/14 00:41, Jordan Justen wrote: ]> On 2014-11-10 15:05:07, Scott Duplichan wrote: ]>> OvmfPkg: fix VS2010 build failures ]>> ]>> Contributed-under: TianoCore Contribution Agreement 1.0 ]>> Signed-off-by: Scott Duplichan <sc...@notabs.org> ]>> --- ]>> ]>> Here is one way to get OvmfPkg building with Visual Studio again. ]>> Several of the changes are needed to make OvmfPkg work with the ]>> proposed NOOPT build, in combination with IA32 target. The ]>> combination of 32-bit, Microsoft compiler, and optimization ]>> disabled causes generation of helper function calls for multiply, ]>> divide, shift, etc when operating on 64-bit integers. Rather than ]>> make significant code changes to add explicit function calls, this ]>> patch type casts some UINT64 integers to UINTN. That way, the 64-bit ]>> build is unaffected. An argument that this safe is based on the ]>> fact that the 64-bit values are addresses in most cases, and ]>> 32-bit code cannot ordinarily access memory above 4GB. In one ]>> case the 64-bit is the size of flash memory. If a 64MB flash ]>> memory is used, it would have to be located above 4GB where 32-bit ]>> code cannot access it. ]>> ]>> Other changes are due to Microsoft's warning about integer truncation. ]>> EDK2 enables this warning for Microsoft tool chains, but not for ]>> gcc tool chains. At least one integer truncation warning is not ]>> handled well by the Microsoft compiler, even with version 2010. ]>> Variable SegmentC holds the value 0xC0000, yet the compiler warns ]>> it is left shifted by 12 bits. On the other hand, I don't understand ]>> why the value is left shifted by 12. In any case, the final address ]>> fits in 32 bits. ]>> ]>> For both Microsoft and gcc compilers, the #include "inttypes.h" fails ]>> for me. The change to XenPvBlkDxe.inf is how I got it to work. ]> ]> Can you separate out the 'inttypes.h' Xen fix? ] ]The patch has the following diffstat: ] ] QemuFlashFvbServicesRuntimeDxe/FwBlockService.c | 6 +-- ] QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 2 - ] QemuVideoDxe/VbeShim.c | 12 +++--- ] VirtioScsiDxe/VirtioScsi.c | 2 - ] XenBusDxe/EventChannel.c | 6 +-- ] XenBusDxe/GrantTable.c | 8 ++-- ] XenBusDxe/XenBus.c | 6 +-- ] XenBusDxe/XenHypercall.c | 8 ++-- ] XenBusDxe/XenStore.c | 28 ++++++++-------- ] XenPvBlkDxe/BlockFront.c | 18 +++++----- ] XenPvBlkDxe/BlockIo.c | 2 - ] XenPvBlkDxe/XenPvBlkDxe.inf | 1 ] 12 files changed, 50 insertions(+), 49 deletions(-) ] ]Here's some changes I'd like to see -- these are not "hard requirements" ]by any means, just how I'd prefer to work with this patch. ] ](1) Please post two independent patches (not even in one series): one ]for Xen, the other for non-Xen. I'd like to review the non-Xen one, and ]I think we can ask Anthony Perard to review the Xen one. OK, they are attached and appended. I would be happy to resubmit without changes for the NOOPT build. I remember the NOOPT build easy to get working. But that was for x64 code. NOOPT + IA32 + Microsoft is not so easy. ](2) Please convince SVN somehow to include the function names in the ]hunks (usually the "-p" option for "diff"). Otherwise it's hard to jump ]to the containing function with any tags-capable editor. And, such ]patches cannot be validated without seeing the context. OK, see attached/appended. ](3) In this case I have the opposite opinion about casts vs. the verbose ]64-bit functions, like LShiftU64(), DivU64x32(), etc. Please consider ]using that family wherever possible, instead of the casts. For example, ]VirtioBlkDxe already uses ModU64x32() and DivU64x32(). ] ](4) The initial value of SegmentC is a (64-bit) linear address. It is ]left-shifted by three nibbles for the UINT32 fields in question because ]those are prepared for 16-bit real mode, and their representation is ]segment:offset, packed in a UINT32. In other words, the 0x000C_xxxx ]linear addresses are transformed into C000:xxxx, represented as ]0xC000_xxxx. This is required by the VBE (VGA BIOS Extension) docs. OK thanks, I see it now. A vbeFarPtr contains segment:offset for use in real mode and is never accessed as a flat address. ] ]> I have a fix for this that doesn't involve StdLib. In fact, we don't ]> want the StdLib dependency added. ] ]Agreed. ] ]> Do you want to work on a different fix (without StdLib), or should I ]> send out the one I have? ]> ]> Thanks for looking at these build issues, ] ](We do realize though that the solution would be a build farm, right? I ]would have absolutely no objections against using the DivU64x32() family ]and the somewhat retarded casts that VS requires *if* I would see those ]errors immediately.) ] ]Scott, feel free to do whatever you like with my requests -- I'm not ]NACKing this patch in any way (that would require me to review it), I ]just don't feel like reviewing it in this form. ] ]Thanks! ]Laszlo > -Jordan > >> --- >> >> Index: OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c >> =================================================================== >> --- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c (revision >> 16323) >> +++ OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c (working >> copy) >> @@ -919,7 +919,7 @@ >> Status = gBS->AllocatePages ( >> AllocateAddress, >> EfiRuntimeServicesData, >> - (UINTN) EFI_SIZE_TO_PAGES (Length), >> + (UINTN) EFI_SIZE_TO_PAGES ((UINTN)Length), >> &BaseAddress >> ); >> ASSERT_EFI_ERROR (Status); >> @@ -979,7 +979,7 @@ >> // Erase all the blocks >> // >> for (Offset = Start; Offset < Start + Length; Offset += BlockSize) { >> - Status = QemuFlashEraseBlock ((EFI_LBA) Offset / BlockSize); >> + Status = QemuFlashEraseBlock ((EFI_LBA) (Offset / BlockSize)); >> ASSERT_EFI_ERROR (Status); >> } >> >> @@ -988,7 +988,7 @@ >> // >> WriteLength = GoodFwVolHeader->HeaderLength; >> Status = QemuFlashWrite ( >> - (EFI_LBA) Start / BlockSize, >> + (EFI_LBA) (Start / BlockSize), >> 0, >> &WriteLength, >> (UINT8 *) GoodFwVolHeader); >> Index: OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c >> =================================================================== >> --- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c (revision 16323) >> +++ OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c (working copy) >> @@ -54,7 +54,7 @@ >> IN UINTN Offset >> ) >> { >> - return mFlashBase + (Lba * mFdBlockSize) + Offset; >> + return mFlashBase + ((UINTN)Lba * mFdBlockSize) + Offset; >> } >> >> >> Index: OvmfPkg/QemuVideoDxe/VbeShim.c >> =================================================================== >> --- OvmfPkg/QemuVideoDxe/VbeShim.c (revision 16323) >> +++ OvmfPkg/QemuVideoDxe/VbeShim.c (working copy) >> @@ -153,13 +153,13 @@ >> CopyMem (VbeInfo->Signature, "VESA", 4); >> VbeInfo->VesaVersion = 0x0300; >> >> - VbeInfo->OemNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr); >> + VbeInfo->OemNameAddress = ((UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr); >> CopyMem (Ptr, "QEMU", 5); >> Ptr += 5; >> >> VbeInfo->Capabilities = BIT0; // DAC can be switched into 8-bit mode >> >> - VbeInfo->ModeListAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr); >> + VbeInfo->ModeListAddress = ((UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr); >> *(UINT16*)Ptr = 0x00f1; // mode number >> Ptr += 2; >> *(UINT16*)Ptr = 0xFFFF; // mode list terminator >> @@ -168,17 +168,17 @@ >> VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536); >> VbeInfo->OemSoftwareVersion = 0x0000; >> >> - VbeInfo->VendorNameAddress = (UINT32)(SegmentC << 12 | >> (UINT16)(UINTN)Ptr); >> + VbeInfo->VendorNameAddress = ((UINT32)SegmentC << 12 | >> (UINT16)(UINTN)Ptr); >> CopyMem (Ptr, "OVMF", 5); >> Ptr += 5; >> >> - VbeInfo->ProductNameAddress = (UINT32)(SegmentC << 12 | >> (UINT16)(UINTN)Ptr); >> + VbeInfo->ProductNameAddress = ((UINT32)SegmentC << 12 | >> (UINT16)(UINTN)Ptr); >> Printed = AsciiSPrint ((CHAR8 *)Ptr, >> sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer), >> "%s", >> CardName); >> Ptr += Printed + 1; >> >> - VbeInfo->ProductRevAddress = (UINT32)(SegmentC << 12 | >> (UINT16)(UINTN)Ptr); >> + VbeInfo->ProductRevAddress = ((UINT32)SegmentC << 12 | >> (UINT16)(UINTN)Ptr); >> CopyMem (Ptr, mProductRevision, sizeof mProductRevision); >> Ptr += sizeof mProductRevision; >> >> @@ -268,7 +268,7 @@ >> // >> // Second, point the Int10h vector at the shim. >> // >> - Int0x10->Segment = (UINT16) (SegmentC >> 4); >> + Int0x10->Segment = (UINT16) ((UINT32)SegmentC >> 4); >> Int0x10->Offset = (UINT16) ((UINTN) (VbeModeInfo + 1) - SegmentC); >> >> DEBUG ((EFI_D_INFO, "%a: VBE shim installed\n", __FUNCTION__)); >> Index: OvmfPkg/VirtioScsiDxe/VirtioScsi.c >> =================================================================== >> --- OvmfPkg/VirtioScsiDxe/VirtioScsi.c (revision 16323) >> +++ OvmfPkg/VirtioScsiDxe/VirtioScsi.c (working copy) >> @@ -253,7 +253,7 @@ >> // >> Request->Lun[0] = 1; >> Request->Lun[1] = (UINT8) Target; >> - Request->Lun[2] = (UINT8) ((Lun >> 8) | 0x40); >> + Request->Lun[2] = (UINT8) (((UINT32)Lun >> 8) | 0x40); >> Request->Lun[3] = (UINT8) Lun; >> >> // >> Index: OvmfPkg/XenBusDxe/EventChannel.c >> =================================================================== >> --- OvmfPkg/XenBusDxe/EventChannel.c (revision 16323) >> +++ OvmfPkg/XenBusDxe/EventChannel.c (working copy) >> @@ -29,7 +29,7 @@ >> >> Send.port = Port; >> ReturnCode = XenHypercallEventChannelOp (Dev, EVTCHNOP_send, &Send); >> - return ReturnCode; >> + return (UINT32)ReturnCode; >> } >> >> UINT32 >> @@ -48,7 +48,7 @@ >> >> Parameter.dom = DOMID_SELF; >> Parameter.remote_dom = DomainId; >> - ReturnCode = XenHypercallEventChannelOp (Private->Dev, >> + ReturnCode = (UINT32)XenHypercallEventChannelOp (Private->Dev, >> EVTCHNOP_alloc_unbound, >> &Parameter); >> if (ReturnCode != 0) { >> @@ -84,5 +84,5 @@ >> >> Private = XENBUS_PRIVATE_DATA_FROM_THIS (This); >> Close.port = Port; >> - return XenHypercallEventChannelOp (Private->Dev, EVTCHNOP_close, &Close); >> + return (UINT32)XenHypercallEventChannelOp (Private->Dev, EVTCHNOP_close, >> &Close); >> } >> Index: OvmfPkg/XenBusDxe/GrantTable.c >> =================================================================== >> --- OvmfPkg/XenBusDxe/GrantTable.c (revision 16323) >> +++ OvmfPkg/XenBusDxe/GrantTable.c (working copy) >> @@ -85,7 +85,7 @@ >> GrantInUseList[Ref] = TRUE; >> #endif >> EfiReleaseLock (&mGrantListLock); >> - return Ref; >> + return (grant_ref_t)Ref; >> } >> >> STATIC >> @@ -101,7 +101,7 @@ >> >> ASSERT (GrantTable != NULL); >> Ref = XenGrantTableGetFreeEntry (); >> - GrantTable[Ref].frame = Frame; >> + GrantTable[Ref].frame = (UINT32)Frame; >> GrantTable[Ref].domid = DomainId; >> MemoryFence (); >> Flags = GTF_permit_access; >> @@ -108,7 +108,7 @@ >> if (ReadOnly) { >> Flags |= GTF_readonly; >> } >> - GrantTable[Ref].flags = Flags; >> + GrantTable[Ref].flags = (UINT16)Flags; >> >> return Ref; >> } >> @@ -152,7 +152,7 @@ >> #endif >> EfiInitializeLock (&mGrantListLock, TPL_NOTIFY); >> for (Index = NR_RESERVED_ENTRIES; Index < NR_GRANT_ENTRIES; Index++) { >> - XenGrantTablePutFreeEntry (Index); >> + XenGrantTablePutFreeEntry ((grant_ref_t)Index); >> } >> >> GrantTable = (VOID*)(UINTN) MmioAddr; >> Index: OvmfPkg/XenBusDxe/XenBus.c >> =================================================================== >> --- OvmfPkg/XenBusDxe/XenBus.c (revision 16323) >> +++ OvmfPkg/XenBusDxe/XenBus.c (working copy) >> @@ -182,7 +182,7 @@ >> Private->XenBusIo.Type = AsciiStrDup (Type); >> Private->XenBusIo.Node = AsciiStrDup (DevicePath); >> Private->XenBusIo.Backend = BackendPath; >> - Private->XenBusIo.DeviceId = AsciiStrDecimalToUintn (Id); >> + Private->XenBusIo.DeviceId = (UINT16)AsciiStrDecimalToUintn (Id); >> Private->Dev = Dev; >> >> TempXenBusPath = AllocateCopyPool (sizeof (XENBUS_DEVICE_PATH), >> @@ -274,7 +274,7 @@ >> XenBusAddDevice (Dev, Type, Directory[Index]); >> } >> >> - FreePool (Directory); >> + FreePool ((VOID*)Directory); >> } >> >> >> @@ -310,7 +310,7 @@ >> XenBusEnumerateDeviceType (Dev, Types[Index]); >> } >> >> - FreePool (Types); >> + FreePool ((VOID*)Types); >> >> return XENSTORE_STATUS_SUCCESS; >> } >> Index: OvmfPkg/XenBusDxe/XenHypercall.c >> =================================================================== >> --- OvmfPkg/XenBusDxe/XenHypercall.c (revision 16323) >> +++ OvmfPkg/XenBusDxe/XenHypercall.c (working copy) >> @@ -52,8 +52,8 @@ >> ASSERT (Dev->Hyperpage != NULL); >> >> Parameter.domid = DOMID_SELF; >> - Parameter.index = Index; >> - Error = XenHypercall2 (Dev->Hyperpage + __HYPERVISOR_hvm_op * 32, >> + Parameter.index = (UINT32)Index; >> + Error = XenHypercall2 ((UINT8*)Dev->Hyperpage + __HYPERVISOR_hvm_op * 32, >> HVMOP_get_param, (INTN) &Parameter); >> if (Error != 0) { >> DEBUG ((EFI_D_ERROR, >> @@ -72,7 +72,7 @@ >> ) >> { >> ASSERT (Dev->Hyperpage != NULL); >> - return XenHypercall2 (Dev->Hyperpage + __HYPERVISOR_memory_op * 32, >> + return XenHypercall2 ((UINT8*)Dev->Hyperpage + __HYPERVISOR_memory_op * >> 32, >> Operation, (INTN) Arguments); >> } >> >> @@ -84,7 +84,7 @@ >> ) >> { >> ASSERT (Dev->Hyperpage != NULL); >> - return XenHypercall2 (Dev->Hyperpage + __HYPERVISOR_event_channel_op * 32, >> + return XenHypercall2 ((UINT8*)Dev->Hyperpage + >> __HYPERVISOR_event_channel_op * 32, >> Operation, (INTN) Arguments); >> } >> >> Index: OvmfPkg/XenBusDxe/XenStore.c >> =================================================================== >> --- OvmfPkg/XenBusDxe/XenStore.c (revision 16323) >> +++ OvmfPkg/XenBusDxe/XenStore.c (working copy) >> @@ -248,7 +248,7 @@ >> >> /* Transfer to one big alloc for easy freeing by the caller. */ >> Dst = AllocatePool (*NumPtr * sizeof (CHAR8 *) + Len); >> - CopyMem (&Dst[*NumPtr], Strings, Len); >> + CopyMem ((VOID*)&Dst[*NumPtr], Strings, Len); >> FreePool (Strings); >> >> /* Extract pointers to newly allocated array. */ >> @@ -493,7 +493,7 @@ >> >> Dest = XenStoreGetOutputChunk (Cons, Prod, xs.XenStore->req, >> &Available); >> if (Available > Len) { >> - Available = Len; >> + Available = (UINT32)Len; >> } >> >> CopyMem (Dest, Data, Available); >> @@ -572,7 +572,7 @@ >> >> Src = XenStoreGetInputChunk (Cons, Prod, xs.XenStore->rsp, &Available); >> if (Available > Len) { >> - Available = Len; >> + Available = (UINT32)Len; >> } >> >> /* >> @@ -660,7 +660,7 @@ >> } else { >> DEBUG ((EFI_D_WARN, "XenStore: Watch handle %a not found\n", >> Message->u.Watch.Vector[XS_WATCH_TOKEN])); >> - FreePool(Message->u.Watch.Vector); >> + FreePool((VOID*)Message->u.Watch.Vector); >> FreePool(Message); >> } >> EfiReleaseLock (&xs.RegisteredWatchesLock); >> @@ -812,7 +812,7 @@ >> Message.type = RequestType; >> Message.len = 0; >> for (Index = 0; Index < NumRequests; Index++) { >> - Message.len += WriteRequest[Index].Len; >> + Message.len += (UINT32)WriteRequest[Index].Len; >> } >> >> Status = XenStoreWriteStore (&Message, sizeof (Message)); >> @@ -829,7 +829,7 @@ >> } >> } >> >> - Status = XenStoreReadReply (&Message.type, LenPtr, &Return); >> + Status = XenStoreReadReply ((enum xsd_sockmsg_type *)&Message.type, >> LenPtr, &Return); >> >> Error: >> if (Status != XENSTORE_STATUS_SUCCESS) { >> @@ -843,7 +843,7 @@ >> } >> >> /* Reply is either error or an echo of our request message type. */ >> - ASSERT (Message.type == RequestType); >> + ASSERT ((enum xsd_sockmsg_type)Message.type == RequestType); >> >> if (ResultPtr) { >> *ResultPtr = Return; >> @@ -975,7 +975,7 @@ >> if (Message->u.Watch.Handle == Token) { >> RemoveEntryList (Entry); >> EfiReleaseLock (&xs.WatchEventsLock); >> - FreePool(Message->u.Watch.Vector); >> + FreePool((VOID*)Message->u.Watch.Vector); >> FreePool(Message); >> return XENSTORE_STATUS_SUCCESS; >> } >> @@ -1057,8 +1057,8 @@ >> >> xs.Dev = Dev; >> >> - xs.EventChannel = XenHypercallHvmGetParam (Dev, HVM_PARAM_STORE_EVTCHN); >> - XenStoreGpfn = XenHypercallHvmGetParam (Dev, HVM_PARAM_STORE_PFN); >> + xs.EventChannel = (evtchn_port_t)XenHypercallHvmGetParam (Dev, >> HVM_PARAM_STORE_EVTCHN); >> + XenStoreGpfn = (UINTN)XenHypercallHvmGetParam (Dev, HVM_PARAM_STORE_PFN); >> xs.XenStore = (VOID *) (XenStoreGpfn << EFI_PAGE_SHIFT); >> DEBUG ((EFI_D_INFO, "XenBusInit: XenBus rings @%p, event channel %x\n", >> xs.XenStore, xs.EventChannel)); >> @@ -1115,7 +1115,7 @@ >> XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry); >> Entry = GetNextNode (&xs.WatchEvents, Entry); >> RemoveEntryList (&Message->Link); >> - FreePool (Message->u.Watch.Vector); >> + FreePool ((VOID*)Message->u.Watch.Vector); >> FreePool (Message); >> } >> } >> @@ -1202,7 +1202,7 @@ >> if (Status != XENSTORE_STATUS_SUCCESS) { >> return FALSE; >> } >> - FreePool (TempStr); >> + FreePool ((VOID*)TempStr); >> return TRUE; >> } >> >> @@ -1283,7 +1283,7 @@ >> Status = XenStoreSingle (XST_NIL, XS_TRANSACTION_START, "", NULL, >> (VOID **) &IdStr); >> if (Status == XENSTORE_STATUS_SUCCESS) { >> - Transaction->Id = AsciiStrDecimalToUintn (IdStr); >> + Transaction->Id = (UINT32)AsciiStrDecimalToUintn (IdStr); >> FreePool (IdStr); >> } >> >> @@ -1419,7 +1419,7 @@ >> Entry = GetNextNode (&xs.WatchEvents, Entry); >> if (Message->u.Watch.Handle == Watch) { >> RemoveEntryList (&Message->Link); >> - FreePool (Message->u.Watch.Vector); >> + FreePool ((VOID*)Message->u.Watch.Vector); >> FreePool (Message); >> } >> } >> Index: OvmfPkg/XenPvBlkDxe/BlockFront.c >> =================================================================== >> --- OvmfPkg/XenPvBlkDxe/BlockFront.c (revision 16323) >> +++ OvmfPkg/XenPvBlkDxe/BlockFront.c (working copy) >> @@ -196,7 +196,7 @@ >> Status)); >> goto Error; >> } >> - Dev->DomainId = Value; >> + Dev->DomainId = (domid_t)Value; >> XenBusIo->EventChannelAllocate (XenBusIo, Dev->DomainId, >> &Dev->EventChannel); >> >> SharedRing = (blkif_sring_t*) AllocatePages (1); >> @@ -262,7 +262,7 @@ >> if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT32_MAX) { >> goto Error2; >> } >> - Dev->MediaInfo.VDiskInfo = Value; >> + Dev->MediaInfo.VDiskInfo = (UINT32)Value; >> if (Dev->MediaInfo.VDiskInfo & VDISK_READONLY) { >> Dev->MediaInfo.ReadWrite = FALSE; >> } else { >> @@ -278,7 +278,7 @@ >> if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT32_MAX) { >> goto Error2; >> } >> - if (Value % 512 != 0) { >> + if ((UINT32)Value % 512 != 0) { >> // >> // This is not supported by the driver. >> // >> @@ -286,7 +286,7 @@ >> "it must be a multiple of 512\n", Value)); >> goto Error2; >> } >> - Dev->MediaInfo.SectorSize = Value; >> + Dev->MediaInfo.SectorSize = (UINT32)Value; >> >> // Default value >> Value = 0; >> @@ -443,7 +443,7 @@ >> >> 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 +452,7 @@ >> 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 +461,9 @@ >> 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[NumSegments - 1].last_sect = >> - (((UINTN) IoData->Buffer + IoData->Size - 1) & EFI_PAGE_MASK) / 512; >> + Request->seg[0].first_sect = (UINT8)(((UINTN) IoData->Buffer & >> EFI_PAGE_MASK) / 512); >> + Request->seg[NumSegments - 1].last_sect = (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, >> Index: OvmfPkg/XenPvBlkDxe/BlockIo.c >> =================================================================== >> --- OvmfPkg/XenPvBlkDxe/BlockIo.c (revision 16323) >> +++ OvmfPkg/XenPvBlkDxe/BlockIo.c (working copy) >> @@ -136,7 +136,7 @@ >> } >> >> IoData.Dev = XEN_BLOCK_FRONT_FROM_BLOCK_IO (This); >> - Sector = Lba * (Media->BlockSize / 512); >> + Sector = (UINTN)MultU64x32 (Lba, Media->BlockSize / 512); >> >> while (BufferSize > 0) { >> if (((UINTN)Buffer & EFI_PAGE_MASK) == 0) { >> Index: OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf >> =================================================================== >> --- OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf (revision 16323) >> +++ OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf (working copy) >> @@ -27,6 +27,7 @@ >> [Packages] >> MdePkg/MdePkg.dec >> OvmfPkg/OvmfPkg.dec >> + StdLib/StdLib.dec >> >> [Sources] >> XenPvBlkDxe.h >> >> >> --- >> ovmf-ia32-msft-xen.patch: Index: OvmfPkg/XenBusDxe/EventChannel.c =================================================================== --- OvmfPkg/XenBusDxe/EventChannel.c (revision 16323) +++ OvmfPkg/XenBusDxe/EventChannel.c (working copy) @@ -29,7 +29,7 @@ XenEventChannelNotify ( Send.port = Port; ReturnCode = XenHypercallEventChannelOp (Dev, EVTCHNOP_send, &Send); - return ReturnCode; + return (UINT32)ReturnCode; } UINT32 @@ -48,7 +48,7 @@ XenBusEventChannelAllocate ( Parameter.dom = DOMID_SELF; Parameter.remote_dom = DomainId; - ReturnCode = XenHypercallEventChannelOp (Private->Dev, + ReturnCode = (UINT32)XenHypercallEventChannelOp (Private->Dev, EVTCHNOP_alloc_unbound, &Parameter); if (ReturnCode != 0) { @@ -84,5 +84,5 @@ XenBusEventChannelClose ( Private = XENBUS_PRIVATE_DATA_FROM_THIS (This); Close.port = Port; - return XenHypercallEventChannelOp (Private->Dev, EVTCHNOP_close, &Close); + return (UINT32)XenHypercallEventChannelOp (Private->Dev, EVTCHNOP_close, &Close); } Index: OvmfPkg/XenBusDxe/GrantTable.c =================================================================== --- OvmfPkg/XenBusDxe/GrantTable.c (revision 16323) +++ OvmfPkg/XenBusDxe/GrantTable.c (working copy) @@ -85,7 +85,7 @@ XenGrantTableGetFreeEntry ( GrantInUseList[Ref] = TRUE; #endif EfiReleaseLock (&mGrantListLock); - return Ref; + return (grant_ref_t)Ref; } STATIC @@ -101,7 +101,7 @@ XenGrantTableGrantAccess ( ASSERT (GrantTable != NULL); Ref = XenGrantTableGetFreeEntry (); - GrantTable[Ref].frame = Frame; + GrantTable[Ref].frame = (UINT32)Frame; GrantTable[Ref].domid = DomainId; MemoryFence (); Flags = GTF_permit_access; @@ -108,7 +108,7 @@ XenGrantTableGrantAccess ( if (ReadOnly) { Flags |= GTF_readonly; } - GrantTable[Ref].flags = Flags; + GrantTable[Ref].flags = (UINT16)Flags; return Ref; } @@ -152,7 +152,7 @@ XenGrantTableInit ( #endif EfiInitializeLock (&mGrantListLock, TPL_NOTIFY); for (Index = NR_RESERVED_ENTRIES; Index < NR_GRANT_ENTRIES; Index++) { - XenGrantTablePutFreeEntry (Index); + XenGrantTablePutFreeEntry ((grant_ref_t)Index); } GrantTable = (VOID*)(UINTN) MmioAddr; Index: OvmfPkg/XenBusDxe/XenBus.c =================================================================== --- OvmfPkg/XenBusDxe/XenBus.c (revision 16323) +++ OvmfPkg/XenBusDxe/XenBus.c (working copy) @@ -182,7 +182,7 @@ XenBusAddDevice ( Private->XenBusIo.Type = AsciiStrDup (Type); Private->XenBusIo.Node = AsciiStrDup (DevicePath); Private->XenBusIo.Backend = BackendPath; - Private->XenBusIo.DeviceId = AsciiStrDecimalToUintn (Id); + Private->XenBusIo.DeviceId = (UINT16)AsciiStrDecimalToUintn (Id); Private->Dev = Dev; TempXenBusPath = AllocateCopyPool (sizeof (XENBUS_DEVICE_PATH), @@ -274,7 +274,7 @@ XenBusEnumerateDeviceType ( XenBusAddDevice (Dev, Type, Directory[Index]); } - FreePool (Directory); + FreePool ((VOID*)Directory); } @@ -310,7 +310,7 @@ XenBusEnumerateBus ( XenBusEnumerateDeviceType (Dev, Types[Index]); } - FreePool (Types); + FreePool ((VOID*)Types); return XENSTORE_STATUS_SUCCESS; } Index: OvmfPkg/XenBusDxe/XenHypercall.c =================================================================== --- OvmfPkg/XenBusDxe/XenHypercall.c (revision 16323) +++ OvmfPkg/XenBusDxe/XenHypercall.c (working copy) @@ -52,8 +52,8 @@ XenHypercallHvmGetParam ( ASSERT (Dev->Hyperpage != NULL); Parameter.domid = DOMID_SELF; - Parameter.index = Index; - Error = XenHypercall2 (Dev->Hyperpage + __HYPERVISOR_hvm_op * 32, + Parameter.index = (UINT32)Index; + Error = XenHypercall2 ((UINT8*)Dev->Hyperpage + __HYPERVISOR_hvm_op * 32, HVMOP_get_param, (INTN) &Parameter); if (Error != 0) { DEBUG ((EFI_D_ERROR, @@ -72,7 +72,7 @@ XenHypercallMemoryOp ( ) { ASSERT (Dev->Hyperpage != NULL); - return XenHypercall2 (Dev->Hyperpage + __HYPERVISOR_memory_op * 32, + return XenHypercall2 ((UINT8*)Dev->Hyperpage + __HYPERVISOR_memory_op * 32, Operation, (INTN) Arguments); } @@ -84,7 +84,7 @@ XenHypercallEventChannelOp ( ) { ASSERT (Dev->Hyperpage != NULL); - return XenHypercall2 (Dev->Hyperpage + __HYPERVISOR_event_channel_op * 32, + return XenHypercall2 ((UINT8*)Dev->Hyperpage + __HYPERVISOR_event_channel_op * 32, Operation, (INTN) Arguments); } Index: OvmfPkg/XenBusDxe/XenStore.c =================================================================== --- OvmfPkg/XenBusDxe/XenStore.c (revision 16323) +++ OvmfPkg/XenBusDxe/XenStore.c (working copy) @@ -248,7 +248,7 @@ Split ( /* Transfer to one big alloc for easy freeing by the caller. */ Dst = AllocatePool (*NumPtr * sizeof (CHAR8 *) + Len); - CopyMem (&Dst[*NumPtr], Strings, Len); + CopyMem ((VOID*)&Dst[*NumPtr], Strings, Len); FreePool (Strings); /* Extract pointers to newly allocated array. */ @@ -493,7 +493,7 @@ XenStoreWriteStore ( Dest = XenStoreGetOutputChunk (Cons, Prod, xs.XenStore->req, &Available); if (Available > Len) { - Available = Len; + Available = (UINT32)Len; } CopyMem (Dest, Data, Available); @@ -572,7 +572,7 @@ XenStoreReadStore ( Src = XenStoreGetInputChunk (Cons, Prod, xs.XenStore->rsp, &Available); if (Available > Len) { - Available = Len; + Available = (UINT32)Len; } /* @@ -660,7 +660,7 @@ XenStoreProcessMessage ( } else { DEBUG ((EFI_D_WARN, "XenStore: Watch handle %a not found\n", Message->u.Watch.Vector[XS_WATCH_TOKEN])); - FreePool(Message->u.Watch.Vector); + FreePool((VOID*)Message->u.Watch.Vector); FreePool(Message); } EfiReleaseLock (&xs.RegisteredWatchesLock); @@ -812,7 +812,7 @@ XenStoreTalkv ( Message.type = RequestType; Message.len = 0; for (Index = 0; Index < NumRequests; Index++) { - Message.len += WriteRequest[Index].Len; + Message.len += (UINT32)WriteRequest[Index].Len; } Status = XenStoreWriteStore (&Message, sizeof (Message)); @@ -829,7 +829,7 @@ XenStoreTalkv ( } } - Status = XenStoreReadReply (&Message.type, LenPtr, &Return); + Status = XenStoreReadReply ((enum xsd_sockmsg_type *)&Message.type, LenPtr, &Return); Error: if (Status != XENSTORE_STATUS_SUCCESS) { @@ -843,7 +843,7 @@ Error: } /* Reply is either error or an echo of our request message type. */ - ASSERT (Message.type == RequestType); + ASSERT ((enum xsd_sockmsg_type)Message.type == RequestType); if (ResultPtr) { *ResultPtr = Return; @@ -975,7 +975,7 @@ XenStoreWaitWatch ( if (Message->u.Watch.Handle == Token) { RemoveEntryList (Entry); EfiReleaseLock (&xs.WatchEventsLock); - FreePool(Message->u.Watch.Vector); + FreePool((VOID*)Message->u.Watch.Vector); FreePool(Message); return XENSTORE_STATUS_SUCCESS; } @@ -1057,8 +1057,8 @@ XenStoreInit ( xs.Dev = Dev; - xs.EventChannel = XenHypercallHvmGetParam (Dev, HVM_PARAM_STORE_EVTCHN); - XenStoreGpfn = XenHypercallHvmGetParam (Dev, HVM_PARAM_STORE_PFN); + xs.EventChannel = (evtchn_port_t)XenHypercallHvmGetParam (Dev, HVM_PARAM_STORE_EVTCHN); + XenStoreGpfn = (UINTN)XenHypercallHvmGetParam (Dev, HVM_PARAM_STORE_PFN); xs.XenStore = (VOID *) (XenStoreGpfn << EFI_PAGE_SHIFT); DEBUG ((EFI_D_INFO, "XenBusInit: XenBus rings @%p, event channel %x\n", xs.XenStore, xs.EventChannel)); @@ -1115,7 +1115,7 @@ XenStoreDeinit ( XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry); Entry = GetNextNode (&xs.WatchEvents, Entry); RemoveEntryList (&Message->Link); - FreePool (Message->u.Watch.Vector); + FreePool ((VOID*)Message->u.Watch.Vector); FreePool (Message); } } @@ -1202,7 +1202,7 @@ XenStorePathExists ( if (Status != XENSTORE_STATUS_SUCCESS) { return FALSE; } - FreePool (TempStr); + FreePool ((VOID*)TempStr); return TRUE; } @@ -1283,7 +1283,7 @@ XenStoreTransactionStart ( Status = XenStoreSingle (XST_NIL, XS_TRANSACTION_START, "", NULL, (VOID **) &IdStr); if (Status == XENSTORE_STATUS_SUCCESS) { - Transaction->Id = AsciiStrDecimalToUintn (IdStr); + Transaction->Id = (UINT32)AsciiStrDecimalToUintn (IdStr); FreePool (IdStr); } @@ -1419,7 +1419,7 @@ XenStoreUnregisterWatch ( Entry = GetNextNode (&xs.WatchEvents, Entry); if (Message->u.Watch.Handle == Watch) { RemoveEntryList (&Message->Link); - FreePool (Message->u.Watch.Vector); + FreePool ((VOID*)Message->u.Watch.Vector); FreePool (Message); } } Index: OvmfPkg/XenPvBlkDxe/BlockFront.c =================================================================== --- OvmfPkg/XenPvBlkDxe/BlockFront.c (revision 16323) +++ OvmfPkg/XenPvBlkDxe/BlockFront.c (working copy) @@ -196,7 +196,7 @@ XenPvBlockFrontInitialization ( Status)); goto Error; } - Dev->DomainId = Value; + Dev->DomainId = (domid_t)Value; XenBusIo->EventChannelAllocate (XenBusIo, Dev->DomainId, &Dev->EventChannel); SharedRing = (blkif_sring_t*) AllocatePages (1); @@ -262,7 +262,7 @@ Again: if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT32_MAX) { goto Error2; } - Dev->MediaInfo.VDiskInfo = Value; + Dev->MediaInfo.VDiskInfo = (UINT32)Value; if (Dev->MediaInfo.VDiskInfo & VDISK_READONLY) { Dev->MediaInfo.ReadWrite = FALSE; } else { @@ -278,7 +278,7 @@ Again: if (Status != XENSTORE_STATUS_SUCCESS || Value > UINT32_MAX) { goto Error2; } - if (Value % 512 != 0) { + if ((UINT32)Value % 512 != 0) { // // This is not supported by the driver. // @@ -286,7 +286,7 @@ Again: "it must be a multiple of 512\n", Value)); goto Error2; } - Dev->MediaInfo.SectorSize = Value; + Dev->MediaInfo.SectorSize = (UINT32)Value; // Default value Value = 0; @@ -443,7 +443,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 +452,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 +461,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[NumSegments - 1].last_sect = - (((UINTN) IoData->Buffer + IoData->Size - 1) & EFI_PAGE_MASK) / 512; + Request->seg[0].first_sect = (UINT8)(((UINTN) IoData->Buffer & EFI_PAGE_MASK) / 512); + Request->seg[NumSegments - 1].last_sect = (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, Index: OvmfPkg/XenPvBlkDxe/BlockIo.c =================================================================== --- OvmfPkg/XenPvBlkDxe/BlockIo.c (revision 16323) +++ OvmfPkg/XenPvBlkDxe/BlockIo.c (working copy) @@ -136,7 +136,7 @@ XenPvBlkDxeBlockIoReadWriteBlocks ( } IoData.Dev = XEN_BLOCK_FRONT_FROM_BLOCK_IO (This); - Sector = Lba * (Media->BlockSize / 512); + Sector = (UINTN)MultU64x32 (Lba, Media->BlockSize / 512); while (BufferSize > 0) { if (((UINTN)Buffer & EFI_PAGE_MASK) == 0) { --- ovmf-ia32-msft-non-xen.patch Index: OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c =================================================================== --- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c (revision 16323) +++ OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c (working copy) @@ -919,7 +919,7 @@ MarkMemoryRangeForRuntimeAccess ( Status = gBS->AllocatePages ( AllocateAddress, EfiRuntimeServicesData, - (UINTN) EFI_SIZE_TO_PAGES (Length), + (UINTN) EFI_SIZE_TO_PAGES ((UINTN)Length), &BaseAddress ); ASSERT_EFI_ERROR (Status); @@ -979,7 +979,7 @@ InitializeVariableFvHeader ( // Erase all the blocks // for (Offset = Start; Offset < Start + Length; Offset += BlockSize) { - Status = QemuFlashEraseBlock ((EFI_LBA) Offset / BlockSize); + Status = QemuFlashEraseBlock ((EFI_LBA) (Offset / BlockSize)); ASSERT_EFI_ERROR (Status); } @@ -988,7 +988,7 @@ InitializeVariableFvHeader ( // WriteLength = GoodFwVolHeader->HeaderLength; Status = QemuFlashWrite ( - (EFI_LBA) Start / BlockSize, + (EFI_LBA) (Start / BlockSize), 0, &WriteLength, (UINT8 *) GoodFwVolHeader); Index: OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c =================================================================== --- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c (revision 16323) +++ OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c (working copy) @@ -54,7 +54,7 @@ QemuFlashPtr ( IN UINTN Offset ) { - return mFlashBase + (Lba * mFdBlockSize) + Offset; + return mFlashBase + ((UINTN)Lba * mFdBlockSize) + Offset; } Index: OvmfPkg/QemuVideoDxe/VbeShim.c =================================================================== --- OvmfPkg/QemuVideoDxe/VbeShim.c (revision 16323) +++ OvmfPkg/QemuVideoDxe/VbeShim.c (working copy) @@ -153,13 +153,13 @@ InstallVbeShim ( CopyMem (VbeInfo->Signature, "VESA", 4); VbeInfo->VesaVersion = 0x0300; - VbeInfo->OemNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr); + VbeInfo->OemNameAddress = ((UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr); CopyMem (Ptr, "QEMU", 5); Ptr += 5; VbeInfo->Capabilities = BIT0; // DAC can be switched into 8-bit mode - VbeInfo->ModeListAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr); + VbeInfo->ModeListAddress = ((UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr); *(UINT16*)Ptr = 0x00f1; // mode number Ptr += 2; *(UINT16*)Ptr = 0xFFFF; // mode list terminator @@ -168,17 +168,17 @@ InstallVbeShim ( VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536); VbeInfo->OemSoftwareVersion = 0x0000; - VbeInfo->VendorNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr); + VbeInfo->VendorNameAddress = ((UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr); CopyMem (Ptr, "OVMF", 5); Ptr += 5; - VbeInfo->ProductNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr); + VbeInfo->ProductNameAddress = ((UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr); Printed = AsciiSPrint ((CHAR8 *)Ptr, sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer), "%s", CardName); Ptr += Printed + 1; - VbeInfo->ProductRevAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr); + VbeInfo->ProductRevAddress = ((UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr); CopyMem (Ptr, mProductRevision, sizeof mProductRevision); Ptr += sizeof mProductRevision; @@ -268,7 +268,7 @@ InstallVbeShim ( // // Second, point the Int10h vector at the shim. // - Int0x10->Segment = (UINT16) (SegmentC >> 4); + Int0x10->Segment = (UINT16) ((UINT32)SegmentC >> 4); Int0x10->Offset = (UINT16) ((UINTN) (VbeModeInfo + 1) - SegmentC); DEBUG ((EFI_D_INFO, "%a: VBE shim installed\n", __FUNCTION__)); Index: OvmfPkg/VirtioScsiDxe/VirtioScsi.c =================================================================== --- OvmfPkg/VirtioScsiDxe/VirtioScsi.c (revision 16323) +++ OvmfPkg/VirtioScsiDxe/VirtioScsi.c (working copy) @@ -253,7 +253,7 @@ PopulateRequest ( // Request->Lun[0] = 1; Request->Lun[1] = (UINT8) Target; - Request->Lun[2] = (UINT8) ((Lun >> 8) | 0x40); + Request->Lun[2] = (UINT8) (((UINT32)Lun >> 8) | 0x40); Request->Lun[3] = (UINT8) Lun; //
ovmf-ia32-msft-xen.patch
Description: Binary data
ovmf-ia32-msft-non-xen.patch
Description: Binary data
------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel