1)Add a new module CapsuleRuntime under EdkModulePkg\Universal\Capsule\RuntimeDxe...
authordavidhuang <davidhuang@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 6 Jul 2006 06:42:48 +0000 (06:42 +0000)
committerdavidhuang <davidhuang@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 6 Jul 2006 06:42:48 +0000 (06:42 +0000)
2)Modify the related files to fit for the runtime services UpdateCapsule/QueryCapsuleCapabilities defined in UEFI2.0 spec
3)Modify the related files to fit for the runtime services QueryVariableInfo defined in UEFI2.0 spec

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@790 6f19259b-4bc3-4df7-8a09-765794883524

24 files changed:
EdkModulePkg/Core/Dxe/DxeMain.msa
EdkModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
EdkModulePkg/EdkModulePkg.spd
EdkModulePkg/Include/EdkDxe.h
EdkModulePkg/Include/EdkDxeCore.h
EdkModulePkg/Include/Guid/ExtendedSalGuid.h
EdkModulePkg/Include/Protocol/Capsule.h [new file with mode: 0644]
EdkModulePkg/Universal/Capsule/RuntimeDxe/Capsule.c [new file with mode: 0644]
EdkModulePkg/Universal/Capsule/RuntimeDxe/Capsule.dxs [new file with mode: 0644]
EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleRuntime.mbd [new file with mode: 0644]
EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleRuntime.msa [new file with mode: 0644]
EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleService.c [new file with mode: 0644]
EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleService.h [new file with mode: 0644]
EdkModulePkg/Universal/Capsule/RuntimeDxe/build.xml [new file with mode: 0644]
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/InitVariable.c
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Ipf/InitVariable.c
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Variable.h
EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.c
EdkModulePkg/Universal/Variable/RuntimeDxe/InitVariable.c
EdkModulePkg/Universal/Variable/RuntimeDxe/Ipf/InitVariable.c
EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c
EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h
EdkNt32Pkg/Nt32.fpd

index 14a4f77..70802a9 100644 (file)
@@ -194,6 +194,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
     <Protocol Usage="ALWAYS_CONSUMED">\r
       <ProtocolCName>TianoDecompress</ProtocolCName>\r
     </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>Capsule</ProtocolCName>\r
+    </Protocol>\r
   </Protocols>\r
   <Guids>\r
     <GuidCNames Usage="ALWAYS_CONSUMED">\r
