summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/Documentation/patches/BaseTools-Pending-Patches.patch
blob: 2265ee1b2bbcc8a59d1dc1855bd7ca8159b57a46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
Index: BaseTools/Conf/build_rule.template
===================================================================
--- BaseTools/Conf/build_rule.template	(revision 12691)
+++ BaseTools/Conf/build_rule.template	(working copy)
@@ -129,7 +129,7 @@
         "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
         "$(SYMRENAME)" $(SYMRENAME_FLAGS) ${dst}
 
-    <Command.ARMGCC>
+    <Command.ARMGCC, Command.ARMLINUXGCC>
         "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
 
 
@@ -217,7 +217,7 @@
     <Command.RVCT>
         "$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST)
     
-    <Command.RVCTCYGWIN, Command.ARMGCC>
+    <Command.RVCTCYGWIN, Command.ARMGCC, Command.ARMLINUXGCC>
         # $(OBJECT_FILES_LIST) has wrong paths for cygwin
         "$(SLINK)" $(SLINK_FLAGS) ${dst} $(OBJECT_FILES)
 
@@ -241,7 +241,7 @@
         "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS)
         "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
 
-    <Command.ARMGCC>
+    <Command.ARMGCC, Command.ARMLINUXGCC>
         "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -\( $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) -\) $(DLINK2_FLAGS)
 
     <Command.RVCT>
@@ -271,7 +271,7 @@
     <Command.GCC>
         "$(DLINK)" $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS)
 
-    <Command.ARMGCC>
+    <Command.ARMGCC, Command.ARMLINUXGCC>
         "$(DLINK)" $(DLINK_FLAGS) -\( $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) -\) $(DLINK2_FLAGS)
 
     <Command.RVCT>
@@ -292,7 +292,7 @@
     <OutputFile>
         $(DEBUG_DIR)(+)$(MODULE_NAME).efi
 
-    <Command.MSFT, Command.INTEL, Command.RVCT, Command.ARMGCC>  
+    <Command.MSFT, Command.INTEL, Command.RVCT, Command.ARMGCC, Command.ARMLINUXGCC>  
         "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
         $(CP) ${dst} $(OUTPUT_DIR)
         $(CP) ${dst} $(BIN_DIR)
@@ -536,7 +536,7 @@
         "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
         "$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst}
         
-    <Command.XCODE, Command.RVCT, Command.ARMGCC>  
+    <Command.XCODE, Command.RVCT, Command.ARMGCC, Command.ARMLINUXGCC>  
         GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES)
         
         
Index: BaseTools/Conf/tools_def.template
===================================================================
--- BaseTools/Conf/tools_def.template	(revision 12691)
+++ BaseTools/Conf/tools_def.template	(working copy)
@@ -467,6 +467,7 @@
 #   MSFT           - Microsoft
 #   GCC            - GNU GCC
 #   INTEL          - INTEL
+#   RVCT           - ARM RealView Toolchain
 ####################################################################################
 ####################################################################################
 #
@@ -4173,11 +4174,69 @@
 *_ARMGCC_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
 
 *_ARMGCC_ARM_SLINK_FLAGS =  -rc
-*_ARMGCC_ARM_DLINK_FLAGS =  $(ARCHDLINK_FLAGS)  --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+*_ARMGCC_ARM_DLINK_FLAGS =  $(ARCHDLINK_FLAGS) -Ttext=0x0 --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
 
   DEBUG_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -combine -O0
 RELEASE_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -combine -Wno-unused
 
