]>
git.proxmox.com Git - mirror_edk2.git/blob - IntelFspPkg/Tools/GenCfgOpt.py
3 # Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
4 # This program and the accompanying materials are licensed and made available under
5 # the terms and conditions of the BSD License that accompanies this distribution.
6 # The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php.
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 from datetime
import date
20 # Generated file copyright header
22 __copyright_txt__
= """## @file
24 # THIS IS AUTO-GENERATED FILE BY BUILD TOOLS AND PLEASE DO NOT MAKE MODIFICATION.
26 # This file lists all VPD informations for a platform collected by build.exe.
28 # Copyright (c) %4d, Intel Corporation. All rights reserved.<BR>
29 # This program and the accompanying materials
30 # are licensed and made available under the terms and conditions of the BSD License
31 # which accompanies this distribution. The full text of the license may be found at
32 # http://opensource.org/licenses/bsd-license.php
34 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
35 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
39 __copyright_bsf__
= """/** @file
41 Boot Setting File for Platform Configuration.
43 Copyright (c) %4d, Intel Corporation. All rights reserved.<BR>
44 This program and the accompanying materials
45 are licensed and made available under the terms and conditions of the BSD License
46 which accompanies this distribution. The full text of the license may be found at
47 http://opensource.org/licenses/bsd-license.php
49 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
50 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
52 This file is automatically generated. Please do NOT modify !!!
58 __copyright_h__
= """/** @file
60 Copyright (c) %4d, Intel Corporation. All rights reserved.<BR>
62 Redistribution and use in source and binary forms, with or without modification,
63 are permitted provided that the following conditions are met:
65 * Redistributions of source code must retain the above copyright notice, this
66 list of conditions and the following disclaimer.
67 * Redistributions in binary form must reproduce the above copyright notice, this
68 list of conditions and the following disclaimer in the documentation and/or
69 other materials provided with the distribution.
70 * Neither the name of Intel Corporation nor the names of its contributors may
71 be used to endorse or promote products derived from this software without
72 specific prior written permission.
74 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
75 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
76 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
77 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
78 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
79 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
80 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
81 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
82 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
83 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
84 THE POSSIBILITY OF SUCH DAMAGE.
86 This file is automatically generated. Please do NOT modify !!!
91 def UpdateMemSiUpdInitOffsetValue ( DscFile
):
92 DscFd
= open ( DscFile
, "r" )
93 DscLines
= DscFd
. readlines ()
99 MemUpdInitOffsetValue
= 0
100 SiUpdInitOffsetValue
= 0
103 DscLine
= DscLines
. pop ( 0 )
104 DscContent
. append ( DscLine
)
105 DscLine
= DscLine
. strip ()
106 Match
= re
. match ( "^([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)" , DscLine
)
108 MemUpdInitOffsetValue
= int ( Match
. group ( 5 ), 0 )
109 Match
= re
. match ( "^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)" , DscLine
)
111 SiUpdInitOffsetValue
= int ( Match
. group ( 5 ), 0 )
112 Match
= re
. match ( "^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450554D454D24)" , DscLine
)
114 MemUpdInitOffset
= int ( Match
. group ( 3 ), 0 )
115 Match
= re
. match ( "^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450555F495324)" , DscLine
)
117 SiUpdInitOffset
= int ( Match
. group ( 3 ), 0 )
119 if MemUpdInitOffsetValue
!= MemUpdInitOffset
or SiUpdInitOffsetValue
!= SiUpdInitOffset
:
120 MemUpdInitOffsetStr
= "0x %0 8X" % MemUpdInitOffset
121 SiUpdInitOffsetStr
= "0x %0 8X" % SiUpdInitOffset
122 DscFd
= open ( DscFile
, "w" )
123 for DscLine
in DscContent
:
124 Match
= re
. match ( "^\s*([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)" , DscLine
)
126 DscLine
= re
. sub ( r
'(?:[^\s]+\s*$)' , MemUpdInitOffsetStr
+ ' \n ' , DscLine
)
127 Match
= re
. match ( "^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)" , DscLine
)
129 DscLine
= re
. sub ( r
'(?:[^\s]+\s*$)' , SiUpdInitOffsetStr
+ ' \n ' , line
)
130 DscFd
. writelines ( DscLine
)
133 class CLogicalExpression
:
138 def errExit ( self
, err
= '' ):
139 print "ERROR: Express parsing for:"
140 print " %s " % self
. string
141 print " %s ^" % ( ' ' * self
. index
)
143 print "INFO : %s " % err
146 def getNonNumber ( self
, n1
, n2
):
153 def getCurr ( self
, lens
= 1 ):
156 return self
. string
[ self
. index
:]
158 if self
. index
+ lens
> len ( self
. string
):
159 lens
= len ( self
. string
) - self
. index
160 return self
. string
[ self
. index
: self
. index
+ lens
]
165 return self
. index
== len ( self
. string
)
167 def moveNext ( self
, len = 1 ):
171 while not self
. isLast ():
172 if self
. getCurr () in ' \t ' :
177 def normNumber ( self
, val
):
178 return True if val
else False
180 def getNumber ( self
, var
):
182 if re
. match ( '^0x[a-fA-F0-9]+$' , var
):
184 elif re
. match ( '^[+-]?\d+$' , var
):
190 def parseValue ( self
):
193 while not self
. isLast ():
194 char
= self
. getCurr ()
195 if re
. match ( '^[\w.]' , char
):
200 val
= self
. getNumber ( var
)
207 def parseSingleOp ( self
):
209 if re
. match ( '^NOT\W' , self
. getCurr (- 1 )):
211 op
= self
. parseBrace ()
212 val
= self
. getNumber ( op
)
214 self
. errExit ( "' %s ' is not a number" % op
)
215 return " %d " % ( not self
. normNumber ( int ( op
)))
217 return self
. parseValue ()
219 def parseBrace ( self
):
221 char
= self
. getCurr ()
224 value
= self
. parseExpr ()
226 if self
. getCurr () != ')' :
227 self
. errExit ( "Expecting closing brace or operator" )
231 value
= self
. parseSingleOp ()
234 def parseCompare ( self
):
235 value
= self
. parseBrace ()
238 char
= self
. getCurr ()
239 if char
in [ '<' , '>' ]:
241 next
= self
. getCurr ()
247 result
= self
. parseBrace ()
248 test
= self
. getNonNumber ( result
, value
)
250 value
= " %d " % self
. normNumber ( eval ( value
+ op
+ result
))
252 self
. errExit ( "' %s ' is not a valid number for comparision" % test
)
253 elif char
in [ '=' , '!' ]:
255 if op
in [ '==' , '!=' ]:
257 result
= self
. parseBrace ()
258 test
= self
. getNonNumber ( result
, value
)
260 value
= " %d " % self
. normNumber (( eval ( value
+ op
+ result
)))
262 value
= " %d " % self
. normNumber ( eval ( "'" + value
+ "'" + op
+ "'" + result
+ "'" ))
270 value
= self
. parseCompare ()
273 if re
. match ( '^AND\W' , self
. getCurr (- 1 )):
275 result
= self
. parseCompare ()
276 test
= self
. getNonNumber ( result
, value
)
278 value
= " %d " % self
. normNumber ( int ( value
) & int ( result
))
280 self
. errExit ( "' %s ' is not a valid op number for AND" % test
)
285 def parseOrXor ( self
):
286 value
= self
. parseAnd ()
291 if re
. match ( '^XOR\W' , self
. getCurr (- 1 )):
294 elif re
. match ( '^OR\W' , self
. getCurr (- 1 )):
300 result
= self
. parseAnd ()
301 test
= self
. getNonNumber ( result
, value
)
303 value
= " %d " % self
. normNumber ( eval ( value
+ op
+ result
))
305 self
. errExit ( "' %s ' is not a valid op number for XOR/OR" % test
)
309 return self
. parseOrXor ()
312 value
= self
. parseExpr ()
314 if not self
. isLast ():
315 self
. errExit ( "Unexpected character found ' %s '" % self
. getCurr ())
316 test
= self
. getNumber ( value
)
318 self
. errExit ( "Result ' %s ' is not a number" % value
)
321 def evaluateExpress ( self
, Expr
):
335 self
._ GlobalDataDef
= """
341 self
._ BuidinOptionTxt
= """
343 Selection 0x1 , "Enabled"
344 Selection 0x0 , "Disabled"
349 self
._ BsfKeyList
= [ 'FIND' , 'NAME' , 'HELP' , 'TYPE' , 'PAGE' , 'OPTION' , 'ORDER' ]
350 self
._ HdrKeyList
= [ 'HEADER' , 'STRUCT' , 'EMBED' ]
351 self
._ BuidinOption
= { '$EN_DIS' : 'EN_DIS' }
354 self
._ CfgBlkDict
= {}
355 self
._ CfgPageDict
= {}
356 self
._ CfgItemList
= []
361 def ParseMacros ( self
, MacroDefStr
):
362 # ['-DABC=1', '-D', 'CFG_DEBUG=1', '-D', 'CFG_OUTDIR=Build']
365 for Macro
in MacroDefStr
:
366 if Macro
. startswith ( '-D' ):
374 Match
= re
. match ( "(\w+)=(.+)" , Macro
)
376 self
._ MacroDict
[ Match
. group ( 1 )] = Match
. group ( 2 )
378 Match
= re
. match ( "(\w+)" , Macro
)
380 self
._ MacroDict
[ Match
. group ( 1 )] = ''
381 if len ( self
._ MacroDict
) == 0 :
386 print "INFO : Macro dictionary:"
387 for Each
in self
._ MacroDict
:
388 print " $( %s ) = [ %s ]" % ( Each
, self
._ MacroDict
[ Each
])
391 def EvaulateIfdef ( self
, Macro
):
392 Result
= Macro
in self
._ MacroDict
394 print "INFO : Eval Ifdef [ %s ] : %s " % ( Macro
, Result
)
397 def ExpandMacros ( self
, Input
):
399 Match
= re
. findall ( "\$\(\w+\)" , Input
)
402 Variable
= Each
[ 2 :- 1 ]
403 if Variable
in self
._ MacroDict
:
404 Line
= Line
. replace ( Each
, self
._ MacroDict
[ Variable
])
407 print "WARN : %s is not defined" % Each
408 Line
= Line
. replace ( Each
, Each
[ 2 :- 1 ])
411 def EvaluateExpress ( self
, Expr
):
412 ExpExpr
= self
. ExpandMacros ( Expr
)
413 LogExpr
= CLogicalExpression ()
414 Result
= LogExpr
. evaluateExpress ( ExpExpr
)
416 print "INFO : Eval Express [ %s ] : %s " % ( Expr
, Result
)
419 def FormatListValue ( self
, ConfigDict
):
420 Struct
= ConfigDict
[ 'struct' ]
421 if Struct
not in [ 'UINT8' , 'UINT16' , 'UINT32' , 'UINT64' ]:
425 binlist
= ConfigDict
[ 'value' ][ 1 :- 1 ]. split ( ',' )
428 if each
. startswith ( '0x' ):
429 value
= int ( each
, 16 )
432 dataarray
. append ( value
)
434 unit
= int ( Struct
[ 4 :]) / 8
435 if int ( ConfigDict
[ 'length' ]) != unit
* len ( dataarray
):
436 raise Exception ( "Array size is not proper for ' %s ' !" % ConfigDict
[ 'cname' ])
439 for each
in dataarray
:
441 for loop
in xrange ( unit
):
442 bytearray
. append ( "0x %0 2X" % ( value
& 0xFF ))
444 newvalue
= '{' + ',' . join ( bytearray
) + '}'
445 ConfigDict
[ 'value' ] = newvalue
448 def ParseDscFile ( self
, DscFile
, FvDir
):
449 self
._ CfgItemList
= []
450 self
._ CfgPageDict
= {}
451 self
._ CfgBlkDict
= {}
452 self
._ DscFile
= DscFile
465 DscFd
= open ( DscFile
, "r" )
466 DscLines
= DscFd
. readlines ()
470 DscLine
= DscLines
. pop ( 0 ). strip ()
472 Match
= re
. match ( "^\[(.+)\]" , DscLine
)
473 if Match
is not None :
474 if Match
. group ( 1 ). lower () == "Defines" . lower ():
478 elif Match
. group ( 1 ). lower () == "PcdsDynamicVpd" . lower ():
480 ConfigDict
[ 'header' ] = 'ON'
481 ConfigDict
[ 'region' ] = 'VPD'
482 ConfigDict
[ 'order' ] = - 1
483 ConfigDict
[ 'page' ] = ''
484 ConfigDict
[ 'name' ] = ''
485 ConfigDict
[ 'find' ] = ''
486 ConfigDict
[ 'struct' ] = ''
487 ConfigDict
[ 'embed' ] = ''
488 ConfigDict
[ 'subreg' ] = []
492 elif Match
. group ( 1 ). lower () == "PcdsDynamicVpd.Upd" . lower ():
494 ConfigDict
[ 'header' ] = 'ON'
495 ConfigDict
[ 'region' ] = 'UPD'
496 ConfigDict
[ 'order' ] = - 1
497 ConfigDict
[ 'page' ] = ''
498 ConfigDict
[ 'name' ] = ''
499 ConfigDict
[ 'find' ] = ''
500 ConfigDict
[ 'struct' ] = ''
501 ConfigDict
[ 'embed' ] = ''
502 ConfigDict
[ 'subreg' ] = []
512 if IsDefSect
or IsUpdSect
or IsVpdSect
:
513 if re
. match ( "^!else($|\s+#.+)" , DscLine
):
515 IfStack
[- 1 ] = not IfStack
[- 1 ]
517 print ( "ERROR: No paired '!if' found for '!else' for line ' %s '" % DscLine
)
519 elif re
. match ( "^!endif($|\s+#.+)" , DscLine
):
522 Level
= ElifStack
. pop ()
526 print ( "ERROR: No paired '!if' found for '!endif' for line ' %s '" % DscLine
)
530 Match
= re
. match ( "!(ifdef|ifndef)\s+(.+)" , DscLine
)
532 Result
= self
. EvaulateIfdef ( Match
. group ( 2 ))
533 if Match
. group ( 1 ) == 'ifndef' :
535 IfStack
. append ( Result
)
538 Match
= re
. match ( "!(if|elseif)\s+(.+)" , DscLine
)
540 Result
= self
. EvaluateExpress ( Match
. group ( 2 ))
541 if Match
. group ( 1 ) == "if" :
543 IfStack
. append ( Result
)
546 IfStack
[- 1 ] = not IfStack
[- 1 ]
547 IfStack
. append ( Result
)
548 ElifStack
[- 1 ] = ElifStack
[- 1 ] + 1
550 print ( "ERROR: No paired '!if' found for '!elif' for line ' %s '" % DscLine
)
554 Handle
= reduce ( lambda x
, y
: x
and y
, IfStack
)
558 Match
= re
. match ( "!include\s+(.+)" , DscLine
)
560 IncludeFilePath
= Match
. group ( 1 )
561 IncludeFilePath
= self
. ExpandMacros ( IncludeFilePath
)
563 IncludeDsc
= open ( IncludeFilePath
, "r" )
565 print ( "ERROR: Cannot open file ' %s '" % IncludeFilePath
)
567 NewDscLines
= IncludeDsc
. readlines ()
569 DscLines
= NewDscLines
+ DscLines
571 if DscLine
. startswith ( '!' ):
572 print ( "ERROR: Unrecoginized directive for line ' %s '" % DscLine
)
578 #DEFINE UPD_TOOL_GUID = 8C3D856A-9BE6-468E-850A-24F7A8D38E09
579 Match
= re
. match ( "^\s*(?:DEFINE\s+)*(\w+)\s*=\s*([-.\w]+)" , DscLine
)
581 self
._ MacroDict
[ Match
. group ( 1 )] = Match
. group ( 2 )
583 print "INFO : DEFINE %s = [ %s ]" % ( Match
. group ( 1 ), Match
. group ( 2 ))
585 Match
= re
. match ( "^\s*#\s+!(BSF|HDR)\s+(.+)" , DscLine
)
587 Remaining
= Match
. group ( 2 )
588 if Match
. group ( 1 ) == 'BSF' :
589 Match
= re
. match ( "(?:^|.+\s+)PAGES:{(.+?)}" , Remaining
)
591 # !BSF PAGES:{HSW:"Haswell System Agent", LPT:"Lynx Point PCH"}
592 PageList
= Match
. group ( 1 ). split ( ',' )
593 for Page
in PageList
:
595 Match
= re
. match ( "(\w+): \" (.+) \" " , Page
)
596 self
._ CfgPageDict
[ Match
. group ( 1 )] = Match
. group ( 2 )
598 Match
= re
. match ( "(?:^|.+\s+)BLOCK:{NAME: \" (.+) \" \s*,\s*VER: \" (.+) \" \s*}" , Remaining
)
600 self
._ CfgBlkDict
[ 'name' ] = Match
. group ( 1 )
601 self
._ CfgBlkDict
[ 'ver' ] = Match
. group ( 2 )
603 for Key
in self
._ BsfKeyList
:
604 Match
= re
. match ( "(?:^|.+\s+) %s :{(.+?)}" % Key
, Remaining
)
606 if Key
in [ 'NAME' , 'HELP' , 'OPTION' ] and Match
. group ( 1 ). startswith ( '+' ):
607 ConfigDict
[ Key
. lower ()] += Match
. group ( 1 )[ 1 :]
609 ConfigDict
[ Key
. lower ()] = Match
. group ( 1 )
611 for Key
in self
._ HdrKeyList
:
612 Match
= re
. match ( "(?:^|.+\s+) %s :{(.+?)}" % Key
, Remaining
)
614 ConfigDict
[ Key
. lower ()] = Match
. group ( 1 )
618 Match
= re
. match ( "^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)" , DscLine
)
620 Match
= re
. match ( "^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)(?:\s*\|\s*(.+))?" , DscLine
)
622 ConfigDict
[ 'space' ] = Match
. group ( 1 )
623 ConfigDict
[ 'cname' ] = Match
. group ( 2 )
624 ConfigDict
[ 'offset' ] = int ( Match
. group ( 3 ), 16 )
625 if ConfigDict
[ 'order' ] == - 1 :
626 ConfigDict
[ 'order' ] = ConfigDict
[ 'offset' ] << 8
628 ( Major
, Minor
) = ConfigDict
[ 'order' ]. split ( '.' )
629 ConfigDict
[ 'order' ] = ( int ( Major
, 16 ) << 8 ) + int ( Minor
, 16 )
631 Value
= Match
. group ( 5 ). strip ()
632 if Match
. group ( 4 ). startswith ( "0x" ):
633 Length
= int ( Match
. group ( 4 ), 16 )
635 Length
= int ( Match
. group ( 4 ))
637 Value
= Match
. group ( 4 )
640 Value
= Value
. strip ()
642 Match
= re
. match ( "^.+\s*\|\s*(.+)" , Value
)
644 Value
= Match
. group ( 1 )
647 ConfigDict
[ 'length' ] = Length
648 Match
= re
. match ( "\$\((\w+)\)" , Value
)
650 if Match
. group ( 1 ) in self
._ MacroDict
:
651 Value
= self
._ MacroDict
[ Match
. group ( 1 )]
653 ConfigDict
[ 'value' ] = Value
654 if ( len ( Value
) > 0 ) and ( Value
[ 0 ] == '{' ):
655 Value
= self
. FormatListValue ( ConfigDict
)
657 if ConfigDict
[ 'name' ] == '' :
658 # Clear BSF specific items
659 ConfigDict
[ 'bsfname' ] = ''
660 ConfigDict
[ 'help' ] = ''
661 ConfigDict
[ 'type' ] = ''
662 ConfigDict
[ 'option' ] = ''
664 self
._ CfgItemList
. append ( ConfigDict
. copy ())
665 ConfigDict
[ 'name' ] = ''
666 ConfigDict
[ 'find' ] = ''
667 ConfigDict
[ 'struct' ] = ''
668 ConfigDict
[ 'embed' ] = ''
669 ConfigDict
[ 'order' ] = - 1
670 ConfigDict
[ 'subreg' ] = []
672 # It could be a virtual item as below
673 # !BSF FIELD:{1:SerialDebugPortAddress0}
674 Match
= re
. match ( "^\s*#\s+!BSF\s+FIELD:{(.+):(\d+)}" , DscLine
)
676 SubCfgDict
= ConfigDict
677 SubCfgDict
[ 'cname' ] = Match
. group ( 1 )
678 SubCfgDict
[ 'length' ] = int ( Match
. group ( 2 ))
679 if SubCfgDict
[ 'length' ] > 0 :
680 LastItem
= self
._ CfgItemList
[- 1 ]
681 if len ( LastItem
[ 'subreg' ]) == 0 :
684 SubOffset
+= LastItem
[ 'subreg' ][- 1 ][ 'length' ]
685 SubCfgDict
[ 'offset' ] = SubOffset
686 LastItem
[ 'subreg' ]. append ( SubCfgDict
. copy ())
687 ConfigDict
[ 'name' ] = ''
690 def UpdateSubRegionDefaultValue ( self
):
692 for Item
in self
._ CfgItemList
:
693 if len ( Item
[ 'subreg' ]) == 0 :
696 if Item
[ 'value' ][ 0 ] == '{' :
697 binlist
= Item
[ 'value' ][ 1 :- 1 ]. split ( ',' )
700 if each
. startswith ( '0x' ):
701 value
= int ( each
, 16 )
704 bytearray
. append ( value
)
706 if Item
[ 'value' ]. startswith ( '0x' ):
707 value
= int ( Item
[ 'value' ], 16 )
709 value
= int ( Item
[ 'value' ])
711 while idx
< Item
[ 'length' ]:
712 bytearray
. append ( value
& 0xFF )
715 for SubItem
in Item
[ 'subreg' ]:
716 if SubItem
[ 'length' ] in ( 1 , 2 , 4 , 8 ):
717 valuelist
= [ b
for b
in bytearray
[ SubItem
[ 'offset' ]: SubItem
[ 'offset' ]+ SubItem
[ 'length' ]]]
719 valuestr
= "" . join ( ' %0 2X' % b
for b
in valuelist
)
720 SubItem
[ 'value' ] = '0x %s ' % valuestr
722 valuestr
= "," . join ( '0x %0 2X' % b
for b
in bytearray
[ SubItem
[ 'offset' ]: SubItem
[ 'offset' ]+ SubItem
[ 'length' ]])
723 SubItem
[ 'value' ] = '{ %s }' % valuestr
726 def UpdateVpdSizeField ( self
):
729 if 'VPD_TOOL_GUID' not in self
._ MacroDict
:
730 self
. Error
= "VPD_TOOL_GUID definition is missing in DSC file"
733 VpdMapFile
= os
. path
. join ( FvDir
, self
._ MacroDict
[ 'VPD_TOOL_GUID' ] + '.map' )
734 if not os
. path
. exists ( VpdMapFile
):
735 self
. Error
= "VPD MAP file ' %s ' does not exist" % VpdMapFile
738 MapFd
= open ( VpdMapFile
, "r" )
739 MapLines
= MapFd
. readlines ()
744 for MapLine
in MapLines
:
745 #gPlatformFspPkgTokenSpaceGuid.PcdVpdRegionSign | DEFAULT | 0x0000 | 8 | 0x534450565F425346
746 #gPlatformFspPkgTokenSpaceGuid.PcdVpdRegionSign | 0x0000 | 8 | 0x534450565F425346
747 #gPlatformFspPkgTokenSpaceGuid.PcdTest | 0x0008 | 5 | {0x01,0x02,0x03,0x04,0x05}
748 Match
= re
. match ( "([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)(\s\|\sDEFAULT)?\s\|\s(0x[0-9A-F] {4} )\s\|\s(\d+|0x[0-9a-fA-F]+)\s\|\s(\{?[x0-9a-fA-F,\s]+\}?)" , MapLine
)
750 Space
= Match
. group ( 1 )
751 Name
= Match
. group ( 2 )
752 if ( self
._ MapVer
== 0 ) and ( Match
. group ( 3 ) != None ):
754 Offset
= int ( Match
. group ( 4 ), 16 )
755 if Match
. group ( 5 ). startswith ( "0x" ):
756 Length
= int ( Match
. group ( 5 ), 16 )
758 Length
= int ( Match
. group ( 5 ))
759 PcdDict
[ "len" ] = Length
760 PcdDict
[ "value" ] = Match
. group ( 6 )
761 VpdDict
[ Space
+ '.' + Name
] = dict ( PcdDict
)
763 for Item
in self
._ CfgItemList
:
764 if Item
[ 'value' ] == '' :
765 Item
[ 'value' ] = VpdDict
[ Item
[ 'space' ]+ '.' + Item
[ 'cname' ]][ 'value' ]
766 if Item
[ 'length' ] == - 1 :
767 Item
[ 'length' ] = VpdDict
[ Item
[ 'space' ]+ '.' + Item
[ 'cname' ]][ 'len' ]
768 if Item
[ 'struct' ] != '' :
769 Type
= Item
[ 'struct' ]. strip ()
770 if Type
. endswith ( '*' ) and ( Item
[ 'length' ] != 4 ):
771 self
. Error
= "Struct pointer ' %s ' has invalid size" % Type
776 def CreateUpdTxtFile ( self
, UpdTxtFile
):
778 if 'UPD_TOOL_GUID' not in self
._ MacroDict
:
779 self
. Error
= "UPD_TOOL_GUID definition is missing in DSC file"
783 UpdTxtFile
= os
. path
. join ( FvDir
, self
._ MacroDict
[ 'UPD_TOOL_GUID' ] + '.txt' )
786 if not os
. path
. exists ( UpdTxtFile
):
789 DscTime
= os
. path
. getmtime ( self
._ DscFile
)
790 TxtTime
= os
. path
. getmtime ( UpdTxtFile
)
791 if DscTime
> TxtTime
:
795 # DSC has not been modified yet
796 # So don't have to re-generate other files
797 self
. Error
= 'No DSC file change, skip to create UPD TXT file'
800 TxtFd
= open ( UpdTxtFile
, "w" )
801 TxtFd
. write ( " %s \n " % ( __copyright_txt__
% date
. today (). year
))
805 if self
._ MapVer
== 1 :
809 for Item
in self
._ CfgItemList
:
810 if Item
[ 'region' ] != 'UPD' :
812 Offset
= Item
[ 'offset' ]
813 if NextOffset
< Offset
:
815 TxtFd
. write ( " %s .UnusedUpdSpace %d | %s0x%0 4X|0x %0 4X| {0} \n " % ( Item
[ 'space' ], SpaceIdx
, Default
, NextOffset
, Offset
- NextOffset
))
816 SpaceIdx
= SpaceIdx
+ 1
817 NextOffset
= Offset
+ Item
[ 'length' ]
818 TxtFd
. write ( " %s . %s | %s0x%0 4X| %s | %s \n " % ( Item
[ 'space' ], Item
[ 'cname' ], Default
, Item
[ 'offset' ], Item
[ 'length' ], Item
[ 'value' ]))
822 def CreateField ( self
, Item
, Name
, Length
, Offset
, Struct
, BsfName
, Help
):
829 if Length
in [ 1 , 2 , 4 , 8 ]:
830 Type
= "UINT %d " % ( Length
* 8 )
835 if Item
and Item
[ 'value' ]. startswith ( '{' ):
841 if Struct
in [ 'UINT8' , 'UINT16' , 'UINT32' , 'UINT64' ]:
843 Unit
= int ( Type
[ 4 :]) / 8
844 Length
= Length
/ Unit
849 Name
= Name
+ '[ %d ]' % Length
851 if len ( Type
) < PosName
:
852 Space1
= PosName
- len ( Type
)
857 NameLine
= " %s \n " % BsfName
860 HelpLine
= " %s \n " % Help
865 OffsetStr
= '0x %0 4X' % Offset
867 return "/** Offset %s \n %s%s **/ \n %s%s%s ; \n " % ( OffsetStr
, NameLine
, HelpLine
, Type
, ' ' * Space1
, Name
,)
869 def PostProcessBody ( self
, TextBody
):
875 for Line
in TextBody
:
876 Match
= re
. match ( "^/\*\sEMBED_STRUCT:(\w+):(\w+):(START|END)\s\*/\s([\s\S]*)" , Line
)
878 Line
= Match
. group ( 4 )
880 if Match
and Match
. group ( 3 ) == 'START' :
881 NewTextBody
. append ( 'typedef struct { \n ' )
882 StructName
= Match
. group ( 1 )
883 VariableName
= Match
. group ( 2 )
884 MatchOffset
= re
. search ( '/\*\*\sOffset\s0x([a-fA-F0-9]+)' , Line
)
886 Offset
= int ( MatchOffset
. group ( 1 ), 16 )
891 OldTextBody
. append ( self
. CreateField ( None , VariableName
, 0 , Offset
, StructName
, '' , '' ))
893 NewTextBody
. append ( Line
)
895 OldTextBody
. append ( Line
)
897 if Match
and Match
. group ( 3 ) == 'END' :
898 if ( StructName
!= Match
. group ( 1 )) or ( VariableName
!= Match
. group ( 2 )):
899 print "Unmatched struct name ' %s ' and ' %s ' !" % ( StructName
, Match
. group ( 1 ))
901 NewTextBody
. append ( '} %s ; \n\n ' % StructName
)
903 NewTextBody
. extend ( OldTextBody
)
906 def CreateHeaderFile ( self
, InputHeaderFile
, IsInternal
):
910 HeaderFile
= os
. path
. join ( FvDir
, 'FspUpdVpdInternal.h' )
912 HeaderFile
= os
. path
. join ( FvDir
, 'FspUpdVpd.h' )
914 # Check if header needs to be recreated
917 if not os
. path
. exists ( HeaderFile
):
920 DscTime
= os
. path
. getmtime ( self
._ DscFile
)
921 HeadTime
= os
. path
. getmtime ( HeaderFile
)
922 if not os
. path
. exists ( InputHeaderFile
):
925 InpTime
= os
. path
. getmtime ( InputHeaderFile
)
926 if DscTime
> HeadTime
or InpTime
> HeadTime
:
930 self
. Error
= "No DSC or input header file is changed, skip the header file generating"
934 for Item
in self
._ CfgItemList
:
935 if str ( Item
[ 'cname' ]) == 'Signature' and Item
[ 'length' ] == 8 :
936 Value
= int ( Item
[ 'value' ], 16 )
939 Chars
. append ( chr ( Value
& 0xFF ))
941 SignatureStr
= '' . join ( Chars
)
942 if int ( Item
[ 'offset' ]) == 0 :
943 TxtBody
. append ( "#define FSP_UPD_SIGNATURE %s /* ' %s ' */ \n " % ( Item
[ 'value' ], SignatureStr
))
944 elif 'MEM' in SignatureStr
:
945 TxtBody
. append ( "#define FSP_MEMORY_INIT_UPD_SIGNATURE %s /* ' %s ' */ \n " % ( Item
[ 'value' ], SignatureStr
))
947 TxtBody
. append ( "#define FSP_SILICON_INIT_UPD_SIGNATURE %s /* ' %s ' */ \n " % ( Item
[ 'value' ], SignatureStr
))
950 for Region
in [ 'UPD' , 'VPD' ]:
952 # Write PcdVpdRegionSign and PcdImageRevision
954 if 'VPD_TOOL_GUID' not in self
._ MacroDict
:
955 self
. Error
= "VPD_TOOL_GUID definition is missing in DSC file"
958 BinFile
= os
. path
. join ( FvDir
, self
._ MacroDict
[ 'VPD_TOOL_GUID' ] + ".bin" )
959 if not os
. path
. exists ( BinFile
):
960 self
. Error
= "VPD binary file ' %s ' does not exist" % BinFile
963 BinFd
= open ( BinFile
, "rb" )
964 IdStr
= BinFd
. read ( 0x08 )
965 ImageId
= struct
. unpack ( '<Q' , IdStr
)
966 ImageRev
= struct
. unpack ( '<I' , BinFd
. read ( 0x04 ))
969 TxtBody
. append ( "#define FSP_IMAGE_ID 0x %0 16X /* ' %s ' */ \n " % ( ImageId
[ 0 ], IdStr
))
970 TxtBody
. append ( "#define FSP_IMAGE_REV 0x %0 8X \n\n " % ImageRev
[ 0 ])
972 TxtBody
. append ( "typedef struct _" + Region
[ 0 ] + "PD_DATA_REGION { \n " )
981 for Item
in self
._ CfgItemList
:
982 if Item
[ 'region' ] != Region
:
985 NextVisible
= LastVisible
987 if LastVisible
and ( Item
[ 'header' ] == 'OFF' ):
989 ResvOffset
= Item
[ 'offset' ]
990 elif ( not LastVisible
) and Item
[ 'header' ] == 'ON' :
992 Name
= "Reserved" + Region
[ 0 ] + "pdSpace %d " % ResvIdx
993 ResvIdx
= ResvIdx
+ 1
994 TxtBody
. append ( self
. CreateField ( Item
, Name
, Item
[ "offset" ] - ResvOffset
, ResvOffset
, '' , '' , '' ))
996 if Offset
< Item
[ "offset" ]:
997 if IsInternal
or LastVisible
:
998 Name
= "Unused" + Region
[ 0 ] + "pdSpace %d " % SpaceIdx
999 LineBuffer
. append ( self
. CreateField ( Item
, Name
, Item
[ "offset" ] - Offset
, Offset
, '' , '' , '' ))
1000 SpaceIdx
= SpaceIdx
+ 1
1001 Offset
= Item
[ "offset" ]
1003 if Offset
!= Item
[ "offset" ]:
1004 self
. Error
= "Unsorted offset 0x %0 4X \n " % Item
[ "offset" ]
1007 LastVisible
= NextVisible
1009 Offset
= Offset
+ Item
[ "length" ]
1010 if IsInternal
or LastVisible
:
1011 for Each
in LineBuffer
:
1012 TxtBody
. append ( Each
)
1014 Embed
= Item
[ "embed" ]. upper ()
1015 if Embed
. endswith ( ':START' ) or Embed
. endswith ( ':END' ):
1016 Marker
= '/* EMBED_STRUCT: %s */ ' % Item
[ "embed" ]
1021 self
. Error
= "Invalid embedded structure format ' %s '! \n " % Item
[ "embed" ]
1023 Line
= Marker
+ self
. CreateField ( Item
, Item
[ "cname" ], Item
[ "length" ], Item
[ "offset" ], Item
[ 'struct' ], Item
[ 'name' ], Item
[ 'help' ])
1024 TxtBody
. append ( Line
)
1026 TxtBody
. append ( "} " + Region
[ 0 ] + "PD_DATA_REGION; \n\n " )
1028 # Handle the embedded data structure
1029 TxtBody
= self
. PostProcessBody ( TxtBody
)
1031 HeaderFd
= open ( HeaderFile
, "w" )
1032 FileBase
= os
. path
. basename ( HeaderFile
)
1033 FileName
= FileBase
. replace ( "." , "_" ). upper ()
1034 HeaderFd
. write ( " %s \n " % ( __copyright_h__
% date
. today (). year
))
1035 HeaderFd
. write ( "#ifndef __ %s __ \n " % FileName
)
1036 HeaderFd
. write ( "#define __ %s __ \n\n " % FileName
)
1037 HeaderFd
. write ( "#pragma pack(1) \n\n " )
1039 if InputHeaderFile
!= '' :
1040 if not os
. path
. exists ( InputHeaderFile
):
1041 self
. Error
= "Input header file ' %s ' does not exist" % InputHeaderFile
1044 InFd
= open ( InputHeaderFile
, "r" )
1045 IncLines
= InFd
. readlines ()
1049 for Line
in IncLines
:
1050 Match
= re
. search ( "!EXPORT\s+EXTERNAL_BOOTLOADER_STRUCT_(BEGIN|END)\s+" , Line
)
1052 if Match
. group ( 1 ) == "BEGIN" :
1059 HeaderFd
. write ( Line
)
1060 HeaderFd
. write ( " \n\n " )
1062 for Line
in TxtBody
:
1063 HeaderFd
. write ( Line
)
1064 HeaderFd
. write ( "#pragma pack() \n\n " )
1065 HeaderFd
. write ( "#endif \n " )
1070 def WriteBsfStruct ( self
, BsfFd
, Item
):
1071 if Item
[ 'type' ] == "None" :
1072 Space
= "gPlatformFspPkgTokenSpaceGuid"
1074 Space
= Item
[ 'space' ]
1075 Line
= " $ %s _ %s " % ( Space
, Item
[ 'cname' ])
1076 Match
= re
. match ( "\s*\{([x0-9a-fA-F,\s]+)\}\s*" , Item
[ 'value' ])
1078 DefaultValue
= Match
. group ( 1 ). strip ()
1080 DefaultValue
= Item
[ 'value' ]. strip ()
1081 BsfFd
. write ( " %s%s% 4d bytes $_DEFAULT_ = %s \n " % ( Line
, ' ' * ( 64 - len ( Line
)), Item
[ 'length' ], DefaultValue
))
1083 if Item
[ 'type' ] == "Combo" :
1084 if not Item
[ 'option' ] in self
._ BuidinOption
:
1085 OptList
= Item
[ 'option' ]. split ( ',' )
1086 for Option
in OptList
:
1087 Option
= Option
. strip ()
1088 ( OpVal
, OpStr
) = Option
. split ( ':' )
1089 TmpList
. append (( OpVal
, OpStr
))
1092 def WriteBsfOption ( self
, BsfFd
, Item
):
1093 PcdName
= Item
[ 'space' ] + '_' + Item
[ 'cname' ]
1095 if Item
[ 'type' ] == "Combo" :
1096 if Item
[ 'option' ] in self
._ BuidinOption
:
1097 Options
= self
._ BuidinOption
[ Item
[ 'option' ]]
1100 BsfFd
. write ( ' %s $ %s , " %s ", & %s , \n ' % ( Item
[ 'type' ], PcdName
, Item
[ 'name' ], Options
));
1102 elif Item
[ 'type' ]. startswith ( "EditNum" ):
1103 Match
= re
. match ( "EditNum\s*,\s*(HEX|DEC)\s*,\s*\((\d+|0x[0-9A-Fa-f]+)\s*,\s*(\d+|0x[0-9A-Fa-f]+)\)" , Item
[ 'type' ])
1105 BsfFd
. write ( ' EditNum $ %s , " %s ", %s , \n ' % ( PcdName
, Item
[ 'name' ], Match
. group ( 1 )));
1107 elif Item
[ 'type' ]. startswith ( "EditText" ):
1108 BsfFd
. write ( ' %s $ %s , " %s ", \n ' % ( Item
[ 'type' ], PcdName
, Item
[ 'name' ]));
1110 elif Item
[ 'type' ] == "Table" :
1111 Columns
= Item
[ 'option' ]. split ( ',' )
1112 if len ( Columns
) != 0 :
1113 BsfFd
. write ( ' %s $ %s " %s ",' % ( Item
[ 'type' ], PcdName
, Item
[ 'name' ]));
1115 Fmt
= Col
. split ( ':' )
1117 raise Exception ( "Column format ' %s ' is invalid !" % Fmt
)
1119 Dtype
= int ( Fmt
[ 1 ]. strip ())
1121 raise Exception ( "Column size ' %s ' is invalid !" % Fmt
[ 1 ])
1122 BsfFd
. write ( ' \n Column " %s ", %d bytes, %s ' % ( Fmt
[ 0 ]. strip (), Dtype
, Fmt
[ 2 ]. strip ()))
1127 HelpLines
= Item
[ 'help' ]. split ( ' \\ n \\ r' )
1129 for HelpLine
in HelpLines
:
1132 BsfFd
. write ( ' Help " %s " \n ' % ( HelpLine
));
1134 BsfFd
. write ( ' " %s " \n ' % ( HelpLine
));
1136 BsfFd
. write ( ' "Valid range: %s ~ %s " \n ' % ( Match
. group ( 2 ), Match
. group ( 3 )));
1138 def GenerateBsfFile ( self
, BsfFile
):
1141 self
. Error
= "BSF output file ' %s ' is invalid" % BsfFile
1146 BsfFd
= open ( BsfFile
, "w" )
1147 BsfFd
. write ( " %s \n " % ( __copyright_bsf__
% date
. today (). year
))
1148 BsfFd
. write ( " %s \n " % self
._ GlobalDataDef
);
1149 BsfFd
. write ( "StructDef \n " )
1151 for Item
in self
._ CfgItemList
:
1152 if Item
[ 'find' ] != '' :
1153 BsfFd
. write ( ' \n Find " %s " \n ' % Item
[ 'find' ])
1154 NextOffset
= Item
[ 'offset' ] + Item
[ 'length' ]
1155 if Item
[ 'name' ] != '' :
1156 if NextOffset
!= Item
[ 'offset' ]:
1157 BsfFd
. write ( " Skip %d bytes \n " % ( Item
[ 'offset' ] - NextOffset
))
1158 if len ( Item
[ 'subreg' ]) > 0 :
1159 NextOffset
= Item
[ 'offset' ]
1160 for SubItem
in Item
[ 'subreg' ]:
1161 NextOffset
+= SubItem
[ 'length' ]
1162 if SubItem
[ 'name' ] == '' :
1163 BsfFd
. write ( " Skip %d bytes \n " % ( SubItem
[ 'length' ]))
1165 Options
= self
. WriteBsfStruct ( BsfFd
, SubItem
)
1166 if len ( Options
) > 0 :
1167 OptionDict
[ SubItem
[ 'space' ]+ '_' + SubItem
[ 'cname' ]] = Options
1168 if ( Item
[ 'offset' ] + Item
[ 'length' ]) < NextOffset
:
1169 self
. Error
= "BSF sub region ' %s ' length does not match" % ( Item
[ 'space' ]+ '.' + Item
[ 'cname' ])
1172 NextOffset
= Item
[ 'offset' ] + Item
[ 'length' ]
1173 Options
= self
. WriteBsfStruct ( BsfFd
, Item
)
1174 if len ( Options
) > 0 :
1175 OptionDict
[ Item
[ 'space' ]+ '_' + Item
[ 'cname' ]] = Options
1176 BsfFd
. write ( " \n EndStruct \n\n " )
1178 BsfFd
. write ( " %s " % self
._ BuidinOptionTxt
);
1180 for Each
in OptionDict
:
1181 BsfFd
. write ( "List & %s \n " % Each
);
1182 for Item
in OptionDict
[ Each
]:
1183 BsfFd
. write ( ' Selection %s , " %s " \n ' % ( Item
[ 0 ], Item
[ 1 ]));
1184 BsfFd
. write ( "EndList \n\n " );
1186 BsfFd
. write ( "BeginInfoBlock \n " );
1187 BsfFd
. write ( ' PPVer " %s " \n ' % ( self
._ CfgBlkDict
[ 'ver' ]));
1188 BsfFd
. write ( ' Description " %s " \n ' % ( self
._ CfgBlkDict
[ 'name' ]));
1189 BsfFd
. write ( "EndInfoBlock \n\n " );
1191 for Each
in self
._ CfgPageDict
:
1192 BsfFd
. write ( 'Page " %s " \n ' % self
._ CfgPageDict
[ Each
]);
1194 for Item
in self
._ CfgItemList
:
1195 if Item
[ 'name' ] != '' :
1196 if Item
[ 'page' ] != Each
:
1198 if len ( Item
[ 'subreg' ]) > 0 :
1199 for SubItem
in Item
[ 'subreg' ]:
1200 if SubItem
[ 'name' ] != '' :
1201 BsfItems
. append ( SubItem
)
1203 BsfItems
. append ( Item
)
1205 BsfItems
. sort ( key
= lambda x
: x
[ 'order' ])
1207 for Item
in BsfItems
:
1208 self
. WriteBsfOption ( BsfFd
, Item
)
1209 BsfFd
. write ( "EndPage \n\n " );
1216 print "GenCfgOpt Version 0.50"
1218 print " GenCfgOpt UPDTXT PlatformDscFile BuildFvDir [TxtOutFile] [-D Macros]"
1219 print " GenCfgOpt HEADER PlatformDscFile BuildFvDir [InputHFile] [-D Macros]"
1220 print " GenCfgOpt GENBSF PlatformDscFile BuildFvDir BsfOutFile [-D Macros]"
1224 # Parse the options and args
1226 GenCfgOpt
= CGenCfgOpt ()
1227 argc
= len ( sys
. argv
)
1232 DscFile
= sys
. argv
[ 2 ]
1233 if not os
. path
. exists ( DscFile
):
1234 print "ERROR: Cannot open DSC file ' %s ' !" % DscFile
1237 UpdateMemSiUpdInitOffsetValue ( DscFile
)
1241 if sys
. argv
[ 4 ][ 0 ] == '-' :
1244 OutFile
= sys
. argv
[ 4 ]
1246 if GenCfgOpt
. ParseMacros ( sys
. argv
[ Start
:]) != 0 :
1247 print "ERROR: Macro parsing failed !"
1251 if not os
. path
. isdir ( FvDir
):
1252 print "ERROR: FV folder ' %s ' is invalid !" % FvDir
1255 if GenCfgOpt
. ParseDscFile ( DscFile
, FvDir
) != 0 :
1256 print "ERROR: %s !" % GenCfgOpt
. Error
1259 if GenCfgOpt
. UpdateVpdSizeField () != 0 :
1260 print "ERROR: %s !" % GenCfgOpt
. Error
1263 if GenCfgOpt
. UpdateSubRegionDefaultValue () != 0 :
1264 print "ERROR: %s !" % GenCfgOpt
. Error
1267 if sys
. argv
[ 1 ] == "UPDTXT" :
1268 Ret
= GenCfgOpt
. CreateUpdTxtFile ( OutFile
)
1270 # No change is detected
1272 print "INFO: %s !" % ( GenCfgOpt
. Error
)
1274 print "ERROR: %s !" % ( GenCfgOpt
. Error
)
1276 elif sys
. argv
[ 1 ] == "HEADER" :
1277 Ret
= GenCfgOpt
. CreateHeaderFile ( OutFile
, True )
1279 # No change is detected
1281 print "INFO: %s !" % ( GenCfgOpt
. Error
)
1283 print "ERROR: %s !" % ( GenCfgOpt
. Error
)
1285 if GenCfgOpt
. CreateHeaderFile ( OutFile
, False ) != 0 :
1286 print "ERROR: %s !" % GenCfgOpt
. Error
1288 elif sys
. argv
[ 1 ] == "GENBSF" :
1289 if GenCfgOpt
. GenerateBsfFile ( OutFile
) != 0 :
1290 print "ERROR: %s !" % GenCfgOpt
. Error
1296 print "ERROR: Unknown command ' %s ' !" % sys
. argv
[ 1 ]
1303 if __name__
== '__main__' :