index 7e49423..7c22a03 100644 (file)
@@ -43,6 +43,9 @@ ARCHITECTURAL_PROTOCOL_ENTRY  mArchProtocols[] = {
   { &gEfiRuntimeArchProtocolGuid,          (VOID **)&gRuntime,       NULL, NULL, FALSE },\r
   { &gEfiVariableArchProtocolGuid,         (VOID **)NULL,            NULL, NULL, FALSE },\r
   { &gEfiVariableWriteArchProtocolGuid,    (VOID **)NULL,            NULL, NULL, FALSE },\r
+  #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  { &gEfiCapsuleArchProtocolGuid,          (VOID **)NULL,            NULL, NULL, FALSE},\r
+  #endif\r
   { &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL,            NULL, NULL, FALSE },\r
   { &gEfiResetArchProtocolGuid,            (VOID **)NULL,            NULL, NULL, FALSE },\r
 //  { &gEfiStatusCodeRuntimeProtocolGuid,    (VOID **)&gStatusCode,    NULL, NULL, FALSE },\r
@@ -225,6 +228,9 @@ static const GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = {
   { &gEfiRuntimeArchProtocolGuid,          (CHAR16 *)L"Runtime"            },\r
   { &gEfiVariableArchProtocolGuid,         (CHAR16 *)L"Variable"           },\r
   { &gEfiVariableWriteArchProtocolGuid,    (CHAR16 *)L"Variable Write"     },\r
+  #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  { &gEfiCapsuleArchProtocolGuid,          (CHAR16 *)L"Capsule"            },\r
+  #endif\r
   { &gEfiMonotonicCounterArchProtocolGuid, (CHAR16 *)L"Monotonic Counter"  },\r
   { &gEfiResetArchProtocolGuid,            (CHAR16 *)L"Reset"              },\r
 //  { &gEfiStatusCodeRuntimeProtocolGuid,       (CHAR16 *)L"Status Code"        },\r
index 4b865a5..55c8cee 100644 (file)
     <Filename>Universal/Variable/Pei/Variable.msa</Filename>\r
     <Filename>Universal/EmuVariable/RuntimeDxe/EmuVariable.msa</Filename>\r
     <Filename>Universal/Variable/RuntimeDxe/Variable.msa</Filename>\r
+    <Filename>Universal/Capsule/RuntimeDxe/CapsuleRuntime.msa</Filename>\r
     <Filename>Universal/WatchdogTimer/Dxe/WatchDogTimer.msa</Filename>\r
   </MsaFiles>\r
   <PackageHeaders>\r
     </Entry>\r
   </GuidDeclarations>\r
   <ProtocolDeclarations>\r
+    <Entry Name="Capsule">\r
+      <C_Name>gEfiCapsuleArchProtocolGuid</C_Name>\r
+      <GuidValue>5053697E-2EBC-4819-90D9-0580DEEE5754</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
     <Entry Name="CustomizedDecompress">\r
       <C_Name>gEfiCustomizedDecompressProtocolGuid</C_Name>\r
       <GuidValue>9A44198E-A4A2-44E6-8A1F-39BEFDAC896F</GuidValue>\r
       <ValidUsage>FIXED_AT_BUILD</ValidUsage>\r
       <HelpText>HELP FIX ME!</HelpText>\r
     </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdSupportUpdateCapsuleRest</C_Name>\r
+      <Token>0x00010020</Token>\r
+      <TokenSpaceGuidCName>FIX_ME_PcdSupportUpdateCapsuleRest</TokenSpaceGuidCName>\r
+      <DatumType>BOOLEAN</DatumType>\r
+      <ValidUsage>FEATURE_FLAG</ValidUsage>\r
+      <HelpText>HELP FIX ME!</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdMaxSizePopulateCapsule</C_Name>\r
+      <Token>0x00010021</Token>\r
+      <TokenSpaceGuidCName>FIX_ME_PcdMaxSizePopulateCapsule</TokenSpaceGuidCName>\r
+      <DatumType>UINT32</DatumType>\r
+      <ValidUsage>FIXED_AT_BUILD</ValidUsage>\r
+      <HelpText>HELP FIX ME!</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdMaxSizeNonPopulateCapsule</C_Name>\r
+      <Token>0x00010022</Token>\r
+      <TokenSpaceGuidCName>FIX_ME_PcdMaxSizeNonPopulateCapsule</TokenSpaceGuidCName>\r
+      <DatumType>UINT32</DatumType>\r
+      <ValidUsage>FIXED_AT_BUILD</ValidUsage>\r
+      <HelpText>HELP FIX ME!</HelpText>\r
+    </PcdEntry>  \r
   </PcdDeclarations>\r
 </PackageSurfaceArea>
\ No newline at end of file
index 7d05ffd..83833e5 100644 (file)
@@ -92,4 +92,8 @@ Abstract:
 #include <Protocol/ScsiIo.h>\r
 #endif\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+#include <Protocol/Capsule.h>\r
+#endif\r
+\r
 #endif\r
index d1b4ca7..d1e57e0 100644 (file)
@@ -50,4 +50,8 @@ Abstract:
 #include <Protocol/EdkDecompress.h>\r
 #include <Protocol/Print.h>\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+#include <Protocol/Capsule.h>\r
+#endif\r
+\r
 #endif\r
index 4a4dbee..6a64776 100644 (file)
@@ -143,6 +143,10 @@ typedef enum {
   EsalGetVariable,\r
   EsalGetNextVariableName,\r
   EsalSetVariable\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  ,\r
+  EsalQueryVariableInfo\r
+#endif\r
 } EFI_EXTENDED_SAL_VARIABLE_SERVICES_FUNC_ID;\r
 \r
 typedef enum {\r
diff --git a/EdkModulePkg/Include/Protocol/Capsule.h b/EdkModulePkg/Include/Protocol/Capsule.h
new file mode 100644 (file)
index 0000000..626f256
--- /dev/null
@@ -0,0 +1,39 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. 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
+  Capsule.h\r
+\r
+Abstract:\r
+\r
+  Capsule Architectural Protocol is newly added to produce UEFI2.0 capsule runtime services.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_CAPSULE_ARCH_H_\r
+#define _ARCH_PROTOCOL_CAPSULE_ARCH_H_\r
+\r
+//\r
+// Global ID for the Capsule Architectural Protocol\r
+//\r
+#define EFI_CAPSULE_ARCH_PROTOCOL_GUID \\r
+  { 0x5053697e, 0x2ebc, 0x4819, {0x90, 0xd9, 0x05, 0x80, 0xde, 0xee, 0x57, 0x54 }}\r
+\r
+extern EFI_GUID gEfiCapsuleArchProtocolGuid;\r
+\r
+typedef struct {\r
+  UINT32   CapsuleArrayNumber;\r
+  VOID*    CapsulePtr[1];\r
+} EFI_CAPSULE_TABLE;\r
+\r
+\r
+#endif \r
diff --git a/EdkModulePkg/Universal/Capsule/RuntimeDxe/Capsule.c b/EdkModulePkg/Universal/Capsule/RuntimeDxe/Capsule.c
new file mode 100644 (file)
index 0000000..125a445
--- /dev/null
@@ -0,0 +1,68 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. 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
+  Capsule.c\r
+\r
+Abstract:\r
+\r
+  Capsule Runtime Service Initialization\r
+\r
+--*/\r
+\r
+#include "CapsuleService.h"\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CapsuleServiceInitialize (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This code is capsule runtime service initialization.\r
+  \r
+Arguments:\r
+\r
+  ImageHandle          The image handle\r
+  SystemTable          The system table.\r
+\r
+Returns:\r
+\r
+  EFI STATUS\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  NewHandle;\r
+\r
+  SystemTable->RuntimeServices->UpdateCapsule                    = UpdateCapsule;\r
+  SystemTable->RuntimeServices->QueryCapsuleCapabilities         = QueryCapsuleCapabilities;\r
+\r
+  //\r
+  // Now install the Capsule Architectural Protocol on a new handle\r
+  //\r
+  NewHandle = NULL;\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &NewHandle,\r
+                  &gEfiCapsuleArchProtocolGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkModulePkg/Universal/Capsule/RuntimeDxe/Capsule.dxs b/EdkModulePkg/Universal/Capsule/RuntimeDxe/Capsule.dxs
new file mode 100644 (file)
index 0000000..11da2b9
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. 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
+  Capsule.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/\r
+#include <AutoGen.h>\r
+#include "DxeDepex.h"\r
+\r
+DEPENDENCY_START\r
+  EFI_VARIABLE_ARCH_PROTOCOL_GUID \r
+DEPENDENCY_END
\ No newline at end of file
diff --git a/EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleRuntime.mbd b/EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleRuntime.mbd
new file mode 100644 (file)
index 0000000..1ae0c53
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0  http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">\r
+  <MbdHeader>\r
+    <BaseName>CapsuleRuntime</BaseName>\r
+    <Guid>42857F0A-13F2-4B21-8A23-53D3F714B840</Guid>\r
+    <Version>0</Version>\r
+    <Description>FIX ME!</Description>\r
+    <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>\r
+    <License>\r
+      All rights reserved. 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
+      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
+    </License>\r
+    <Created>2006-03-12 17:09</Created>\r
+    <Modified>2006-03-19 15:19</Modified>\r
+  </MbdHeader>\r
+  <Libraries>\r
+    <Library>BaseLib</Library>\r
+    <Library>BaseMemoryLib</Library>\r
+    <Library>UefiDriverEntryPoint</Library>\r
+    <Library>DxeServicesTableLib</Library>\r
+    <Library>EdkDxeRuntimeDriverLib</Library>\r
+    <Library>UefiLib</Library>\r
+    <Library>BaseDebugLibNull</Library>\r
+    <Library>BasePrintLib</Library>\r
+    <Library>DxeMemoryAllocationLib</Library>\r
+    <Library>UefiBootServicesTableLib</Library>    \r
+  </Libraries>\r
+  <BuildOptions ToolChain="MSFT">\r
+    <ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>\r
+  </BuildOptions>\r
+</ModuleBuildDescription>\r
diff --git a/EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleRuntime.msa b/EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleRuntime.msa
new file mode 100644 (file)
index 0000000..ea947cc
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->\r
+<ModuleSurfaceArea  xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>CapsuleRuntime</ModuleName>\r
+    <ModuleType>DXE_RUNTIME_DRIVER</ModuleType>\r
+    <GuidValue>42857F0A-13F2-4B21-8A23-53D3F714B840</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for Capsule module.</Abstract>\r
+    <Description>FIX ME!</Description>\r
+    <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials
+      are licensed and made available under the terms and conditions of the BSD License
+      which accompanies this distribution.  The full text of the license may be found at
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>CapsuleRuntime</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DxeServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DxeRuntimeDriverLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>Capsule.c</Filename>\r
+    <Filename>CapsuleService.c</Filename>\r
+    <Filename>CapsuleService.h</Filename>\r
+    <Filename>Capsule.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="B6EC423C-21D2-490D-85C6-DD5864EAA674"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>Capsule</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>CapsuleVendor</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>Capsule</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00090000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>CapsuleServiceInitialize</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdSupportUpdateCapsuleRest</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>Fix Me!</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FIXED_AT_BUILD">\r
+      <C_Name>MaxSizePopulateCapsule</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>Fix Me!</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FIXED_AT_BUILD">\r
+      <C_Name>MaxSizeNonPopulateCapsule</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>Fix Me!</HelpText>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleService.c b/EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleService.c
new file mode 100644 (file)
index 0000000..e07cbc8
--- /dev/null
@@ -0,0 +1,238 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. 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
+  CapsuleService.c\r
+\r
+Abstract:\r
+\r
+  Capsule Runtime Service.\r
+\r
+--*/\r
+\r
+#include "CapsuleService.h"\r
+\r
+\r
+STATIC EFI_GUID mEfiCapsuleHeaderGuid = EFI_CAPSULE_GUID;\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UpdateCapsule (\r
+  IN UEFI_CAPSULE_HEADER     **CapsuleHeaderArray,\r
+  IN UINTN                   CapsuleCount,\r
+  IN EFI_PHYSICAL_ADDRESS    ScatterGatherList OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This code finds whether the capsules need reset to update, if not, update immediately.\r
+\r
+Arguments:\r
+\r
+  CapsuleHeaderArray             A array of pointers to capsule headers passed in\r
+  CapsuleCount                   The number of capsule\r
+  ScatterGatherList              Physical address of datablock list points to capsule\r
+  \r
+Returns:\r
+\r
+  EFI STATUS\r
+  EFI_SUCCESS                    Valid capsule was passed.If CAPSULE_FLAG_PERSIT_ACROSS_RESET is\r
+                                 not set, the capsule has been successfully processed by the firmware.\r
+                                 If it set, the ScattlerGatherList is successfully to be set.\r
+  EFI_INVALID_PARAMETER          CapsuleCount is less than 1,CapsuleGuid is not supported.\r
+  EFI_DEVICE_ERROR               Failed to SetVariable or AllocatePool or ProcessFirmwareVolume. \r
+  \r
+--*/\r
+{\r
+  UINTN                     CapsuleSize;\r
+  UINTN                     ArrayNumber;\r
+  VOID                      *BufferPtr;\r
+  EFI_STATUS                Status;\r
+  EFI_HANDLE                FvHandle;\r
+  UEFI_CAPSULE_HEADER       *CapsuleHeader;\r
+\r
+  if (CapsuleCount < 1) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  BufferPtr       = NULL;\r
+  CapsuleHeader   = NULL;\r
+\r
+  //\r
+  //Compare GUIDs with EFI_CAPSULE_GUID, if capsule header contains CAPSULE_FLAGS_PERSIST_ACROSS_RESET\r
+  //and CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE flags,whatever the GUID is ,the service supports.\r
+  //\r
+  for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {\r
+    CapsuleHeader = CapsuleHeaderArray[ArrayNumber];\r
+    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) && !(CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET)) {\r
+      return EFI_INVALID_PARAMETER;      \r
+    }\r
+    if (!CompareGuid (&CapsuleHeader->CapsuleGuid, &mEfiCapsuleHeaderGuid)) {\r
+      if (!(CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE)) {\r
+        return EFI_UNSUPPORTED;\r
+      }  \r
+    }   \r
+  }\r
+\r
+  //\r
+  //Assume that capsules have the same flags on reseting or not. \r
+  //\r
+  CapsuleHeader = CapsuleHeaderArray[0];\r
+\r
+  if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {\r
+    //\r
+    //Check if the platform supports update capsule across a system reset\r
+    //\r
+    if (!FeaturePcdGet(PcdSupportUpdateCapsuleRest)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+    \r
+    if (ScatterGatherList == 0) {\r
+      return EFI_INVALID_PARAMETER;\r
+    } else {\r
+      Status = EfiSetVariable (\r
+                 EFI_CAPSULE_VARIABLE_NAME,  \r
+                 &gEfiCapsuleVendorGuid,     \r
+                 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,  \r
+                 sizeof (UINTN), \r
+                 (VOID *) &ScatterGatherList \r
+                 );\r
+      if (Status != EFI_SUCCESS) { \r
+        return EFI_DEVICE_ERROR;\r
+      }\r
+    }\r
+    return EFI_SUCCESS;\r
+  }\r
+  \r
+  //\r
+  //The rest occurs in the condition of non-reset mode\r
+  //\r
+  if (EfiAtRuntime ()) { \r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  //Here should be in the boot-time\r
+  //\r
+  for (ArrayNumber = 0; ArrayNumber < CapsuleCount ; ArrayNumber++) {\r
+    CapsuleHeader = CapsuleHeaderArray[ArrayNumber];\r
+    CapsuleSize = CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize;\r
+    Status = gBS->AllocatePool (EfiBootServicesData, CapsuleSize, &BufferPtr);\r
+    if (Status != EFI_SUCCESS) {\r
+      goto Done;\r
+    }\r
+    gBS->CopyMem (BufferPtr, (UINT8*)CapsuleHeader+ CapsuleHeader->HeaderSize, CapsuleSize);\r
+\r
+    //\r
+    //Call DXE service ProcessFirmwareVolume to process immediatelly \r
+    //\r
+    Status = gDS->ProcessFirmwareVolume (BufferPtr, CapsuleSize, &FvHandle);\r
+    if (Status != EFI_SUCCESS) {\r
+      gBS->FreePool (BufferPtr);\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+    gDS->Dispatch ();\r
+    gBS->FreePool (BufferPtr);\r
+  }\r
+  return EFI_SUCCESS;\r
+\r
+Done:\r
+  if (BufferPtr != NULL) {\r
+    gBS->FreePool (BufferPtr);\r
+  }     \r
+  return EFI_DEVICE_ERROR;\r
+}\r
+\r
+\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+QueryCapsuleCapabilities (\r
+  IN  UEFI_CAPSULE_HEADER  **CapsuleHeaderArray,\r
+  IN  UINTN                CapsuleCount,\r
+  OUT UINT64               *MaxiumCapsuleSize,\r
+  OUT EFI_RESET_TYPE       *ResetType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This code is to query about capsule capability.\r
+\r
+Arguments:\r
+\r
+  CapsuleHeaderArray              A array of pointers to capsule headers passed in\r
+  CapsuleCount                    The number of capsule\r
+  MaxiumCapsuleSize               Max capsule size is supported\r
+  ResetType                       Reset type the capsule indicates, if reset is not needed,return EfiResetCold.\r
+                                  If reset is needed, return EfiResetWarm.\r
+\r
+Returns:\r
+\r
+  EFI STATUS\r
+  EFI_SUCCESS                     Valid answer returned\r
+  EFI_INVALID_PARAMETER           MaxiumCapsuleSize is NULL,ResetType is NULL.CapsuleCount is less than 1,CapsuleGuid is not supported.\r
+  EFI_UNSUPPORTED                 The capsule type is not supported.\r
+\r
+--*/\r
+{\r
+  UINTN                     ArrayNumber;\r
+  UEFI_CAPSULE_HEADER       *CapsuleHeader;\r
+\r
+  if (CapsuleCount < 1) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if ((MaxiumCapsuleSize == NULL) ||(ResetType == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }  \r
+\r
+  CapsuleHeader = NULL;\r
+  \r
+  //\r
+  //Compare GUIDs with EFI_CAPSULE_GUID, if capsule header contains CAPSULE_FLAGS_PERSIST_ACROSS_RESET\r
+  //and CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE flags,whatever the GUID is ,the service supports.\r
+  //\r
+  for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {\r
+    CapsuleHeader = CapsuleHeaderArray[ArrayNumber];\r
+    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) && !(CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET)) {\r
+      return EFI_INVALID_PARAMETER;      \r
+    }\r
+    if (!CompareGuid (&CapsuleHeader->CapsuleGuid, &mEfiCapsuleHeaderGuid)) {\r
+      if (!(CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+    }  \r
+  }\r
+\r
+  //\r
+  //Assume that capsules have the same flags on reseting or not. \r
+  //\r
+  CapsuleHeader = CapsuleHeaderArray[0];  \r
+  if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {\r
+    //\r
+    //Check if the platform supports update capsule across a system reset\r
+    //\r
+    if (!FeaturePcdGet(PcdSupportUpdateCapsuleRest)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+    *ResetType = EfiResetWarm;\r
+    *MaxiumCapsuleSize = FixedPcdGet32(PcdMaxSizePopulateCapsule);    \r
+  } else {\r
+    *ResetType = EfiResetCold;\r
+    *MaxiumCapsuleSize = FixedPcdGet32(PcdMaxSizeNonPopulateCapsule);\r
+  }  \r
+  return EFI_SUCCESS;\r
+} \r
+\r
diff --git a/EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleService.h b/EdkModulePkg/Universal/Capsule/RuntimeDxe/CapsuleService.h
new file mode 100644 (file)
index 0000000..c5ff6c7
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. 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
+  CapsuleService.h\r
+\r
+Abstract:\r
+\r
+  Capsule Runtime Service\r
+\r
+--*/\r
+\r
+#ifndef  _CAPSULE_RUNTIME_H_\r
+#define  _CAPSULE_RUNTIME_H_\r
+\r
+#include <Common/CapsuleName.h>\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UpdateCapsule(\r
+  IN UEFI_CAPSULE_HEADER     **CapsuleHeaderArray,\r
+  IN UINTN                   CapsuleCount,\r
+  IN EFI_PHYSICAL_ADDRESS    ScatterGatherList OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+QueryCapsuleCapabilities(\r
+  IN  UEFI_CAPSULE_HEADER  **CapsuleHeaderArray,\r
+  IN  UINTN                CapsuleCount,\r
+  OUT UINT64               *MaxiumCapsuleSize,\r
+  OUT EFI_RESET_TYPE       *ResetType\r
+  );\r
+\r
+#endif\r
+\r
diff --git a/EdkModulePkg/Universal/Capsule/RuntimeDxe/build.xml b/EdkModulePkg/Universal/Capsule/RuntimeDxe/build.xml
new file mode 100644 (file)
index 0000000..d376719
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- Copyright (c) 2006, Intel Corporation \r
+All rights reserved. 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
+<project basedir="." default="CapsuleRuntime"><!--Apply external ANT tasks-->\r
+   <taskdef resource="GenBuild.tasks"/>\r
+   <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+   <property environment="env"/>\r
+   <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>\r
+   <import file="${WORKSPACE_DIR}/Tools/Conf/BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->\r
+   <property name="MODULE_RELATIVE_PATH" value="Universal/Capsule/RuntimeDxe"/>\r
+   <property name="MODULE_DIR" value="${PACKAGE_DIR}/${MODULE_RELATIVE_PATH}"/>\r
+   <property name="COMMON_FILE" value="${WORKSPACE_DIR}/Tools/Conf/Common.xml"/>\r
+   <target name="CapsuleRuntime">\r
+      <GenBuild baseName="CapsuleRuntime" mbdFilename="${MODULE_DIR}/CapsuleRuntime.mbd" msaFilename="${MODULE_DIR}/CapsuleRuntime.msa"/>\r
+   </target>\r
+   <target depends="CapsuleRuntime_clean" name="clean"/>\r
+   <target depends="CapsuleRuntime_cleanall" name="cleanall"/>\r
+   <target name="CapsuleRuntime_clean">\r
+      <OutputDirSetup baseName="CapsuleRuntime" mbdFilename="${MODULE_DIR}/CapsuleRuntime.mbd" msaFilename="${MODULE_DIR}/CapsuleRuntime.msa"/>\r
+      <if>\r
+         <available file="${DEST_DIR_OUTPUT}/CapsuleRuntime_build.xml"/>\r
+         <then>\r
+            <ant antfile="${DEST_DIR_OUTPUT}/CapsuleRuntime_build.xml" target="clean"/>\r
+         </then>\r
+      </if>\r
+      <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>\r
+   </target>\r
+   <target name="CapsuleRuntime_cleanall">\r
+      <OutputDirSetup baseName="CapsuleRuntime" mbdFilename="${MODULE_DIR}/CapsuleRuntime.mbd" msaFilename="${MODULE_DIR}/CapsuleRuntime.msa"/>\r
+      <if>\r
+         <available file="${DEST_DIR_OUTPUT}/CapsuleRuntime_build.xml"/>\r
+         <then>\r
+            <ant antfile="${DEST_DIR_OUTPUT}/CapsuleRuntime_build.xml" target="cleanall"/>\r
+         </then>\r
+      </if>\r
+      <delete dir="${DEST_DIR_OUTPUT}"/>\r
+      <delete dir="${DEST_DIR_DEBUG}"/>\r
+      <delete>\r
+         <fileset dir="${BIN_DIR}" includes="**CapsuleRuntime*"/>\r
+      </delete>\r
+   </target>\r
+</project>
\ No newline at end of file
index beb404f..6614bb0 100644 (file)
@@ -656,6 +656,125 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+EFI_STATUS\r
+EFIAPI\r
+QueryVariableInfo (\r
+  IN  UINT32                 Attributes,\r
+  OUT UINT64                 *MaximumVariableStorageSize,\r
+  OUT UINT64                 *RemainingVariableStorageSize,\r
+  OUT UINT64                 *MaximumVariableSize,\r
+  IN  VARIABLE_GLOBAL        *Global,\r
+  IN  UINT32                 Instance\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This code returns information about the EFI variables.\r
+\r
+Arguments:\r
+\r
+  Attributes                      Attributes bitmask to specify the type of variables \r
+                                  on which to return information.\r
+  MaximumVariableStorageSize      Pointer to the maximum size of the storage space available\r
+                                  for the EFI variables associated with the attributes specified.\r
+  RemainingVariableStorageSize    Pointer to the remaining size of the storage space available \r
+                                  for the EFI variables associated with the attributes specified.\r
+  MaximumVariableSize             Pointer to the maximum size of the individual EFI variables\r
+                                  associated with the attributes specified.\r
+  Global                          Pointer to VARIABLE_GLOBAL structure.\r
+  Instance                        Instance of the Firmware Volume.\r
+\r
+Returns:\r
+\r
+  EFI STATUS\r
+  EFI_INVALID_PARAMETER           - An invalid combination of attribute bits was supplied.\r
+  EFI_SUCCESS                     - Query successfully.\r
+  EFI_UNSUPPORTED                 - The attribute is not supported on this platform.\r
+\r
+--*/\r
+{\r
+  VARIABLE_HEADER        *Variable;\r
+  VARIABLE_HEADER        *NextVariable;\r
+  UINT64                 VariableSize;\r
+  VARIABLE_STORE_HEADER  *VariableStoreHeader;\r
+  \r
+  if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)) == 0) {\r
+    //\r
+    // Make sure the Attributes combination is supported by the platform.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\r
+    //\r
+    // Make sure if runtime bit is set, boot service bit is set also.\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
+  } else if (EfiAtRuntime () && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {\r
+    //\r
+    //   Make sure RT Attribute is set if we are in Runtime phase.\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
+    //\r
+    // Query is Volatile related.\r
+    //\r
+    VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) Global->VolatileVariableBase);    \r
+  } else {\r
+    //\r
+    // Query is Non-Volatile related.\r
+    //\r
+    VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) Global->NonVolatileVariableBase);\r
+  }\r
+\r
+  //\r
+  // Now let's fill *MaximumVariableStorageSize *RemainingVariableStorageSize \r
+  // with the storage size (excluding the storage header size)\r
+  //\r
+  *MaximumVariableStorageSize   = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);\r
+  *RemainingVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);\r
+\r
+  //\r
+  // Let *MaximumVariableSize be MAX_VARIABLE_SIZE \r
+  //\r
+  *MaximumVariableSize = MAX_VARIABLE_SIZE;\r
+\r
+  //\r
+  // Point to the starting address of the variables.\r
+  //\r
+  Variable = (VARIABLE_HEADER *) (VariableStoreHeader + 1);\r
+\r
+  //\r
+  // Now walk through the related variable store.\r
+  //\r
+  while (Variable < GetEndPointer (VariableStoreHeader)) {\r
+    if (Variable->StartId != VARIABLE_DATA) {\r
+      break;\r
+    }\r
+\r
+    NextVariable = (VARIABLE_HEADER *) (GetVariableDataPtr (Variable) + Variable->DataSize + GET_PAD_SIZE (Variable->DataSize));\r
+    VariableSize = (UINT64) (UINTN) NextVariable - (UINT64) (UINTN) Variable;\r
+\r
+    if (Variable->State == VAR_ADDED) {\r
+      *RemainingVariableStorageSize -= VariableSize;\r
+    }\r
+\r
+    //\r
+    // Go to the next one.\r
+    //\r
+    Variable = NextVariable;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+#endif\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 InitializeVariableStore (\r
index 0ad8664..477869c 100644 (file)
@@ -114,6 +114,36 @@ Returns:
           );\r
 }\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+EFI_STATUS\r
+EFIAPI\r
+RuntimeServiceQueryVariableInfo (\r
+  IN  UINT32                 Attributes,\r
+  OUT UINT64                 *MaximumVariableStorageSize,\r
+  OUT UINT64                 *RemainingVariableStorageSize,\r
+  OUT UINT64                 *MaximumVariableSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  return QueryVariableInfo (\r
+          Attributes,\r
+          MaximumVariableStorageSize,\r
+          RemainingVariableStorageSize,\r
+          MaximumVariableSize,\r
+          &mVariableModuleGlobal->VariableBase[Physical],\r
+          mVariableModuleGlobal->FvbInstance\r
+          );\r
+}\r
+#endif\r
+\r
 VOID\r
 EFIAPI\r
 VariableClassAddressChangeEvent (\r
@@ -166,6 +196,9 @@ Returns:
   SystemTable->RuntimeServices->GetVariable         = RuntimeServiceGetVariable;\r
   SystemTable->RuntimeServices->GetNextVariableName = RuntimeServiceGetNextVariableName;\r
   SystemTable->RuntimeServices->SetVariable         = RuntimeServiceSetVariable;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  SystemTable->RuntimeServices->QueryVariableInfo   = RuntimeServiceQueryVariableInfo;\r
+#endif\r
 \r
   //\r
   // Now install the Variable Runtime Architectural Protocol on a new handle\r
index 061e6db..ee2a485 100644 (file)
@@ -89,6 +89,19 @@ Returns:
                         );\r
     return ReturnVal;\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  case EsalQueryVariableInfo:\r
+    ReturnVal.Status = QueryVariableInfo (\r
+                        (UINT32) Arg2,\r
+                        (UINT64 *) Arg3,\r
+                        (UINT64 *) Arg4,\r
+                        (UINT64 *) Arg5,\r
+                        &Global->VariableBase[VirtualMode],\r
+                        Global->FvbInstance\r
+                        );\r
+    return ReturnVal;\r
+#endif\r
+\r
   default:\r
     ReturnVal.Status = EFI_SAL_INVALID_ARGUMENT;\r
     return ReturnVal;\r
@@ -160,6 +173,10 @@ Returns:
     EsalGetNextVariableName,\r
     EsalVariableCommonEntry,\r
     EsalSetVariable,\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+    EsalVariableCommonEntry,\r
+    EsalQueryVariableInfo,\r
+#endif\r
     NULL\r
     );\r
 \r
