]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UnixPkg/Sec/SecMain.c
Fix issue with fixing tabs.
[mirror_edk2.git] / UnixPkg / Sec / SecMain.c
index da83e3fa5cc8f15dc22483e4f3a8679f83c920d4..a82ec1cce18642632cbfe9209a5e370c50671edb 100644 (file)
@@ -1,7 +1,7 @@
 /*++
 
 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
 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
@@ -279,17 +279,17 @@ Returns:
     // Open the FD and remmeber where it got mapped into our processes address space
     //
     Status = MapFile (
-                     FileName,
-                     &gFdInfo[Index].Address,
-                     &gFdInfo[Index].Size
-                     );
+          FileName,
+          &gFdInfo[Index].Address,
+          &gFdInfo[Index].Size
+          );
     if (EFI_ERROR (Status)) {
       printf ("ERROR : Can not open Firmware Device File %s (%x).  Exiting.\n", FileName, (unsigned int)Status);
       exit (1);
     }
 
     printf ("  FD loaded from %s at 0x%08lx",
-           FileName, (unsigned long)gFdInfo[Index].Address);
+      FileName, (unsigned long)gFdInfo[Index].Address);
 
     if (PeiCoreFile == NULL) {
       //
@@ -419,10 +419,10 @@ Returns:
       /* Read entry address.  */
       lseek (fd, FileSize - 0x20, SEEK_SET);
       if (read (fd, &EntryAddress, 4) != 4)
-       {
-         close (fd);
-         return EFI_DEVICE_ERROR;
-       }
+  {
+    close (fd);
+    return EFI_DEVICE_ERROR;
+  }
     }
 #endif
 
@@ -664,8 +664,8 @@ Returns:
 
   *MemoryBase = 0;
   res = MapMemory(0, gSystemMemory[Index].Size,
-                 PROT_READ | PROT_WRITE | PROT_EXEC,
-                 MAP_PRIVATE | MAP_ANONYMOUS);
+      PROT_READ | PROT_WRITE | PROT_EXEC,
+      MAP_PRIVATE | MAP_ANONYMOUS);
   if (res == MAP_FAILED)
     return EFI_DEVICE_ERROR;
   *MemorySize = gSystemMemory[Index].Size;
@@ -1114,6 +1114,18 @@ SecPeCoffRelocateImageExtraAction (
 {
 
 #ifdef __APPLE__
+  BOOLEAN EnabledOnEntry;
+
+   //
+   // Make sure writting of the file is an atomic operation
+   //
+   if (UnixInterruptEanbled ()) {
+     UnixDisableInterrupt ();
+     EnabledOnEntry = TRUE;
+   } else {
+     EnabledOnEntry = FALSE;
+   }
+
   PrintLoadAddress (ImageContext);
 
   //
@@ -1165,10 +1177,17 @@ SecPeCoffRelocateImageExtraAction (
       // Hey what can you say scripting in gdb is not that great....
       //
       SecGdbScriptBreak ();
+    } else {
+      ASSERT (FALSE);
     }
 
     AddHandle (ImageContext, ImageContext->PdbPointer);
 
+    if (EnabledOnEntry) {
+      UnixEnableInterrupt ();
+    }
+
+    
   }
 
 #else
@@ -1223,12 +1242,20 @@ SecPeCoffLoaderUnloadImageExtraAction (
 
 #ifdef __APPLE__
   FILE  *GdbTempFile;
+  BOOLEAN EnabledOnEntry;
 
   if (Handle != NULL) {
     //
     // Need to skip .PDB files created from VC++
     //
     if (!IsPdbFile (ImageContext->PdbPointer)) {
+       if (UnixInterruptEanbled ()) {
+         UnixDisableInterrupt ();
+         EnabledOnEntry = TRUE;
+       } else {
+         EnabledOnEntry = FALSE;
+       }
+       
       //
       // Write the file we need for the gdb script
       //
@@ -1242,6 +1269,12 @@ SecPeCoffLoaderUnloadImageExtraAction (
         // Hey what can you say scripting in gdb is not that great....
         //
         SecGdbScriptBreak ();
+      } else {
+        ASSERT (FALSE);
+      }
+      
+      if (EnabledOnEntry) {
+        UnixEnableInterrupt ();
       }
     }
   }