]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Gcd/gcd.c
Add comments and DoxyGen format for these files.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Gcd / gcd.c
index 4d58687c69230e9b365212fc8cd1473748852ae6..23477be04748bc2d4e766efb145edc3c247f65d6 100644 (file)
@@ -1,6 +1,10 @@
-/*++\r
+/** @file \r
+\r
+    The file contains the GCD related services in the EFI Boot Services Table.\r
+    The GCD services are used to manage the memory and I/O regions that \r
+    are accessible to the CPU that is executing the DXE core.\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2008, 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
@@ -9,16 +13,7 @@ http://opensource.org/licenses/bsd-license.php
 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
-    gcd.c\r
-\r
-Abstract:\r
-    The file contains the GCD related services in the EFI Boot Services Table.\r
-    The GCD services are used to manage the memory and I/O regions that \r
-    are accessible to the CPU that is executing the DXE core.\r
-\r
---*/\r
+**/\r
 \r
 #include <DxeMain.h>\r
 \r
@@ -2242,7 +2237,7 @@ Returns:
 \r
 EFI_STATUS\r
 CoreInitializeGcdServices (\r
-  IN VOID                  **HobStart,\r
+  IN OUT VOID                  **HobStart,\r
   IN EFI_PHYSICAL_ADDRESS  MemoryBaseAddress,\r
   IN UINT64                MemoryLength\r
   )\r
@@ -2255,7 +2250,8 @@ Routine Description:
   memory map, so memory allocations and resource allocations can be made.  The first\r
   part of this function can not depend on any memory services until at least one\r
   memory descriptor is provided to the memory services.  Then the memory services\r
-  can be used to intialize the GCD map.\r
+  can be used to intialize the GCD map. The HobStart will be relocated to a pool \r
+  buffer.\r
 \r
 Arguments:\r
 \r
@@ -2414,18 +2410,18 @@ Returns:
     if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
       MemoryHob = Hob.MemoryAllocation;\r
       BaseAddress = MemoryHob->AllocDescriptor.MemoryBaseAddress;\r
-      Status = CoreAllocateMemorySpace (\r
-                 EfiGcdAllocateAddress,\r
-                 EfiGcdMemoryTypeSystemMemory, \r
-                 0,\r
-                 MemoryHob->AllocDescriptor.MemoryLength,\r
-                 &BaseAddress,\r
-                 gDxeCoreImageHandle,\r
-                 NULL\r
-                 );\r
+      Status = CoreGetMemorySpaceDescriptor  (BaseAddress, &Descriptor);\r
       if (!EFI_ERROR (Status)) {\r
-        Status = CoreGetMemorySpaceDescriptor (MemoryHob->AllocDescriptor.MemoryBaseAddress, &Descriptor);\r
-        if (!EFI_ERROR (Status)) {\r
+        Status = CoreAllocateMemorySpace (\r
+                   EfiGcdAllocateAddress,\r
+                   Descriptor.GcdMemoryType, \r
+                   0,\r
+                   MemoryHob->AllocDescriptor.MemoryLength,\r
+                   &BaseAddress,\r
+                   gDxeCoreImageHandle,\r
+                   NULL\r
+                   );\r
+        if (!EFI_ERROR (Status) && Descriptor.GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {\r
           CoreAddMemoryDescriptor (\r
             MemoryHob->AllocDescriptor.MemoryType,\r
             MemoryHob->AllocDescriptor.MemoryBaseAddress,\r
@@ -2472,6 +2468,9 @@ Returns:
       if (MemorySpaceMap[Index].ImageHandle == NULL) {\r
         BaseAddress  = PageAlignAddress (MemorySpaceMap[Index].BaseAddress);\r
         Length       = PageAlignLength  (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - BaseAddress);\r
+        if (Length == 0 || MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length < BaseAddress) {\r
+          continue;\r
+        }\r
         CoreAddMemoryDescriptor (\r
           EfiConventionalMemory,\r
           BaseAddress,\r