Convert NT32 to use PCD settings for UEFI Timeout and language variables as a POC...
authorAJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 13 Jul 2007 22:51:36 +0000 (22:51 +0000)
committerAJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 13 Jul 2007 22:51:36 +0000 (22:51 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3241 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/MdePkg.dec
Nt32Pkg/Library/EdkGenericBdsLib/BdsMisc.c
Nt32Pkg/Library/EdkGenericBdsLib/EdkGenericBdsLib.inf
Nt32Pkg/Library/EdkGenericBdsLib/EdkGenericBdsLibInternal.h
Nt32Pkg/Nt32Pkg.dsc
Nt32Pkg/PlatformBdsDxe/CommonHeader.h
Nt32Pkg/PlatformBdsDxe/Generic/Language.c
Nt32Pkg/PlatformBdsDxe/PlatformBds.inf
Nt32Pkg/PlatformBdsDxe/PlatformData.c

index 5680f851277a847c30cfc2dc1a24ef45ea4cd4a9..f07e4a7ef38f5c955c44bcd3d0f518d699141a6d 100644 (file)
   PcdDriverDiagnosticsDisable|0x0000000e|gEfiMdePkgTokenSpaceGuid|BOOLEAN|FALSE\r
   PcdComponentName2Disable|0x0000000f|gEfiMdePkgTokenSpaceGuid|BOOLEAN|FALSE\r
   PcdDriverDiagnostics2Disable|0x00000010|gEfiMdePkgTokenSpaceGuid|BOOLEAN|FALSE\r
+  PcdUefiVariableDefaultLangDepricate|0x0000001a|gEfiMdePkgTokenSpaceGuid|BOOLEAN|FALSE\r
 \r
 [PcdsFixedAtBuild.common]\r
   PcdMaximumUnicodeStringLength|0x00000001|gEfiMdePkgTokenSpaceGuid|UINT32|1000000\r
   PcdStatusCodeValueRemoteConsoleReset|0x00000012|gEfiMdePkgTokenSpaceGuid|UINT32|0x01040001        # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_RESET\r
   PcdStatusCodeValueRemoteConsoleInputError|0x00000013|gEfiMdePkgTokenSpaceGuid|UINT32|0x01040007   # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_INPUT_ERROR\r
   PcdStatusCodeValueRemoteConsoleOutputError|0x00000014|gEfiMdePkgTokenSpaceGuid|UINT32|0x01040008  # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_OUTPUT_ERROR\r
+  PcdUefiVariableDefaultTimeout|0x00000015|gEfiMdePkgTokenSpaceGuid|UINT16|0x0008\r
+  PcdUefiVariableDefaultLangCodes|0x00000016|gEfiMdePkgTokenSpaceGuid|VOID*|"engfra"\r
+  PcdUefiVariableDefaultLang|0x00000017|gEfiMdePkgTokenSpaceGuid|VOID*|"eng"\r
+  PcdUefiVariableDefaultPlatformLangCodes|0x00000018|gEfiMdePkgTokenSpaceGuid|VOID*|"en"\r
+  PcdUefiVariableDefaultPlatformLang|0x00000019|gEfiMdePkgTokenSpaceGuid|VOID*|"en;fr"\r
 \r
 [PcdsPatchableInModule.common]\r
   PcdDebugPrintErrorLevel|0x00000006|gEfiMdePkgTokenSpaceGuid|UINT32|0x80000000\r
index 13ec89f501b2ea62977b7013526b341d9fdbda28..9fa05ffd6d04afb88076da9d40e6f6d7a84c50ac 100644 (file)
@@ -25,7 +25,7 @@ Abstract:
 #define MAX_STRING_LEN        200\r
 static BOOLEAN   mFeaturerSwitch = TRUE;\r
 static BOOLEAN   mResetRequired  = FALSE;\r
-extern UINT16 gPlatformBootTimeOutDefault;\r
+\r
 \r
 UINT16\r
 BdsLibGetTimeout (\r
@@ -66,7 +66,7 @@ Returns:
   // present.\r
   // This code should be removed later.\r
   //\r
-  Timeout = gPlatformBootTimeOutDefault;\r
+  Timeout = PcdGet16 (PcdUefiVariableDefaultTimeout);\r
 \r
   //\r
   // Notes: Platform should set default variable if non exists on all error cases!!!\r
index ca25796624b64be7ec4ab454b84c5dca2941f737..b4d579f36e28f9761de3c93581e57526d6456834 100644 (file)
@@ -63,6 +63,7 @@
   DxeServicesTableLib\r
   UefiLib\r
   BaseLib\r
+  PcdLib\r
 \r
 [Guids]\r
   gEfiGlobalVariableGuid                        # ALWAYS_CONSUMED\r
@@ -85,3 +86,5 @@
   gEfiFirmwareVolumeProtocolGuid                # PROTOCOL SOMETIMES_CONSUMED\r
   gEfiLoadedImageProtocolGuid                   # PROTOCOL ALWAYS_CONSUMED\r
 \r
+[PcdsFixedAtBuild.common]\r
+  PcdUefiVariableDefaultTimeout|gEfiMdePkgTokenSpaceGuid\r
index 9d07a5c88be7878542edb1795ca0602a7aed7586..2b49ce4fe69c278d9ad9d2452e8f9f87377b998c 100644 (file)
 //\r
 #include <PiDxe.h>\r
 #include <WinNtDxe.h>\r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
 #include <Protocol/Cpu.h>\r
 #include <Protocol/SimpleTextIn.h>\r
 #include <Protocol/SimpleTextOut.h>\r
 #include <Protocol/LoadedImage.h>\r
-#include <Guid/GenericPlatformVariable.h>\r
-#include <Guid/ShellFile.h>\r
 #include <Protocol/SimpleFileSystem.h>\r
 #include <Protocol/BlockIo.h>\r
 #include <Protocol/SimpleNetwork.h>\r
 #include <Protocol/AcpiS3Save.h>\r
-#include <Guid/GlobalVariable.h>\r
 #include <Protocol/FormBrowserFramework.h>\r
 #include <Protocol/LegacyBios.h>\r
 #include <Protocol/DriverBinding.h>\r
 #include <Protocol/Performance.h>\r
 #include <Protocol/WinNtIo.h>\r
 #include <Guid/PcAnsi.h>\r
-\r
-//\r
-// The Library classes this module consumes\r
-//\r
+#include <Guid/GlobalVariable.h>\r
+#include <Guid/GenericPlatformVariable.h>\r
+#include <Guid/ShellFile.h>\r
 #include <Library/EdkGenericBdsLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/UefiLib.h>\r
@@ -62,6 +55,8 @@
 #include <Library/DevicePathLib.h>\r
 #include <Library/PerformanceLib.h>\r
 #include <Library/PeCoffLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
 \r
 #define PERF_TOKEN_LENGTH       28\r
 #define PERF_PEI_ENTRY_MAX_NUM  50\r
index 043e2bebb625842aa1fa94f279661ea9b22025f1..33ef254d76ca99390fd3dd284d1ad1e972225d1b 100644 (file)
   PcdDxeIplSupportEfiDecompress|gEfiMdeModulePkgTokenSpaceGuid|TRUE\r
   PcdDxeIplSupportTianoDecompress|gEfiMdeModulePkgTokenSpaceGuid|TRUE\r
   PcdDxeIplSupportCustomDecompress|gEfiMdeModulePkgTokenSpaceGuid|TRUE  \r
+  PcdUefiVariableDefaultLangDepricate|gEfiMdePkgTokenSpaceGuid|FALSE\r
 \r
 [PcdsPatchableInModule.IA32]\r
   PcdStatusCodeMemorySize|gEfiIntelFrameworkModulePkgTokenSpaceGuid|1\r
   PcdStatusCodeRuntimeMemorySize|gEfiIntelFrameworkModulePkgTokenSpaceGuid|128\r
 \r
 [PcdsFixedAtBuild.IA32]\r
-  PcdWinNtMemorySizeForSecMain|gEfiNt32PkgTokenSpaceGuid|L"64!64"|10\r
+  PcdWinNtMemorySizeForSecMain|gEfiNt32PkgTokenSpaceGuid|L"64!64"|12\r
   PcdWinNtFirmwareVolume|gEfiNt32PkgTokenSpaceGuid|L"..\\Fv\\Fv_Recovery.fd"|52\r
   PcdWinNtBootMode|gEfiNt32PkgTokenSpaceGuid|1\r
   PcdMaximumUnicodeStringLength|gEfiMdePkgTokenSpaceGuid|1000000\r
   PcdStatusCodeValueRemoteConsoleReset|gEfiMdePkgTokenSpaceGuid|0x01040001        # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_RESET\r
   PcdStatusCodeValueRemoteConsoleInputError|gEfiMdePkgTokenSpaceGuid|0x01040007   # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_INPUT_ERROR\r
   PcdStatusCodeValueRemoteConsoleOutputError|gEfiMdePkgTokenSpaceGuid|0x01040008  # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_OUTPUT_ERROR\r
+  PcdUefiVariableDefaultTimeout|gEfiMdePkgTokenSpaceGuid|0x0008\r
+  PcdUefiVariableDefaultLangCodes|gEfiMdePkgTokenSpaceGuid|"engfra"|7\r
+  PcdUefiVariableDefaultLang|gEfiMdePkgTokenSpaceGuid|"eng"|4\r
+  PcdUefiVariableDefaultPlatformLangCodes|gEfiMdePkgTokenSpaceGuid|"en;fr"|6\r
+  PcdUefiVariableDefaultPlatformLang|gEfiMdePkgTokenSpaceGuid|"en"|2\r
 \r
 [PcdsFeatureFlag.IA32]\r
   PcdPeiPcdDatabaseTraverseEnabled|gEfiMdeModulePkgTokenSpaceGuid|TRUE\r
index c4fb48eeee5ba204161944934bfb14b9a03f54e1..8f9a6d63ca202cff986882b54f0a482d151a6147 100644 (file)
 #ifndef __COMMON_HEADER_H_\r
 #define __COMMON_HEADER_H_\r
 \r
-\r
-//\r
-// The package level header files this module uses\r
-//\r
 #include <PiDxe.h>\r
-\r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
+#include <Common/MaxBbsEntries.h>\r
 #include <Protocol/FormCallbackFramework.h>\r
-#include <Guid/FileSystemVolumeLabelInfo.h>\r
 #include <Protocol/DevicePath.h>\r
-#include <Guid/BootState.h>\r
 #include <Protocol/LoadFile.h>\r
 #include <Protocol/CpuIo.h>\r
-#include <Guid/FileInfo.h>\r
 #include <Protocol/Bds.h>\r
 #include <Protocol/DataHub.h>\r
 #include <Protocol/FormBrowserFramework.h>\r
-#include <Guid/Bmp.h>\r
 #include <Protocol/UgaDraw.h>\r
 #include <Protocol/BlockIo.h>\r
-#include <Guid/GlobalVariable.h>\r
 #include <Protocol/ConsoleControl.h>\r
 #include <Protocol/GenericMemoryTest.h>\r
 #include <Protocol/GraphicsOutput.h>\r
 #include <Protocol/SimpleFileSystem.h>\r
 #include <Protocol/HiiFramework.h>\r
-#include <Guid/GenericPlatformVariable.h>\r
 #include <Protocol/SerialIo.h>\r
 #include <Protocol/LegacyBios.h>\r
-#include <Common/MaxBbsEntries.h>\r
+#include <Protocol/Performance.h>\r
 #include <Guid/PcAnsi.h>\r
 #include <Guid/DataHubRecords.h>\r
-#include <Protocol/Performance.h>\r
+#include <Guid/Bmp.h>\r
+#include <Guid/FileInfo.h>\r
+#include <Guid/BootState.h>\r
+#include <Guid/FileSystemVolumeLabelInfo.h>\r
+#include <Guid/GenericPlatformVariable.h>\r
+#include <Guid/GlobalVariable.h>\r
 \r
-//\r
-// The Library classes this module consumes\r
-//\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -73,6 +62,7 @@
 #include <Library/DevicePathLib.h>\r
 #include <Library/HiiLibFramework.h>\r
 #include <Library/PeCoffLib.h>\r
+#include <Library/PcdLib.h>\r
 \r
 //\r
 // The rest of the includes\r
index 60b92f0c7eaf3445bf920f9a0e797cba65ef221b..c8e73a21bc626e35e869802a406ec4993ccfa78f 100644 (file)
@@ -29,11 +29,6 @@ Revision History
 #include "BdsString.h"\r
 #include "Language.h"\r
 \r
-//\r
-// Default language code, currently is English\r
-//\r
-CHAR8 *mDefaultLangCode = "eng";\r
-\r
 \r
 VOID\r
 InitializeLanguage (\r
@@ -53,83 +48,107 @@ Returns:
 --*/\r
 {\r
   EFI_STATUS  Status;\r
-  UINTN       Index;\r
   UINTN       Size;\r
+  CHAR8       *Lang;\r
   CHAR8       LangCode[ISO_639_2_ENTRY_SIZE];\r
   CHAR8       *LangCodes;\r
-  CHAR16      *LanguageString;\r
-\r
-  LanguageString  = NULL;\r
-  LangCodes       = NULL;\r
-\r
-  //\r
-  // Collect the languages from what our current Language support is based on our VFR\r
-  //\r
-  gHii->GetPrimaryLanguages (gHii, gStringPackHandle, &LanguageString);\r
+  CHAR8       *PlatformLang;\r
+  CHAR8       *PlatformLangCodes;\r
+  UINTN       Index;\r
+  BOOLEAN     Invalid;\r
 \r
-  LangCodes = AllocatePool (StrLen (LanguageString));\r
-  ASSERT (LangCodes);\r
 \r
-  //\r
-  // Convert LanguageString from Unicode to EFI defined ASCII LangCodes\r
-  //\r
-  for (Index = 0; LanguageString[Index] != 0x0000; Index++) {\r
-    LangCodes[Index] = (CHAR8) LanguageString[Index];\r
-  }\r
+  LangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLangCodes);\r
+  if (LangCodesSettingRequired) {\r
+    if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate)) {\r
+      //\r
+      // UEFI 2.1 depricated this variable so we support turning it off\r
+      //\r
+      Status = gRT->SetVariable (\r
+                      L"LangCodes",\r
+                      &gEfiGlobalVariableGuid,\r
+                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                      AsciiStrLen (LangCodes),\r
+                      LangCodes\r
+                      );\r
+    }\r
 \r
-  LangCodes[Index] = 0;\r
 \r
-  if (LangCodesSettingRequired) {\r
+    PlatformLangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes);\r
     Status = gRT->SetVariable (\r
-                    L"LangCodes",\r
+                    L"PlatformLangCodes",\r
                     &gEfiGlobalVariableGuid,\r
                     EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                    AsciiStrLen (LangCodes),\r
-                    LangCodes\r
+                    AsciiStrSize (PlatformLangCodes),\r
+                    PlatformLangCodes\r
                     );\r
   }\r
-  //\r
-  // Find current LangCode from Lang NV Variable\r
-  //\r
-  Size = ISO_639_2_ENTRY_SIZE;\r
-  Status = gRT->GetVariable (\r
-                  L"Lang",\r
-                  &gEfiGlobalVariableGuid,\r
-                  NULL,\r
-                  &Size,\r
-                  &LangCode\r
-                  );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = EFI_NOT_FOUND;\r
-    for (Index = 0; LangCodes[Index] != 0; Index += ISO_639_2_ENTRY_SIZE) {\r
-      if (CompareMem (&LangCodes[Index], LangCode, ISO_639_2_ENTRY_SIZE) == 0) {\r
-        Status = EFI_SUCCESS;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // If we cannot get language code from Lang variable,\r
-  // or LangCode cannot be found from language table,\r
-  // set the mDefaultLangCode to Lang variable.\r
-  //\r
-  if (EFI_ERROR (Status)) {\r
-    Status = gRT->SetVariable (\r
+\r
+  if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate)) {\r
+    //\r
+    // UEFI 2.1 depricated this variable so we support turning it off\r
+    //\r
+\r
+    //\r
+    // Find current LangCode from Lang NV Variable\r
+    //\r
+    Size = ISO_639_2_ENTRY_SIZE;\r
+    Status = gRT->GetVariable (\r
                     L"Lang",\r
                     &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                    ISO_639_2_ENTRY_SIZE,\r
-                    mDefaultLangCode\r
+                    NULL,\r
+                    &Size,\r
+                    &LangCode\r
                     );\r
-  }\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = EFI_NOT_FOUND;\r
+      for (Index = 0; LangCodes[Index] != 0; Index += ISO_639_2_ENTRY_SIZE) {\r
+        if (CompareMem (&LangCodes[Index], LangCode, ISO_639_2_ENTRY_SIZE) == 0) {\r
+          Status = EFI_SUCCESS;\r
+          break;\r
+        }\r
+      }\r
+    }\r
 \r
-  if (LangCodes) {\r
-    FreePool (LangCodes);\r
+    //\r
+    // If we cannot get language code from Lang variable,\r
+    // or LangCode cannot be found from language table,\r
+    // set the mDefaultLangCode to Lang variable.\r
+    //\r
+    if (EFI_ERROR (Status)) {\r
+      Lang = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLang);\r
+      Status = gRT->SetVariable (\r
+                      L"Lang",\r
+                      &gEfiGlobalVariableGuid,\r
+                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                      ISO_639_2_ENTRY_SIZE,\r
+                      Lang\r
+                      );\r
+    }\r
   }\r
 \r
-  if (LanguageString != NULL) {\r
-    FreePool (LanguageString);\r
+  Invalid = FALSE;\r
+  PlatformLang = BdsLibGetVariableAndSize (L"PlatformLang", &gEfiGlobalVariableGuid, &Size);\r
+  if (PlatformLang != NULL) {\r
+    //\r
+    // Check Current PlatformLang value against PlatformLangCode. Need a library that is TBD\r
+    // Set Invalid based on state of PlatformLang.\r
+    //\r
+\r
+    FreePool (PlatformLang);\r
+  } else {\r
+    // No valid variable is set\r
+    Invalid = TRUE;\r
   }\r
 \r
+  if (Invalid) {\r
+    PlatformLang = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLang);\r
+    Status = gRT->SetVariable (\r
+                    L"PlatformLang",\r
+                    &gEfiGlobalVariableGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                    AsciiStrSize (PlatformLang),\r
+                    PlatformLang\r
+                    );\r
+  }\r
 }\r
