+++ /dev/null
-/**@file\r
-\r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- BdsPlatform.c\r
-\r
-Abstract:\r
-\r
- This file include all platform action which can be customized\r
- by IBV/OEM.\r
-\r
-**/\r
-\r
-#include "BdsPlatform.h"\r
-\r
-WIN_NT_SYSTEM_CONFIGURATION mSystemConfigData;\r
-\r
-VOID\r
-SetupVariableInit (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Size;\r
-\r
- Size = sizeof (mSystemConfigData);\r
- Status = gRT->GetVariable (\r
- L"Setup",\r
- &gEfiWinNtSystemConfigGuid,\r
- NULL,\r
- &Size,\r
- (VOID *) &mSystemConfigData\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // SetupVariable is corrupt\r
- //\r
- mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);\r
- mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);\r
-\r
- Status = gRT->SetVariable (\r
- L"Setup",\r
- &gEfiWinNtSystemConfigGuid,\r
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- sizeof (mSystemConfigData),\r
- (VOID *) &mSystemConfigData\r
- );\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));\r
- }\r
- }\r
-}\r
-\r
-//\r
-// BDS Platform Functions\r
-//\r
-VOID\r
-EFIAPI\r
-PlatformBdsInit (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Platform Bds init. Include the platform firmware vendor, revision\r
- and so crc check.\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
- None.\r
-\r
---*/\r
-{\r
- BdsLibSaveMemoryTypeInformation ();\r
- SetupVariableInit ();\r
-}\r
-\r
-EFI_STATUS\r
-PlatformBdsConnectConsole (\r
- IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Connect the predefined platform default console device. Always try to find\r
- and enable the vga device if have.\r
-\r
-Arguments:\r
-\r
- PlatformConsole - Predfined platform default console device array.\r
- \r
-Returns:\r
-\r
- EFI_SUCCESS - Success connect at least one ConIn and ConOut \r
- device, there must have one ConOut device is \r
- active vga device.\r
- \r
- EFI_STATUS - Return the status of \r
- BdsLibConnectAllDefaultConsoles ()\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
-\r
- Index = 0;\r
- Status = EFI_SUCCESS;\r
-\r
- //\r
- // Have chance to connect the platform default console,\r
- // the platform default console is the minimue device group\r
- // the platform should support\r
- //\r
- while (PlatformConsole[Index].DevicePath != NULL) {\r
- //\r
- // Update the console variable with the connect type\r
- //\r
- if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
- BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
- }\r
-\r
- if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
- BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
- }\r
-\r
- if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
- BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
- }\r
-\r
- Index++;\r
- }\r
- //\r
- // Connect the all the default console with current cosole variable\r
- //\r
- Status = BdsLibConnectAllDefaultConsoles ();\r
- \r
- return Status;\r
-}\r
-\r
-VOID\r
-PlatformBdsConnectSequence (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Connect with predeined platform connect sequence, \r
- the OEM/IBV can customize with their own connect sequence.\r
- \r
-Arguments:\r
-\r
- None.\r
- \r
-Returns:\r
-\r
- None.\r
- \r
---*/\r
-{\r
- UINTN Index;\r
-\r
- Index = 0;\r
-\r
- //\r
- // Here we can get the customized platform connect sequence\r
- // Notes: we can connect with new variable which record the\r
- // last time boots connect device path sequence\r
- //\r
- while (gPlatformConnectSequence[Index] != NULL) {\r
- //\r
- // Build the platform boot option\r
- //\r
- BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
- Index++;\r
- }\r
-\r
- //\r
- // Jst use the simple policy to connect all devices\r
- //\r
- BdsLibConnectAll ();\r
-}\r
-\r
-VOID\r
-PlatformBdsGetDriverOption (\r
- IN OUT LIST_ENTRY *BdsDriverLists\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Load the predefined driver option, OEM/IBV can customize this\r
- to load their own drivers\r
- \r
-Arguments:\r
-\r
- BdsDriverLists - The header of the driver option link list.\r
- \r
-Returns:\r
-\r
- None.\r
- \r
---*/\r
-{\r
- UINTN Index;\r
-\r
- Index = 0;\r
-\r
- //\r
- // Here we can get the customized platform driver option\r
- //\r
- while (gPlatformDriverOption[Index] != NULL) {\r
- //\r
- // Build the platform boot option\r
- //\r
- BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
- Index++;\r
- }\r
-\r
-}\r
-\r
-VOID\r
-PlatformBdsDiagnostics (\r
- IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
- IN BOOLEAN QuietBoot,\r
- IN BASEM_MEMORY_TEST BaseMemoryTest \r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Perform the platform diagnostic, such like test memory. OEM/IBV also\r
- can customize this fuction to support specific platform diagnostic.\r
- \r
-Arguments:\r
-\r
- MemoryTestLevel - The memory test intensive level\r
- \r
- QuietBoot - Indicate if need to enable the quiet boot\r
-\r
- BaseMemoryTest - A pointer to BdsMemoryTest() \r
-\r
-Returns:\r
-\r
- None.\r
- \r
---*/\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Here we can decide if we need to show\r
- // the diagnostics screen\r
- // Notes: this quiet boot code should be remove\r
- // from the graphic lib\r
- //\r
- if (QuietBoot) {\r
- EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
- //\r
- // Perform system diagnostic\r
- //\r
- Status = BaseMemoryTest (MemoryTestLevel);\r
- if (EFI_ERROR (Status)) {\r
- DisableQuietBoot ();\r
- }\r
-\r
- return ;\r
- }\r
- //\r
- // Perform system diagnostic\r
- //\r
- Status = BaseMemoryTest (MemoryTestLevel);\r
-}\r
-\r
-/**\r
- The function will excute with as the platform policy, current policy\r
- is driven by boot mode. IBV/OEM can customize this code for their specific\r
- policy action.\r
-\r
- @param DriverOptionList The header of the driver option link list\r
- @param BootOptionList The header of the boot option link list\r
- @param ProcessCapsules A pointer to ProcessCapsules()\r
- @param BaseMemoryTest A pointer to BaseMemoryTest()\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsPolicyBehavior (\r
- IN OUT LIST_ENTRY *DriverOptionList,\r
- IN OUT LIST_ENTRY *BootOptionList,\r
- IN PROCESS_CAPSULES ProcessCapsules,\r
- IN BASEM_MEMORY_TEST BaseMemoryTest\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT16 Timeout;\r
- EFI_BOOT_MODE BootMode;\r
-\r
- //\r
- // Init the time out value\r
- //\r
- Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
-\r
- //\r
- // Load the driver option as the driver option list\r
- //\r
- PlatformBdsGetDriverOption (DriverOptionList);\r
-\r
- //\r
- // Get current Boot Mode\r
- //\r
- Status = BdsLibGetBootMode (&BootMode);\r
-\r
- //\r
- // Go the different platform policy with different boot mode\r
- // Notes: this part code can be change with the table policy\r
- //\r
- switch (BootMode) {\r
-\r
- case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
- case BOOT_WITH_MINIMAL_CONFIGURATION:\r
- //\r
- // In no-configuration boot mode, we can connect the\r
- // console directly.\r
- //\r
- BdsLibConnectAllDefaultConsoles ();\r
- PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE, BaseMemoryTest);\r
-\r
- //\r
- // Perform some platform specific connect sequence\r
- //\r
- PlatformBdsConnectSequence ();\r
-\r
- //\r
- // Notes: current time out = 0 can not enter the\r
- // front page\r
- //\r
- PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-\r
- //\r
- // Check the boot option with the boot option list\r
- //\r
- BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
- break;\r
-\r
- case BOOT_ON_FLASH_UPDATE:\r
- //\r
- // Boot with the specific configuration\r
- //\r
- PlatformBdsConnectConsole (gPlatformConsole);\r
- PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
- BdsLibConnectAll ();\r
- ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
- break;\r
-\r
- case BOOT_IN_RECOVERY_MODE:\r
- //\r
- // In recovery mode, just connect platform console\r
- // and show up the front page\r
- //\r
- PlatformBdsConnectConsole (gPlatformConsole);\r
- PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
-\r
- //\r
- // In recovery boot mode, we still enter to the\r
- // frong page now\r
- //\r
- PlatformBdsEnterFrontPage (Timeout, FALSE);\r
- break;\r
-\r
- case BOOT_WITH_FULL_CONFIGURATION:\r
- case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
- case BOOT_WITH_DEFAULT_SETTINGS:\r
- default:\r
- //\r
- // Connect platform console\r
- //\r
- Status = PlatformBdsConnectConsole (gPlatformConsole);\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // Here OEM/IBV can customize with defined action\r
- //\r
- PlatformBdsNoConsoleAction ();\r
- }\r
-\r
- PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE, BaseMemoryTest);\r
-\r
- //\r
- // Perform some platform specific connect sequence\r
- //\r
- PlatformBdsConnectSequence ();\r
-\r
- //\r
- // Give one chance to enter the setup if we\r
- // have the time out\r
- //\r
- PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-\r
- //\r
- // Here we have enough time to do the enumeration of boot device\r
- //\r
- BdsLibEnumerateAllBootOption (BootOptionList);\r
- break;\r
- }\r
-\r
- return ;\r
-\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootSuccess (\r
- IN BDS_COMMON_OPTION *Option\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Hook point after a boot attempt succeeds. We don't expect a boot option to\r
- return, so the EFI 1.0 specification defines that you will default to an\r
- interactive mode and stop processing the BootOrder list in this case. This\r
- is alos a platform implementation and can be customized by IBV/OEM.\r
-\r
-Arguments:\r
-\r
- Option - Pointer to Boot Option that succeeded to boot.\r
-\r
-Returns:\r
- \r
- None.\r
-\r
---*/\r
-{\r
- CHAR16 *TmpStr;\r
-\r
- //\r
- // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
- // select loop then we need to pop up a UI and wait for user input.\r
- //\r
- TmpStr = Option->StatusString;\r
- if (TmpStr != NULL) {\r
- BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
- FreePool (TmpStr);\r
- }\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootFail (\r
- IN BDS_COMMON_OPTION *Option,\r
- IN EFI_STATUS Status,\r
- IN CHAR16 *ExitData,\r
- IN UINTN ExitDataSize\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Hook point after a boot attempt fails.\r
-\r
-Arguments:\r
- \r
- Option - Pointer to Boot Option that failed to boot.\r
-\r
- Status - Status returned from failed boot.\r
-\r
- ExitData - Exit data returned from failed boot.\r
-\r
- ExitDataSize - Exit data size returned from failed boot.\r
-\r
-Returns:\r
- \r
- None.\r
-\r
---*/\r
-{\r
- CHAR16 *TmpStr;\r
-\r
- //\r
- // If Boot returned with failed status then we need to pop up a UI and wait\r
- // for user input.\r
- //\r
- TmpStr = Option->StatusString;\r
- if (TmpStr != NULL) {\r
- BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
- FreePool (TmpStr);\r
- }\r
-\r
-}\r
-\r
-EFI_STATUS\r
-PlatformBdsNoConsoleAction (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- This function is remained for IBV/OEM to do some platform action,\r
- if there no console device can be connected.\r
-\r
-Arguments:\r
- \r
- None.\r
- \r
-Returns:\r
- \r
- EFI_SUCCESS - Direct return success now.\r
-\r
---*/\r
-{\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- This function locks platform flash that is not allowed to be updated during normal boot path.\r
- The flash layout is platform specific.\r
-\r
- **/\r
-VOID\r
-EFIAPI\r
-PlatformBdsLockNonUpdatableFlash (\r
- VOID\r
- )\r
-{\r
- return;\r
-}\r
-\r
-/**\r
- Lock the ConsoleIn device in system table. All key\r
- presses will be ignored until the Password is typed in. The only way to\r
- disable the password is to type it in to a ConIn device.\r
-\r
- @param Password Password used to lock ConIn device.\r
-\r
- @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
- @retval EFI_UNSUPPORTED Password not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LockKeyboards (\r
- IN CHAR16 *Password\r
- )\r
-{\r
- return EFI_UNSUPPORTED;\r
-}\r