index d1fd5e2..55423a2 100644 (file)
@@ -140,4 +140,18 @@ SetVariable (
   )\r
 ;\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+EFI_STATUS\r
+EFIAPI\r
+QueryVariableInfo (\r
+  IN  UINT32                 Attributes,\r
+  OUT UINT64                 *MaximumVariableStorageSize,\r
+  OUT UINT64                 *RemainingVariableStorageSize,\r
+  OUT UINT64                 *MaximumVariableSize,\r
+  IN  VARIABLE_GLOBAL        *Global,\r
+  IN  UINT32                 Instance\r
+  )\r
+;\r
+#endif\r
+\r
 #endif\r
index 5a21d49..d2428ea 100644 (file)
@@ -92,6 +92,9 @@ UINTN                         mVirtualMapMaxIndex;
 \r
 EFI_LOADED_IMAGE_PROTOCOL     *mMyLoadedImage;\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+STATIC EFI_GUID mEfiCapsuleHeaderGuid = EFI_CAPSULE_GUID;\r
+#endif\r
 //\r
 // Worker Functions\r
 //\r
@@ -356,6 +359,9 @@ RuntimeDriverSetVirtualAddressMap (
   UINTN                         Index1;\r
   EFI_DRIVER_OS_HANDOFF_HEADER  *DriverOsHandoffHeader;\r
   EFI_DRIVER_OS_HANDOFF         *DriverOsHandoff;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  EFI_CAPSULE_TABLE             *CapsuleTable; \r
+#endif\r
 \r
   //\r
   // Can only switch to virtual addresses once the memory map is locked down,\r
@@ -464,6 +470,11 @@ RuntimeDriverSetVirtualAddressMap (
   RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetVariable);\r
   RuntimeDriverConvertInternalPointer ((VOID **) &gRT->SetVariable);\r
   RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetNextVariableName);\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  RuntimeDriverConvertInternalPointer ((VOID **) &gRT->QueryVariableInfo);\r