index 7e2442365b5820d1400f7212a350990030afa60b..1e084a3f184261c04fea3a7d80e2e7389f7d2746 100644 (file)
   gEfiLegacyBiosProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED\r
   gEfiBdsArchProtocolGuid                       # PROTOCOL ALWAYS_PRODUCED\r
 \r
+[PcdsFeatureFlag.common]\r
+  PcdUefiVariableDefaultLangDepricate|gEfiMdePkgTokenSpaceGuid|\r
+\r
+[PcdsFixedAtBuild.common]\r
+  PcdUefiVariableDefaultLangCodes|gEfiMdePkgTokenSpaceGuid\r
+  PcdUefiVariableDefaultLang|gEfiMdePkgTokenSpaceGuid\r
+  PcdUefiVariableDefaultPlatformLangCodes|gEfiMdePkgTokenSpaceGuid\r
+  PcdUefiVariableDefaultPlatformLang|gEfiMdePkgTokenSpaceGuid\r
+\r
 [depex]\r
   gEfiHiiProtocolGuid\r
   
\ No newline at end of file
index 68818ef34b7222cb8fc14ca2ea4359fb41030854..5b1d7c55c54b23c46d899e64a5af2ddf7dcb0858 100644 (file)
@@ -30,10 +30,6 @@ Abstract:
 #include <Protocol/WinNtThunk.h>\r
 #include <Protocol/WinNtIo.h>\r
 \r
-//\r
-// Predefined platform default time out value\r
-//\r
-UINT16                      gPlatformBootTimeOutDefault = 10;\r
 \r
 //\r
 // Platform specific keyboard device path\r