mirror of
				https://git.proxmox.com/git/mirror_edk2
				synced 2025-11-04 02:40:26 +00:00 
			
		
		
		
	BaseTools: refactor to remove duplicate functions
Update GenFdsGlobalVariable GetAlignment to support G. replace use of local function in Region with updated shared function. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bob C Feng <bob.c.feng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
		
							parent
							
								
									b48ec0e8ab
								
							
						
					
					
						commit
						7bf1eb6ef8
					
				@ -512,14 +512,15 @@ class GenFdsGlobalVariable:
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def GetAlignment (AlignString):
 | 
			
		||||
        if AlignString is None:
 | 
			
		||||
        if not AlignString:
 | 
			
		||||
            return 0
 | 
			
		||||
        if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K"):
 | 
			
		||||
        if AlignString.endswith('K'):
 | 
			
		||||
            return int (AlignString.rstrip('K')) * 1024
 | 
			
		||||
        elif AlignString in ("1M", "2M", "4M", "8M", "16M"):
 | 
			
		||||
        if AlignString.endswith('M'):
 | 
			
		||||
            return int (AlignString.rstrip('M')) * 1024 * 1024
 | 
			
		||||
        else:
 | 
			
		||||
            return int (AlignString)
 | 
			
		||||
        if AlignString.endswith('G'):
 | 
			
		||||
            return int (AlignString.rstrip('G')) * 1024 * 1024 * 1024
 | 
			
		||||
        return int (AlignString)
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None,
 | 
			
		||||
 | 
			
		||||
@ -124,7 +124,7 @@ class Region(RegionClassObject):
 | 
			
		||||
                        #
 | 
			
		||||
                        self.BlockInfoOfRegion(BlockSizeList, FvObj)
 | 
			
		||||
                        self.FvAddress = self.FvAddress + FvOffset
 | 
			
		||||
                        FvAlignValue = self.GetFvAlignValue(FvObj.FvAlignment)
 | 
			
		||||
                        FvAlignValue = GenFdsGlobalVariable.GetAlignment(FvObj.FvAlignment)
 | 
			
		||||
                        if self.FvAddress % FvAlignValue != 0:
 | 
			
		||||
                            EdkLogger.error("GenFds", GENFDS_ERROR,
 | 
			
		||||
                                            "FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment))
 | 
			
		||||
@ -277,25 +277,6 @@ class Region(RegionClassObject):
 | 
			
		||||
            GenFdsGlobalVariable.InfLogger('   Region Name = None')
 | 
			
		||||
            self.PadBuffer(Buffer, ErasePolarity, Size)
 | 
			
		||||
 | 
			
		||||
    def GetFvAlignValue(self, Str):
 | 
			
		||||
        AlignValue = 1
 | 
			
		||||
        Granu = 1
 | 
			
		||||
        Str = Str.strip().upper()
 | 
			
		||||
        if Str.endswith('K'):
 | 
			
		||||
            Granu = 1024
 | 
			
		||||
            Str = Str[:-1]
 | 
			
		||||
        elif Str.endswith('M'):
 | 
			
		||||
            Granu = 1024 * 1024
 | 
			
		||||
            Str = Str[:-1]
 | 
			
		||||
        elif Str.endswith('G'):
 | 
			
		||||
            Granu = 1024 * 1024 * 1024
 | 
			
		||||
            Str = Str[:-1]
 | 
			
		||||
        else:
 | 
			
		||||
            pass
 | 
			
		||||
 | 
			
		||||
        AlignValue = int(Str) * Granu
 | 
			
		||||
        return AlignValue
 | 
			
		||||
 | 
			
		||||
    ## BlockSizeOfRegion()
 | 
			
		||||
    #
 | 
			
		||||
    #   @param  BlockSizeList        List of block information
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user