+####################################################################################
+#
+# ARM GNU/Linux GCC
+#
+####################################################################################
+#  ARMLINUXGCC         - ARM version of the GCC cross compiler
+
+*_ARMLINUXGCC_*_*_FAMILY          = GCC
+*_ARMLINUXGCC_*_*_BUILDRULEFAMILY = ARMLINUXGCC
+
+*_ARMLINUXGCC_*_MAKE_PATH         = make
+*_ARMLINUXGCC_*_MAKE_FLAGS        = --no-print-directory
+
+##################
+# ASL definitions
+##################
+*_ARMLINUXGCC_*_ASL_PATH           = DEF(UNIX_IASL_BIN)
+*_ARMLINUXGCC_*_ASL_FLAGS          = DEF(IASL_FLAGS)
+*_ARMLINUXGCC_*_ASL_OUTFLAGS       = DEF(IASL_OUTFLAGS)
+*_ARMLINUXGCC_*_ASLPP_FLAGS        = -x c -E -P
+*_ARMLINUXGCC_*_ASLCC_FLAGS        = -x c
+*_ARMLINUXGCC_*_ASLDLINK_FLAGS     = DEF(GCC_DLINK_FLAGS_COMMON) --entry _ReferenceAcpiTable
+
+##################
+# ARM definitions
+##################
+
+*_ARMLINUXGCC_ARM_ASLCC_PATH      = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc
+*_ARMLINUXGCC_ARM_ASLDLINK_PATH   = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-ld
+*_ARMLINUXGCC_ARM_ASLPP_PATH      = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc
+
+*_ARMLINUXGCC_ARM_CC_PATH         = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc
+*_ARMLINUXGCC_ARM_SLINK_PATH      = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-ar
+*_ARMLINUXGCC_ARM_DLINK_PATH      = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-ld
+*_ARMLINUXGCC_ARM_ASM_PATH        = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-as
+*_ARMLINUXGCC_ARM_PP_PATH         = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc
+*_ARMLINUXGCC_ARM_VFRPP_PATH      = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc
+
+#
+# Use default values, or override in DSC file
+#
+*_ARMLINUXGCC_ARM_ARCHCC_FLAGS    = -mthumb
+*_ARMLINUXGCC_ARM_ARCHASM_FLAGS   = 
+*_ARMLINUXGCC_ARM_ARCHDLINK_FLAGS =
+*_ARMLINUXGCC_ARM_PLATFORM_FLAGS  = -march=armv7-a
+
+  DEBUG_ARMLINUXGCC_ARM_ASM_FLAGS   = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) -mlittle-endian -g
+RELEASE_ARMLINUXGCC_ARM_ASM_FLAGS   = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) -mlittle-endian
+
+*_ARMLINUXGCC_ARM_PP_FLAGS    = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+*_ARMLINUXGCC_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+
+*_ARMLINUXGCC_ARM_SLINK_FLAGS =  -rc
+*_ARMLINUXGCC_ARM_DLINK_FLAGS =  $(ARCHDLINK_FLAGS) -Ttext=0x0 --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+
+  DEBUG_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -O0
+RELEASE_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -Wno-unused-but-set-variable
+
 #################
 # ASM 16 linker defintions
 #################
Index: BaseTools/Source/Python/Workspace/MetaFileParser.py
===================================================================
--- BaseTools/Source/Python/Workspace/MetaFileParser.py	(revision 12691)
+++ BaseTools/Source/Python/Workspace/MetaFileParser.py	(working copy)
@@ -1280,6 +1280,9 @@
             Records = IncludedFileTable.GetAll()
             if Records:
                 self._Content[self._ContentIndex:self._ContentIndex] = Records
+                self._Content.pop(self._ContentIndex-1)
+                self._ValueList = None
+                self._ContentIndex -= 1
 
     def __ProcessSkuId(self):
         self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=True)
Index: BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
===================================================================
--- BaseTools/Source/Python/Workspace/WorkspaceDatabase.py	(revision 12691)
+++ BaseTools/Source/Python/Workspace/WorkspaceDatabase.py	(working copy)
@@ -2319,7 +2319,7 @@
     # @param GlobalMacros       Global macros used for replacement during file parsing
     # @prarm RenewDb=False      Create new database file if it's already there
     #
-    def __init__(self, DbPath, RenewDb=False):
+    def __init__(self, DbPath, RenewDb=False, DbSignature={}):
         self._DbClosedFlag = False
         if not DbPath:
             DbPath = os.path.normpath(os.path.join(GlobalData.gWorkspace, self._DB_PATH_))
@@ -2331,7 +2331,7 @@
                 os.makedirs(DbDir)
 
             # remove db file in case inconsistency between db and file in file system
-            if self._CheckWhetherDbNeedRenew(RenewDb, DbPath):
+            if self._CheckWhetherDbNeedRenew(RenewDb, DbPath, DbSignature):
                 os.remove(DbPath)
         
         # create db with optimized parameters
@@ -2367,7 +2367,38 @@
     #
     #  @return Bool value for whether need renew workspace databse
     #
