Fix GCC X64 build warning
authorlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 2 Feb 2009 05:16:30 +0000 (05:16 +0000)
committerlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 2 Feb 2009 05:16:30 +0000 (05:16 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1466 7335b38e-4728-0410-8992-fb3ffe349368

Source/C/Common/WinNtInclude.h
Source/C/GenFw/GenFw.c

index 574a7d8..96c1799 100644 (file)
@@ -20,6 +20,19 @@ Abstract:
 #ifndef __WIN_NT_INCLUDE_H__\r
 #define __WIN_NT_INCLUDE_H__\r
 \r
+#define GUID  _WINNT_DUP_GUID_____\r
+#define _LIST_ENTRY  _WINNT_DUP_LIST_ENTRY_FORWARD\r
+#define LIST_ENTRY   _WINNT_DUP_LIST_ENTRY\r
+#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement\r
+#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement\r
+#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64\r
+#undef UNALIGNED\r
+#undef CONST\r
+#undef VOID\r
+\r
+#ifndef __GNUC__\r
+#include "windows.h"\r
+\r
 //\r
 // Win32 include files do not compile clean with /W4, so we use the warning\r
 // pragma to suppress the warnings for Win32 only. This way our code can stil\r
@@ -32,18 +45,13 @@ Abstract:
 #pragma warning(disable : 4028)\r
 #pragma warning(disable : 4133)\r
 \r
-#define GUID  _WINNT_DUP_GUID_____\r
-#define _LIST_ENTRY  _WINNT_DUP_LIST_ENTRY_FORWARD\r
-#define LIST_ENTRY   _WINNT_DUP_LIST_ENTRY\r
-#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement\r
-#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement\r
-#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64\r
-#undef UNALIGNED\r
-#undef CONST\r
-#undef VOID\r
+//\r
+// Set the warnings back on as the EFI code must be /W4.\r
+//\r
+#pragma warning(default : 4115)\r
+#pragma warning(default : 4201)\r
+#pragma warning(default : 4214)\r
 \r
-#ifndef __GNUC__\r
-#include "windows.h"\r
 #endif\r
 \r
 #undef GUID\r
@@ -62,12 +70,4 @@ Abstract:
 #undef LoadImage\r
 #undef CreateEvent\r
 \r
-//\r
-// Set the warnings back on as the EFI code must be /W4.\r
-//\r
-#pragma warning(default : 4115)\r
-#pragma warning(default : 4201)\r
-#pragma warning(default : 4214)\r
-\r
-\r
 #endif\r
index 7fdf8dd..0bf5df7 100644 (file)
@@ -92,16 +92,16 @@ Abstract:
 // Structure definition for a microcode header\r
 //\r
 typedef struct {\r
-  UINTN  HeaderVersion;\r
-  UINTN  PatchId;\r
-  UINTN  Date;\r
-  UINTN  CpuId;\r
-  UINTN  Checksum;\r
-  UINTN  LoaderVersion;\r
-  UINTN  PlatformId;\r
-  UINTN  DataSize;   // if 0, then TotalSize = 2048, and TotalSize field is invalid\r
-  UINTN  TotalSize;  // number of bytes\r
-  UINTN  Reserved[3];\r
+  UINT32  HeaderVersion;\r
+  UINT32  PatchId;\r
+  UINT32  Date;\r
+  UINT32  CpuId;\r
+  UINT32  Checksum;\r
+  UINT32  LoaderVersion;\r
+  UINT32  PlatformId;\r
+  UINT32  DataSize;   // if 0, then TotalSize = 2048, and TotalSize field is invalid\r
+  UINT32  TotalSize;  // number of bytes\r
+  UINT32  Reserved[3];\r
 } MICROCODE_IMAGE_HEADER;\r
 \r
 STATIC CHAR8 *mInImageName;\r
@@ -123,7 +123,7 @@ STATIC
 STATUS\r
 MicrocodeReadData (\r
   FILE          *InFptr,\r
-  UINT        *Data\r
+  UINT32        *Data\r
   );\r
 \r
 STATIC\r
@@ -643,7 +643,6 @@ ScanSections(
     | EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED\r
     | EFI_IMAGE_FILE_32BIT_MACHINE;\r
   \r
-  NtHdr->OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
   NtHdr->OptionalHeader.SizeOfCode = DataOffset - TextOffset;\r
   NtHdr->OptionalHeader.SizeOfInitializedData = RelocOffset - DataOffset;\r
   NtHdr->OptionalHeader.SizeOfUninitializedData = 0;\r
@@ -651,8 +650,16 @@ ScanSections(
 \r
   NtHdr->OptionalHeader.BaseOfCode = TextOffset;\r
 \r
-#if   defined (MDE_CPU_IA32)\r
+#if defined (MDE_CPU_IA32)\r
   NtHdr->OptionalHeader.BaseOfData = DataOffset;\r
+  NtHdr->OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
+  NtHdr->FileHeader.Machine = EFI_IMAGE_MACHINE_IA32;\r
+#elif defined (MDE_CPU_X64)\r
+  NtHdr->OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+  NtHdr->FileHeader.Machine = EFI_IMAGE_MACHINE_X64;\r
+#elif defined (MDE_CPU_IPF)\r
+  NtHdr->OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+  NtHdr->FileHeader.Machine = EFI_IMAGE_MACHINE_IPF;\r
 #endif\r
   NtHdr->OptionalHeader.ImageBase = 0;\r
   NtHdr->OptionalHeader.SectionAlignment = CoffAlignment;\r
@@ -917,7 +924,7 @@ WriteDebug(
 VOID\r
 ConvertElf (\r
   UINT8  **FileBuffer,\r
-  UINTN *FileLength\r
+  UINT32 *FileLength\r
   )\r
 {\r
   EFI_IMAGE_NT_HEADERS *NtHdr;\r
@@ -1141,10 +1148,10 @@ Returns:
   FILE              *fpIn;\r
   FILE              *fpOut;\r
   FILE              *fpInOut;\r
-  UINT            Data;\r
-  UINT            *DataPointer;\r
-  UINT            *OldDataPointer;\r
-  UINT            CheckSum;\r
+  UINT32            Data;\r
+  UINT32            *DataPointer;\r
+  UINT32            *OldDataPointer;\r
+  UINT32            CheckSum;\r
   UINT32            Index;\r
   UINT32            Index1;\r
   UINT32            Index2;\r
@@ -1602,7 +1609,7 @@ Returns:
     // Re-read the file, storing the data into our buffer\r
     //\r
     fseek (fpIn, 0, SEEK_SET);\r
-    DataPointer = (UINTN *) FileBuffer;\r
+    DataPointer = (UINT32 *) FileBuffer;\r
     OldDataPointer = DataPointer;\r
     do {\r
       OldDataPointer = DataPointer;\r
@@ -1638,13 +1645,13 @@ Returns:
     //\r
     // Checksum the contents\r
     //\r
-    DataPointer = (UINTN *) FileBuffer;\r
+    DataPointer = (UINT32 *) FileBuffer;\r
     CheckSum  = 0;\r
     Index     = 0;\r
     while (Index < FileLength) {\r
       CheckSum    += *DataPointer;\r
       DataPointer ++;\r
-      Index       += sizeof (UINTN);\r
+      Index       += sizeof (*DataPointer);\r
     }\r
     if (CheckSum != 0) {\r
       Error (NULL, 0, 3000, "Invalid", "checksum (0x%x) failed on file %s.", CheckSum, mInImageName);\r
@@ -2353,9 +2360,9 @@ Returns:
 \r
 --*/\r
 {\r
-  UINTN                           Index;\r
-  UINTN                           DebugDirectoryEntryRva;\r
-  UINTN                           DebugDirectoryEntryFileOffset;\r
+  UINT32                           Index;\r
+  UINT32                           DebugDirectoryEntryRva;\r
+  UINT32                           DebugDirectoryEntryFileOffset;\r
   EFI_IMAGE_DOS_HEADER            *DosHdr;\r
   EFI_IMAGE_FILE_HEADER           *FileHdr;\r
   EFI_IMAGE_OPTIONAL_HEADER32     *Optional32Hdr;\r
@@ -2451,13 +2458,13 @@ Returns:
   struct tm                       stime;\r
   struct tm                       *ptime;\r
   time_t                          newtime;\r
-  UINTN                           Index;\r
-  UINTN                           DebugDirectoryEntryRva;\r
-  UINTN                           DebugDirectoryEntryFileOffset;\r
-  UINTN                           ExportDirectoryEntryRva;\r
-  UINTN                           ExportDirectoryEntryFileOffset;\r
-  UINTN                           ResourceDirectoryEntryRva;\r
-  UINTN                           ResourceDirectoryEntryFileOffset;\r
+  UINT32                           Index;\r
+  UINT32                           DebugDirectoryEntryRva;\r
+  UINT32                           DebugDirectoryEntryFileOffset;\r
+  UINT32                           ExportDirectoryEntryRva;\r
+  UINT32                           ExportDirectoryEntryFileOffset;\r
+  UINT32                           ResourceDirectoryEntryRva;\r
+  UINT32                           ResourceDirectoryEntryFileOffset;\r
   EFI_IMAGE_DOS_HEADER            *DosHdr;\r
   EFI_IMAGE_FILE_HEADER           *FileHdr;\r
   EFI_IMAGE_OPTIONAL_HEADER32     *Optional32Hdr;\r
@@ -2632,7 +2639,7 @@ STATIC
 STATUS\r
 MicrocodeReadData (\r
   FILE          *InFptr,\r
-  UINT        *Data\r
+  UINT32        *Data\r
   )\r
 /*++\r
 \r