+  RuntimeDriverConvertInternalPointer ((VOID **) &gRT->UpdateCapsule);\r
+  RuntimeDriverConvertInternalPointer ((VOID **) &gRT->QueryCapsuleCapabilities);\r
+#endif\r
   RuntimeDriverCalculateEfiHdrCrc (&gRT->Hdr);\r
 \r
   //\r
@@ -486,6 +497,15 @@ RuntimeDriverSetVirtualAddressMap (
 \r
       RuntimeDriverConvertPointer (EFI_OPTIONAL_POINTER, (VOID **) &(gST->ConfigurationTable[Index].VendorTable));\r
     }\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+    if (CompareGuid (&mEfiCapsuleHeaderGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
+      CapsuleTable = gST->ConfigurationTable[Index].VendorTable;\r
+      for (Index1 = 0; Index1 < CapsuleTable->CapsuleArrayNumber; Index1++) {\r
+        RuntimeDriverConvertPointer (EFI_OPTIONAL_POINTER, (VOID **) &CapsuleTable->CapsulePtr[Index1]);\r
+      }     \r
+      RuntimeDriverConvertPointer (EFI_OPTIONAL_POINTER, (VOID **) &(gST->ConfigurationTable[Index].VendorTable));\r
+    }\r
+#endif\r
   }\r
   //\r
   // Convert the runtime fields of the EFI System Table and recompute the CRC-32\r
