Skip to content

Commit

Permalink
CpuExceptionHandlerLib: Added PcdSerialUseMmio condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Sep 23, 2024
1 parent 469ae18 commit e609112
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize
gUefiOvmfPkgTokenSpaceGuid.PcdUartBase ## CONSUMES
gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSUMES

[FeaturePcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard ## CONSUMES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,22 +231,25 @@ ArchSetupExceptionStack (
StackTop -= CPU_KNOWN_GOOD_STACK_SIZE;
Tss->SS0 = AsmReadSs ();
Tss->IOMapBaseAddress = sizeof (IA32_TASK_STATE_SEGMENT);
//
// Allow access to gUartBase = 0x3F8 and Offsets: 0x01, 0x03, 0x04, 0x05, 0x06;
// and DebugIoPort = 0x402.
//

IOBitMap = (UINT8 *)((UINTN)Tss + Tss->IOMapBaseAddress);
SetMem (IOBitMap, IO_BIT_MAP_SIZE, 0xFF);

IOBitMapPointer = (UINT8 *)((UINTN)IOBitMap + FixedPcdGet16 (PcdUartBase) / 8);
Offset = (UINT8)(FixedPcdGet16 (PcdUartBase) & 0x7U);
*(UINT16 *)IOBitMapPointer &= ~((1U << Offset) | (1U << (Offset + 1))
| (1U << (Offset + 3)) | (1U << (Offset + 4))
| (1U << (Offset + 5)) | (1U << (Offset + 6)));

IOBitMapPointer = (UINT8 *)((UINTN)IOBitMap + FixedPcdGet16 (PcdDebugIoPort) / 8);
Offset = (UINT8)(FixedPcdGet16 (PcdDebugIoPort) & 0x7U);
*IOBitMapPointer &= ~(1U << Offset);
if (!FixedPcdGetBool (PcdSerialUseMmio)) {
//
// Allow access to gUartBase = 0x3F8 and Offsets: 0x01, 0x03, 0x04, 0x05, 0x06;
// and DebugIoPort = 0x402.
//
IOBitMapPointer = (UINT8 *)((UINTN)IOBitMap + FixedPcdGet16 (PcdUartBase) / 8);
Offset = (UINT8)(FixedPcdGet16 (PcdUartBase) & 0x7U);
*(UINT16 *)IOBitMapPointer &= ~((1U << Offset) | (1U << (Offset + 1))
| (1U << (Offset + 3)) | (1U << (Offset + 4))
| (1U << (Offset + 5)) | (1U << (Offset + 6)));

IOBitMapPointer = (UINT8 *)((UINTN)IOBitMap + FixedPcdGet16 (PcdDebugIoPort) / 8);
Offset = (UINT8)(FixedPcdGet16 (PcdDebugIoPort) & 0x7U);
*IOBitMapPointer &= ~(1U << Offset);
}

Tss = (IA32_TASK_STATE_SEGMENT *)((UINTN)Tss + sizeof (IA32_TASK_STATE_SEGMENT) + IO_BIT_MAP_SIZE);
++TssDesc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList
gUefiOvmfPkgTokenSpaceGuid.PcdUartBase ## CONSUMES
gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSUMES

[FeaturePcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard ## CONSUMES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize
gUefiOvmfPkgTokenSpaceGuid.PcdUartBase ## CONSUMES
gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSUMES

[FeaturePcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard ## CONSUMES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize
gUefiOvmfPkgTokenSpaceGuid.PcdUartBase ## CONSUMES
gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSUMES

[FeaturePcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard ## CONSUMES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,25 @@ ArchSetupExceptionStack (
Tss->RSP0 = StackTop;
StackTop -= CPU_KNOWN_GOOD_STACK_SIZE;
Tss->IOMapBaseAddress = sizeof (IA32_TASK_STATE_SEGMENT);
//
// Allow access to gUartBase = 0x3F8 and Offsets: 0x01, 0x03, 0x04, 0x05, 0x06;
// and DebugIoPort = 0x402.
//

IOBitMap = (UINT8 *)((UINTN)Tss + Tss->IOMapBaseAddress);
SetMem (IOBitMap, IO_BIT_MAP_SIZE, 0xFF);

IOBitMapPointer = (UINT8 *)((UINTN)IOBitMap + FixedPcdGet16 (PcdUartBase) / 8);
Offset = (UINT8)(FixedPcdGet16 (PcdUartBase) & 0x7U);
*(UINT16 *)IOBitMapPointer &= ~((1U << Offset) | (1U << (Offset + 1))
| (1U << (Offset + 3)) | (1U << (Offset + 4))
| (1U << (Offset + 5)) | (1U << (Offset + 6)));

IOBitMapPointer = (UINT8 *)((UINTN)IOBitMap + FixedPcdGet16 (PcdDebugIoPort) / 8);
Offset = (UINT8)(FixedPcdGet16 (PcdDebugIoPort) & 0x7U);
*IOBitMapPointer &= ~(1U << Offset);

if (!FixedPcdGetBool (PcdSerialUseMmio)) {
//
// Allow access to gUartBase = 0x3F8 and Offsets: 0x01, 0x03, 0x04, 0x05, 0x06;
// and DebugIoPort = 0x402.
//
IOBitMapPointer = (UINT8 *)((UINTN)IOBitMap + FixedPcdGet16 (PcdUartBase) / 8);
Offset = (UINT8)(FixedPcdGet16 (PcdUartBase) & 0x7U);
*(UINT16 *)IOBitMapPointer &= ~((1U << Offset) | (1U << (Offset + 1))
| (1U << (Offset + 3)) | (1U << (Offset + 4))
| (1U << (Offset + 5)) | (1U << (Offset + 6)));

IOBitMapPointer = (UINT8 *)((UINTN)IOBitMap + FixedPcdGet16 (PcdDebugIoPort) / 8);
Offset = (UINT8)(FixedPcdGet16 (PcdDebugIoPort) & 0x7U);
*IOBitMapPointer &= ~(1U << Offset);
}
//
// Fixup IST and task-state segment
//
Expand Down

0 comments on commit e609112

Please sign in to comment.