/** Platform specific mechanism to transfer control to 16bit OS waking vector @param[in] AcpiWakingVector The 16bit OS waking vector @param[in] AcpiLowMemoryBase A buffer under 1M which could be used during the transfer **/ VOID PlatformTransferControl16 ( IN UINT32 AcpiWakingVector, IN UINT32 AcpiLowMemoryBase ) { UINT32 NewValue; UINT64 BaseAddress; UINT64 SmramLength; UINTN Index; DEBUG (( EFI_D_INFO, "PlatformTransferControl - Entry\r\n")); // // Need to make sure the GDT is loaded with values that support long mode and real mode. // AsmWriteGdtr (&mGdt); // // Disable eSram block (this will also clear/zero eSRAM) // We only use eSRAM in the PEI phase. Disable now that we are resuming the OS // NewValue = QNCPortRead (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_ESRAMPGCTRL_BLOCK); NewValue |= BLOCK_DISABLE_PG; QNCPortWrite (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_ESRAMPGCTRL_BLOCK, NewValue); // // Update HMBOUND to top of DDR3 memory and LOCK // We disabled eSRAM so now we move HMBOUND down to top of DDR3 // QNCGetTSEGMemoryRange (&BaseAddress, &SmramLength); NewValue = (UINT32)(BaseAddress + SmramLength); DEBUG ((EFI_D_INFO,"Locking HMBOUND at: = 0x%8x\n",NewValue)); QNCPortWrite (QUARK_NC_HOST_BRIDGE_SB_PORT_ID, QUARK_NC_HOST_BRIDGE_HMBOUND_REG, (NewValue | HMBOUND_LOCK)); // // Lock all IMR regions now that HMBOUND is locked // for (Index = (QUARK_NC_MEMORY_MANAGER_IMR0+QUARK_NC_MEMORY_MANAGER_IMRXL); Index <= (QUARK_NC_MEMORY_MANAGER_IMR7+QUARK_NC_MEMORY_MANAGER_IMRXL); Index += 4) { NewValue = QNCPortRead (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, Index); NewValue |= IMR_LOCK; QNCPortWrite (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, Index, NewValue); } // // Call ASM routine to switch to real mode and jump to 16bit OS waking vector // AsmTransferControl(AcpiWakingVector, 0); // // Never run to here // CpuDeadLoop(); }
VOID EFIAPI PlatformConfigOnSmmConfigurationProtocol ( IN EFI_EVENT Event, IN VOID *Context ) /*++ Routine Description: Function runs in PI-DXE to perform platform specific config when SmmConfigurationProtocol is installed. Arguments: Event - The event that occured. Context - For EFI compatiblity. Not used. Returns: None. --*/ { EFI_STATUS Status; UINT32 NewValue; UINT64 BaseAddress; UINT64 SmramLength; EFI_CPU_ARCH_PROTOCOL *CpuArchProtocol; // RTC:28208 - System hang/crash when entering probe mode(ITP) when relocating SMBASE VOID *SmmCfgProt; Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, &SmmCfgProt); if (Status != EFI_SUCCESS){ DEBUG ((DEBUG_INFO, "gEfiSmmConfigurationProtocolGuid triggered but not valid.\n")); return; } if (mMemCfgDone) { DEBUG ((DEBUG_INFO, "Platform DXE Mem config already done.\n")); return; } // // Disable eSram block (this will also clear/zero eSRAM) // We only use eSRAM in the PEI phase. Disable now that we are in the DXE phase // NewValue = QNCPortRead (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_ESRAMPGCTRL_BLOCK); NewValue |= BLOCK_DISABLE_PG; QNCPortWrite (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_ESRAMPGCTRL_BLOCK, NewValue); // // Update HMBOUND to top of DDR3 memory and LOCK // We disabled eSRAM so now we move HMBOUND down to top of DDR3 // QNCGetTSEGMemoryRange (&BaseAddress, &SmramLength); NewValue = (UINT32)(BaseAddress + SmramLength); DEBUG ((EFI_D_INFO,"Locking HMBOUND at: = 0x%8x\n",NewValue)); QNCPortWrite (QUARK_NC_HOST_BRIDGE_SB_PORT_ID, QUARK_NC_HOST_BRIDGE_HMBOUND_REG, (NewValue | HMBOUND_LOCK)); if(FeaturePcdGet (PcdEnableSecureLock)) { // // Lock IMR5 now that HMBOUND is locked (legacy S3 region) // NewValue = QNCPortRead (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_IMR5+QUARK_NC_MEMORY_MANAGER_IMRXL); NewValue |= IMR_LOCK; QNCPortWrite (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_IMR5+QUARK_NC_MEMORY_MANAGER_IMRXL, NewValue); // // Lock IMR6 now that HMBOUND is locked (ACPI Reclaim/ACPI/Runtime services/Reserved) // NewValue = QNCPortRead (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_IMR6+QUARK_NC_MEMORY_MANAGER_IMRXL); NewValue |= IMR_LOCK; QNCPortWrite (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_IMR6+QUARK_NC_MEMORY_MANAGER_IMRXL, NewValue); // // Disable IMR2 memory protection (RMU Main Binary) // QncImrWrite ( QUARK_NC_MEMORY_MANAGER_IMR2, (UINT32)(IMRL_RESET & ~IMR_EN), (UINT32)IMRH_RESET, (UINT32)IMRX_ALL_ACCESS, (UINT32)IMRX_ALL_ACCESS ); // // Disable IMR3 memory protection (Default SMRAM) // QncImrWrite ( QUARK_NC_MEMORY_MANAGER_IMR3, (UINT32)(IMRL_RESET & ~IMR_EN), (UINT32)IMRH_RESET, (UINT32)IMRX_ALL_ACCESS, (UINT32)IMRX_ALL_ACCESS ); // // Disable IMR4 memory protection (eSRAM). // QncImrWrite ( QUARK_NC_MEMORY_MANAGER_IMR4, (UINT32)(IMRL_RESET & ~IMR_EN), (UINT32)IMRH_RESET, (UINT32)IMRX_ALL_ACCESS, (UINT32)IMRX_ALL_ACCESS ); } // // RTC:28208 - System hang/crash when entering probe mode(ITP) when relocating SMBASE // Workaround to make default SMRAM UnCachable // Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **) &CpuArchProtocol); ASSERT_EFI_ERROR (Status); CpuArchProtocol->SetMemoryAttributes ( CpuArchProtocol, (EFI_PHYSICAL_ADDRESS) SMM_DEFAULT_SMBASE, SMM_DEFAULT_SMBASE_SIZE_BYTES, EFI_MEMORY_WB ); mMemCfgDone = TRUE; }