]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / CapsulePei / UefiCapsule.c
index 043365f7f770193ca2e02af507da9e1f614fd13d..36b04e34064b1caec15d86b4fffb23e9bb6532af 100644 (file)
@@ -1,17 +1,10 @@
 /** @file\r
   Capsule update PEIM for UEFI2.0\r
 \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
 \r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions\r
-of the BSD License which accompanies this distribution.  The\r
-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
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -133,7 +126,7 @@ Create4GPageTables (
   IN EFI_PHYSICAL_ADDRESS   PageTablesAddress,\r
   IN BOOLEAN                Page1GSupport\r
   )\r
-{  \r
+{\r
   UINT8                                         PhysicalAddressBits;\r
   EFI_PHYSICAL_ADDRESS                          PageAddress;\r
   UINTN                                         IndexOfPml4Entries;\r
@@ -172,7 +165,7 @@ Create4GPageTables (
   }\r
 \r
   //\r
-  // Pre-allocate big pages to avoid later allocations. \r
+  // Pre-allocate big pages to avoid later allocations.\r
   //\r
   BigPageAddress = (UINTN) PageTablesAddress;\r
 \r
@@ -201,7 +194,7 @@ Create4GPageTables (
 \r
     if (Page1GSupport) {\r
       PageDirectory1GEntry = (VOID *) PageDirectoryPointerEntry;\r
-    \r
+\r
       for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) {\r
         //\r
         // Fill in the Page Directory entries\r
@@ -216,7 +209,7 @@ Create4GPageTables (
         //\r
         // Each Directory Pointer entries points to a page of Page Directory entires.\r
         // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.\r
-        //       \r
+        //\r
         PageDirectoryEntry = (VOID *) BigPageAddress;\r
         BigPageAddress += SIZE_4KB;\r
 \r
@@ -360,7 +353,7 @@ Thunk32To64 (
   if ((UINTN) ReturnContext->ReturnStatus != 0) {\r
     Status = ENCODE_ERROR ((UINTN) ReturnContext->ReturnStatus);\r
   }\r
-  \r
+\r
   return Status;\r
 }\r
 \r
@@ -401,7 +394,7 @@ ModeSwitch (
 \r
   ZeroMem (&Context, sizeof (SWITCH_32_TO_64_CONTEXT));\r
   ZeroMem (&ReturnContext, sizeof (SWITCH_64_TO_32_CONTEXT));\r
-  \r
+\r
   MemoryBase64  = (UINT64) (UINTN) *MemoryBase;\r
   MemorySize64  = (UINT64) (UINTN) *MemorySize;\r
   MemoryEnd64   = MemoryBase64 + MemorySize64;\r
@@ -409,7 +402,7 @@ ModeSwitch (
   Page1GSupport = IsPage1GSupport ();\r
 \r
   //\r
-  // Merge memory range reserved for stack and page table  \r
+  // Merge memory range reserved for stack and page table\r
   //\r
   if (LongModeBuffer->StackBaseAddress < LongModeBuffer->PageTableAddress) {\r
     ReservedRangeBase = LongModeBuffer->StackBaseAddress;\r
@@ -462,14 +455,14 @@ ModeSwitch (
   // Will save the return status of processing capsule\r
   //\r
   ReturnContext.ReturnStatus       = 0;\r
-  \r
+\r
   //\r
   // Save original GDT\r
   //\r
   AsmReadGdtr ((IA32_DESCRIPTOR *)&ReturnContext.Gdtr);\r
-  \r
+\r
   Status = Thunk32To64 (LongModeBuffer->PageTableAddress, &Context, &ReturnContext);\r
-  \r
+\r
   if (!EFI_ERROR (Status)) {\r
     *MemoryBase = (VOID *) (UINTN) MemoryBase64;\r
     *MemorySize = (UINTN) MemorySize64;\r
@@ -685,7 +678,7 @@ MergeMemoryResourceDescriptor (
       if (NewMemoryResourceEntry != MemoryResourceEntry) {\r
         NewMemoryResourceEntry->ResourceLength += NextMemoryResourceEntry->ResourceLength;\r
       }\r
\r
+\r
       NextMemoryResourceEntry = NextMemoryResourceEntry + 1;\r
     }\r
 \r
@@ -743,7 +736,7 @@ BuildMemoryResourceDescriptor (
     Status = PeiServicesAllocatePool ((1 + 1) * sizeof (MEMORY_RESOURCE_DESCRIPTOR), (VOID **) &MemoryResource);\r
     ASSERT_EFI_ERROR (Status);\r
     ZeroMem (MemoryResource, (1 + 1) * sizeof (MEMORY_RESOURCE_DESCRIPTOR));\r
-  \r
+\r
     MemoryResource[0].PhysicalStart = 0;\r
     MemoryResource[0].ResourceLength = LShiftU64 (1, GetPhysicalAddressBits ());\r
     DEBUG ((EFI_D_INFO, "MemoryResource[0x0] - Start(0x%0lx) Length(0x%0lx)\n",\r
@@ -828,7 +821,7 @@ GetCapsuleDescriptors (
   CapsuleVarName[0] = 0;\r
   ValidIndex        = 0;\r
   CapsuleDataPtr64  = 0;\r
-  \r
+\r
   Status = PeiServicesLocatePpi (\r
               &gEfiPeiReadOnlyVariable2PpiGuid,\r
               0,\r
@@ -885,7 +878,7 @@ GetCapsuleDescriptors (
         if (EFI_ERROR (Status)) {\r
           break;\r
         }\r
-        \r
+\r
         //\r
         // If this BlockList has been linked before, skip this variable\r
         //\r
@@ -901,7 +894,7 @@ GetCapsuleDescriptors (
           continue;\r
         }\r
       }\r
-      \r
+\r
       //\r
       // Cache BlockList which has been processed\r
       //\r
@@ -909,7 +902,7 @@ GetCapsuleDescriptors (
       Index ++;\r
     }\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -949,7 +942,7 @@ CapsuleCoalesce (
   UINTN                                VariableCount;\r
   CHAR16                               CapsuleVarName[30];\r
   CHAR16                               *TempVarName;\r
-  EFI_PHYSICAL_ADDRESS                 CapsuleDataPtr64;  \r
+  EFI_PHYSICAL_ADDRESS                 CapsuleDataPtr64;\r
   EFI_STATUS                           Status;\r
   EFI_BOOT_MODE                        BootMode;\r
   EFI_PEI_READ_ONLY_VARIABLE2_PPI      *PPIVariableServices;\r
@@ -973,11 +966,11 @@ CapsuleCoalesce (
   //\r
   Status = PeiServicesGetBootMode (&BootMode);\r
   if (EFI_ERROR (Status) || (BootMode != BOOT_ON_FLASH_UPDATE)) {\r
-    DEBUG ((EFI_D_ERROR, "Boot mode is not correct for capsule update path.\n"));    \r
+    DEBUG ((EFI_D_ERROR, "Boot mode is not correct for capsule update path.\n"));\r
     Status = EFI_NOT_FOUND;\r
     goto Done;\r
   }\r
-  \r
+\r
   //\r
   // User may set the same ScatterGatherList with several different variables,\r
   // so cache all ScatterGatherList for check later.\r
@@ -1022,9 +1015,9 @@ CapsuleCoalesce (
     VariableCount++;\r
     Index++;\r
   }\r
-  \r
+\r
   DEBUG ((EFI_D_INFO,"Capsule variable count = %d\n", VariableCount));\r
-  \r
+\r
   //\r
   // The last entry is the end flag.\r
   //\r
@@ -1037,9 +1030,9 @@ CapsuleCoalesce (
     DEBUG ((EFI_D_ERROR, "AllocatePages Failed!, Status = %x\n", Status));\r
     goto Done;\r
   }\r
-  \r
+\r
   ZeroMem (VariableArrayAddress, (VariableCount + 1) * sizeof (EFI_PHYSICAL_ADDRESS));\r
-  \r
+\r
   //\r
   // Find out if we actually have a capsule.\r
   // GetCapsuleDescriptors depends on variable PPI, so it should run in 32-bit environment.\r
@@ -1068,7 +1061,7 @@ CapsuleCoalesce (
       Status = EFI_NOT_FOUND;\r
       goto Done;\r
     }\r
-    \r
+\r
     Status = FindCapsuleCoalesceImage (&CoalesceImageEntryPoint, &CoalesceImageMachineType);\r
     if ((EFI_ERROR (Status)) || (CoalesceImageMachineType != EFI_IMAGE_MACHINE_X64)) {\r
       DEBUG ((EFI_D_ERROR, "Fail to find CapsuleX64 module in FV!\n"));\r
@@ -1090,13 +1083,13 @@ CapsuleCoalesce (
   //\r
   Status = CapsuleDataCoalesce (PeiServices, (EFI_PHYSICAL_ADDRESS *)(UINTN)VariableArrayAddress, MemoryResource, MemoryBase, MemorySize);\r
 #endif\r
-  \r
+\r
   DEBUG ((EFI_D_INFO, "Capsule Coalesce Status = %r!\n", Status));\r
 \r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     DEBUG ((EFI_D_ERROR, "There is not enough memory to process capsule!\n"));\r
   }\r
-  \r
+\r
   if (Status == EFI_NOT_FOUND) {\r
     DEBUG ((EFI_D_ERROR, "Fail to parse capsule descriptor in memory!\n"));\r
     REPORT_STATUS_CODE (\r
@@ -1129,9 +1122,9 @@ CheckCapsuleUpdate (
   return Status;\r
 }\r
 /**\r
-  This function will look at a capsule and determine if it's a test pattern. \r
+  This function will look at a capsule and determine if it's a test pattern.\r
   If it is, then it will verify it and emit an error message if corruption is detected.\r
-  \r
+\r
   @param PeiServices   Standard pei services pointer\r
   @param CapsuleBase   Base address of coalesced capsule, which is preceeded\r
                        by private data. Very implementation specific.\r
@@ -1220,7 +1213,7 @@ CreateState (
   UINT32                        Index;\r
   EFI_PHYSICAL_ADDRESS          BaseAddress;\r
   UINT64                        Length;\r
\r
+\r
   PrivateData    = (EFI_CAPSULE_PEIM_PRIVATE_DATA *) CapsuleBase;\r
   if (PrivateData->Signature != EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE) {\r
     return EFI_VOLUME_CORRUPTED;\r
@@ -1276,7 +1269,7 @@ CreateState (
 \r
     BuildCvHob (BaseAddress, Length);\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r