index 0ad8664..477869c 100644 (file)
@@ -114,6 +114,36 @@ Returns:
           );\r
 }\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+EFI_STATUS\r
+EFIAPI\r
+RuntimeServiceQueryVariableInfo (\r
+  IN  UINT32                 Attributes,\r
+  OUT UINT64                 *MaximumVariableStorageSize,\r
+  OUT UINT64                 *RemainingVariableStorageSize,\r
+  OUT UINT64                 *MaximumVariableSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  return QueryVariableInfo (\r
+          Attributes,\r
+          MaximumVariableStorageSize,\r
+          RemainingVariableStorageSize,\r
+          MaximumVariableSize,\r
+          &mVariableModuleGlobal->VariableBase[Physical],\r
+          mVariableModuleGlobal->FvbInstance\r
+          );\r
+}\r
+#endif\r
+\r
 VOID\r
 EFIAPI\r
 VariableClassAddressChangeEvent (\r
@@ -166,6 +196,9 @@ Returns:
   SystemTable->RuntimeServices->GetVariable         = RuntimeServiceGetVariable;\r
   SystemTable->RuntimeServices->GetNextVariableName = RuntimeServiceGetNextVariableName;\r
   SystemTable->RuntimeServices->SetVariable         = RuntimeServiceSetVariable;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  SystemTable->RuntimeServices->QueryVariableInfo   = RuntimeServiceQueryVariableInfo;\r
+#endif\r
 \r
   //\r
   // Now install the Variable Runtime Architectural Protocol on a new handle\r
index 061e6db..ee2a485 100644 (file)
@@ -89,6 +89,19 @@ Returns:
                         );\r
     return ReturnVal;\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  case EsalQueryVariableInfo:\r
