From 7a38833070cf4499e8b7c2d485b5b6e1070e1eb0 Mon Sep 17 00:00:00 2001 From: Bret Barkelew Date: Tue, 12 Jun 2018 09:01:05 -0700 Subject: [PATCH] Everything else MSCHANGEs. --- .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 2 +- .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.h | 2 +- MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 10 +- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 17 ++- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c | 125 ++++++++++++++++-- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h | 2 + MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c | 29 ++++ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h | 14 ++ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 16 +++ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c | 17 +++ MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 6 +- .../UsbMouseAbsolutePointer.c | 2 +- MdeModulePkg/Core/Dxe/Image/Image.c | 31 +++-- MdeModulePkg/Core/Dxe/Mem/Page.c | 14 +- MdeModulePkg/Core/DxeIplPeim/DxeIpl.h | 20 ++- MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 5 +- MdeModulePkg/Core/DxeIplPeim/DxeLoad.c | 19 ++- MdeModulePkg/Core/Pei/Image/Image.c | 36 ++--- MdeModulePkg/Core/Pei/PeiMain.inf | 4 + MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 38 ++++++ MdeModulePkg/Core/PiSmmCore/Dispatcher.c | 31 +++-- MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 9 +- .../Include/Library/PlatformBootManagerLib.h | 48 +++++++ .../PlatformBootManager.c | 63 +++++++++ .../Library/UefiBootManagerLib/BmBoot.c | 9 +- .../UefiBootManagerLib/UefiBootManagerLib.inf | 2 + MdeModulePkg/MdeModulePkg.dec | 7 + MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 12 ++ MdeModulePkg/Universal/CapsulePei/Capsule.h | 85 ++++++------ .../Universal/CapsulePei/CapsuleX64.inf | 8 ++ .../CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf | 1 + .../CapsuleRuntimeDxe/CapsuleService.c | 57 ++++++++ .../Console/ConSplitterDxe/ConSplitter.c | 31 ++++- .../ConSplitterDxe/ConSplitterGraphics.c | 11 +- .../GraphicsConsoleDxe/GraphicsConsole.c | 37 ++++-- MdeModulePkg/Universal/HiiDatabaseDxe/Font.c | 5 + MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 3 + .../Universal/Variable/RuntimeDxe/Variable.c | 48 +++++-- .../Variable/RuntimeDxe/VariableSmm.c | 25 ++-- MdePkg/Include/Guid/EventGroup.h | 11 ++ MdePkg/Include/IndustryStandard/PeImage.h | 28 ++++ MdePkg/Include/Library/DebugLib.h | 2 + MdePkg/MdePkg.dec | 6 + NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c | 19 +-- NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 4 +- NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 58 +++++--- NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h | 1 + NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c | 112 ++++++++++++++-- .../PcatRealTimeClockRuntimeDxe/PcRtc.h | 21 ++- 49 files changed, 964 insertions(+), 199 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c index 6594b8eae8..3abfd2a194 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c @@ -2628,7 +2628,7 @@ PciEnumeratorLight ( **/ EFI_STATUS PciGetBusRange ( - IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, + IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, // MS_CHANGE added OUT macro OUT UINT16 *MinBus, OUT UINT16 *MaxBus, OUT UINT16 *BusRange diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h index 7daa6e020d..bab1fe94e0 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h @@ -409,7 +409,7 @@ PciEnumeratorLight ( **/ EFI_STATUS PciGetBusRange ( - IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, + IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, // MS_CHANGE added OUT macro OUT UINT16 *MinBus, OUT UINT16 *MaxBus, OUT UINT16 *BusRange diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c index 84fc0161a1..02b6c87c87 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c @@ -1100,6 +1100,7 @@ PciScanBus ( EFI_HPC_STATE State; UINT64 PciAddress; EFI_HPC_PADDING_ATTRIBUTES Attributes; + VOID *DescriptorsBuffer = NULL; // MS_CHANGE EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors; EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *NextDescriptors; UINT16 BusRange; @@ -1257,7 +1258,7 @@ PciScanBus ( PciDevice->DevicePath, PciAddress, &State, - (VOID **)&Descriptors, + &DescriptorsBuffer, // MS_CHANGE &Attributes ); @@ -1265,6 +1266,7 @@ PciScanBus ( return Status; } + Descriptors = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)DescriptorsBuffer; // MS_CHANGE BusRange = 0; NextDescriptors = Descriptors; Status = PciGetBusRange ( @@ -1274,7 +1276,11 @@ PciScanBus ( &BusRange ); - FreePool (Descriptors); + // MS_CHANGE [BEGIN] + FreePool (DescriptorsBuffer); + DescriptorsBuffer = NULL; + Descriptors = NULL; + // MS_CHANGE [END] if (!EFI_ERROR (Status)) { BusPadding = TRUE; diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c index 05528a478b..11e1a04b5b 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -1173,6 +1173,8 @@ XhcCheckUrbResult ( continue; } + CheckedUrb->Ring->RingDequeue = TRBPtr; // MS_CHANGE_274185 + switch (EvtTrb->Completecode) { case TRB_COMPLETION_STALL_ERROR: CheckedUrb->Result |= EFI_USB_ERR_STALL; @@ -1210,9 +1212,11 @@ XhcCheckUrbResult ( case TRB_COMPLETION_SHORT_PACKET: case TRB_COMPLETION_SUCCESS: - if (EvtTrb->Completecode == TRB_COMPLETION_SHORT_PACKET) { - DEBUG ((DEBUG_VERBOSE, "XhcCheckUrbResult: short packet happens!\n")); - } + // MS_CHANGE_161866 + // if (EvtTrb->Completecode == TRB_COMPLETION_SHORT_PACKET) { + // DEBUG ((DEBUG_VERBOSE, "XhcCheckUrbResult: short packet happens!\n")); + // } + // END TRBType = (UINT8)(TRBPtr->Type); if ((TRBType == TRB_TYPE_DATA_STAGE) || @@ -2003,6 +2007,7 @@ XhcSyncTrsRing ( if (TrsTrb != TrsRing->RingEnqueue) { TrsRing->RingEnqueue = TrsTrb; + ASSERT (TrsTrb != TrsRing->RingDequeue); // MS_CHANGE_274185 } // @@ -3555,6 +3560,12 @@ XhcSetTrDequeuePointer ( if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "XhcSetTrDequeuePointer: Set TR Dequeue Pointer Failed, Status = %r\n", Status)); } + // MS_CHANGE_274185 + else { + Urb->Ring->RingDequeue = Urb->Ring->RingEnqueue; + } + + // END return Status; } diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c index c25f3cc2f2..fd36c1b01c 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c @@ -80,6 +80,14 @@ UsbIoControlTransfer ( UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + // MS_CHANGE_166714 + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + DEBUG ((EFI_D_ERROR, "UsbIoControlTransfer No media\n")); + goto ON_EXIT; + } + + // END RequestedDataLength = DataLength; Status = UsbHcControlTransfer ( @@ -264,7 +272,14 @@ UsbIoBulkTransfer ( UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + // MS_CHANGE_166714 + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + DEBUG ((EFI_D_ERROR, "UsbIoBulkTransfer No media\n")); + goto ON_EXIT; + } + // END EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint); if ((EpDesc == NULL) || (USB_ENDPOINT_TYPE (&EpDesc->Desc) != USB_ENDPOINT_BULK)) { @@ -357,7 +372,14 @@ UsbIoSyncInterruptTransfer ( UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + // MS_CHANGE_166714 + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + DEBUG ((EFI_D_ERROR, "UsbIoSyncInterruptTransfer No media\n")); + goto ON_EXIT; + } + // END EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint); if ((EpDesc == NULL) || (USB_ENDPOINT_TYPE (&EpDesc->Desc) != USB_ENDPOINT_INTERRUPT)) { @@ -433,7 +455,14 @@ UsbIoAsyncInterruptTransfer ( OldTpl = gBS->RaiseTPL (USB_BUS_TPL); UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + // MS_CHANGE_166714 + if ((Dev->Connected == FALSE) && (IsNewTransfer == TRUE)) { + Status = EFI_DEVICE_ERROR; + DEBUG ((EFI_D_ERROR, "UsbIoAsyncInterruptTransfer No media\n")); + goto ON_EXIT; + } + // END EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint); if ((EpDesc == NULL) || (USB_ENDPOINT_TYPE (&EpDesc->Desc) != USB_ENDPOINT_INTERRUPT)) { @@ -537,6 +566,7 @@ UsbIoGetDeviceDescriptor ( USB_DEVICE *Dev; USB_INTERFACE *UsbIf; EFI_TPL OldTpl; + EFI_STATUS Status; // // MS_CHANGE_166714 if (Descriptor == NULL) { return EFI_INVALID_PARAMETER; @@ -546,11 +576,21 @@ UsbIoGetDeviceDescriptor ( UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + // MS_CHANGE_166714 + Status = EFI_SUCCESS; + + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + goto ON_EXIT; + } + + // END CopyMem (Descriptor, &Dev->DevDesc->Desc, sizeof (EFI_USB_DEVICE_DESCRIPTOR)); +ON_EXIT: // MS_CHANGE_166714 gBS->RestoreTPL (OldTpl); - return EFI_SUCCESS; + return Status; // MS_CHANGE_166714 } /** @@ -585,7 +625,13 @@ UsbIoGetActiveConfigDescriptor ( UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + // MS_CHANGE_166714 + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + goto ON_EXIT; + } + // END if (Dev->ActiveConfig == NULL) { Status = EFI_NOT_FOUND; goto ON_EXIT; @@ -615,8 +661,10 @@ UsbIoGetInterfaceDescriptor ( OUT EFI_USB_INTERFACE_DESCRIPTOR *Descriptor ) { + USB_DEVICE *Dev; // MS_CHANGE_166714 USB_INTERFACE *UsbIf; EFI_TPL OldTpl; + EFI_STATUS Status; // MS_CHANGE_166714 if (Descriptor == NULL) { return EFI_INVALID_PARAMETER; @@ -625,10 +673,22 @@ UsbIoGetInterfaceDescriptor ( OldTpl = gBS->RaiseTPL (USB_BUS_TPL); UsbIf = USB_INTERFACE_FROM_USBIO (This); + // MS_CHANGE_166714 + Dev = UsbIf->Device; + Status = EFI_SUCCESS; + + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + goto ON_EXIT; + } + + // END + CopyMem (Descriptor, &(UsbIf->IfSetting->Desc), sizeof (EFI_USB_INTERFACE_DESCRIPTOR)); +ON_EXIT: // MS_CHANGE_166714 gBS->RestoreTPL (OldTpl); - return EFI_SUCCESS; + return Status; // MS_CHANGE_166714 } /** @@ -651,21 +711,37 @@ UsbIoGetEndpointDescriptor ( OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor ) { + USB_DEVICE *Dev; // MS_CHANGE_166714 USB_INTERFACE *UsbIf; EFI_TPL OldTpl; + EFI_STATUS Status; // MS_CHANGE_166714 OldTpl = gBS->RaiseTPL (USB_BUS_TPL); UsbIf = USB_INTERFACE_FROM_USBIO (This); + // MS_CHANGE_166714 + Dev = UsbIf->Device; + Status = EFI_SUCCESS; + + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + goto ON_EXIT; + } + + // END if ((Descriptor == NULL) || (Index > 15)) { - gBS->RestoreTPL (OldTpl); - return EFI_INVALID_PARAMETER; + // MS_CHANGE_166714 + Status = EFI_INVALID_PARAMETER; + goto ON_EXIT; + // END } if (Index >= UsbIf->IfSetting->Desc.NumEndpoints) { - gBS->RestoreTPL (OldTpl); - return EFI_NOT_FOUND; + // MS_CHANGE_166714 + Status = EFI_NOT_FOUND; + goto ON_EXIT; + // END } CopyMem ( @@ -674,8 +750,9 @@ UsbIoGetEndpointDescriptor ( sizeof (EFI_USB_ENDPOINT_DESCRIPTOR) ); +ON_EXIT: // MS_CHANGE_166714 gBS->RestoreTPL (OldTpl); - return EFI_SUCCESS; + return Status; // MS_CHANGE_166714 } /** @@ -699,17 +776,28 @@ UsbIoGetSupportedLanguages ( USB_DEVICE *Dev; USB_INTERFACE *UsbIf; EFI_TPL OldTpl; + EFI_STATUS Status; // MS_CHANGE_166714 OldTpl = gBS->RaiseTPL (USB_BUS_TPL); UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + // MS_CHANGE_166714 + Status = EFI_SUCCESS; + + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + goto ON_EXIT; + } + + // END *LangIDTable = Dev->LangId; *TableSize = (UINT16)(Dev->TotalLangId * sizeof (UINT16)); +ON_EXIT: // MS_CHANGE_166714 gBS->RestoreTPL (OldTpl); - return EFI_SUCCESS; + return Status; // MS_CHANGE_166714 } /** @@ -749,6 +837,13 @@ UsbIoGetStringDescriptor ( UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + // MS_CHANGE_166714 + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + goto ON_EXIT; + } + + // END // // Check whether language ID is supported @@ -826,7 +921,14 @@ UsbIoPortReset ( UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + // MS_CHANGE_166714 + if (Dev->Connected == FALSE) { + Status = EFI_DEVICE_ERROR; + DEBUG ((EFI_D_ERROR, "UsbIoPortReset No media\n")); + goto ON_EXIT; + } + // END if (UsbIf->IsHub) { Status = EFI_INVALID_PARAMETER; goto ON_EXIT; @@ -877,6 +979,13 @@ UsbIoPortReset ( DEBUG ((DEBUG_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address)); + // MS_CHANGE_291137 + // + // Endpoint descriptor state needs to be updated following a reset. + // + UsbUpdateDescriptors (Dev); + // END + // // Reset the current active configure, after this device // is in CONFIGURED state. diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h index 21a24218fc..6336930279 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h @@ -188,6 +188,7 @@ struct _USB_DEVICE { USB_INTERFACE *ParentIf; UINT8 ParentPort; // Start at 0 UINT8 Tier; + BOOLEAN Connected; // MS_CHANGE_166714 BOOLEAN DisconnectFail; }; @@ -228,6 +229,7 @@ struct _USB_INTERFACE { // connected to EHCI. // UINT8 MaxSpeed; + volatile UINT8 PollCount; // MS_CHANGE_168923 }; // diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c index 8b078e7e49..2c1d51f218 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c @@ -1009,3 +1009,32 @@ UsbIoClearFeature ( return Status; } + +// MS_CHANGE_291137 + +/** + Update the device's descriptor information. + + @param UsbDev The Usb device. + +**/ +VOID +UsbUpdateDescriptors ( + IN USB_DEVICE *UsbDev + ) +{ + EFI_USB_CONFIG_DESCRIPTOR *ConfDesc; + EFI_USB_DEVICE_DESCRIPTOR DevDesc; + UINT8 Index; + EFI_STATUS Status; + + Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_DEVICE, 0, 0, &DevDesc, sizeof (EFI_USB_DEVICE_DESCRIPTOR)); + for (Index = 0; Index < DevDesc.NumConfigurations; Index++) { + ConfDesc = UsbGetOneConfig (UsbDev, Index); + FreePool (ConfDesc); + } + + return; +} + +// END diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h index ce205e706d..7b1f8990a9 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h @@ -224,4 +224,18 @@ UsbIoClearFeature ( IN UINT16 Index ); +// MS_CHANGE_291137 + +/** + Usb UsbIo interface to update descriptor information. + + @param UsbDev The Usb device. + +**/ +VOID +UsbUpdateDescriptors ( + IN USB_DEVICE *UsbDev + ); + +// END #endif diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c index b3a40639f2..10dca0d497 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c @@ -233,6 +233,10 @@ UsbCreateDevice ( Device->ParentIf = ParentIf; Device->ParentPort = ParentPort; Device->Tier = (UINT8)(ParentIf->Device->Tier + 1); + // MS_CHANGE_166714 + Device->Connected = TRUE; + DEBUG ((EFI_D_INFO, "UsbCreateDevice: ParentIf %p port %d Connected\n", ParentIf, ParentPort)); + // END return Device; } @@ -594,6 +598,10 @@ UsbRemoveDevice ( return ReturnStatus; } + // MS_CHANGE_166714 + Device->Connected = FALSE; + DEBUG ((EFI_D_INFO, "UsbRemoveDevice: ParentIf %p port %d Disonnected\n", Device->ParentIf, Device->ParentPort)); + // END Status = UsbRemoveConfig (Device); if (!EFI_ERROR (Status)) { @@ -1077,6 +1085,14 @@ UsbRootHubEnumeration ( RootHub = (USB_INTERFACE *)Context; + // MS_CHANGE_168923 + // MSCHANGE Implement Enumeration delay + if (RootHub->PollCount < 200) { + RootHub->PollCount++; + } + + // END + for (Index = 0; Index < RootHub->NumOfPort; Index++) { Child = UsbFindChild (RootHub, Index); if ((Child != NULL) && (Child->DisconnectFail == TRUE)) { diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c index 1a473d0998..ec9ab870c9 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c @@ -998,6 +998,23 @@ UsbRootHubInit ( if (EFI_ERROR (Status)) { gBS->CloseEvent (HubIf->HubNotify); + // MS_CHANGE_168923 + } else { + // MSCHANGE Add USB Hub Enumeration delay + EFI_TPL OldTpl; + + OldTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); + gBS->RestoreTPL (TPL_APPLICATION); + + while (HubIf->PollCount < 6) { + // 6 * (USB_ROOTHUB_POLL_INTERVAL 100 ms) + } + + if (OldTpl > TPL_APPLICATION) { + gBS->RaiseTPL (OldTpl); + } + + // END } return Status; diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c index b5a6459a35..71df372b54 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -1187,7 +1187,7 @@ KeyboardHandler ( // KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, CurKeyCodeBuffer[Index]); if (KeyDescriptor == NULL) { - continue; + return EFI_INVALID_PARAMETER; // MS_CHANGE_168925 } if ((KeyDescriptor->Modifier == EFI_NUM_LOCK_MODIFIER) || (KeyDescriptor->Modifier == EFI_CAPS_LOCK_MODIFIER)) { @@ -1265,7 +1265,7 @@ USBParseKey ( KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, UsbKey.KeyCode); if (KeyDescriptor == NULL) { - continue; + return EFI_INVALID_PARAMETER; // MS_CHANGE_168925 } if (!UsbKey.Down) { @@ -1577,7 +1577,7 @@ UsbKeyCodeToEfiInputKey ( // KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, KeyCode); if (KeyDescriptor == NULL) { - return EFI_DEVICE_ERROR; + return EFI_INVALID_PARAMETER; // MS_CHANGE_168925 } if (KeyDescriptor->Modifier == EFI_NS_KEY_MODIFIER) { diff --git a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c index ad5f066ec9..6271f7a684 100644 --- a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c +++ b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c @@ -847,7 +847,7 @@ OnMouseInterruptComplete ( UsbMouseAbsolutePointerDevice->State.CurrentZ = MIN ( MAX ( - (INT64)UsbMouseAbsolutePointerDevice->State.CurrentZ + *((INT8 *)Data + 1), + (INT64)UsbMouseAbsolutePointerDevice->State.CurrentZ + *((INT8 *)Data + 3), // MS_CHANGE changed to +3 from +1 (INT64)UsbMouseAbsolutePointerDevice->Mode.AbsoluteMinZ ), (INT64)UsbMouseAbsolutePointerDevice->Mode.AbsoluteMaxZ diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index 9f6af608f6..5e677f8a7b 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -824,18 +824,26 @@ CoreLoadPeImage ( // Print the load address and the PDB file name if it is available // - DEBUG_CODE_BEGIN (); - + // MS_CHANGE_304324 + // DEBUG_CODE_BEGIN (); + // END UINTN Index; UINTN StartIndex; CHAR8 EfiFileName[256]; - DEBUG (( - DEBUG_INFO | DEBUG_LOAD, - "Loading driver at 0x%11p EntryPoint=0x%11p ", - (VOID *)(UINTN)Image->ImageContext.ImageAddress, - FUNCTION_ENTRY_POINT (Image->ImageContext.EntryPoint) - )); + // MS_CHANGE_304324 + if (DebugCodeEnabled ()) { + DEBUG (( + DEBUG_INFO | DEBUG_LOAD, + "Loading driver at 0x%11p EntryPoint=0x%11p ", + (VOID *)(UINTN)Image->ImageContext.ImageAddress, + FUNCTION_ENTRY_POINT (Image->ImageContext.EntryPoint) + )); + } else { + DEBUG ((DEBUG_LOAD, "Loading driver ")); + } + + // END // // Print Module Name by Pdb file path. @@ -873,11 +881,14 @@ CoreLoadPeImage ( EfiFileName[Index] = 0; } - DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex])); + DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex])); // MS_CHANGE_304324 } - DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n")); + DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "\n")); // MS_CHANGE_304324 + // MS_CHANGE_304324 + // DEBUG_CODE_END (); + // END // MS_CHANGE_? Status = PeCoffLoaderGetSecurityCookieAddress (&Image->ImageContext, &SecurityCookieAddress); if (!EFI_ERROR (Status)) { diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index 6497af5733..c5fd093185 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -775,7 +775,7 @@ CoreConvertPagesEx ( } if (Link == &gMemoryMap) { - DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: failed to find range %lx - %lx\n", Start, End)); + DEBUG ((DEBUG_PAGE, "ConvertPages: failed to find range %lx - %lx\n", Start, End)); // MS_CHANGE_316852 return EFI_NOT_FOUND; } @@ -815,11 +815,11 @@ CoreConvertPagesEx ( // Debug code - verify conversion is allowed // if (!((NewType == EfiConventionalMemory) ? 1 : 0) ^ ((Entry->Type == EfiConventionalMemory) ? 1 : 0)) { - DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible memory types, ")); + DEBUG ((DEBUG_PAGE, "ConvertPages: Incompatible memory types, ")); // MS_CHANGE_316852 if (Entry->Type == EfiConventionalMemory) { - DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "the pages to free have been freed\n")); + DEBUG ((DEBUG_PAGE, "the pages to free have been freed\n")); // MS_CHANGE_316852 } else { - DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "the pages to allocate have been allocated\n")); + DEBUG ((DEBUG_PAGE, "the pages to allocate have been allocated\n")); // MS_CHANGE_316852 } return EFI_NOT_FOUND; @@ -2092,7 +2092,7 @@ CoreAllocatePoolPages ( // Convert it to boot services data // if (Start == 0) { - DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "AllocatePoolPages: failed to allocate %d pages\n", (UINT32)NumberOfPages)); + DEBUG ((DEBUG_PAGE, "AllocatePoolPages: failed to allocate %d pages\n", (UINT32)NumberOfPages)); // MS_CHANGE_316852 } else { if (NeedGuard) { CoreConvertPagesWithGuard (Start, NumberOfPages, PoolType); @@ -2158,13 +2158,13 @@ CoreTerminateMemoryMap ( ASSERT (Entry->Type != EfiACPIReclaimMemory); ASSERT (Entry->Type != EfiACPIMemoryNVS); if ((Entry->Start & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) { - DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n")); + DEBUG ((DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n")); // MS_CHANGE_316852 Status = EFI_INVALID_PARAMETER; goto Done; } if (((Entry->End + 1) & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) { - DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n")); + DEBUG ((DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n")); // MS_CHANGE_316852 Status = EFI_INVALID_PARAMETER; goto Done; } diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h index 2f015befce..394d821cc6 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h @@ -15,9 +15,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include +// MS_CHANGE_190466 +// #include +// END #include -#include +// MS_CHANGE_190466 +// #include +// END #include #include #include @@ -34,8 +38,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include -#include +// MS_CHANGE_190466 +// #include +// #include +// END #include #include #include @@ -134,6 +140,9 @@ UpdateStackHob ( IN UINT64 Length ); +// MS_CHANGE_190466 +#if 0 + /** The ExtractSection() function processes the input section and returns a pointer to the section contents. If the section being @@ -228,3 +237,6 @@ Decompress ( ); #endif +// END + +#endif diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf index f1990eac77..ef22bc1212 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf @@ -56,8 +56,8 @@ PcdLib MemoryAllocationLib BaseMemoryLib - ExtractGuidedSectionLib - UefiDecompressLib +# ExtractGuidedSectionLib ## MS_CHANGE_190466 +# UefiDecompressLib ## MS_CHANGE_190466 ReportStatusCodeLib PeiServicesLib HobLib @@ -107,6 +107,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## CONSUMES [Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c index 2c19f1a507..0e64b024a2 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c +++ b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c @@ -24,6 +24,8 @@ CONST EFI_PEI_PPI_DESCRIPTOR mDxeIplPpiList = { (VOID *)&mDxeIplPpi }; +// MS_CHANGE_190466 +#if 0 CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI mCustomGuidedSectionExtractionPpi = { CustomGuidedSectionExtract }; @@ -37,6 +39,8 @@ CONST EFI_PEI_PPI_DESCRIPTOR mDecompressPpiList = { &gEfiPeiDecompressPpiGuid, (VOID *)&mDecompressPpi }; +#endif +// END CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = { (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), @@ -147,7 +151,10 @@ InstallIplPermanentMemoryPpis ( IN VOID *Ppi ) { - EFI_STATUS Status; + EFI_STATUS Status; + + // MS_CHANGE_190466 + #if 0 EFI_GUID *ExtractHandlerGuidTable; UINTN ExtractHandlerNumber; EFI_PEI_PPI_DESCRIPTOR *GuidPpi; @@ -177,7 +184,9 @@ InstallIplPermanentMemoryPpis ( // Status = PeiServicesInstallPpi (&mDecompressPpiList); ASSERT_EFI_ERROR (Status); - + #endif + Status = EFI_SUCCESS; + // MS_CHANGE - END return Status; } @@ -511,6 +520,9 @@ DxeIplFindDxeCore ( } } +// MS_CHANGE_190466 +#if 0 + /** The ExtractSection() function processes the input section and returns a pointer to the section contents. If the section being @@ -794,6 +806,9 @@ Decompress ( return EFI_SUCCESS; } +#endif +// END + /** Updates the Stack HOB passed to DXE phase. diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Image/Image.c index cee9f09c6e..55cb7a9523 100644 --- a/MdeModulePkg/Core/Pei/Image/Image.c +++ b/MdeModulePkg/Core/Pei/Image/Image.c @@ -623,6 +623,13 @@ PeiLoadImageLoadImage ( UINT16 Machine; EFI_SECTION_TYPE SearchType1; EFI_SECTION_TYPE SearchType2; + // MS_CHANGE_304324 + CHAR8 *AsciiString; + CHAR8 EfiFileName[512]; + INT32 Index; + INT32 StartIndex; + + // END *EntryPoint = 0; ImageSize = 0; @@ -706,24 +713,21 @@ PeiLoadImageLoadImage ( *ImageSizeArg = ImageSize; } - DEBUG_CODE_BEGIN (); - CHAR8 *AsciiString; - CHAR8 EfiFileName[512]; - INT32 Index; - INT32 StartIndex; - + // MS_CHANGE_304324 + // DEBUG_CODE_BEGIN (); + // END // - // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi + // For IPF Image, the real entry point should be print. // - if (Machine != EFI_IMAGE_MACHINE_IA64) { + // MS_CHANGE_304324 + if (DebugCodeEnabled ()) { DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)*EntryPoint)); } else { - // - // For IPF Image, the real entry point should be print. - // - DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)(*(UINT64 *)(UINTN)*EntryPoint))); + DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM ")); } + // END + // // Print Module Name by PeImage PDB file name. // @@ -761,12 +765,14 @@ PeiLoadImageLoadImage ( EfiFileName[Index] = 0; } - DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName)); + DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "%a", EfiFileName)); // MS_CHANGE_304324 } - DEBUG_CODE_END (); + // MS_CHANGE_304324 + // DEBUG_CODE_END (); + // END - DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n")); + DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "\n")); return EFI_SUCCESS; } diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf index 61b4b1816f..12ba49322b 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/MdeModulePkg/Core/Pei/PeiMain.inf @@ -66,6 +66,7 @@ PeCoffLib PeiServicesTablePointerLib PcdLib + TimerLib ## MS_CHANGE [Guids] gPeiAprioriFileNameGuid ## SOMETIMES_CONSUMES ## File @@ -78,6 +79,7 @@ gEfiFirmwareFileSystem3Guid gStatusCodeCallbackGuid gEdkiiMigratedFvInfoGuid ## SOMETIMES_PRODUCES ## HOB + gEfiFirmwarePerformanceGuid # MS_CHANGE_161871 - needed to build SEC perf HOB gEfiDelayedDispatchTableGuid # MSCHANGE gPerfDelayedDispatchEndOfPei # MS_CHANGE @@ -102,7 +104,9 @@ gEfiPeiReset2PpiGuid ## SOMETIMES_CONSUMES gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES gEfiPeiCoreFvLocationPpiGuid ## SOMETIMES_CONSUMES + gPeiSecPerformancePpiGuid #MS_CHANGE_161871 - needed to build SEC perf HOB gEfiDelayedDispatchPpiGuid # MSCHANGE + gEfiEndOfPeiSignalPpiGuid # MSCHANGE [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c index cb1187b3ce..18d5312f37 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -8,6 +8,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "PeiMain.h" +// MS_CHANGE_161871 +// MSCHANGE - Include these in order to build the performance HOB here instead of +// FirmwarePerformancePei. Necessary because Firmware firmwarePerformancePei +// is loaded postmem when CAR is gone. +#include +#include +// END + EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = { (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), &gEfiPeiMemoryDiscoveredPpiGuid, @@ -178,6 +186,12 @@ PeiCore ( EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable; EFI_PEI_TEMPORARY_RAM_DONE_PPI *TemporaryRamDonePpi; UINTN Index; + // MS_CHANGE_161871 + // MSCHANGE - Build the performance HOB here instead of FirmwarePerformancePei. + FIRMWARE_SEC_PERFORMANCE Performance; + PEI_SEC_PERFORMANCE_PPI *SecPerf; + + // END // // Retrieve context passed into PEI Core @@ -437,6 +451,30 @@ PeiCore ( if (PpiList != NULL) { ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps, PpiList); } + + // MS_CHANGE_161871 + // + // MSCHANGE: Build Hob for SEC performance data. + // + Status = PeiServicesLocatePpi ( + &gPeiSecPerformancePpiGuid, + 0, + NULL, + (VOID **)&SecPerf + ); + if (!EFI_ERROR (Status)) { + Status = SecPerf->GetPerformance ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps, SecPerf, &Performance); + if (!EFI_ERROR (Status)) { + BuildGuidDataHob ( + &gEfiFirmwarePerformanceGuid, + &Performance, + sizeof (FIRMWARE_SEC_PERFORMANCE) + ); + DEBUG ((DEBUG_ERROR, "SEC Performance Hob ResetEnd = %ld\n", Performance.ResetEnd)); + } + } + + // END } else { if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) { // diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c index 92fe05e609..37bf50240a 100644 --- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c +++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c @@ -666,18 +666,27 @@ SmmLoadImage ( // Print the load address and the PDB file name if it is available // - DEBUG_CODE_BEGIN (); + // MS_CHANGE_304324 + // DEBUG_CODE_BEGIN (); + // END UINTN Index; UINTN StartIndex; CHAR8 EfiFileName[256]; - DEBUG (( - DEBUG_INFO | DEBUG_LOAD, - "Loading SMM driver at 0x%11p EntryPoint=0x%11p ", - (VOID *)(UINTN)ImageContext.ImageAddress, - FUNCTION_ENTRY_POINT (ImageContext.EntryPoint) - )); + // MS_CHANGE_304324 + if (DebugCodeEnabled ()) { + DEBUG (( + DEBUG_INFO | DEBUG_LOAD, + "Loading SMM driver at 0x%11p EntryPoint=0x%11p ", + (VOID *)(UINTN)ImageContext.ImageAddress, + FUNCTION_ENTRY_POINT (ImageContext.EntryPoint) + )); + } else { + DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "Loading SMM driver ")); + } + + // END // // Print Module Name by Pdb file path. @@ -715,10 +724,14 @@ SmmLoadImage ( EfiFileName[Index] = 0; } - DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex])); + DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex])); // MS_CHANGE_304324 } - DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n")); + DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "\n")); // MS_CHANGE_304324 + + // MS_CHANGE_304324 + // DEBUG_CODE_END (); + // END // MS_CHANGE_? Status = PeCoffLoaderGetSecurityCookieAddress (&ImageContext, &SecurityCookieAddress); diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c index fbba868fd0..b3a0ab5cfe 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c @@ -1125,7 +1125,14 @@ ExecuteSmmCoreFromSmram ( // // Print debug message showing SMM Core load address. // - DEBUG ((DEBUG_INFO, "SMM IPL loading SMM Core at SMRAM address %p\n", (VOID *)(UINTN)ImageContext.ImageAddress)); + // MS_CHANGE_304324 + if (DebugCodeEnabled ()) { + DEBUG ((DEBUG_INFO, "SMM IPL loading SMM Core at SMRAM address %p\n", (VOID *)(UINTN)ImageContext.ImageAddress)); + } else { + DEBUG ((DEBUG_ERROR, "SMM IPL loading SMM Core (PiSmmCore.efi)\n")); + } + + // END // // Load the image to our new buffer diff --git a/MdeModulePkg/Include/Library/PlatformBootManagerLib.h b/MdeModulePkg/Include/Library/PlatformBootManagerLib.h index 9dd590c9e0..827481e23b 100644 --- a/MdeModulePkg/Include/Library/PlatformBootManagerLib.h +++ b/MdeModulePkg/Include/Library/PlatformBootManagerLib.h @@ -65,4 +65,52 @@ PlatformBootManagerUnableToBoot ( VOID ); +/** MSCHANGE begin + Do Platform specific action required at start of BDS + +**/ +VOID +EFIAPI +PlatformBootManagerBdsEntry ( + VOID + ); + +/** +ProcessBootCompletion +*/ +VOID +EFIAPI +PlatformBootManagerProcessBootCompletion ( + IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption + ); + +/** + HardKeyBoot +*/ +VOID +EFIAPI +PlatformBootManagerPriorityBoot ( + UINT16 **BootNext + ); + +/** + BDS Deadloop - error, unable to boot any boot option +*/ +VOID +EFIAPI +PlatformBootManagerDeadloop ( + VOID + ); + +/** + OnDemandConInCOnnect + */ +VOID +EFIAPI +PlatformBootManagerOnDemandConInConnect ( + VOID + ); + +/** MSCHANGE end */ + #endif diff --git a/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c b/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c index db6ada3aac..d746d34691 100644 --- a/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c +++ b/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c @@ -74,3 +74,66 @@ PlatformBootManagerUnableToBoot ( { return; } + +/** MSCHANGE begin + Do Platform specific action required at start of BDS + +**/ +VOID +EFIAPI +PlatformBootManagerBdsEntry ( + VOID + ) +{ + return; +} + +/** +ProcessBootCompletion +*/ +VOID +EFIAPI +PlatformBootManagerProcessBootCompletion ( + IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption + ) +{ + return; +} + +/** + HardKeyBoot +*/ +VOID +EFIAPI +PlatformBootManagerPriorityBoot ( + UINT16 **BootNext + ) +{ + return; +} + +/** + BDS Deadloop - error, unable to boot any boot option +*/ +VOID +EFIAPI +PlatformBootManagerDeadloop ( + VOID + ) +{ + return; +} + +/** + OnDemandConInCOnnect + */ +VOID +EFIAPI +PlatformBootManagerOnDemandConInConnect ( + VOID + ) +{ + return; +} + +/** MSCHANGE end */ diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index 7a97f7cdcc..fb58bc72be 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -1907,7 +1907,9 @@ EfiBootManagerBoot ( DEBUG ((DEBUG_INFO, "[Bds] Booting Boot Manager Menu.\n")); BmStopHotkeyService (NULL, NULL); } else { + EfiEventGroupSignal (&gEfiEventPreReadyToBootGuid); // MSCHANGE EfiSignalEventReadyToBoot (); + EfiEventGroupSignal (&gEfiEventPostReadyToBootGuid); // MSCHANGE // // Report Status Code to indicate ReadyToBoot was signalled // @@ -2582,7 +2584,12 @@ BmRegisterBootManagerMenu ( EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); ); - return EfiBootManagerAddLoadOptionVariable (BootOption, (UINTN)-1); + if (!EFI_ERROR (Status) && (PcdGetBool (PcdBootManagerInBootOrder))) { + // MSCHANGE + Status = EfiBootManagerAddLoadOptionVariable (BootOption, (UINTN)-1); + } // MSCHANGE + + return Status; // MSCHANGE } /** diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf index 2fc0a80a4e..0a86872509 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf +++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf @@ -86,6 +86,8 @@ gEfiDiskInfoScsiInterfaceGuid ## SOMETIMES_CONSUMES ## GUID gEfiDiskInfoSdMmcInterfaceGuid ## SOMETIMES_CONSUMES ## GUID gEfiDiskInfoUfsInterfaceGuid ## SOMETIMES_CONSUMES ## GUID + gEfiEventPreReadyToBootGuid ## PRODUCES ##MSCHANGE + gEfiEventPostReadyToBootGuid ## PRODUCES ##MSCHANGE [Protocols] gEfiPciRootBridgeIoProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 21daf17726..618eb444be 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1812,6 +1812,13 @@ # @Prompt Reset on memory type information change. gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE|BOOLEAN|0x00010056 + ## MSCHANGE + ## Indicates if the Boot Manager should be in the Boot Order list.

## MSCHANGE + # TRUE - Add Boot Manager to boot order.
## MSCHANGE + # FALSE - Does not add Boot Manager to boot order.
## MSCHANGE + # @Prompt Store Boot Manager in BootOrder. ## MSCHANGE + gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerInBootOrder|TRUE|BOOLEAN|0x0001007A ## MSCHANGE + ## Indicates if the BDS supports Platform Recovery.

# TRUE - BDS supports Platform Recovery.
# FALSE - BDS does not support Platform Recovery.
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c index 72de8d3211..792bbb3330 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -68,6 +68,9 @@ BdsDxeOnConnectConInCallBack ( { EFI_STATUS Status; + // Inform platform of duties to perform before connecting consoles. // MSCHANGE + PlatformBootManagerOnDemandConInConnect (); // MSCHANGE + // // When Osloader call ReadKeyStroke to signal this event // no driver dependency is assumed existing. So use a non-dispatch version @@ -413,6 +416,8 @@ BootBootOptions ( // EfiBootManagerBoot (&BootOptions[Index]); + PlatformBootManagerProcessBootCompletion (&BootOptions[Index]); // MSCHANGE 00076 - record boot status + // // If the boot via Boot#### returns with a status of EFI_SUCCESS, platform firmware // supports boot manager menu, and if firmware is configured to boot in an @@ -703,6 +708,7 @@ BdsEntry ( PERF_CROSSMODULE_END ("DXE"); PERF_CROSSMODULE_BEGIN ("BDS"); DEBUG ((DEBUG_INFO, "[Bds] Entry...\n")); + PlatformBootManagerBdsEntry (); // MSCHANGE 00076 - Signal start of BDS // // Fill in FirmwareVendor and FirmwareRevision from PCDs @@ -1049,6 +1055,8 @@ BdsEntry ( EfiBootManagerHotkeyBoot (); + PlatformBootManagerPriorityBoot (&BootNext); // MSCHANGE 00076 Check for hard button boot selection + if (BootNext != NULL) { // // Delete "BootNext" NV variable before transferring control to it to prevent loops. @@ -1072,6 +1080,7 @@ BdsEntry ( Status = EfiBootManagerVariableToLoadOption (BootNextVariableName, &LoadOption); if (!EFI_ERROR (Status)) { EfiBootManagerBoot (&LoadOption); + PlatformBootManagerProcessBootCompletion (&LoadOption); // MSCHANGE 00076 - record boot status EfiBootManagerFreeLoadOption (&LoadOption); if ((LoadOption.Status == EFI_SUCCESS) && (BootManagerMenuStatus != EFI_NOT_FOUND) && @@ -1119,6 +1128,9 @@ BdsEntry ( DEBUG ((DEBUG_ERROR, "[Bds] Unable to boot!\n")); PlatformBootManagerUnableToBoot (); + + PlatformBootManagerDeadloop (); // MSCHANGE + CpuDeadLoop (); } diff --git a/MdeModulePkg/Universal/CapsulePei/Capsule.h b/MdeModulePkg/Universal/CapsulePei/Capsule.h index c16f83a07a..12390312f2 100644 --- a/MdeModulePkg/Universal/CapsulePei/Capsule.h +++ b/MdeModulePkg/Universal/CapsulePei/Capsule.h @@ -22,6 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include // MS_CHANGE #include #include #include @@ -45,18 +46,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent typedef union { struct { - UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory - UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write - UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User - UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching - UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached - UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU) - UINT64 Reserved : 1; // Reserved - UINT64 MustBeZero : 2; // Must Be Zero - UINT64 Available : 3; // Available for use by system software - UINT64 PageTableBaseAddress : 40; // Page Table Base Address - UINT64 AvabilableHigh : 11; // Available for use by system software - UINT64 Nx : 1; // No Execute bit + UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User + UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Reserved : 1; // Reserved + UINT64 MustBeZero : 2; // Must Be Zero + UINT64 Available : 3; // Available for use by system software + UINT64 PageTableBaseAddress : 40; // Page Table Base Address + UINT64 AvabilableHigh : 11; // Available for use by system software + UINT64 Nx : 1; // No Execute bit } Bits; UINT64 Uint64; } PAGE_MAP_AND_DIRECTORY_POINTER; @@ -66,21 +67,21 @@ typedef union { // typedef union { struct { - UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory - UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write - UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User - UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching - UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached - UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU) - UINT64 Dirty : 1; // 0 = Not Dirty, 1 = written by processor on access to page - UINT64 MustBe1 : 1; // Must be 1 - UINT64 Global : 1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write - UINT64 Available : 3; // Available for use by system software - UINT64 PAT : 1; // - UINT64 MustBeZero : 8; // Must be zero; - UINT64 PageTableBaseAddress : 31; // Page Table Base Address - UINT64 AvabilableHigh : 11; // Available for use by system software - UINT64 Nx : 1; // 0 = Execute Code, 1 = No Code Execution + UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User + UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Dirty : 1; // 0 = Not Dirty, 1 = written by processor on access to page + UINT64 MustBe1 : 1; // Must be 1 + UINT64 Global : 1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write + UINT64 Available : 3; // Available for use by system software + UINT64 PAT : 1; // + UINT64 MustBeZero : 8; // Must be zero; + UINT64 PageTableBaseAddress : 31; // Page Table Base Address + UINT64 AvabilableHigh : 11; // Available for use by system software + UINT64 Nx : 1; // 0 = Execute Code, 1 = No Code Execution } Bits; UINT64 Uint64; } PAGE_TABLE_ENTRY; @@ -90,21 +91,21 @@ typedef union { // typedef union { struct { - UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory - UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write - UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User - UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching - UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached - UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU) - UINT64 Dirty : 1; // 0 = Not Dirty, 1 = written by processor on access to page - UINT64 MustBe1 : 1; // Must be 1 - UINT64 Global : 1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write - UINT64 Available : 3; // Available for use by system software - UINT64 PAT : 1; // - UINT64 MustBeZero : 17; // Must be zero; - UINT64 PageTableBaseAddress : 22; // Page Table Base Address - UINT64 AvabilableHigh : 11; // Available for use by system software - UINT64 Nx : 1; // 0 = Execute Code, 1 = No Code Execution + UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User + UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Dirty : 1; // 0 = Not Dirty, 1 = written by processor on access to page + UINT64 MustBe1 : 1; // Must be 1 + UINT64 Global : 1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write + UINT64 Available : 3; // Available for use by system software + UINT64 PAT : 1; // + UINT64 MustBeZero : 17; // Must be zero; + UINT64 PageTableBaseAddress : 22; // Page Table Base Address + UINT64 AvabilableHigh : 11; // Available for use by system software + UINT64 Nx : 1; // 0 = Execute Code, 1 = No Code Execution } Bits; UINT64 Uint64; } PAGE_TABLE_1G_ENTRY; diff --git a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf index 35d2535a5b..db7a84268b 100644 --- a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf +++ b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf @@ -50,3 +50,11 @@ [UserExtensions.TianoCore."ExtraFiles"] CapsuleX64Extra.uni + +## MS_CHANGE_211478 +## MSChange [BEGIN] - This is necessary to avoid the alignment change introduced with the Memory Attributes Table +[BuildOptions.X64] + DEBUG_*_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG + RELEASE_*_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text + NOOPT_*_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG +## MSChange [END] diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf index 29c1143ce9..a6e54d93d1 100644 --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf @@ -76,6 +76,7 @@ gEfiCapsuleVendorGuid gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID # FMP capsule GUID gCapsuleArmedResetGuid + gEfiEventExitBootServicesGuid ## MS_CHANGE_161994 - add lock support [Protocols] gEfiCapsuleArchProtocolGuid ## PRODUCES diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c index 6451972ec6..99238cc839 100644 --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c @@ -11,6 +11,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "CapsuleService.h" +// MS_CHANGE_161994 +#include +// END_MS_CHANGE_161994 #include // MS_CHANGE_250018 - ResetSystem refactoring. @@ -19,6 +22,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // EFI_HANDLE mNewHandle = NULL; +// MS_CHANGE_161994 +// +// Support locking capsule interface. +// +BOOLEAN mAfterLocked = FALSE; +// END MS_CHANGE_161994 + // // The times of calling UpdateCapsule () // @@ -89,6 +99,14 @@ UpdateCapsule ( return EFI_INVALID_PARAMETER; } + // MS_CHANGE_161994 + if (mAfterLocked) { + DEBUG ((DEBUG_INFO, "Capsule Interface Locked\n.")); + return EFI_UNSUPPORTED; + } + + // END MS_CHANGE_161994 + NeedReset = FALSE; InitiateReset = FALSE; CapsuleHeader = NULL; @@ -354,6 +372,30 @@ QueryCapsuleCapabilities ( return EFI_SUCCESS; } +// MS_CHANGE_161994 + +/** + +LockCapsuleInterface - Event handler +- locks the capsule interface so no input is accepted. + +@param[in] Event Event whose notification function is being invoked +@param[in] Context Pointer to the notification function's context + +**/ +VOID +EFIAPI +LockCapsuleInterface ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + mAfterLocked = TRUE; + DEBUG ((DEBUG_INFO, "Capsule Interface Locked!!\nMS_CHANGE_161994\n")); +} + +// END MS_CHANGE_161994 + /** This code installs UEFI capsule runtime service. @@ -372,6 +414,10 @@ CapsuleServiceInitialize ( ) { EFI_STATUS Status; + // MS_CHANGE_161994 + EFI_EVENT Event; + + // END MS_CHANGE_161994 mMaxSizePopulateCapsule = PcdGet32 (PcdMaxSizePopulateCapsule); mMaxSizeNonPopulateCapsule = PcdGet32 (PcdMaxSizeNonPopulateCapsule); @@ -403,5 +449,16 @@ CapsuleServiceInitialize ( ); ASSERT_EFI_ERROR (Status); + // MS_CHANGE_161994 - add lock support + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + LockCapsuleInterface, + NULL, + &gEfiEventExitBootServicesGuid, + &Event + ); + // END MS_CHANGE_161994 + return Status; } diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index 8b5e62e3a8..d399e9aa1a 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -1389,6 +1389,10 @@ ConSplitterConOutDriverBindingStart ( // mConOut.TextOutMode.Mode = 0xFF; + // MS_CHANGE_? + // MSCHANGE - Force the initial state of TextOut device to CursorInvisible. + TextOut->Mode->CursorVisible = FALSE; + // // If both ConOut and StdErr incorporate the same Text Out device, // their MaxMode and QueryData should be the intersection of both. @@ -1899,7 +1903,10 @@ ConSplitterTextInAddDevice ( // // Extra CheckEvent added to reduce the double CheckEvent(). // - gBS->CheckEvent (TextIn->WaitForKey); + // MS_CHANGE_? + // MSchange - this check-event triggers the Surface on-screen keyboard to auto-activate when it shouldn't since + // no one is actually waiting on a key input event. + // gBS->CheckEvent (TextIn->WaitForKey); return EFI_SUCCESS; } @@ -2037,7 +2044,10 @@ ConSplitterTextInExAddDevice ( // // Extra CheckEvent added to reduce the double CheckEvent(). // - gBS->CheckEvent (TextInEx->WaitForKeyEx); + // MS_CHANGE_? + // MSchange - this check-event triggers the Surface on-screen keyboard to auto-activate when it shouldn't since + // no one is actually waiting on a key input event. + // gBS->CheckEvent (TextInEx->WaitForKeyEx); return EFI_SUCCESS; } @@ -3674,6 +3684,15 @@ ConSplitterTextInWaitForKey ( Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *)Context; + // MS_CHANGE_162381 + if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) { + DEBUG ((EFI_D_INFO, "Connect ConIn in first WaitForKey in Lazy ConIn mode.\n")); + gBS->SignalEvent (Private->ConnectConInEvent); + mConInIsConnect = TRUE; + } + + // END + if (Private->KeyEventSignalState) { // // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke() @@ -4995,9 +5014,11 @@ ConSplitterTextOutClearScreen ( // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should // always be supported. // - Private->TextOutMode.CursorColumn = 0; - Private->TextOutMode.CursorRow = 0; - Private->TextOutMode.CursorVisible = TRUE; + Private->TextOutMode.CursorColumn = 0; + Private->TextOutMode.CursorRow = 0; + // MS_CHANGE_? + // MSCHANGE - Default to cursor not visible + Private->TextOutMode.CursorVisible = FALSE; return ReturnStatus; } diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c index 64ad567a6d..d250cfcb6b 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c @@ -613,10 +613,11 @@ TextOutSetMode ( // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should // always be supported. // - Private->TextOutMode.Mode = (INT32)ModeNumber; - Private->TextOutMode.CursorColumn = 0; - Private->TextOutMode.CursorRow = 0; - Private->TextOutMode.CursorVisible = TRUE; - + Private->TextOutMode.Mode = (INT32)ModeNumber; + Private->TextOutMode.CursorColumn = 0; + Private->TextOutMode.CursorRow = 0; + // MS_CHANGE_? + // MSCHANGE - Initialize the console with the cursor not visible. + Private->TextOutMode.CursorVisible = FALSE; return; } diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index b895dafede..1b06dec314 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c @@ -55,6 +55,9 @@ EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; EFI_HII_FONT_PROTOCOL *mHiiFont; EFI_HII_HANDLE mHiiHandle; VOID *mHiiRegistration; +// MS_CHANGE_? +// MSCHANGE - Maintain seamless screen from PEI logo display +static BOOLEAN mClearScreen = FALSE; EFI_GUID mFontPackageListGuid = { 0xf5f219d3, 0x7006, 0x4648, { 0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad } @@ -1409,18 +1412,25 @@ GraphicsConsoleConOutSetMode ( // // The current graphics mode is correct, so simply clear the entire display // - Status = GraphicsOutput->Blt ( - GraphicsOutput, - &mGraphicsEfiColors[0], - EfiBltVideoFill, - 0, - 0, - 0, - 0, - ModeData->GopWidth, - ModeData->GopHeight, - 0 - ); + // MS_CHANGE_? + // MSCHANGE - Don't clear screen first time through to maintain + // seamless screen from PEI logo display. + if (mClearScreen != FALSE) { + Status = GraphicsOutput->Blt ( + GraphicsOutput, + &mGraphicsEfiColors[0], + EfiBltVideoFill, + 0, + 0, + 0, + 0, + ModeData->GopWidth, + ModeData->GopHeight, + 0 + ); + } + + // END } } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { // @@ -1485,6 +1495,9 @@ GraphicsConsoleConOutSetMode ( Status = EFI_SUCCESS; Done: + // MS_CHANGE_? + // MSCHANGE - Used to prevent screen clear first time through. + mClearScreen = TRUE; gBS->RestoreTPL (OldTpl); return Status; } diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c index 8a0b12f72f..069b7955d1 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c @@ -2127,7 +2127,12 @@ HiiStringToImage ( if ((Flags & EFI_HII_DIRECT_TO_SCREEN) == EFI_HII_DIRECT_TO_SCREEN) { BltBuffer = NULL; if (RowInfo[RowIndex].LineWidth != 0) { + // Fill in the current background + // MS_CHANGE_185410 + UINT32 Bkgnd = Background.Blue | Background.Green << 8 | Background.Red << 16; BltBuffer = AllocatePool (RowInfo[RowIndex].LineWidth * RowInfo[RowIndex].LineHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); + SetMem32 (BltBuffer, RowInfo[RowIndex].LineWidth * RowInfo[RowIndex].LineHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), Bkgnd); + // END if (BltBuffer == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Exit; diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c index b5b9625969..031bd341c4 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c @@ -274,6 +274,7 @@ Output1bitPixel ( CopyRgbToGopPixel (&PaletteValue[0], &Palette->PaletteValue[0], 1); CopyRgbToGopPixel (&PaletteValue[1], &Palette->PaletteValue[1], 1); FreePool (Palette); + Palette = NULL; // MSChange - Make sure to manage this pointer safely. MS_CHANGE_? // // Convert the pixel from one bit to corresponding color. @@ -363,6 +364,7 @@ Output4bitPixel ( ZeroMem (PaletteValue, sizeof (PaletteValue)); CopyRgbToGopPixel (PaletteValue, Palette->PaletteValue, MIN (PaletteNum, ARRAY_SIZE (PaletteValue))); FreePool (Palette); + Palette = NULL; // MSChange - Make sure to manage this pointer safely. MS_CHANGE_? // // Convert the pixel from 4 bit to corresponding color. @@ -440,6 +442,7 @@ Output8bitPixel ( ZeroMem (PaletteValue, sizeof (PaletteValue)); CopyRgbToGopPixel (PaletteValue, Palette->PaletteValue, MIN (PaletteNum, ARRAY_SIZE (PaletteValue))); FreePool (Palette); + Palette = NULL; // MSChange - Make sure to manage this pointer safely. MS_CHANGE_? // // Convert the pixel from 8 bits to corresponding color. diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 7a1331255b..4206c6f77a 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -53,6 +53,13 @@ VARIABLE_INFO_ENTRY *gVariableInfo = NULL; /// BOOLEAN mEndOfDxe = FALSE; +// MS_CHANGE_279849 +/// +/// The flag to indicate if a Reclaim has been done at Runtime. +/// +BOOLEAN mReclaimedAtRuntime = FALSE; +// END + /// /// It indicates the var check request source. /// In the implementation, DXE is regarded as untrusted, and SMM is trusted. @@ -560,6 +567,9 @@ Reclaim ( CommonUserVariableTotalSize = 0; HwErrVariableTotalSize = 0; + // MS_CHANGE_? - This may be specific to the MS implementation. + DEBUG ((DEBUG_INFO, "%a Reclaim variables started.\n", __FUNCTION__)); + if (IsVolatile || mVariableModuleGlobal->VariableGlobal.EmuNvMode) { // // Start Pointers for the variable. @@ -1298,11 +1308,16 @@ CheckRemainingSpaceForConsistencyInternal ( // return TRUE; } else if (AtRuntime ()) { - // - // At runtime, no reclaim. - // The original variable space of Variables can't be reused. - // - return FALSE; + // MS_CHANGE_279849 //MSCHANGE - Allow Reclaim once at Runtime + if (mReclaimedAtRuntime) { + // + // At runtime, only allow one reclaim. + // The original variable space of Variables can't be reused. + // + return FALSE; + } + + // END } VA_COPY (Args, Marker); @@ -2119,16 +2134,23 @@ UpdateVariable ( || (IsCommonUserVariable && ((VarSize + mVariableModuleGlobal->CommonUserVariableTotalSize) > mVariableModuleGlobal->CommonMaxUserVariableSpace))) { if (AtRuntime ()) { - if (IsCommonUserVariable && ((VarSize + mVariableModuleGlobal->CommonUserVariableTotalSize) > mVariableModuleGlobal->CommonMaxUserVariableSpace)) { - RecordVarErrorFlag (VAR_ERROR_FLAG_USER_ERROR, VariableName, VendorGuid, Attributes, VarSize); - } + // MS_CHANGE_279849 + // MSCHANGE -- Allow reclaim once at Runtime. + if (!mReclaimedAtRuntime) { + mReclaimedAtRuntime = TRUE; + } else { + // END + if (IsCommonUserVariable && ((VarSize + mVariableModuleGlobal->CommonUserVariableTotalSize) > mVariableModuleGlobal->CommonMaxUserVariableSpace)) { + RecordVarErrorFlag (VAR_ERROR_FLAG_USER_ERROR, VariableName, VendorGuid, Attributes, VarSize); + } - if (IsCommonVariable && ((VarSize + mVariableModuleGlobal->CommonVariableTotalSize) > mVariableModuleGlobal->CommonRuntimeVariableSpace)) { - RecordVarErrorFlag (VAR_ERROR_FLAG_SYSTEM_ERROR, VariableName, VendorGuid, Attributes, VarSize); - } + if (IsCommonVariable && ((VarSize + mVariableModuleGlobal->CommonVariableTotalSize) > mVariableModuleGlobal->CommonRuntimeVariableSpace)) { + RecordVarErrorFlag (VAR_ERROR_FLAG_SYSTEM_ERROR, VariableName, VendorGuid, Attributes, VarSize); + } - Status = EFI_OUT_OF_RESOURCES; - goto Done; + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } // MS_CHANGE_279849 } // diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c index 5253c328dc..86c92d63ae 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c @@ -738,17 +738,20 @@ SmmVariableHandler ( break; case SMM_VARIABLE_FUNCTION_LOCK_VARIABLE: - if (mEndOfDxe) { - Status = EFI_ACCESS_DENIED; - } else { - VariableToLock = (SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE *)SmmVariableFunctionHeader->Data; - Status = VariableLockRequestToLock ( - NULL, - VariableToLock->Name, - &VariableToLock->Guid - ); - } - + // MS_CHANGE_90369 + // MSChange [BEGIN] - Don't block these requests outright after EndOfDxe. + // Give the library a chance to evaluate which requests should be allowed. + // if (mEndOfDxe) { + // Status = EFI_ACCESS_DENIED; + // } else { + VariableToLock = (SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE *)SmmVariableFunctionHeader->Data; + Status = VariableLockRequestToLock ( + NULL, + VariableToLock->Name, + &VariableToLock->Guid + ); + // } + // MSChange [END] break; case SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_SET: if (mEndOfDxe) { diff --git a/MdePkg/Include/Guid/EventGroup.h b/MdePkg/Include/Guid/EventGroup.h index b0dc002a18..b6829a7ef9 100644 --- a/MdePkg/Include/Guid/EventGroup.h +++ b/MdePkg/Include/Guid/EventGroup.h @@ -49,4 +49,15 @@ extern EFI_GUID gEfiEventDxeDispatchGuid; extern EFI_GUID gEfiEndOfDxeEventGroupGuid; +// MSCHANGE begin +#define EFI_PRE_READY_TO_BOOT_GUID \ + { 0x10c41e8f, 0xc52a, 0x4ea4, {0xa2, 0x69, 0x0b, 0x45, 0x09, 0x31, 0xab, 0xf6}} + +extern EFI_GUID gEfiEventPreReadyToBootGuid; + +#define EFI_POST_READY_TO_BOOT_GUID \ + { 0xa5b489b4, 0x18fd, 0x4425, { 0x91, 0xa4, 0x61, 0x3a, 0xdd, 0xd2, 0x74, 0x5 }} + +extern EFI_GUID gEfiEventPostReadyToBootGuid; +// MSCHANGE end #endif diff --git a/MdePkg/Include/IndustryStandard/PeImage.h b/MdePkg/Include/IndustryStandard/PeImage.h index 596c2fc3cd..ed87795be6 100644 --- a/MdePkg/Include/IndustryStandard/PeImage.h +++ b/MdePkg/Include/IndustryStandard/PeImage.h @@ -117,6 +117,34 @@ typedef struct { UINT32 Size; } EFI_IMAGE_DATA_DIRECTORY; +// MS_CHANGE_? - Something to do with Stack Cookies? +// +// Load Config Directory from PeCoff +// +typedef struct { + UINTN Size; + UINTN TimeDateStamp; + UINT8 MajorVersion; + UINT8 MinorVersion; + UINTN GlobalFlagsClear; + UINTN GlobalFlagsSet; + UINTN CriticalSectionDefaultTimeout; + UINTN DeCommitFreeBlockThreshold; + UINTN DeCommitTotalFreeThreshold; + UINTN LockPrefixTable; // VA + UINTN MaximumAllocationSize; + UINTN VirtualMemoryThreshold; + UINTN ProcessHeapFlags; + UINTN ProcessAffinityMask; + UINT8 CSDVersion; + UINT8 Reserved1; + UINTN EditList; // VA + UINTN SecurityCookie; + VOID **SEHandlerTable; + UINTN SEHandlerCount; +} EFI_IMAGE_LOAD_CONFIG_DIRECTORY; +// END + // // Directory Entries // diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index f0c9f64487..51885a0c04 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -38,6 +38,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define DEBUG_INFO 0x00000040 // Informational debug messages #define DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers #define DEBUG_VARIABLE 0x00000100 // Variable +#define DEBUG_SMI 0x00000200 // MS_CHANGE_141550: Added for SMI audting options. #define DEBUG_BM 0x00000400 // Boot Manager #define DEBUG_BLKIO 0x00001000 // BlkIo Driver #define DEBUG_NET 0x00004000 // Network Io Driver @@ -64,6 +65,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define EFI_D_INFO DEBUG_INFO #define EFI_D_DISPATCH DEBUG_DISPATCH #define EFI_D_VARIABLE DEBUG_VARIABLE +#define EFI_D_SMI DEBUG_SMI // MS_CHANGE_141550: Added for SMI audting options. #define EFI_D_BM DEBUG_BM #define EFI_D_BLKIO DEBUG_BLKIO #define EFI_D_NET DEBUG_NET diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index f04be4a2ea..48e33c8fdc 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -436,9 +436,15 @@ ## Include/Protocol/Hash.h gEfiHashAlgorithmSha1Guid = { 0x2AE9D80F, 0x3FB2, 0x4095, { 0xB7, 0xB1, 0xE9, 0x31, 0x57, 0xB9, 0x46, 0xB6 }} + ## Include/Guid/EventGroup.h ##MSCHANGE + gEfiEventPreReadyToBootGuid = { 0x7b94c75c, 0x36a4, 0x4aa4, {0xa1, 0xdf, 0x14, 0xbc, 0x9a, 0x04, 0x9a, 0xe4}} ##MSCHANGE + ## Include/Guid/EventGroup.h gEfiEventReadyToBootGuid = { 0x7CE88FB3, 0x4BD7, 0x4679, { 0x87, 0xA8, 0xA8, 0xD8, 0xDE, 0xE5, 0x0D, 0x2B }} + ## Include/Guid/EventGroup.h ##MSCHANGE + gEfiEventPostReadyToBootGuid = { 0xa5b489b4, 0x18fd, 0x4425, { 0x91, 0xa4, 0x61, 0x3a, 0xdd, 0xd2, 0x74, 0x5 }} ##MSCHANGE + ## Include/Guid/EventGroup.h gEfiEventAfterReadyToBootGuid = { 0x3a2a00ad, 0x98b9, 0x4cdf, { 0xa4, 0x78, 0x70, 0x27, 0x77, 0xf1, 0xc1, 0x0b }} diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c index 91146b78cb..3a40954ffb 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c @@ -1744,14 +1744,17 @@ PxeBcDhcp4Dora ( AsciiPrint ("\n"); ON_EXIT: - if (EFI_ERROR (Status)) { - Dhcp4->Stop (Dhcp4); - Dhcp4->Configure (Dhcp4, NULL); - } else { - ZeroMem (&Config, sizeof (EFI_DHCP4_CONFIG_DATA)); - Dhcp4->Configure (Dhcp4, &Config); - Private->IsAddressOk = TRUE; - } + if (!Private->DEADBEEF) { + // MS_CHANGE_162958 + if (EFI_ERROR (Status)) { + Dhcp4->Stop (Dhcp4); + Dhcp4->Configure (Dhcp4, NULL); + } else { + ZeroMem (&Config, sizeof (EFI_DHCP4_CONFIG_DATA)); + Dhcp4->Configure (Dhcp4, &Config); + Private->IsAddressOk = TRUE; + } + } // MS_CHANGE_162958 return Status; } diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c index d84aca7e85..ea887b9175 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c @@ -1507,7 +1507,7 @@ PxeBcStart ( } if (FirstStart && (Private != NULL)) { - FreePool (Private); + Private->DEADBEEF = TRUE; // MS_CHANGE_162958 } return Status; @@ -1633,7 +1633,7 @@ PxeBcStop ( &gEfiCallerIdGuid, &Private->Id ); - FreePool (Private); + Private->DEADBEEF = TRUE; // MS_CHANGE_162958 } return EFI_SUCCESS; diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c index 0a4baf6f90..eb21c38727 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c @@ -428,8 +428,15 @@ EfiPxeBcDhcp ( return EFI_INVALID_PARAMETER; } - Status = EFI_SUCCESS; - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This); + Status = EFI_SUCCESS; + Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This); + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END + Mode = Private->PxeBc.Mode; Mode->IcmpErrorReceived = FALSE; Private->Function = EFI_PXE_BASE_CODE_FUNCTION_DHCP; @@ -463,14 +470,17 @@ EfiPxeBcDhcp ( Status = PxeBcDhcp4Dora (Private, Private->Dhcp4); } - // - // Reconfigure the UDP instance with the default configuration. - // - if (Mode->UsingIpv6) { - Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData); - } else { - Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData); - } + if (!Private->DEADBEEF) { + // MS_CHANGE_162958 + // + // Reconfigure the UDP instance with the default configuration. + // + if (Mode->UsingIpv6) { + Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData); + } else { + Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData); + } + } // MS_CHANGE_162958 // // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP @@ -1000,18 +1010,24 @@ EfiPxeBcMtftp ( break; } - if (Status == EFI_ICMP_ERROR) { - Mode->IcmpErrorReceived = TRUE; - } - - // - // Reconfigure the UDP instance with the default configuration. - // - if (Mode->UsingIpv6) { - Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData); + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + Status = EFI_DEVICE_ERROR; } else { - Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData); - } + // END + if (Status == EFI_ICMP_ERROR) { + Mode->IcmpErrorReceived = TRUE; + } + + // + // Reconfigure the UDP instance with the default configuration. + // + if (Mode->UsingIpv6) { + Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData); + } else { + Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData); + } + } // MS_CHANGE_162958 // // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h index 732889f23d..9e13a5850a 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h @@ -219,6 +219,7 @@ struct _PXEBC_PRIVATE_DATA { UINT32 OfferNum; UINT32 OfferCount[PxeOfferTypeMax]; UINT32 OfferIndex[PxeOfferTypeMax][PXEBC_OFFER_MAX_NUM]; + BOOLEAN DEADBEEF; // MS_CHANGE_162958 }; extern EFI_PXE_BASE_CODE_PROTOCOL gPxeBcProtocolTemplate; diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c b/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c index 3ac9c7a8aa..acc8e97a7f 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c @@ -48,7 +48,13 @@ PxeBcMtftp6CheckPacket ( EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback; EFI_STATUS Status; - Private = (PXEBC_PRIVATE_DATA *)Token->Context; + Private = (PXEBC_PRIVATE_DATA *)Token->Context; + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END Callback = Private->PxeBcCallback; Status = EFI_SUCCESS; @@ -140,6 +146,12 @@ PxeBcMtftp6GetFileSize ( OptCnt = 1; Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT; + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END Status = Mtftp6->Configure (Mtftp6, Config); if (EFI_ERROR (Status)) { return Status; @@ -274,6 +286,12 @@ PxeBcMtftp6ReadFile ( UINT8 WindowsizeBuf[10]; EFI_STATUS Status; + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END Status = EFI_DEVICE_ERROR; Mtftp6 = Private->Mtftp6; OptCnt = 0; @@ -324,8 +342,13 @@ PxeBcMtftp6ReadFile ( // *BufferSize = Token.BufferSize; - Mtftp6->Configure (Mtftp6, NULL); + // MSCHANGE -- don't trust Mtftp6 after a surprise removal + // MS_CHANGE_162958 + if (!Private->DEADBEEF) { + Mtftp6->Configure (Mtftp6, NULL); + } + // END return Status; } @@ -363,6 +386,13 @@ PxeBcMtftp6WriteFile ( UINT8 OptBuf[128]; EFI_STATUS Status; + // MSCHANGE + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END Status = EFI_DEVICE_ERROR; Mtftp6 = Private->Mtftp6; OptCnt = 0; @@ -398,7 +428,13 @@ PxeBcMtftp6WriteFile ( // *BufferSize = Token.BufferSize; - Mtftp6->Configure (Mtftp6, NULL); + // MSCHANGE -- don't trust Mtftp6 after a surprise removal + // MS_CHANGE_162958 + if (!Private->DEADBEEF) { + Mtftp6->Configure (Mtftp6, NULL); + } + + // END return Status; } @@ -489,8 +525,13 @@ PxeBcMtftp6ReadDirectory ( // Get the real size of received buffer. // *BufferSize = Token.BufferSize; + // MSCHANGE + // MS_CHANGE_162958 + if (!Private->DEADBEEF) { + Mtftp6->Configure (Mtftp6, NULL); + } - Mtftp6->Configure (Mtftp6, NULL); + // END return Status; } @@ -526,7 +567,15 @@ PxeBcMtftp4CheckPacket ( EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback; EFI_STATUS Status; - Private = (PXEBC_PRIVATE_DATA *)Token->Context; + Private = (PXEBC_PRIVATE_DATA *)Token->Context; + + // MSCHANGE + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END Callback = Private->PxeBcCallback; Status = EFI_SUCCESS; @@ -608,6 +657,14 @@ PxeBcMtftp4GetFileSize ( UINT32 OptCnt; EFI_STATUS Status; + // MSCHANGE + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END + *BufferSize = 0; Status = EFI_DEVICE_ERROR; Mtftp4 = Private->Mtftp4; @@ -752,6 +809,13 @@ PxeBcMtftp4ReadFile ( UINT8 WindowsizeBuf[10]; EFI_STATUS Status; + // MSCHANGE + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END Status = EFI_DEVICE_ERROR; Mtftp4 = Private->Mtftp4; OptCnt = 0; @@ -802,7 +866,13 @@ PxeBcMtftp4ReadFile ( // *BufferSize = Token.BufferSize; - Mtftp4->Configure (Mtftp4, NULL); + // MSCHANGE -- don't trust Mtftp6 after a surprise removal + // MS_CHANGE_162958 + if (!Private->DEADBEEF) { + Mtftp4->Configure (Mtftp4, NULL); + } + + // END return Status; } @@ -841,6 +911,13 @@ PxeBcMtftp4WriteFile ( UINT8 OptBuf[128]; EFI_STATUS Status; + // MSCHANGE + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END Status = EFI_DEVICE_ERROR; Mtftp4 = Private->Mtftp4; OptCnt = 0; @@ -876,7 +953,13 @@ PxeBcMtftp4WriteFile ( // *BufferSize = Token.BufferSize; - Mtftp4->Configure (Mtftp4, NULL); + // MSCHANGE -- don't trust Mtftp6 after a surprise removal + // MS_CHANGE_162958 + if (!Private->DEADBEEF) { + Mtftp4->Configure (Mtftp4, NULL); + } + + // END return Status; } @@ -918,6 +1001,13 @@ PxeBcMtftp4ReadDirectory ( UINT8 WindowsizeBuf[10]; EFI_STATUS Status; + // MSCHANGE + // MS_CHANGE_162958 + if (Private->DEADBEEF) { + return EFI_DEVICE_ERROR; + } + + // END Status = EFI_DEVICE_ERROR; Mtftp4 = Private->Mtftp4; OptCnt = 0; @@ -968,7 +1058,13 @@ PxeBcMtftp4ReadDirectory ( // *BufferSize = Token.BufferSize; - Mtftp4->Configure (Mtftp4, NULL); + // MSCHANGE + // MS_CHANGE_162958 + if (!Private->DEADBEEF) { + Mtftp4->Configure (Mtftp4, NULL); + } + + // END return Status; } diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h index 7e0e98fbcc..046e772981 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h @@ -63,8 +63,25 @@ extern PC_RTC_MODULE_GLOBALS mModuleGlobal; #define RTC_INIT_SECOND 0 #define RTC_INIT_MINUTE 0 #define RTC_INIT_HOUR 0 -#define RTC_INIT_DAY 1 -#define RTC_INIT_MONTH 1 +// MS_CHANGE_162988 +// MSChange - base the default date on the build date midnight. Since we are in PST/PDT, if anyone between here and the international date line +// tries to use this UEFI within 6 hours, they might go in the future. +#define RTC_INIT_DAY ( ((__DATE__)[5] - '0') + ( (((__DATE__)[4] >= '0') && ((__DATE__)[4] <= '3') ) ? (((__DATE__)[4] - '0') * 10) : 0 ) ) +#define RTC_INIT_MONTH ( (__DATE__[0] == 'F') ? 2 : (\ + (__DATE__[0] == 'S') ? 9 : (\ + (__DATE__[0] == 'O') ? 10 : (\ + (__DATE__[0] == 'N') ? 11 : (\ + (__DATE__[0] == 'D') ? 12 : (\ + (__DATE__[2] == 'l') ? 7 : (\ + (__DATE__[2] == 'g') ? 8 : (\ + (__DATE__[2] == 'y') ? 5 : (\ + (__DATE__[1] == 'p') ? 4 : (\ + (__DATE__[1] == 'u') ? 6 : (\ + (__DATE__[0] == 'J') ? 1 : (\ + 3)))))))))))) + +#define RTC_INIT_YEAR (((__DATE__)[7] - '0')*1000 + ((__DATE__)[8] - '0')*100 + ((__DATE__)[9] - '0')*10 + ((__DATE__)[10] - '0')) +// END #pragma pack(1) //