mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-01 12:53:27 +01:00
workarounds for gcc12 bug
Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
parent
ee4d7a61b8
commit
0fc7980fa8
@ -2147,8 +2147,11 @@ BiosKeyboardTimerHandler (
|
||||
//
|
||||
// Clear the CTRL and ALT BDA flag
|
||||
//
|
||||
KbFlag1 = *((UINT8 *) (UINTN) 0x417); // read the STATUS FLAGS 1
|
||||
KbFlag2 = *((UINT8 *) (UINTN) 0x418); // read STATUS FLAGS 2
|
||||
volatile UINT8 * volatile kbf;
|
||||
kbf = (volatile UINT8 *) (UINTN) 0x417;
|
||||
KbFlag1 = *kbf; // read the STATUS FLAGS 1
|
||||
kbf = (volatile UINT8 *) (UINTN) 0x418;
|
||||
KbFlag2 = *kbf; // read STATUS FLAGS 2
|
||||
/*
|
||||
DEBUG_CODE (
|
||||
{
|
||||
@ -2217,9 +2220,12 @@ BiosKeyboardTimerHandler (
|
||||
// Clear left alt and left ctrl BDA flag
|
||||
//
|
||||
KbFlag2 &= ~(KB_LEFT_ALT_PRESSED | KB_LEFT_CTRL_PRESSED);
|
||||
*((UINT8 *) (UINTN) 0x418) = KbFlag2;
|
||||
|
||||
kbf = (volatile UINT8 *) (UINTN) 0x418;
|
||||
*kbf = KbFlag2;
|
||||
KbFlag1 &= ~0x0C;
|
||||
*((UINT8 *) (UINTN) 0x417) = KbFlag1;
|
||||
kbf = (volatile UINT8 *) (UINTN) 0x417;
|
||||
*kbf = KbFlag1;
|
||||
|
||||
|
||||
//
|
||||
|
@ -652,8 +652,9 @@ Return:
|
||||
// Allocate memory only up to EBDA (EBDA boundry speicifed at EFI_MEMORY_BELOW_1MB_END is not universal!)
|
||||
// Bottom of EBDA is usually available by examining 0x40E, which should contain EBDA base address >> 4
|
||||
// If value is not sane, we use default value at EFI_MEMORY_BELOW_1MB_END (0x9F800)
|
||||
|
||||
EbdaAddress = LShiftU64((UINT64)(*(UINT16 *)(UINTN)(0x40E)), 4);
|
||||
volatile UINT16 * volatile ebda;
|
||||
ebda = (volatile UINT16 *)(UINTN)(0x40E);
|
||||
EbdaAddress = LShiftU64((UINT64)(*ebda), 4);
|
||||
if (EbdaAddress < 0x90000 || EbdaAddress > EFI_MEMORY_BELOW_1MB_END) {
|
||||
EbdaAddress = 0x9A000;
|
||||
}
|
||||
|
@ -47,10 +47,11 @@ FindAcpiRsdPtr (
|
||||
//
|
||||
// Search EBDA
|
||||
//
|
||||
|
||||
Address = (*(UINT16 *)(UINTN)(EBDA_BASE_ADDRESS)) << 4;
|
||||
volatile UINT16 * volatile ebda;
|
||||
ebda = (volatile UINT16 *)(UINTN)(EBDA_BASE_ADDRESS);
|
||||
Address = (UINTN)(*ebda) << 4;
|
||||
for (Index = 0; Index < 0x400 ; Index += 16) {
|
||||
if (*(UINT64 *)(Address + Index) == EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {
|
||||
if (*(volatile UINT64 *)(Address + Index) == EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {
|
||||
return (VOID *)Address;
|
||||
}
|
||||
}
|
||||
@ -95,10 +96,13 @@ FindMPSPtr (
|
||||
//
|
||||
// Search EBDA
|
||||
//
|
||||
volatile UINT16 * volatile ebda;
|
||||
ebda = (volatile UINT16 *)(UINTN)(EBDA_BASE_ADDRESS);
|
||||
Address = (UINTN)(*ebda) << 4;
|
||||
|
||||
Address = (*(UINT16 *)(UINTN)(EBDA_BASE_ADDRESS)) << 4;
|
||||
// Address = (*(UINT16 *)(UINTN)(EBDA_BASE_ADDRESS)) << 4;
|
||||
for (Index = 0; Index < 0x400 ; Index += 16) {
|
||||
if (*(UINT32 *)(Address + Index) == MPS_PTR) {
|
||||
if (*(volatile UINT32 *)(Address + Index) == MPS_PTR) {
|
||||
return (VOID *)Address;
|
||||
}
|
||||
}
|
||||
|
@ -167,8 +167,11 @@ GenMemoryMap (
|
||||
UINT64 EBDAsize = 2;
|
||||
|
||||
// EBDA memory protection
|
||||
volatile UINT16 * volatile ebda;
|
||||
ebda = (volatile UINT16 *)(UINTN)(0x40E);
|
||||
EBDAaddr = LShiftU64((UINT64)(*ebda), 4);
|
||||
|
||||
EBDAaddr = LShiftU64((UINT64)(*(UINT16 *)(UINTN)(0x40E)), 4);
|
||||
// EBDAaddr = LShiftU64((UINT64)(*(volatile UINT16 *)(UINTN)(0x40E)), 4);
|
||||
//fool proof
|
||||
if (EBDAaddr < 0x90000 || EBDAaddr > 0x9F800) {
|
||||
EBDAaddr = 0x9A000;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 2a9f1370b811ea9f5b7a1abb1c0c68768eeb52f4
|
||||
Subproject commit cde12f2c5b0efb2120f191eccaeb413f1465864e
|
@ -1157,6 +1157,8 @@ InitializeCpu (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN Called = FALSE;
|
||||
if (Called) {
|
||||
EFI_EVENT IdleLoopEvent;
|
||||
|
||||
InitializePageTableLib();
|
||||
@ -1167,7 +1169,6 @@ InitializeCpu (
|
||||
// Make sure interrupts are disabled
|
||||
//
|
||||
DisableInterrupts ();
|
||||
|
||||
//
|
||||
// Init GDT for DXE
|
||||
//
|
||||
@ -1211,6 +1212,7 @@ InitializeCpu (
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
}
|
||||
Status = InitializeMpSupport ();
|
||||
|
||||
return Status;
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = CpuDxe
|
||||
BASE_NAME = CpuMpDxe
|
||||
MODULE_UNI_FILE = CpuDxe.uni
|
||||
FILE_GUID = 1A1E4886-9517-440e-9FDE-3BE44CEE2136
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
@ -86,3 +86,8 @@
|
||||
|
||||
[UserExtensions.TianoCore."ExtraFiles"]
|
||||
CpuDxeExtra.uni
|
||||
|
||||
[BuildOptions]
|
||||
# XCODE:*_*_*_CC_FLAGS = -Os
|
||||
GCC:*_*_*_CC_FLAGS = -fno-lto
|
||||
|
||||
|
@ -6,6 +6,11 @@
|
||||
|
||||
**/
|
||||
|
||||
/*
|
||||
* Modified by Slice 2022
|
||||
* to use this driver after external UEFI made initialization
|
||||
*/
|
||||
|
||||
#include "CpuDxe.h"
|
||||
#include "CpuMp.h"
|
||||
|
||||
@ -816,28 +821,32 @@ InitializeMpSupport (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN Called = FALSE;
|
||||
UINTN NumberOfProcessors;
|
||||
UINTN NumberOfEnabledProcessors;
|
||||
|
||||
//
|
||||
// Wakeup APs to do initialization
|
||||
//
|
||||
Status = MpInitLibInitialize ();
|
||||
return Status;
|
||||
if (Called) Status = MpInitLibInitialize ();
|
||||
// return Status;
|
||||
|
||||
MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors);
|
||||
mNumberOfProcessors = NumberOfProcessors;
|
||||
if (Called) MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors);
|
||||
// mNumberOfProcessors = NumberOfProcessors;
|
||||
|
||||
UINT64 msr = AsmReadMsr64 (MSR_CORE_THREAD_COUNT);
|
||||
mNumberOfProcessors = msr && 0xFF;
|
||||
DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mNumberOfProcessors));
|
||||
|
||||
//
|
||||
// Initialize special exception handlers for each logic processor.
|
||||
//
|
||||
InitializeMpExceptionHandlers ();
|
||||
if (Called) InitializeMpExceptionHandlers ();
|
||||
|
||||
//
|
||||
// Update CPU healthy information from Guided HOB
|
||||
//
|
||||
CollectBistDataFromHob ();
|
||||
if (Called) CollectBistDataFromHob ();
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&mMpServiceHandle,
|
||||
|
@ -9,6 +9,8 @@
|
||||
#ifndef _CPU_MP_H_
|
||||
#define _CPU_MP_H_
|
||||
|
||||
#define MSR_CORE_THREAD_COUNT 0x35
|
||||
|
||||
/**
|
||||
Initialize Multi-processor support.
|
||||
|
||||
|
@ -125,7 +125,11 @@ void* FindAcpiRsdPtr()
|
||||
//
|
||||
// Search EBDA
|
||||
//
|
||||
Address = (*(UINT16 *)(UINTN)(EBDA_BASE_ADDRESS)) << 4;
|
||||
volatile UINT16 * volatile ebda;
|
||||
ebda = (volatile UINT16 *)(UINTN)(EBDA_BASE_ADDRESS);
|
||||
Address = LShiftU64((UINT64)(*ebda), 4);
|
||||
|
||||
// Address = (*(UINT16 *)(UINTN)(EBDA_BASE_ADDRESS)) << 4;
|
||||
if ( Address == 0 ) return 0; // Jief : if Address==0, the first access at *(UINT64 *)(Address + Index) is at address 0. It's supposed to crash.
|
||||
for (Index = 0; Index < 0x400 ; Index += 16) {
|
||||
if (*(UINT64 *)(Address + Index) == EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {
|
||||
|
@ -604,7 +604,7 @@ EFI_STATUS bootPBRtest(REFIT_VOLUME* volume)
|
||||
EFI_BLOCK_IO* pDisk = volume->BlockIO;
|
||||
UINT8* pBootSector = (UINT8*)(UINTN)0x7C00;
|
||||
UINT8* mBootSector;
|
||||
MBR_PARTITION_INFO* pMBR = (MBR_PARTITION_INFO*)(UINTN)0x7BE;
|
||||
volatile MBR_PARTITION_INFO* volatile pMBR; // = (MBR_PARTITION_INFO*)(UINTN)0x7BE;
|
||||
UINT32 LbaOffset = 0;
|
||||
UINT32 LbaSize = 0;
|
||||
HARDDRIVE_DEVICE_PATH *HdPath = NULL;
|
||||
@ -613,12 +613,14 @@ EFI_STATUS bootPBRtest(REFIT_VOLUME* volume)
|
||||
// UINT16 OldMask;
|
||||
// UINT16 NewMask;
|
||||
UINTN i, j; //for debug dump
|
||||
UINT8 *ptr;
|
||||
UINT8* ptr;
|
||||
// UINT32 MBRCRC32;
|
||||
//UINTN LogSize;
|
||||
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtPointer = NULL;
|
||||
EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs = NULL;
|
||||
|
||||
pMBR = (volatile MBR_PARTITION_INFO*)(UINTN)0x7BE;
|
||||
|
||||
IA32_REGISTER_SET Regs;
|
||||
SetMem(&Regs, sizeof (Regs), 0);
|
||||
addrEnablePaging(0);
|
||||
@ -699,7 +701,7 @@ EFI_STATUS bootPBRtest(REFIT_VOLUME* volume)
|
||||
ptr = (UINT8*)(UINTN)0x7F00;
|
||||
CopyMem(ptr, &VideoTest[0], 30);
|
||||
|
||||
CopyMem(pMBR, &tMBR, 16);
|
||||
CopyMem((void*)pMBR, &tMBR, 16);
|
||||
pMBR->StartLBA = LbaOffset;
|
||||
pMBR->Size = LbaSize;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user