-    def _CheckWhetherDbNeedRenew (self, force, DbPath):
+    def _CheckWhetherDbNeedRenew (self, force, DbPath, DbSignature):
+        DbDir = os.path.split(DbPath)[0]
+        MacroFilePath = os.path.normpath(os.path.join(DbDir, "build.mac"))
+        MacroMatch = False
+        if os.path.exists(MacroFilePath) and os.path.isfile(MacroFilePath):
+            LastMacros = None
+            try:
+                f = open(MacroFilePath,'r')
+                LastMacros = pickle.load(f)
+                f.close()
+            except IOError:
+                pass
+            except:
+                f.close()
+
+            if LastMacros != None and type(LastMacros) is DictType:
+                if LastMacros == DbSignature:
+                    MacroMatch = True
+
+        if not MacroMatch:
+            # save command line macros to file
+            try:
+                f = open(MacroFilePath,'w')
+                pickle.dump(DbSignature, f, 2)
+                f.close()
+            except IOError:
+                pass
+            except:
+                f.close()
+
+            force = True
+
         # if database does not exist, we need do nothing
         if not os.path.exists(DbPath): return False
             
Index: BaseTools/Source/Python/build/build.py
===================================================================
--- BaseTools/Source/Python/build/build.py	(revision 12691)
+++ BaseTools/Source/Python/build/build.py	(working copy)
@@ -704,6 +704,8 @@
     #
     def __init__(self, Target, WorkspaceDir, BuildOptions):
         self.WorkspaceDir   = WorkspaceDir
+        DbSignature = {'Target': Target, 'BuildOptions': BuildOptions }
+        
         self.Target         = Target
         self.PlatformFile   = BuildOptions.PlatformFile
         self.ModuleFile     = BuildOptions.ModuleFile
@@ -726,7 +728,7 @@
         if BuildOptions.DisableCache:
             self.Db         = WorkspaceDatabase(":memory:")
         else:
-            self.Db         = WorkspaceDatabase(None, self.Reparse)
+            self.Db         = WorkspaceDatabase(None, self.Reparse, DbSignature)
         self.BuildDatabase  = self.Db.BuildObject
         self.Platform       = None
         self.LoadFixAddress = 0
Index: BaseTools/Source/Python/Trim/Trim.py
===================================================================
--- BaseTools/Source/Python/Trim/Trim.py	(revision 12691)
+++ BaseTools/Source/Python/Trim/Trim.py	(working copy)
@@ -37,7 +37,9 @@
 ## Regular expression for matching "#pragma pack"
 gPragmaPattern = re.compile("^\s*#pragma\s+pack", re.MULTILINE)
 ## Regular expression for matching HEX number
-gHexNumberPattern = re.compile("0[xX]([0-9a-fA-F]+)")
+gHexNumberPattern = re.compile("(0[xX])([0-9a-fA-F]+)U?")
+## Regular expression for matching decimal number
+gDecNumberPattern = re.compile("([0-9]+)U?")
 ## Regular expression for matching "Include ()" in asl file
 gAslIncludePattern = re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE)
 ## Regular expression for matching C style #include "XXX.asl" in asl file
@@ -169,10 +171,15 @@
 
         # convert HEX number format if indicated
         if ConvertHex:
-            Line = gHexNumberPattern.sub(r"0\1h", Line)
+            Line = gHexNumberPattern.sub(r"0\2h", Line)
+        else:
+            Line = gHexNumberPattern.sub(r"\1\2", Line)
         if TrimLong:
             Line = gLongNumberPattern.sub(r"\1", Line)
 
+        # convert Decimal number format
+        Line = gDecNumberPattern.sub(r"\1", Line)
+
         if LineNumber != None:
             EdkLogger.verbose("Got line directive: line=%d" % LineNumber)
             # in case preprocessor removed some lines, like blank or comment lines
