diff options
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 9 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 60 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 56 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c | 2 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h | 2 | ||||
-rw-r--r-- | MdeModulePkg/Core/Pei/FwVol/FwVol.c | 38 | ||||
-rw-r--r-- | MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h | 10 | ||||
-rw-r--r-- | MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c | 73 | ||||
-rw-r--r-- | MdeModulePkg/MdeModulePkg.dec | 8 | ||||
-rw-r--r-- | MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 1 | ||||
-rw-r--r-- | MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 4 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c | 9 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h | 4 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c | 40 | ||||
-rw-r--r-- | MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 3 |
15 files changed, 207 insertions, 112 deletions
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c index c830db6..c337f15 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c @@ -837,6 +837,10 @@ XhcTransfer ( }
Xhc->PciIo->Flush (Xhc->PciIo);
+ //
+ // Do not free URB data, since it is passed in as an external argument
+ // and allocated and managed by the caller.
+ //
XhcFreeUrb (Xhc, Urb);
return Status;
}
@@ -1227,8 +1231,9 @@ ON_EXIT: sending or receiving.
@param DataBuffersNumber Number of data buffers prepared for the transfer.
@param Data Array of pointers to the buffers of data to transmit
- from or receive into.
- @param DataLength The lenght of the data buffer.
+ from or receive into. The caller is responsible for freeing
+ the buffers after the transfers are completed.
+ @param DataLength The length of the data buffer.
@param DataToggle On input, the initial data toggle for the transfer;
On output, it is updated to to next data toggle to
use of the subsequent bulk transfer.
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c index 50d7d4b..52551a3 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -107,6 +107,10 @@ XhcCmdTransfer ( Status = EFI_SUCCESS;
}
+ //
+ // Do not free URB data, since `XhcCreateCmdTrb` does not allocate any data
+ // and the `Data` field is not used in command transfers.
+ //
XhcFreeUrb (Xhc, Urb);
ON_EXIT:
@@ -184,6 +188,9 @@ XhcCreateUrb ( /**
Free an allocated URB.
+ The `Data` field of the URB is not owned by the URB and is not freed here.
+ The caller is which allocates `Data` is responsible for freeing it.
+ Freeing `Data` must be done AFTER calling `XhcFreeUrb`, since this function may unmap the `DataMap` field.
@param Xhc The XHCI device.
@param Urb The URB to free.
@@ -1388,6 +1395,7 @@ XhciDelAsyncIntTransfer ( LIST_ENTRY *Entry;
LIST_ENTRY *Next;
URB *Urb;
+ VOID *UrbData;
EFI_USB_DATA_DIRECTION Direction;
EFI_STATUS Status;
@@ -1412,8 +1420,16 @@ XhciDelAsyncIntTransfer ( }
RemoveEntryList (&Urb->UrbList);
- FreePool (Urb->Data);
+ //
+ // For `XhciDelAsyncIntTransfer`, the URB is created through `XhciInsertAsyncIntTransfer`
+ // and allocates and manages its own data buffer, so free it here.
+ //
+ UrbData = Urb->Data;
XhcFreeUrb (Xhc, Urb);
+ if (UrbData != NULL) {
+ FreePool (UrbData);
+ }
+
return EFI_SUCCESS;
}
}
@@ -1435,6 +1451,7 @@ XhciDelAllAsyncIntTransfers ( LIST_ENTRY *Entry;
LIST_ENTRY *Next;
URB *Urb;
+ VOID *UrbData;
EFI_STATUS Status;
BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
@@ -1450,8 +1467,15 @@ XhciDelAllAsyncIntTransfers ( }
RemoveEntryList (&Urb->UrbList);
- FreePool (Urb->Data);
+ //
+ // For `XhciDelAllAsyncIntTransfers`, the URB is created through `XhciInsertAsyncIntTransfer`
+ // and allocates and manages its own data buffer, so free it here.
+ //
+ UrbData = Urb->Data;
XhcFreeUrb (Xhc, Urb);
+ if (UrbData != NULL) {
+ FreePool (UrbData);
+ }
}
}
@@ -1631,6 +1655,17 @@ XhcMonitorAsyncRequests ( Xhc = (USB_XHCI_INSTANCE *)Context;
BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
+ //
+ // Save values passed into the callback.
+ // `XhcUpdateAsyncRequest` must be called before the callback
+ // since the callback may free the URB, leading to a fault.
+ // However, the callback depends on values of the URB *before*
+ // `XhcUpdateAsyncRequest` is called, so we must save a copy.
+ //
+ UINTN cbCompleted;
+ UINT32 cbResult;
+ VOID *cbContext;
+
Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
//
@@ -1683,6 +1718,19 @@ XhcMonitorAsyncRequests ( }
//
+ // Store values of URB before `XhcUpdateAsyncRequest`, since the callback depends on these values.
+ //
+ cbCompleted = Urb->Completed;
+ cbResult = Urb->Result;
+ cbContext = Urb->Context;
+
+ //
+ // The update call must occur before the callback since the callback
+ // may remove and free the URB, leading to a fault.
+ //
+ XhcUpdateAsyncRequest (Xhc, Urb);
+
+ //
// Leave error recovery to its related device driver. A
// common case of the error recovery is to re-submit the
// interrupt transfer which is linked to the head of the
@@ -1694,19 +1742,17 @@ XhcMonitorAsyncRequests ( //
if (Urb->Callback != NULL) {
//
- // Restore the old TPL, USB bus maybe connect device in
- // his callback. Some drivers may has a lower TPL restriction.
+ // Restore the previous TPL. The USB bus may connect a device in its callback,
+ // and some drivers require a lower TPL to run correctly.
//
gBS->RestoreTPL (OldTpl);
- (Urb->Callback)(ProcBuf, Urb->Completed, Urb->Context, Urb->Result);
+ (Urb->Callback)(ProcBuf, cbCompleted, cbContext, cbResult);
OldTpl = gBS->RaiseTPL (XHC_TPL);
}
if (ProcBuf != NULL) {
gBS->FreePool (ProcBuf);
}
-
- XhcUpdateAsyncRequest (Xhc, Urb);
}
gBS->RestoreTPL (OldTpl);
}
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index a03b2ce..c1072af 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -1862,43 +1862,47 @@ UfsEnableHostController ( }
}
- //
- // UFS 2.0 spec section 7.1.1 - Host Controller Initialization
- //
- // Reinitialize the UFS host controller if HCE bit of HC register is set.
- //
- Status = UfsMmioRead32 (Private, UFS_HC_ENABLE_OFFSET, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if ((Data & UFS_HC_HCE_EN) == UFS_HC_HCE_EN) {
+ if ((mUfsHcPlatform == NULL) ||
+ ((mUfsHcPlatform->Version >= 3) && !mUfsHcPlatform->SkipHceReenable))
+ {
//
- // Write a 0 to the HCE register at first to disable the host controller.
+ // UFS 2.0 spec section 7.1.1 - Host Controller Initialization
//
- Status = UfsMmioWrite32 (Private, UFS_HC_ENABLE_OFFSET, 0);
+ // Reinitialize the UFS host controller if HCE bit of HC register is set.
+ //
+ Status = UfsMmioRead32 (Private, UFS_HC_ENABLE_OFFSET, &Data);
if (EFI_ERROR (Status)) {
return Status;
}
+ if ((Data & UFS_HC_HCE_EN) == UFS_HC_HCE_EN) {
+ //
+ // Write a 0 to the HCE register at first to disable the host controller.
+ //
+ Status = UfsMmioWrite32 (Private, UFS_HC_ENABLE_OFFSET, 0);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Wait until HCE is read as '0' before continuing.
+ //
+ Status = UfsWaitMemSet (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN, 0, UFS_TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ }
+
//
- // Wait until HCE is read as '0' before continuing.
+ // Write a 1 to the HCE register to enable the UFS host controller.
//
- Status = UfsWaitMemSet (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN, 0, UFS_TIMEOUT);
+ Status = UfsMmioWrite32 (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ return Status;
}
}
//
- // Write a 1 to the HCE register to enable the UFS host controller.
- //
- Status = UfsMmioWrite32 (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
// Wait until HCE is read as '1' before continuing.
//
Status = UfsWaitMemSet (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN, UFS_HC_HCE_EN, UFS_TIMEOUT);
@@ -1945,6 +1949,10 @@ UfsDeviceDetection ( }
}
+ if ((mUfsHcPlatform != NULL) && (mUfsHcPlatform->Version >= 3) && mUfsHcPlatform->SkipLinkStartup) {
+ return EFI_SUCCESS;
+ }
+
//
// Start UFS device detection.
// Try up to 3 times for establishing data link with device.
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c index 451d4b9..13c5b22 100644 --- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c +++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c @@ -732,7 +732,7 @@ InitializeUsbMouseDevice ( @param Data A pointer to a buffer that is filled with key data which is
retrieved via asynchronous interrupt transfer.
@param DataLength Indicates the size of the data buffer.
- @param Context Pointing to USB_KB_DEV instance.
+ @param Context Pointing to USB_MOUSE_DEV instance.
@param Result Indicates the result of the asynchronous interrupt transfer.
@retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h index 3ddd765..6766831 100644 --- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h +++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h @@ -402,7 +402,7 @@ InitializeUsbMouseDevice ( @param Data A pointer to a buffer that is filled with key data which is
retrieved via asynchronous interrupt transfer.
@param DataLength Indicates the size of the data buffer.
- @param Context Pointing to USB_KB_DEV instance.
+ @param Context Pointing to USB_MOUSE_DEV instance.
@param Result Indicates the result of the asynchronous interrupt transfer.
@retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c index 04bec98..1c0aa9d 100644 --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -2,7 +2,7 @@ Pei Core Firmware File System service routines.
Copyright (c) 2015 HP Development Company, L.P.
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2025, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -456,6 +456,29 @@ FindFileEx ( }
/**
+ Return the pointer to the Firmware Volume GUID name in the FV header.
+
+ @param[in] FvHeader Pointer to the header of the Firmware Volume.
+
+ @retval Pointer to the Firmware Volume GUID name in the FV header.
+ NULL if the FV is anonymous without an extended header.
+**/
+EFI_GUID *
+GetFvName (
+ IN CONST EFI_FIRMWARE_VOLUME_HEADER *FvHeader
+ )
+{
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FvExtHeader;
+
+ if (FvHeader->ExtHeaderOffset == 0) {
+ return NULL;
+ }
+
+ FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)((UINT8 *)FvHeader + FvHeader->ExtHeaderOffset);
+ return &FvExtHeader->FvName;
+}
+
+/**
Initialize PeiCore FV List.
@param PrivateData - Pointer to PEI_CORE_INSTANCE.
@@ -519,8 +542,9 @@ PeiInitializeFv ( PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = 0;
DEBUG ((
DEBUG_INFO,
- "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n",
+ "The %dth FV[%g] start address is 0x%11p, size is 0x%08x, handle is 0x%p\n",
(UINT32)PrivateData->FvCount,
+ GetFvName (BfvHeader),
(VOID *)BfvHeader,
(UINT32)BfvHeader->FvLength,
FvHandle
@@ -661,8 +685,9 @@ FirmwareVolumeInfoPpiNotifyCallback ( CurFvCount = PrivateData->FvCount;
DEBUG ((
DEBUG_INFO,
- "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n",
+ "The %dth FV[%g] start address is 0x%11p, size is 0x%08x, handle is 0x%p\n",
(UINT32)CurFvCount,
+ GetFvName ((EFI_FIRMWARE_VOLUME_HEADER *)FvInfo2Ppi.FvInfo),
(VOID *)FvInfo2Ppi.FvInfo,
FvInfo2Ppi.FvInfoSize,
FvHandle
@@ -696,7 +721,7 @@ FirmwareVolumeInfoPpiNotifyCallback ( }
}
- DEBUG ((DEBUG_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, CurFvCount, FvHandle));
+ DEBUG ((DEBUG_INFO, "Found firmware volume Image File[%g] %p in FV[%d] %p\n", FileHandle, FileHandle, CurFvCount, FvHandle));
ProcessFvFile (PrivateData, &PrivateData->Fv[CurFvCount], FileHandle);
}
} while (FileHandle != NULL);
@@ -2434,8 +2459,9 @@ ThirdPartyFvPpiNotifyCallback ( CurFvCount = PrivateData->FvCount;
DEBUG ((
DEBUG_INFO,
- "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n",
+ "The %dth FV[%g] start address is 0x%11p, size is 0x%08x, handle is 0x%p\n",
(UINT32)CurFvCount,
+ GetFvName ((EFI_FIRMWARE_VOLUME_HEADER *)FvInfo),
(VOID *)FvInfo,
FvInfoSize,
FvHandle
@@ -2469,7 +2495,7 @@ ThirdPartyFvPpiNotifyCallback ( }
}
- DEBUG ((DEBUG_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, CurFvCount, FvHandle));
+ DEBUG ((DEBUG_INFO, "Found firmware volume Image File[%g] %p in FV[%d] %p\n", FileHandle, FileHandle, CurFvCount, FvHandle));
ProcessFvFile (PrivateData, &PrivateData->Fv[CurFvCount], FileHandle);
}
} while (FileHandle != NULL);
diff --git a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h b/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h index 32e9f64..b5b3160 100644 --- a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h +++ b/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h @@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Protocol/UfsHostController.h>
-#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 2
+#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 3
extern EFI_GUID gEdkiiUfsHcPlatformProtocolGuid;
@@ -129,6 +129,14 @@ struct _EDKII_UFS_HC_PLATFORM_PROTOCOL { /// Reference Clock Frequency Ufs Card Attribute that need to be set in this Ufs Host Environment.
///
EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE RefClkFreq;
+ ///
+ /// Flag to skip HCE re-enable.
+ ///
+ BOOLEAN SkipHceReenable;
+ ///
+ /// Flag to skip link startup.
+ ///
+ BOOLEAN SkipLinkStartup;
};
#endif
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c index 2d807bf..bd5b8f5 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c @@ -3,6 +3,7 @@ This library class defines a set of interfaces to customize Display module
Copyright (c) 2013-2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2025, Loongson Technology Corporation Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -859,10 +860,7 @@ PrintInternal ( )
{
CHAR16 *Buffer;
- CHAR16 *BackupBuffer;
UINTN Index;
- UINTN PreviousIndex;
- UINTN Count;
UINTN TotalCount;
UINTN PrintWidth;
UINTN CharWidth;
@@ -870,10 +868,8 @@ PrintInternal ( //
// For now, allocate an arbitrarily long buffer
//
- Buffer = AllocateZeroPool (0x10000);
- BackupBuffer = AllocateZeroPool (0x10000);
+ Buffer = AllocateZeroPool (0x10000);
ASSERT (Buffer);
- ASSERT (BackupBuffer);
if (Column != (UINTN)-1) {
Out->SetCursorPosition (Out, Column, Row);
@@ -884,73 +880,42 @@ PrintInternal ( Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;
Out->SetAttribute (Out, Out->Mode->Attribute);
+ Out->OutputString (Out, Buffer);
- Index = 0;
- PreviousIndex = 0;
- Count = 0;
- TotalCount = 0;
- PrintWidth = 0;
- CharWidth = 1;
+ Index = 0;
+ TotalCount = 0;
+ PrintWidth = 0;
+ CharWidth = 1;
do {
- for ( ; (Buffer[Index] != NARROW_CHAR) && (Buffer[Index] != WIDE_CHAR) && (Buffer[Index] != 0); Index++) {
- BackupBuffer[Index] = Buffer[Index];
- }
-
if (Buffer[Index] == 0) {
break;
}
- //
- // Print this out, we are about to switch widths
- //
- Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
- Count = StrLen (&BackupBuffer[PreviousIndex]);
- PrintWidth += Count * CharWidth;
- TotalCount += Count;
-
- //
- // Preserve the current index + 1, since this is where we will start printing from next
- //
- PreviousIndex = Index + 1;
-
- //
- // We are at a narrow or wide character directive. Set attributes and strip it and print it
- //
- if (Buffer[Index] == NARROW_CHAR) {
- //
- // Preserve bits 0 - 6 and zero out the rest
- //
- Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;
- Out->SetAttribute (Out, Out->Mode->Attribute);
- CharWidth = 1;
- } else {
- //
- // Must be wide, set bit 7 ON
- //
- Out->Mode->Attribute = Out->Mode->Attribute | EFI_WIDE_ATTRIBUTE;
- Out->SetAttribute (Out, Out->Mode->Attribute);
- CharWidth = 2;
+ switch (Buffer[Index]) {
+ case NARROW_CHAR:
+ CharWidth = 1;
+ break;
+ case WIDE_CHAR:
+ CharWidth = 2;
+ break;
+ default:
+ PrintWidth += CharWidth;
+ TotalCount += 1;
+ break;
}
Index++;
} while (Buffer[Index] != 0);
//
- // We hit the end of the string - print it
+ // We hit the end of the string - fill remaining space with SPACE.
//
- Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
- Count = StrLen (&BackupBuffer[PreviousIndex]);
- PrintWidth += Count * CharWidth;
- TotalCount += Count;
if (PrintWidth < Width) {
- Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;
- Out->SetAttribute (Out, Out->Mode->Attribute);
Out->OutputString (Out, &mSpaceBuffer[SPACE_BUFFER_SIZE - Width + PrintWidth]);
}
FreePool (Buffer);
- FreePool (BackupBuffer);
return TotalCount;
}
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 24cc64f..8820059 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1674,6 +1674,14 @@ # @Prompt Maximum Number of PEI Reset Filters, Reset Notifications or Reset Handlers.
gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies|0x10|UINT32|0x0000010A
+ ## Whether to report support of FMP capsules in OsIndicationSupport.<BR><BR>
+ # This PCD indicates if support of FMP capsules should be advertised.<BR>
+ # TRUE - support of FMP capsules is advertised.<BR>
+ # FALSE - support of FMP capsules is not advertised.<BR>
+ # If platform does not use this feature, this PCD should be set to FALSE.<BR><BR>
+ # @Prompt Enable advertising support of FMP capsules.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleFmpSupport|FALSE|BOOLEAN|0x00000028
+
## Capsule On Disk is to deliver capsules via files on Mass Storage device.<BR><BR>
# This PCD indicates if the Capsule On Disk is supported.<BR>
# TRUE - Capsule On Disk is supported.<BR>
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf index 5bac635..95d2607 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf @@ -97,6 +97,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleFmpSupport ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport ## CONSUMES
[Depex]
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c index 72de8d3..7856491 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -580,6 +580,10 @@ BdsFormalizeOSIndicationVariable ( OsIndicationSupport |= EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED;
}
+ if (PcdGetBool (PcdCapsuleFmpSupport)) {
+ OsIndicationSupport |= EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED;
+ }
+
Status = gRT->SetVariable (
EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index 50a88f5..981844c 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c @@ -2,6 +2,7 @@ This is the main routine for initializing the Graphics Console support routines.
Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2025, Loongson Technology Corporation Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -1095,6 +1096,14 @@ GraphicsConsoleConOutTestString ( Count = 0;
while (WString[Count] != 0) {
+ //
+ // In TerminalConOutOutputString(), WIDE_CHAR/NARROW_CHAR will be ignored.
+ // So, WString contains WIDE_CHAR/NARROW_CHAR is also valid.
+ //
+ if ((WString[Count] == WIDE_CHAR) || (WString[Count] == NARROW_CHAR)) {
+ continue;
+ }
+
Status = mHiiFont->GetGlyph (
mHiiFont,
WString[Count],
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h index 66438be..7a7aa5b 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h @@ -4,6 +4,7 @@ Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.<BR>
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
+Copyright (c) 2025, Loongson Technology Corporation Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -17,6 +18,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Guid/PcAnsi.h>
#include <Guid/TtyTerm.h>
#include <Guid/StatusCodeDataTypeVariable.h>
+#include <Guid/MdeModuleHii.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/SerialIo.h>
@@ -161,7 +163,7 @@ typedef union { #define FOREGROUND_CONTROL_OFFSET 6
#define BACKGROUND_CONTROL_OFFSET 11
#define ROW_OFFSET 2
-#define COLUMN_OFFSET 5
+#define COLUMN_OFFSET 6
#define FW_BACK_OFFSET 2
#define RESIZE_ROW_OFFSET 4
#define RESIZE_COLUMN_OFFSET 8
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c index eb8658c..54539c3 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -4,6 +4,7 @@ Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.<BR>
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
+Copyright (c) 2025, Loongson Technology Corporation Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -75,12 +76,12 @@ UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = { };
CHAR16 mSetModeString[] = { ESC, '[', '=', '3', 'h', 0 };
-CHAR16 mSetModeStringResize[] = { ESC, '[', '8', ';', '0', '0', '0', ';', '0', '0', '0', 't', '0', 0 };
+CHAR16 mSetModeStringResize[] = { ESC, '[', '8', ';', '0', '0', '0', ';', '0', '0', '0', 't', 0 };
CHAR16 mSetAttributeString[] = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };
CHAR16 mClearScreenString[] = { ESC, '[', '2', 'J', 0 };
-CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };
-CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', 'C', 0 };
-CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', 'D', 0 };
+CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', '0', ';', '0', '0', '0', 'H', 0 };
+CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', '0', 'C', 0 };
+CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', '0', 'D', 0 };
//
// Body of the ConOut functions
@@ -216,6 +217,13 @@ TerminalConOutOutputString ( );
for ( ; *WString != CHAR_NULL; WString++) {
+ //
+ // Skip WIDE_CHAR/NARROW_CHAR, because they are not displayable.
+ //
+ if ((*WString == WIDE_CHAR) || (*WString == NARROW_CHAR)) {
+ continue;
+ }
+
switch (TerminalDevice->TerminalType) {
case TerminalTypePcAnsi:
case TerminalTypeVt100:
@@ -497,10 +505,10 @@ TerminalConOutSetMode ( Rows = TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows;
mSetModeStringResize[RESIZE_ROW_OFFSET + 0] = (CHAR16)('0' + (Rows / 100));
- mSetModeStringResize[RESIZE_ROW_OFFSET + 1] = (CHAR16)('0' + ((Rows - ((Rows / 100) * 100)) / 10));
+ mSetModeStringResize[RESIZE_ROW_OFFSET + 1] = (CHAR16)('0' + ((Rows % 100) / 10));
mSetModeStringResize[RESIZE_ROW_OFFSET + 2] = (CHAR16)('0' + (Rows % 10));
mSetModeStringResize[RESIZE_COLUMN_OFFSET + 0] = (CHAR16)('0' + (Columns / 100));
- mSetModeStringResize[RESIZE_COLUMN_OFFSET + 1] = (CHAR16)('0' + ((Columns - ((Columns / 100) * 100)) / 10));
+ mSetModeStringResize[RESIZE_COLUMN_OFFSET + 1] = (CHAR16)('0' + ((Columns % 100) / 10));
mSetModeStringResize[RESIZE_COLUMN_OFFSET + 2] = (CHAR16)('0' + (Columns % 10));
String = mSetModeStringResize;
@@ -804,21 +812,25 @@ TerminalConOutSetCursorPosition ( ((UINTN)Mode->CursorRow == Row))
{
if ((UINTN)Mode->CursorColumn > Column) {
- mCursorBackwardString[FW_BACK_OFFSET + 0] = (CHAR16)('0' + ((Mode->CursorColumn - Column) / 10));
- mCursorBackwardString[FW_BACK_OFFSET + 1] = (CHAR16)('0' + ((Mode->CursorColumn - Column) % 10));
+ mCursorBackwardString[FW_BACK_OFFSET + 0] = (CHAR16)('0' + ((Mode->CursorColumn - Column) / 100));
+ mCursorBackwardString[FW_BACK_OFFSET + 1] = (CHAR16)('0' + (((Mode->CursorColumn - Column) % 100) / 10));
+ mCursorBackwardString[FW_BACK_OFFSET + 2] = (CHAR16)('0' + ((Mode->CursorColumn - Column) % 10));
String = mCursorBackwardString;
} else if (Column > (UINTN)Mode->CursorColumn) {
- mCursorForwardString[FW_BACK_OFFSET + 0] = (CHAR16)('0' + ((Column - Mode->CursorColumn) / 10));
- mCursorForwardString[FW_BACK_OFFSET + 1] = (CHAR16)('0' + ((Column - Mode->CursorColumn) % 10));
+ mCursorForwardString[FW_BACK_OFFSET + 0] = (CHAR16)('0' + ((Column - Mode->CursorColumn) / 100));
+ mCursorForwardString[FW_BACK_OFFSET + 1] = (CHAR16)('0' + (((Column - Mode->CursorColumn) % 100) / 10));
+ mCursorForwardString[FW_BACK_OFFSET + 2] = (CHAR16)('0' + ((Column - Mode->CursorColumn) % 10));
String = mCursorForwardString;
} else {
String = L""; // No cursor motion necessary
}
} else {
- mSetCursorPositionString[ROW_OFFSET + 0] = (CHAR16)('0' + ((Row + 1) / 10));
- mSetCursorPositionString[ROW_OFFSET + 1] = (CHAR16)('0' + ((Row + 1) % 10));
- mSetCursorPositionString[COLUMN_OFFSET + 0] = (CHAR16)('0' + ((Column + 1) / 10));
- mSetCursorPositionString[COLUMN_OFFSET + 1] = (CHAR16)('0' + ((Column + 1) % 10));
+ mSetCursorPositionString[ROW_OFFSET + 0] = (CHAR16)('0' + ((Row + 1) / 100));
+ mSetCursorPositionString[ROW_OFFSET + 1] = (CHAR16)('0' + (((Row + 1) % 100) / 10));
+ mSetCursorPositionString[ROW_OFFSET + 2] = (CHAR16)('0' + ((Row + 1) % 10));
+ mSetCursorPositionString[COLUMN_OFFSET + 0] = (CHAR16)('0' + ((Column + 1) / 100));
+ mSetCursorPositionString[COLUMN_OFFSET + 1] = (CHAR16)('0' + (((Column + 1) % 100) / 10));
+ mSetCursorPositionString[COLUMN_OFFSET + 2] = (CHAR16)('0' + ((Column + 1) % 10));
String = mSetCursorPositionString;
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index c9aabaa..a282f6d 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -2,6 +2,7 @@ Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.
Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2025, Loongson Technology Corporation Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -4265,7 +4266,7 @@ GenerateAltConfigResp ( // Convert Value to a hex string in "%x" format
// NOTE: This is in the opposite byte that GUID and PATH use
//
- if (BlockData->OpCode == EFI_IFR_STRING_OP) {
+ if ((BlockData->OpCode == EFI_IFR_STRING_OP) && (DefaultValueData->Value.string != 0)) {
DefaultString = InternalGetString (HiiHandle, DefaultValueData->Value.string);
TmpBuffer = AllocateZeroPool (Width);
ASSERT (TmpBuffer != NULL);
|