+    ReturnVal.Status = QueryVariableInfo (\r
+                        (UINT32) Arg2,\r
+                        (UINT64 *) Arg3,\r
+                        (UINT64 *) Arg4,\r
+                        (UINT64 *) Arg5,\r
+                        &Global->VariableBase[VirtualMode],\r
+                        Global->FvbInstance\r
+                        );\r
+    return ReturnVal;\r
+#endif\r
+\r
   default:\r
     ReturnVal.Status = EFI_SAL_INVALID_ARGUMENT;\r
     return ReturnVal;\r
@@ -160,6 +173,10 @@ Returns:
     EsalGetNextVariableName,\r
     EsalVariableCommonEntry,\r
     EsalSetVariable,\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+    EsalVariableCommonEntry,\r
+    EsalQueryVariableInfo,\r
+#endif\r
     NULL\r
     );\r
 \r
index 0d91520..cfd3183 100644 (file)
@@ -1090,6 +1090,135 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+EFI_STATUS\r
+EFIAPI\r
+QueryVariableInfo (\r
+  IN  UINT32                 Attributes,\r
+  OUT UINT64                 *MaximumVariableStorageSize,\r
+  OUT UINT64                 *RemainingVariableStorageSize,\r
+  OUT UINT64                 *MaximumVariableSize,\r
+  IN  VARIABLE_GLOBAL        *Global,\r
+  IN  UINT32                 Instance\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This code returns information about the EFI variables.\r
+\r
+Arguments:\r
+\r
+  Attributes                      Attributes bitmask to specify the type of variables \r
+                                  on which to return information.\r
+  MaximumVariableStorageSize      Pointer to the maximum size of the storage space available\r
+                                  for the EFI variables associated with the attributes specified.\r
+  RemainingVariableStorageSize    Pointer to the remaining size of the storage space available \r
+                                  for the EFI variables associated with the attributes specified.\r
+  MaximumVariableSize             Pointer to the maximum size of the individual EFI variables\r
+                                  associated with the attributes specified.\r
+  Global                          Pointer to VARIABLE_GLOBAL structure.\r
+  Instance                        Instance of the Firmware Volume.\r
+\r
+Returns:\r
+\r
+  EFI STATUS\r
+  EFI_INVALID_PARAMETER           - An invalid combination of attribute bits was supplied.\r
+  EFI_SUCCESS                     - Query successfully.\r
+  EFI_UNSUPPORTED                 - The attribute is not supported on this platform.\r
+\r
+--*/\r
+{\r
+  VARIABLE_HEADER        *Variable;\r
+  VARIABLE_HEADER        *NextVariable;\r
+  UINT64                 VariableSize;\r
+  VARIABLE_STORE_HEADER  *VariableStoreHeader;\r
+  \r
+  if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)) == 0) {\r
+    //\r
+    // Make sure the Attributes combination is supported by the platform.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\r
+    //\r
+    // Make sure if runtime bit is set, boot service bit is set also.\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
+  } else if (EfiAtRuntime () && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {\r
+    //\r
+    // Make sure RT Attribute is set if we are in Runtime phase.\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
+    //\r
+    // Query is Volatile related.\r
+    //\r
+    VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) Global->VolatileVariableBase);    \r
+  } else {\r
+    //\r
+    // Query is Non-Volatile related.\r
+    //\r
+    VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) Global->NonVolatileVariableBase);\r
+  }\r
+\r
+  //\r
+  // Now let's fill *MaximumVariableStorageSize *RemainingVariableStorageSize \r
+  // with the storage size (excluding the storage header size).\r
+  //\r
+  *MaximumVariableStorageSize   = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);\r
+  *RemainingVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);\r
+\r
+  //\r
+  // Let *MaximumVariableSize be MAX_VARIABLE_SIZE.\r
+  //\r
+  *MaximumVariableSize = MAX_VARIABLE_SIZE;\r
+\r
+  //\r
+  // Point to the starting address of the variables.\r
+  //\r
+  Variable = (VARIABLE_HEADER *) (VariableStoreHeader + 1);\r
+\r
+  //\r
+  // Now walk through the related variable store.\r
+  //\r
+  while (IsValidVariableHeader (Variable) && (Variable < GetEndPointer (VariableStoreHeader))) {\r
+    NextVariable = GetNextVariablePtr (Variable);\r
+    VariableSize = (UINT64) (UINTN) NextVariable - (UINT64) (UINTN) Variable;\r
+\r
+    if (EfiAtRuntime ()) {\r
+      //\r
+      // we don't take the state of the variables in mind \r
+      // when calculating RemainingVariableStorageSize,\r
+      // since the space occupied by variables not marked with \r
+      // VAR_ADDED is not allowed to be reclaimed in Runtime.\r
+      //\r
+      *RemainingVariableStorageSize -= VariableSize;\r
+    } else {\r
+      //\r
+      // Only care about Variables with State VAR_ADDED,because \r
+      // the space not marked as VAR_ADDED is reclaimable now.\r
+      //\r
+      if (Variable->State == VAR_ADDED) {\r
+        *RemainingVariableStorageSize -= VariableSize;\r
+      }\r
+    }\r
+    \r
+    //\r
+    // Go to the next one\r
+    //\r
+    Variable = NextVariable;\r
+  }\r
\r
+  return EFI_SUCCESS;\r
+}\r
+#endif\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 VariableCommonInitialize (\r
index d1fd5e2..55423a2 100644 (file)
@@ -140,4 +140,18 @@ SetVariable (
   )\r
 ;\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+EFI_STATUS\r