Index: BaseTools/Source/C/GenFv/GenFv.c
===================================================================
--- BaseTools/Source/C/GenFv/GenFv.c	(revision 12691)
+++ BaseTools/Source/C/GenFv/GenFv.c	(working copy)
@@ -623,12 +623,7 @@
               );
   } else {
     VerboseMsg ("Create Fv image and its map file");
-    //
-    // Will take rebase action at below situation:
-    // 1. ForceRebase Flag specified to TRUE;
-    // 2. ForceRebase Flag not specified, BaseAddress greater than zero.
-    //
-    if (((mFvDataInfo.BaseAddress > 0) && (mFvDataInfo.ForceRebase == -1)) || (mFvDataInfo.ForceRebase == 1)) {
+    if (mFvDataInfo.BaseAddressSet) {
       VerboseMsg ("FvImage Rebase Address is 0x%llX", (unsigned long long) mFvDataInfo.BaseAddress);
     }
     //
Index: BaseTools/Source/C/GenFv/GenFvInternalLib.c
===================================================================
--- BaseTools/Source/C/GenFv/GenFvInternalLib.c	(revision 12691)
+++ BaseTools/Source/C/GenFv/GenFvInternalLib.c	(working copy)
@@ -506,6 +506,7 @@
 
 EFI_STATUS
 AddPadFile (
+  IN FV_INFO          *FvInfo,
   IN OUT MEMORY_FILE  *FvImage,
   IN UINT32           DataAlignment,
   IN VOID             *FvEnd,
@@ -537,6 +538,8 @@
 {
   EFI_FFS_FILE_HEADER *PadFile;
   UINTN               PadFileSize;
+  UINTN               PadFileOffset;
+  UINTN               ExtHeaderSize;
 
   //
   // Verify input parameters.
@@ -559,32 +562,29 @@
   // This is the earliest possible valid offset (current plus pad file header
   // plus the next file header)
   //
-  PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2);
+  // The padding is added into its own FFS file (which requires a header) added before the aligned file:
+  // | ... FV data before AlignedFile ... | Pad File FFS Header | Padding | AlignedFile FFS Header (+ ExtHeader) | AlignedData
 
   //
-  // Add whatever it takes to get to the next aligned address
+  // Calculate the Offset of the Pad File from the beginning of the FV file
   //
-  while ((PadFileSize % DataAlignment) != 0) {
-    PadFileSize++;
-  }
-  //
-  // Subtract the next file header size
-  //
-  PadFileSize -= sizeof (EFI_FFS_FILE_HEADER);
-
-  //
-  // Subtract the starting offset to get size
-  //
-  PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;
+  PadFileOffset = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;
   
   //
-  // Append extension header size
+  // Get the size of the extension header if exists
   //
   if (ExtHeader != NULL) {
-    PadFileSize = PadFileSize + ExtHeader->ExtHeaderSize;
+    ExtHeaderSize = ExtHeader->ExtHeaderSize;
+  } else {
+    ExtHeaderSize = 0;
   }
 
   //
+  // Calculate the Size of the Padding to ensure the alignment of the data of the Next file
+  //
+  PadFileSize = DataAlignment - ((FvInfo->BaseAddress + PadFileOffset + sizeof (EFI_FFS_FILE_HEADER) + ExtHeaderSize) & (DataAlignment - 1));
+
+  //
   // Verify that we have enough space for the file header
   //
   if (((UINTN) FvImage->CurrentFilePointer + PadFileSize) > (UINTN) FvEnd) {
@@ -1115,7 +1115,7 @@
   //
   // Add pad file if necessary
   //
-  Status = AddPadFile (FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL);
+  Status = AddPadFile (FvInfo, FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL);
   if (EFI_ERROR (Status)) {
     Error (NULL, 0, 4002, "Resource", "FV space is full, could not add pad file for data alignment property.");
     free (FileBuffer);
@@ -2304,7 +2304,7 @@
     //
     // Add FV Extended Header contents to the FV as a PAD file
     //
-    AddPadFile (&FvImageMemoryFile, 4, VtfFileImage, FvExtHeader);
+    AddPadFile (&mFvDataInfo, &FvImageMemoryFile, 4, VtfFileImage, FvExtHeader);
 
     //
     // Fv Extension header change update Fv Header Check sum
@@ -2825,20 +2825,12 @@
   PeFileBuffer       = NULL;
 
   //
-  // Don't need to relocate image when BaseAddress is zero and no ForceRebase Flag specified.
+  // Don't need to relocate image when BaseAddress is not set.
   //
-  if ((FvInfo->BaseAddress == 0) && (FvInfo->ForceRebase == -1)) {
+  if (FvInfo->BaseAddressSet == FALSE) {
     return EFI_SUCCESS;
   }
-  
-  //
-  // If ForceRebase Flag specified to FALSE, will always not take rebase action.
-  //
-  if (FvInfo->ForceRebase == 0) {
-    return EFI_SUCCESS;
-  }
 
-
   XipBase = FvInfo->BaseAddress + XipOffset;
 
   //