]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Apply changes(Unix Type to Windows Type) to the rest of the 2 files:
authoralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 6 Jun 2006 07:15:42 +0000 (07:15 +0000)
committeralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 6 Jun 2006 07:15:42 +0000 (07:15 +0000)
edk2\EdkModulePkg\Core\Pei\Image\Image.c
edk2\EdkModulePkg\Core\Pei\PeiMain\Peimain.c

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

EdkModulePkg/Core/Pei/Image/Image.c
EdkModulePkg/Core/Pei/PeiMain/PeiMain.c

index 15807501422e6fd622fe456455ea3f06fd7a9d78..42ecc862fd8f803a5d9a9ae6d408b0a5a99227a7 100644 (file)
-/*++
-
-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.             
-
-Module Name:
-
-  Image.c
-
-Abstract:
-
-  Pei Core Load Image Support
-
---*/
-
-#include <PeiMain.h>
-
-EFI_STATUS
-PeiLoadImage (
-  IN EFI_PEI_SERVICES         **PeiServices,
-  IN EFI_FFS_FILE_HEADER      *PeimFileHeader,
-  OUT VOID                    **EntryPoint
-  )
-/*++
-
-Routine Description:
-
-  Routine for loading file image.
-
-Arguments:
-
-  PeiServices     - The PEI core services table.
-  PeimFileHeader  - Pointer to the FFS file header of the image.
-  EntryPoint      - Pointer to entry point of specified image file for output.
-
-Returns:
-
-  Status - EFI_SUCCESS    - Image is successfully loaded.
-           EFI_NOT_FOUND  - Fail to locate necessary PPI
-           Others         - Fail to load file.
-
---*/
-{
-  EFI_STATUS                  Status;
-  VOID                        *Pe32Data;
-  EFI_PEI_FV_FILE_LOADER_PPI  *FvLoadFilePpi;
-  EFI_PHYSICAL_ADDRESS        ImageAddress;
-  UINT64                      ImageSize;
-  EFI_PHYSICAL_ADDRESS        ImageEntryPoint;
-  EFI_TE_IMAGE_HEADER         *TEImageHeader;
-
-  *EntryPoint   = NULL;
-  TEImageHeader = NULL;
-
-  //
-  // Try to find a PE32 section.
-  //
-  Status = PeiCoreFfsFindSectionData (
-             EFI_SECTION_PE32,
-             PeimFileHeader,
-             &Pe32Data
-             );
-  //
-  // If we didn't find a PE32 section, try to find a TE section.
-  //
-  if (EFI_ERROR (Status)) {
-    Status = PeiCoreFfsFindSectionData (
-               EFI_SECTION_TE,
-               PeimFileHeader,
-               (VOID **) &TEImageHeader
-               );
-    if (EFI_ERROR (Status) || TEImageHeader == NULL) {
-      //
-      // There was not a PE32 or a TE section, so assume that it's a Compressed section
-      // and use the LoadFile
-      //
-      Status = PeiCoreLocatePpi (
-                &gEfiPeiFvFileLoaderPpiGuid,
-                0,
-                NULL,
-                (VOID **)&FvLoadFilePpi
-                );
-      if (EFI_ERROR (Status)) {
-        return EFI_NOT_FOUND;
-      }
-
-      Status = FvLoadFilePpi->FvLoadFile (
-                                FvLoadFilePpi,
-                                PeimFileHeader,
-                                &ImageAddress,
-                                &ImageSize,
-                                &ImageEntryPoint
-                                );
-
-      if (EFI_ERROR (Status)) {
-        return EFI_NOT_FOUND;
-      }
-
-      //
-      // Retrieve the entry point from the PE/COFF image header
-      //
-      Status = PeCoffLoaderGetEntryPoint ((VOID *)(UINTN)ImageAddress, EntryPoint);
-      if (EFI_ERROR (Status)) {
-        return EFI_NOT_FOUND;
-      }
-    } else {
-      //
-      // Retrieve the entry point from the TE image header
-      //
-      ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) TEImageHeader;
-      *EntryPoint = (VOID *)((UINTN) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) +
-                    TEImageHeader->AddressOfEntryPoint - TEImageHeader->StrippedSize);
-    }
-  } else {
-    //
-    // Retrieve the entry point from the PE/COFF image header
-    //
-    ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) Pe32Data;
-    Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint);
-    if (EFI_ERROR (Status)) {
-      return EFI_NOT_FOUND;
-    }
-  }
-
-  //
-  // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi
-  //
-  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%08x EntryPoint=0x%08x ", Pe32Data, *EntryPoint));
-  DEBUG_CODE (
-    EFI_IMAGE_DATA_DIRECTORY * DirectoryEntry;
-    EFI_IMAGE_DEBUG_DIRECTORY_ENTRY * DebugEntry;
-    UINTN DirCount;
-    UINTN Index;
-    UINTN Index1;
-    BOOLEAN FileNameFound;
-    CHAR8 *AsciiString;
-    CHAR8 AsciiBuffer[512];
-    VOID *CodeViewEntryPointer;
-    INTN TEImageAdjust;
-    EFI_IMAGE_DOS_HEADER  *DosHeader;
-    EFI_IMAGE_NT_HEADERS  *PeHeader;
-
-    //
-    // Pe32Data is NULL when load TE image 
-    //    
-    PeHeader = NULL;
-    if (TEImageHeader == NULL) {
-      DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
-      if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
-        //
-        // DOS image header is present, so read the PE header after the DOS image header
-        //
-        PeHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));
-      } else {
-        //
-        // DOS image header is not present, so PE header is at the image base
-        //
-        PeHeader = (EFI_IMAGE_NT_HEADERS *) Pe32Data;
-      }
-    }
-
-    //
-    // Find the codeview info in the image and display the file name
-    // being loaded.
-    //
-    // Per the PE/COFF spec, you can't assume that a given data directory
-    // is present in the image. You have to check the NumberOfRvaAndSizes in
-    // the optional header to verify a desired directory entry is there.
-    //
-    DebugEntry      = NULL;
-    DirectoryEntry  = NULL;
-    TEImageAdjust   = 0;
-    if (TEImageHeader == NULL) {
-      if (PeHeader->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
-        DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(PeHeader->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
-        DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) ImageAddress + DirectoryEntry->VirtualAddress);
-      }
-    } else {
-      if (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
-        DirectoryEntry  = &TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
-        TEImageAdjust   = sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize;
-        DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) TEImageHeader +
-                      TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
-                      TEImageAdjust);
-      }
-    }
-
-    if (DebugEntry != NULL && DirectoryEntry != NULL) {
-      for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) {
-        if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
-          if (DebugEntry->SizeOfData > 0) {
-            CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageAddress + (UINTN)TEImageAdjust);
-            switch (* (UINT32 *) CodeViewEntryPointer) {
-              case CODEVIEW_SIGNATURE_NB10:
-                AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
-                break;
-
-              case CODEVIEW_SIGNATURE_RSDS:
-                AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
-                break;
-
-              default:
-                AsciiString = NULL;
-                break;
-            }
-            if (AsciiString != NULL) {
-              FileNameFound = FALSE;
-              for (Index = 0, Index1 = 0; AsciiString[Index] != 0; Index++) {
-                if (AsciiString[Index] == '\\') {
-                  Index1 = Index;
-                  FileNameFound = TRUE;
-                }
-              }
-
-              if (FileNameFound) {
-                for (Index = Index1 + 1; AsciiString[Index] != '.'; Index++) {
-                  AsciiBuffer[Index - (Index1 + 1)] = AsciiString[Index];
-                }
-                AsciiBuffer[Index - (Index1 + 1)] = 0;
-                DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a.efi", AsciiBuffer));
-                break;
-              }
-            }
-          }
-        }
-      }
-    }
-  );
-
-  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n"));
-
-  return EFI_SUCCESS;
-}
+/*++\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
+  Image.c\r
+\r
+Abstract:\r
+\r
+  Pei Core Load Image Support\r
+\r
+--*/\r
+\r
+#include <PeiMain.h>\r
+\r
+EFI_STATUS\r
+PeiLoadImage (\r
+  IN EFI_PEI_SERVICES         **PeiServices,\r
+  IN EFI_FFS_FILE_HEADER      *PeimFileHeader,\r
+  OUT VOID                    **EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Routine for loading file image.\r
+\r
+Arguments:\r
+\r
+  PeiServices     - The PEI core services table.\r
+  PeimFileHeader  - Pointer to the FFS file header of the image.\r
+  EntryPoint      - Pointer to entry point of specified image file for output.\r
+\r
+Returns:\r
+\r
+  Status - EFI_SUCCESS    - Image is successfully loaded.\r
+           EFI_NOT_FOUND  - Fail to locate necessary PPI\r
+           Others         - Fail to load file.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  VOID                        *Pe32Data;\r
+  EFI_PEI_FV_FILE_LOADER_PPI  *FvLoadFilePpi;\r
+//#ifdef EFI_NT_EMULATOR\r
+//  EFI_PEI_PPI_DESCRIPTOR      *PpiDescriptor;\r
+//  NT_PEI_LOAD_FILE_PPI        *PeiNtService;\r
+//#endif\r
+  EFI_PHYSICAL_ADDRESS        ImageAddress;\r
+  UINT64                      ImageSize;\r
+  EFI_PHYSICAL_ADDRESS        ImageEntryPoint;\r
+  EFI_TE_IMAGE_HEADER         *TEImageHeader;\r
+\r
+  *EntryPoint   = NULL;\r
+  TEImageHeader = NULL;\r
+\r
+  //\r
+  // Try to find a PE32 section.\r
+  //\r
+  Status = PeiCoreFfsFindSectionData (\r
+             EFI_SECTION_PE32,\r
+             PeimFileHeader,\r
+             &Pe32Data\r
+             );\r
+  //\r
+  // If we didn't find a PE32 section, try to find a TE section.\r
+  //\r
+  if (EFI_ERROR (Status)) {\r
+    Status = PeiCoreFfsFindSectionData (\r
+               EFI_SECTION_TE,\r
+               PeimFileHeader,\r
+               (VOID **) &TEImageHeader\r
+               );\r
+    if (EFI_ERROR (Status) || TEImageHeader == NULL) {\r
+      //\r
+      // There was not a PE32 or a TE section, so assume that it's a Compressed section\r
+      // and use the LoadFile\r
+      //\r
+      Status = PeiCoreLocatePpi (\r
+                &gEfiPeiFvFileLoaderPpiGuid,\r
+                0,\r
+                NULL,\r
+                (VOID **)&FvLoadFilePpi\r
+                );\r
+      if (EFI_ERROR (Status)) {\r
+        return EFI_NOT_FOUND;\r
+      }\r
+\r
+      Status = FvLoadFilePpi->FvLoadFile (\r
+                                FvLoadFilePpi,\r
+                                PeimFileHeader,\r
+                                &ImageAddress,\r
+                                &ImageSize,\r
+                                &ImageEntryPoint\r
+                                );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        return EFI_NOT_FOUND;\r
+      }\r
+\r
+      //\r
+      // Retrieve the entry point from the PE/COFF image header\r
+      //\r
+      Status = PeCoffLoaderGetEntryPoint ((VOID *)(UINTN)ImageAddress, EntryPoint);\r
+      if (EFI_ERROR (Status)) {\r
+        return EFI_NOT_FOUND;\r
+      }\r
+    } else {\r
+      //\r
+      // Retrieve the entry point from the TE image header\r
+      //\r
+      ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) TEImageHeader;\r
+      *EntryPoint = (VOID *)((UINTN) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) +\r
+                    TEImageHeader->AddressOfEntryPoint - TEImageHeader->StrippedSize);\r
+    }\r
+  } else {\r
+    //\r
+    // Retrieve the entry point from the PE/COFF image header\r
+    //\r
+    ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) Pe32Data;\r
+    Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi\r
+  //\r
+  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%08x EntryPoint=0x%08x ", Pe32Data, *EntryPoint));\r
+  DEBUG_CODE (\r
+    EFI_IMAGE_DATA_DIRECTORY * DirectoryEntry;\r
+    EFI_IMAGE_DEBUG_DIRECTORY_ENTRY * DebugEntry;\r
+    UINTN DirCount;\r
+    UINTN Index;\r
+    UINTN Index1;\r
+    BOOLEAN FileNameFound;\r
+    CHAR8 *AsciiString;\r
+    CHAR8 AsciiBuffer[512];\r
+    VOID *CodeViewEntryPointer;\r
+    INTN TEImageAdjust;\r
+    EFI_IMAGE_DOS_HEADER  *DosHeader;\r
+    EFI_IMAGE_NT_HEADERS  *PeHeader;\r
+\r
+    //\r
+    // Pe32Data is NULL when load TE image \r
+    //    \r
+    PeHeader = NULL;\r
+    if (TEImageHeader == NULL) {\r
+      DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
+      if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+        //\r
+        // DOS image header is present, so read the PE header after the DOS image header\r
+        //\r
+        PeHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));\r
+      } else {\r
+        //\r
+        // DOS image header is not present, so PE header is at the image base\r
+        //\r
+        PeHeader = (EFI_IMAGE_NT_HEADERS *) Pe32Data;\r
+      }\r
+    }\r
+\r
+    //\r
+    // Find the codeview info in the image and display the file name\r
+    // being loaded.\r
+    //\r
+    // Per the PE/COFF spec, you can't assume that a given data directory\r
+    // is present in the image. You have to check the NumberOfRvaAndSizes in\r
+    // the optional header to verify a desired directory entry is there.\r
+    //\r
+    DebugEntry      = NULL;\r
+    DirectoryEntry  = NULL;\r
+    TEImageAdjust   = 0;\r
+    if (TEImageHeader == NULL) {\r
+      if (PeHeader->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
+        DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(PeHeader->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+        DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) ImageAddress + DirectoryEntry->VirtualAddress);\r
+      }\r
+    } else {\r
+      if (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {\r
+        DirectoryEntry  = &TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];\r
+        TEImageAdjust   = sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize;\r
+        DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) TEImageHeader +\r
+                      TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +\r
+                      TEImageAdjust);\r
+      }\r
+    }\r
+\r
+    if (DebugEntry != NULL && DirectoryEntry != NULL) {\r
+      for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) {\r
+        if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+          if (DebugEntry->SizeOfData > 0) {\r
+            CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageAddress + (UINTN)TEImageAdjust);\r
+            switch (* (UINT32 *) CodeViewEntryPointer) {\r
+              case CODEVIEW_SIGNATURE_NB10:\r
+                AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);\r
+                break;\r
+\r
+              case CODEVIEW_SIGNATURE_RSDS:\r
+                AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);\r
+                break;\r
+\r
+              default:\r
+                AsciiString = NULL;\r
+                break;\r
+            }\r
+            if (AsciiString != NULL) {\r
+              FileNameFound = FALSE;\r
+              for (Index = 0, Index1 = 0; AsciiString[Index] != 0; Index++) {\r
+                if (AsciiString[Index] == '\\') {\r
+                  Index1 = Index;\r
+                  FileNameFound = TRUE;\r
+                }\r
+              }\r
+\r
+              if (FileNameFound) {\r
+                for (Index = Index1 + 1; AsciiString[Index] != '.'; Index++) {\r
+                  AsciiBuffer[Index - (Index1 + 1)] = AsciiString[Index];\r
+                }\r
+                AsciiBuffer[Index - (Index1 + 1)] = 0;\r
+                DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a.efi", AsciiBuffer));\r
+                break;\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  );\r
+\r
+  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n"));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
index 7b4c2f99a6326733556ac1c7f50b9ddf4a730fb7..f27b0274f5366b8588361b160351e1b2881e650c 100644 (file)
-/*++
-
-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.
-
-Module Name:
-
-  PeiMain.c
-
-Abstract:
-
-  Pei Core Main Entry Point
-
-Revision History
-
---*/
-
-#include <PeiMain.h>
-
-//
-//CAR is filled with this initial value during SEC phase
-//
-#define INIT_CAR_VALUE 0x5AA55AA5
-
-static EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {
-  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
-  &gEfiPeiMemoryDiscoveredPpiGuid,
-  NULL
-};
-
-//
-// Pei Core Module Variables
-//
-//
-static EFI_PEI_SERVICES  mPS = {
-  {
-    PEI_SERVICES_SIGNATURE,
-    PEI_SERVICES_REVISION,
-    sizeof (EFI_PEI_SERVICES),
-    0,
-    0
-  },
-  PeiInstallPpi,
-  PeiReInstallPpi,
-  PeiLocatePpi,
-  PeiNotifyPpi,
-
-  PeiGetBootMode,
-  PeiSetBootMode,
-
-  PeiGetHobList,
-  PeiCreateHob,
-
-  PeiFvFindNextVolume,
-  PeiFfsFindNextFile,
-  PeiFfsFindSectionData,
-
-  PeiInstallPeiMemory,
-  PeiAllocatePages,
-  PeiAllocatePool,
-  (EFI_PEI_COPY_MEM)CopyMem,
-  (EFI_PEI_SET_MEM)SetMem,
-
-  PeiReportStatusCode,
-
-  PeiResetSystem
-};
-
-EFI_STATUS
-EFIAPI
-PeiCore (
-  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,
-  IN PEI_CORE_INSTANCE           *OldCoreData
-  )
-/*++
-
-Routine Description:
-
-  Main entry point to Pei Core. After switching stack in the PEI core, 
-  it will restart with the old core data.
-
-Arguments:
-
-  PeiStartupDescriptor - Information and services provided by SEC phase.
-  OldCoreData          - Pointer to old core data that is used to initialize the
-                         core's data areas.
-
-Returns:
-
-  This function never returns
-  EFI_NOT_FOUND        - Never reach
-
---*/
-{
-  PEI_CORE_INSTANCE                                     PrivateData;
-  EFI_STATUS                                            Status;
-  PEI_CORE_TEMP_POINTERS                                TempPtr;
-  PEI_CORE_DISPATCH_DATA                                *DispatchData;
-  UINT64                                                mTick;
-
-  mTick = 0;
-
-#ifdef EFI_PEI_PERFORMANCE
-  if (OldCoreData == NULL) {
-    mTick = GetPerformanceCounter ();
-  }
-#endif
-
-  //
-  // For IPF in CAR mode the real memory access is uncached,in InstallPeiMemory()
-  //  the 63-bit of address is set to 1.
-  //
-  SWITCH_TO_CACHE_MODE (OldCoreData);
-
-  if (OldCoreData != NULL) {
-    CopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE));
-  } else {
-    ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));
-  }
-
-  PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;
-  PrivateData.PS = &mPS;
-
-  //
-  // Initialize libraries that the PeiCore is linked against
-  // BUGBUG: The FfsHeader is passed in as NULL.  Do we look it up or remove it from the lib init?
-  //
-  ProcessLibraryConstructorList (NULL, &PrivateData.PS);
-
-  InitializeMemoryServices (&PrivateData.PS, PeiStartupDescriptor, OldCoreData);
-
-  InitializePpiServices (&PrivateData.PS, OldCoreData);
-
-  InitializeSecurityServices (&PrivateData.PS, OldCoreData);
-
-  InitializeDispatcherData (&PrivateData.PS, OldCoreData, PeiStartupDescriptor);
-
-  if (OldCoreData != NULL) {
-
-    PERF_END (NULL,"PreMem", NULL, 0);
-    PERF_START (NULL,"PostMem", NULL, 0);
-
-    //
-    // The following code dumps out interesting cache as RAM usage information
-    // so we can keep tabs on how the cache as RAM is being utilized.  The
-    // DEBUG_CODE macro is used to prevent this code from being compiled
-    // on a debug build.
-    //
-    DEBUG_CODE (
-      UINTN  *StackPointer;
-      UINTN  StackValue;
-
-      StackValue = INIT_CAR_VALUE;
-      for (StackPointer = (UINTN *) OldCoreData->MaxTopOfCarHeap;
-           ((UINTN) StackPointer < ((UINTN) OldCoreData->BottomOfCarHeap + OldCoreData->SizeOfCacheAsRam))
-           && StackValue == INIT_CAR_VALUE;
-           StackPointer++) {
-        StackValue = *StackPointer;
-      }
-
-      DEBUG ((EFI_D_INFO, "Total Cache as RAM:    %d bytes.\n", OldCoreData->SizeOfCacheAsRam));
-      DEBUG ((EFI_D_INFO, "  CAR stack ever used: %d bytes.\n",
-        ((UINTN) OldCoreData->TopOfCarHeap - (UINTN) StackPointer)
-        ));
-      DEBUG ((EFI_D_INFO, "  CAR heap used:       %d bytes.\n",
-        ((UINTN) OldCoreData->HobList.HandoffInformationTable->EfiFreeMemoryBottom -
-        (UINTN) OldCoreData->HobList.Raw)
-        ));
-    );
-
-    //
-    // Alert any listeners that there is permanent memory available
-    //
-    PERF_START (NULL,"DisMem", NULL, 0);
-    Status = PeiCoreInstallPpi (&mMemoryDiscoveredPpi);
-    PERF_END (NULL,"DisMem", NULL, 0);
-
-  } else {
-
-    //
-    // Report Status Code EFI_SW_PC_INIT
-    //
-    REPORT_STATUS_CODE (
-      EFI_PROGRESS_CODE,
-      EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT
-      );
-
-    //
-    // If first pass, start performance measurement.
-    //
-    PERF_START (NULL,"PreMem", NULL, mTick);
-
-    //
-    // If SEC provided any PPI services to PEI, install them.
-    //
-    if (PeiStartupDescriptor->DispatchTable != NULL) {
-      Status = PeiCoreInstallPpi (PeiStartupDescriptor->DispatchTable);
-      ASSERT_EFI_ERROR (Status);
-    }
-  }
-
-  DispatchData = &PrivateData.DispatchData;
-
-  //
-  // Call PEIM dispatcher
-  //
-  PeiDispatcher (PeiStartupDescriptor, &PrivateData, DispatchData);
-
-  //
-  // Check if InstallPeiMemory service was called.
-  //
-  ASSERT(PrivateData.PeiMemoryInstalled == TRUE);
-
-  PERF_END (NULL, "PostMem", NULL, 0);
-
-  Status = PeiCoreLocatePpi (
-             &gEfiDxeIplPpiGuid,
-             0,
-             NULL,
-             (VOID **)&TempPtr.DxeIpl
-             );
-  ASSERT_EFI_ERROR (Status);
-
-  DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));
-  Status = TempPtr.DxeIpl->Entry (
-                             TempPtr.DxeIpl,
-                             &PrivateData.PS,
-                             PrivateData.HobList
-                             );
-
-  ASSERT_EFI_ERROR (Status);
-
-  return EFI_NOT_FOUND;
-}
-
+/*++\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
+  PeiMain.c\r
+\r
+Abstract:\r
+\r
+  Pei Core Main Entry Point\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include <PeiMain.h>\r
+\r
+//\r
+//CAR is filled with this initial value during SEC phase\r
+//\r
+#define INIT_CAR_VALUE 0x5AA55AA5\r
+\r
+static EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiMemoryDiscoveredPpiGuid,\r
+  NULL\r
+};\r
+\r
+//\r
+// Pei Core Module Variables\r
+//\r
+//\r
+static EFI_PEI_SERVICES  mPS = {\r
+  {\r
+    PEI_SERVICES_SIGNATURE,\r
+    PEI_SERVICES_REVISION,\r
+    sizeof (EFI_PEI_SERVICES),\r
+    0,\r
+    0\r
+  },\r
+  PeiInstallPpi,\r
+  PeiReInstallPpi,\r
+  PeiLocatePpi,\r
+  PeiNotifyPpi,\r
+\r
+  PeiGetBootMode,\r
+  PeiSetBootMode,\r
+\r
+  PeiGetHobList,\r
+  PeiCreateHob,\r
+\r
+  PeiFvFindNextVolume,\r
+  PeiFfsFindNextFile,\r
+  PeiFfsFindSectionData,\r
+\r
+  PeiInstallPeiMemory,\r
+  PeiAllocatePages,\r
+  PeiAllocatePool,\r
+  (EFI_PEI_COPY_MEM)CopyMem,\r
+  (EFI_PEI_SET_MEM)SetMem,\r
+\r
+  PeiReportStatusCode,\r
+\r
+  PeiResetSystem\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiCore (\r
+  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r
+  IN PEI_CORE_INSTANCE           *OldCoreData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The entry routine to Pei Core, invoked by PeiMain during transition\r
+  from SEC to PEI. After switching stack in the PEI core, it will restart\r
+  with the old core data.\r
+\r
+Arguments:\r
+\r
+  PeiStartupDescriptor - Information and services provided by SEC phase.\r
+  OldCoreData          - Pointer to old core data that is used to initialize the\r
+                         core's data areas.\r
+\r
+Returns:\r
+\r
+  This function never returns\r
+  EFI_NOT_FOUND        - Never reach\r
+\r
+--*/\r
+{\r
+  PEI_CORE_INSTANCE                                     PrivateData;\r
+  EFI_STATUS                                            Status;\r
+  PEI_CORE_TEMP_POINTERS                                TempPtr;\r
+  PEI_CORE_DISPATCH_DATA                                *DispatchData;\r
+  UINT64                                                mTick;\r
+\r
+  mTick = 0;\r
+\r
+#ifdef EFI_PEI_PERFORMANCE\r
+  if (OldCoreData == NULL) {\r
+    mTick = GetPerformanceCounter ();\r
+  }\r
+#endif\r
+\r
+  //\r
+  // For IPF in CAR mode the real memory access is uncached,in InstallPeiMemory()\r
+  //  the 63-bit of address is set to 1.\r
+  //\r
+  SWITCH_TO_CACHE_MODE (OldCoreData);\r
+\r
+  if (OldCoreData != NULL) {\r
+    CopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE));\r
+  } else {\r
+    ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));\r
+  }\r
+\r
+  PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r
+  PrivateData.PS = &mPS;\r
+\r
+  //\r
+  // Initialize libraries that the PeiCore is linked against\r
+  // BUGBUG: The FfsHeader is passed in as NULL.  Do we look it up or remove it from the lib init?\r
+  //\r
+  ProcessLibraryConstructorList (NULL, &PrivateData.PS);\r
+\r
+  InitializeMemoryServices (&PrivateData.PS, PeiStartupDescriptor, OldCoreData);\r
+\r
+  InitializePpiServices (&PrivateData.PS, OldCoreData);\r
+\r
+  InitializeSecurityServices (&PrivateData.PS, OldCoreData);\r
+\r
+  InitializeDispatcherData (&PrivateData.PS, OldCoreData, PeiStartupDescriptor);\r
+\r
+  if (OldCoreData != NULL) {\r
+\r
+    PERF_END (NULL,"PreMem", NULL, 0);\r
+    PERF_START (NULL,"PostMem", NULL, 0);\r
+\r
+    //\r
+    // The following code dumps out interesting cache as RAM usage information\r
+    // so we can keep tabs on how the cache as RAM is being utilized.  The\r
+    // DEBUG_CODE macro is used to prevent this code from being compiled\r
+    // on a debug build.\r
+    //\r
+    DEBUG_CODE (\r
+      UINTN  *StackPointer;\r
+      UINTN  StackValue;\r
+\r
+      StackValue = INIT_CAR_VALUE;\r
+      for (StackPointer = (UINTN *) OldCoreData->MaxTopOfCarHeap;\r
+           ((UINTN) StackPointer < ((UINTN) OldCoreData->BottomOfCarHeap + OldCoreData->SizeOfCacheAsRam))\r
+           && StackValue == INIT_CAR_VALUE;\r
+           StackPointer++) {\r
+        StackValue = *StackPointer;\r
+      }\r
+\r
+      DEBUG ((EFI_D_INFO, "Total Cache as RAM:    %d bytes.\n", OldCoreData->SizeOfCacheAsRam));\r
+      DEBUG ((EFI_D_INFO, "  CAR stack ever used: %d bytes.\n",\r
+        ((UINTN) OldCoreData->TopOfCarHeap - (UINTN) StackPointer)\r
+        ));\r
+      DEBUG ((EFI_D_INFO, "  CAR heap used:       %d bytes.\n",\r
+        ((UINTN) OldCoreData->HobList.HandoffInformationTable->EfiFreeMemoryBottom -\r
+        (UINTN) OldCoreData->HobList.Raw)\r
+        ));\r
+    );\r
+\r
+    //\r
+    // Alert any listeners that there is permanent memory available\r
+    //\r
+    PERF_START (NULL,"DisMem", NULL, 0);\r
+    Status = PeiCoreInstallPpi (&mMemoryDiscoveredPpi);\r
+    PERF_END (NULL,"DisMem", NULL, 0);\r
+\r
+  } else {\r
+\r
+    //\r
+    // Report Status Code EFI_SW_PC_INIT\r
+    //\r
+    REPORT_STATUS_CODE (\r
+      EFI_PROGRESS_CODE,\r
+      EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT\r
+      );\r
+\r
+    //\r
+    // If first pass, start performance measurement.\r
+    //\r
+    PERF_START (NULL,"PreMem", NULL, mTick);\r
+\r
+    //\r
+    // If SEC provided any PPI services to PEI, install them.\r
+    //\r
+    if (PeiStartupDescriptor->DispatchTable != NULL) {\r
+      Status = PeiCoreInstallPpi (PeiStartupDescriptor->DispatchTable);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+  }\r
+\r
+  DispatchData = &PrivateData.DispatchData;\r
+\r
+  //\r
+  // Call PEIM dispatcher\r
+  //\r
+  PeiDispatcher (PeiStartupDescriptor, &PrivateData, DispatchData);\r
+\r
+  //\r
+  // Check if InstallPeiMemory service was called.\r
+  //\r
+  ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r
+\r
+  PERF_END (NULL, "PostMem", NULL, 0);\r
+\r
+  Status = PeiCoreLocatePpi (\r
+             &gEfiDxeIplPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&TempPtr.DxeIpl\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));\r
+  Status = TempPtr.DxeIpl->Entry (\r
+                             TempPtr.DxeIpl,\r
+                             &PrivateData.PS,\r
+                             PrivateData.HobList\r
+                             );\r
+\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r