]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Capsule/RuntimeDxe/CapsuleService.c
Adjust directory structures.
[mirror_edk2.git] / MdeModulePkg / Universal / Capsule / RuntimeDxe / CapsuleService.c
diff --git a/MdeModulePkg/Universal/Capsule/RuntimeDxe/CapsuleService.c b/MdeModulePkg/Universal/Capsule/RuntimeDxe/CapsuleService.c
deleted file mode 100644 (file)
index 5a923cd..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2007, 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
-EFI_STATUS\r
-EFIAPI\r
-UpdateCapsule (\r
-  IN EFI_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
-  EFI_CAPSULE_HEADER        *CapsuleHeader;\r
-\r
-  if (CapsuleCount < 1) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  BufferPtr       = NULL;\r
-  CapsuleHeader   = NULL;\r
-\r
-  for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {\r
-    CapsuleHeader = CapsuleHeaderArray[ArrayNumber];\r
-    if ((CapsuleHeader->Flags & (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE)) == CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {\r
-      return EFI_UNSUPPORTED;\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
-\r
-    BufferPtr = AllocatePool (CapsuleSize);\r
-    if (BufferPtr == NULL) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    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
-      FreePool (BufferPtr);\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-    gDS->Dispatch ();\r
-    FreePool (BufferPtr);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-QueryCapsuleCapabilities (\r
-  IN  EFI_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
-  EFI_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
-  for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {\r
-    CapsuleHeader = CapsuleHeaderArray[ArrayNumber];\r
-    if ((CapsuleHeader->Flags & (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE)) == CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {\r
-      return EFI_UNSUPPORTED;\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
-\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