+EFIAPI\r
+QueryVariableInfo (\r
+  IN  UINT32                 Attributes,\r
+  OUT UINT64                 *MaximumVariableStorageSize,\r
+  OUT UINT64                 *RemainingVariableStorageSize,\r
+  OUT UINT64                 *MaximumVariableSize,\r
+  IN  VARIABLE_GLOBAL        *Global,\r
+  IN  UINT32                 Instance\r
+  )\r
+;\r
+#endif\r
+\r
 #endif\r
index c7b747c..235bdc7 100644 (file)
         <FfsFormatKey>RT_DRIVER</FfsFormatKey>
       </ModuleSaBuildOptions>
     </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="B6EC423C-21D2-490D-85C6-DD5864EAA674" ModuleGuid="42857F0A-13F2-4B21-8A23-53D3F714B840">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="baa1baa3-0a8d-402c-8042-985115fae953" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9ba1d976-0624-41a3-8650-28165e8d9ae8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b1ee6c28-54aa-4d17-b705-3e28ccb27b2e" PackageGuid="B6EC423C-21D2-490D-85C6-DD5864EAA674"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="PATCHABLE_IN_MODULE">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdSupportUpdateCapsuleRest</C_Name>
+          <Token>0x00010020</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>   
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaxSizePopulateCapsule</C_Name>
+          <Token>0x00010021</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>   
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaxSizeNonPopulateCapsule</C_Name>
+          <Token>0x00010022</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>   
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>RT_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
     <ModuleSA SupArchList="IA32" PackageGuid="B6EC423C-21D2-490D-85C6-DD5864EAA674" ModuleGuid="F80697E9-7FD6-4665-8646-88E33EF71DFC">
       <Libraries>
         <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>