@ -29,11 +29,11 @@ bool getVoltages(ProgVoltageType type, TQDomElement element)
data ( ) - > _voltages [ type ] . min = voltages . attribute ( " min " ) . toDouble ( & ok1 ) ;
data ( ) - > _voltages [ type ] . min = voltages . attribute ( " min " ) . toDouble ( & ok1 ) ;
data ( ) - > _voltages [ type ] . max = voltages . attribute ( " max " ) . toDouble ( & ok2 ) ;
data ( ) - > _voltages [ type ] . max = voltages . attribute ( " max " ) . toDouble ( & ok2 ) ;
data ( ) - > _voltages [ type ] . nominal = voltages . attribute ( " nominal " ) . toDouble ( & ok3 ) ;
data ( ) - > _voltages [ type ] . nominal = voltages . attribute ( " nominal " ) . toDouble ( & ok3 ) ;
if ( ! ok1 | | ! ok2 | | ! ok3 ) qFatal( TQString ( " Cannot extract voltage value for \" %1 \" " ) . arg ( type . key ( ) ) ) ;
if ( ! ok1 | | ! ok2 | | ! ok3 ) t qFatal( TQString ( " Cannot extract voltage value for \" %1 \" " ) . arg ( type . key ( ) ) ) ;
if ( data ( ) - > _voltages [ type ] . min > data ( ) - > _voltages [ type ] . max
if ( data ( ) - > _voltages [ type ] . min > data ( ) - > _voltages [ type ] . max
| | data ( ) - > _voltages [ type ] . nominal < data ( ) - > _voltages [ type ] . min
| | data ( ) - > _voltages [ type ] . nominal < data ( ) - > _voltages [ type ] . min
| | data ( ) - > _voltages [ type ] . nominal > data ( ) - > _voltages [ type ] . max )
| | data ( ) - > _voltages [ type ] . nominal > data ( ) - > _voltages [ type ] . max )
qFatal( " Inconsistent voltages order " ) ;
t qFatal( " Inconsistent voltages order " ) ;
return true ;
return true ;
}
}
@ -45,46 +45,46 @@ bool getMemoryRange(MemoryRangeType type, TQDomElement element)
bool ok ;
bool ok ;
uint nbCharsAddress = data ( ) - > nbCharsAddress ( ) ;
uint nbCharsAddress = data ( ) - > nbCharsAddress ( ) ;
data ( ) - > _ranges [ type ] . start = fromHexLabel ( range . attribute ( " start " ) , nbCharsAddress , & ok ) ;
data ( ) - > _ranges [ type ] . start = fromHexLabel ( range . attribute ( " start " ) , nbCharsAddress , & ok ) ;
if ( ! ok ) qFatal( " Cannot extract start address " ) ;
if ( ! ok ) t qFatal( " Cannot extract start address " ) ;
data ( ) - > _ranges [ type ] . end = fromHexLabel ( range . attribute ( " end " ) , nbCharsAddress , & ok ) ;
data ( ) - > _ranges [ type ] . end = fromHexLabel ( range . attribute ( " end " ) , nbCharsAddress , & ok ) ;
if ( ! ok ) qFatal( " Cannot extract end address " ) ;
if ( ! ok ) t qFatal( " Cannot extract end address " ) ;
if ( data ( ) - > _ranges [ type ] . end < data ( ) - > _ranges [ type ] . start ) qFatal( " Memory range end is before its start " ) ;
if ( data ( ) - > _ranges [ type ] . end < data ( ) - > _ranges [ type ] . start ) t qFatal( " Memory range end is before its start " ) ;
uint nbCharsWord = data ( ) - > nbCharsWord ( type ) ;
uint nbCharsWord = data ( ) - > nbCharsWord ( type ) ;
if ( data ( ) - > nbBitsWord ( type ) = = 0 ) qFatal( TQString ( " Architecture doesn't contain memory range %1 " ) . arg ( type . key ( ) ) ) ;
if ( data ( ) - > nbBitsWord ( type ) = = 0 ) t qFatal( TQString ( " Architecture doesn't contain memory range %1 " ) . arg ( type . key ( ) ) ) ;
if ( type = = MemoryRangeType : : UserId ) {
if ( type = = MemoryRangeType : : UserId ) {
data ( ) - > _userIdRecommendedMask = fromHexLabel ( range . attribute ( " rmask " ) , nbCharsWord , & ok ) ;
data ( ) - > _userIdRecommendedMask = fromHexLabel ( range . attribute ( " rmask " ) , nbCharsWord , & ok ) ;
if ( ! ok ) qFatal( " Cannot extract rmask value for user id " ) ;
if ( ! ok ) t qFatal( " Cannot extract rmask value for user id " ) ;
if ( ! data ( ) - > _userIdRecommendedMask . isInside ( data ( ) - > mask ( type ) ) ) qFatal( TQString ( " rmask is not inside mask %1 (%2) " ) . arg ( toHexLabel ( data ( ) - > _userIdRecommendedMask , 8 ) ) . arg ( toHexLabel ( data ( ) - > mask ( type ) , 8 ) ) ) ;
if ( ! data ( ) - > _userIdRecommendedMask . isInside ( data ( ) - > mask ( type ) ) ) t qFatal( TQString ( " rmask is not inside mask %1 (%2) " ) . arg ( toHexLabel ( data ( ) - > _userIdRecommendedMask , 8 ) ) . arg ( toHexLabel ( data ( ) - > mask ( type ) , 8 ) ) ) ;
}
}
if ( range . attribute ( " hexfile_offset " ) ! = " ? " ) {
if ( range . attribute ( " hexfile_offset " ) ! = " ? " ) {
data ( ) - > _ranges [ type ] . properties | = Programmable ;
data ( ) - > _ranges [ type ] . properties | = Programmable ;
if ( ! range . attribute ( " hexfile_offset " ) . isEmpty ( ) ) {
if ( ! range . attribute ( " hexfile_offset " ) . isEmpty ( ) ) {
data ( ) - > _ranges [ type ] . hexFileOffset = fromHexLabel ( range . attribute ( " hexfile_offset " ) , nbCharsAddress , & ok ) ;
data ( ) - > _ranges [ type ] . hexFileOffset = fromHexLabel ( range . attribute ( " hexfile_offset " ) , nbCharsAddress , & ok ) ;
if ( ! ok ) qFatal( " Cannot extract hexfile_offset " ) ;
if ( ! ok ) t qFatal( " Cannot extract hexfile_offset " ) ;
}
}
}
}
if ( type = = MemoryRangeType : : Cal & & ! data ( ) - > is18Family ( ) ) {
if ( type = = MemoryRangeType : : Cal & & ! data ( ) - > is18Family ( ) ) {
data ( ) - > _calibration . opcodeMask = fromHexLabel ( range . attribute ( " cal_opmask " ) , nbCharsWord , & ok ) ;
data ( ) - > _calibration . opcodeMask = fromHexLabel ( range . attribute ( " cal_opmask " ) , nbCharsWord , & ok ) ;
if ( ! ok ) qFatal( " Cannot extract calibration opcode mask " ) ;
if ( ! ok ) t qFatal( " Cannot extract calibration opcode mask " ) ;
data ( ) - > _calibration . opcode = fromHexLabel ( range . attribute ( " cal_opcode " ) , nbCharsWord , & ok ) ;
data ( ) - > _calibration . opcode = fromHexLabel ( range . attribute ( " cal_opcode " ) , nbCharsWord , & ok ) ;
if ( ! ok ) qFatal( " Cannot extract calibration opcode " ) ;
if ( ! ok ) t qFatal( " Cannot extract calibration opcode " ) ;
if ( ! data ( ) - > _calibration . opcode . isInside ( data ( ) - > _calibration . opcodeMask ) ) qFatal( " Calibration opcode should be inside opcode mask " ) ;
if ( ! data ( ) - > _calibration . opcode . isInside ( data ( ) - > _calibration . opcodeMask ) ) t qFatal( " Calibration opcode should be inside opcode mask " ) ;
if ( ! data ( ) - > _calibration . opcodeMask . isInside ( data ( ) - > mask ( type ) ) ) qFatal( " Calibration mask should be inside opcode mask " ) ;
if ( ! data ( ) - > _calibration . opcodeMask . isInside ( data ( ) - > mask ( type ) ) ) t qFatal( " Calibration mask should be inside opcode mask " ) ;
}
}
TQString wwa = range . attribute ( " word_write_align " ) ;
TQString wwa = range . attribute ( " word_write_align " ) ;
TQString wea = range . attribute ( " word_erase_align " ) ;
TQString wea = range . attribute ( " word_erase_align " ) ;
if ( type = = MemoryRangeType : : Code ) {
if ( type = = MemoryRangeType : : Code ) {
if ( data ( ) - > _architecture = = Architecture : : P18F | | data ( ) - > _architecture = = Architecture : : P18J ) {
if ( data ( ) - > _architecture = = Architecture : : P18F | | data ( ) - > _architecture = = Architecture : : P18J ) {
data ( ) - > _nbWordsCodeWrite = wwa . toUInt ( & ok ) ;
data ( ) - > _nbWordsCodeWrite = wwa . toUInt ( & ok ) ;
if ( ! ok | | data ( ) - > _nbWordsCodeWrite = = 0 | | ( data ( ) - > _nbWordsCodeWrite % 4 ) ! = 0 ) qFatal( " Missing or malformed word write align " ) ;
if ( ! ok | | data ( ) - > _nbWordsCodeWrite = = 0 | | ( data ( ) - > _nbWordsCodeWrite % 4 ) ! = 0 ) t qFatal( " Missing or malformed word write align " ) ;
data ( ) - > _nbWordsCodeRowErase = wea . toUInt ( & ok ) ;
data ( ) - > _nbWordsCodeRowErase = wea . toUInt ( & ok ) ;
if ( ! ok | | ( data ( ) - > _nbWordsCodeRowErase % 4 ) ! = 0 ) qFatal( " Missing or malformed word erase align " ) ;
if ( ! ok | | ( data ( ) - > _nbWordsCodeRowErase % 4 ) ! = 0 ) t qFatal( " Missing or malformed word erase align " ) ;
} else {
} else {
if ( ! wwa . isEmpty ( ) | | ! wea . isEmpty ( ) ) qFatal( " word align should not be defined for this device family/subfamily " ) ;
if ( ! wwa . isEmpty ( ) | | ! wea . isEmpty ( ) ) t qFatal( " word align should not be defined for this device family/subfamily " ) ;
data ( ) - > _nbWordsCodeWrite = 0 ; // #### TODO
data ( ) - > _nbWordsCodeWrite = 0 ; // #### TODO
data ( ) - > _nbWordsCodeRowErase = 0 ; // #### TODO
data ( ) - > _nbWordsCodeRowErase = 0 ; // #### TODO
}
}
} else if ( ! wwa . isEmpty ( ) | | ! wea . isEmpty ( ) ) qFatal( " word align should not be defined for this memory range " ) ;
} else if ( ! wwa . isEmpty ( ) | | ! wea . isEmpty ( ) ) t qFatal( " word align should not be defined for this memory range " ) ;
return true ;
return true ;
}
}
@ -100,35 +100,35 @@ void processName(const Pic::Config::Mask &cmask, BitValue pmask, Pic::Config::Va
TQStringList & cnames = cvalue . configNames [ Pic : : ConfigNameType : : Default ] ;
TQStringList & cnames = cvalue . configNames [ Pic : : ConfigNameType : : Default ] ;
if ( cvalue . name = = " invalid " ) {
if ( cvalue . name = = " invalid " ) {
cvalue . name = TQString ( ) ;
cvalue . name = TQString ( ) ;
if ( ! cnames . isEmpty ( ) ) qFatal( TQString ( " No cname should be defined for invalid value in mask %1 " ) . arg ( cmask . name ) ) ;
if ( ! cnames . isEmpty ( ) ) t qFatal( TQString ( " No cname should be defined for invalid value in mask %1 " ) . arg ( cmask . name ) ) ;
return ;
return ;
}
}
if ( cvalue . name . isEmpty ( ) ) qFatal( TQString ( " Empty value name in mask %1 " ) . arg ( cmask . name ) ) ;
if ( cvalue . name . isEmpty ( ) ) t qFatal( TQString ( " Empty value name in mask %1 " ) . arg ( cmask . name ) ) ;
if ( cmask . value . isInside ( pmask ) ) { // protected bits
if ( cmask . value . isInside ( pmask ) ) { // protected bits
if ( ! cnames . isEmpty ( ) ) qFatal( TQString ( " Config name should be null for protected config mask \" %1 \" " ) . arg ( cmask . name ) ) ;
if ( ! cnames . isEmpty ( ) ) t qFatal( TQString ( " Config name should be null for protected config mask \" %1 \" " ) . arg ( cmask . name ) ) ;
} else {
} else {
if ( cnames . isEmpty ( ) & & cmask . name ! = " BSSEC " & & cmask . name ! = " BSSIZ " & & cmask . name ! = " SSSEC " & & cmask . name ! = " SSSIZ " ) {
if ( cnames . isEmpty ( ) & & cmask . name ! = " BSSEC " & & cmask . name ! = " BSSIZ " & & cmask . name ! = " SSSEC " & & cmask . name ! = " SSSIZ " ) {
// ### FIXME: 18J 24H 30F1010/202X
// ### FIXME: 18J 24H 30F1010/202X
if ( data ( ) - > architecture ( ) ! = Pic : : Architecture : : P18J & & data ( ) - > architecture ( ) ! = Pic : : Architecture : : P24H
if ( data ( ) - > architecture ( ) ! = Pic : : Architecture : : P18J & & data ( ) - > architecture ( ) ! = Pic : : Architecture : : P24H
& & data ( ) - > architecture ( ) ! = Pic : : Architecture : : P24F & & data ( ) - > architecture ( ) ! = Pic : : Architecture : : P33F
& & data ( ) - > architecture ( ) ! = Pic : : Architecture : : P24F & & data ( ) - > architecture ( ) ! = Pic : : Architecture : : P33F
& & data ( ) - > name ( ) ! = " 30F1010 " & & data ( ) - > name ( ) ! = " 30F2020 " & & data ( ) - > name ( ) ! = " 30F2023 " )
& & data ( ) - > name ( ) ! = " 30F1010 " & & data ( ) - > name ( ) ! = " 30F2020 " & & data ( ) - > name ( ) ! = " 30F2023 " )
qFatal( TQString ( " cname not defined for \" %1 \" (%2) " ) . arg ( cvalue . name ) . arg ( cmask . name ) ) ;
t qFatal( TQString ( " cname not defined for \" %1 \" (%2) " ) . arg ( cvalue . name ) . arg ( cmask . name ) ) ;
}
}
if ( cnames . count ( ) = = 1 & & cnames [ 0 ] = = " _ " ) cnames . clear ( ) ;
if ( cnames . count ( ) = = 1 & & cnames [ 0 ] = = " _ " ) cnames . clear ( ) ;
for ( uint i = 0 ; i < uint ( cnames . count ( ) ) ; i + + ) {
for ( uint i = 0 ; i < uint ( cnames . count ( ) ) ; i + + ) {
if ( cnames [ i ] . startsWith ( " 0x " ) ) {
if ( cnames [ i ] . startsWith ( " 0x " ) ) {
if ( cnames . count ( ) ! = 1 ) qFatal( " Hex cname cannot be combined " ) ;
if ( cnames . count ( ) ! = 1 ) t qFatal( " Hex cname cannot be combined " ) ;
bool ok ;
bool ok ;
BitValue v = fromHexLabel ( cnames [ i ] , & ok ) ;
BitValue v = fromHexLabel ( cnames [ i ] , & ok ) ;
uint nbChars = data ( ) - > nbCharsWord ( MemoryRangeType : : Config ) ;
uint nbChars = data ( ) - > nbCharsWord ( MemoryRangeType : : Config ) ;
BitValue mask = cmask . value . complementInMask ( maxValue ( NumberBase : : Hex , nbChars ) ) ;
BitValue mask = cmask . value . complementInMask ( maxValue ( NumberBase : : Hex , nbChars ) ) ;
if ( ok & & v = = ( mask | cvalue . value ) ) continue ;
if ( ok & & v = = ( mask | cvalue . value ) ) continue ;
} else if ( XOR ( cnames [ i ] . startsWith ( " _ " ) , data ( ) - > architecture ( ) = = Pic : : Architecture : : P30F ) ) continue ;
} else if ( XOR ( cnames [ i ] . startsWith ( " _ " ) , data ( ) - > architecture ( ) = = Pic : : Architecture : : P30F ) ) continue ;
qFatal( TQString ( " Invalid config name for \" %1 \" / \" %2 \" " ) . arg ( cmask . name ) . arg ( cvalue . name ) ) ;
t qFatal( TQString ( " Invalid config name for \" %1 \" / \" %2 \" " ) . arg ( cmask . name ) . arg ( cvalue . name ) ) ;
}
}
TQStringList & ecnames = cvalue . configNames [ Pic : : ConfigNameType : : Extra ] ;
TQStringList & ecnames = cvalue . configNames [ Pic : : ConfigNameType : : Extra ] ;
for ( uint i = 0 ; i < uint ( ecnames . count ( ) ) ; i + + )
for ( uint i = 0 ; i < uint ( ecnames . count ( ) ) ; i + + )
if ( ecnames [ i ] [ 0 ] ! = ' _ ' ) qFatal( TQString ( " Invalid extra config name for %1 " ) . arg ( cvalue . name ) ) ;
if ( ecnames [ i ] [ 0 ] ! = ' _ ' ) t qFatal( TQString ( " Invalid extra config name for %1 " ) . arg ( cvalue . name ) ) ;
}
}
}
}
@ -140,30 +140,30 @@ Pic::Config::Mask toConfigMask(TQDomElement mask, BitValue pmask)
TQMap < Pic : : ConfigNameType , TQStringList > defConfigNames ;
TQMap < Pic : : ConfigNameType , TQStringList > defConfigNames ;
Config : : Mask cmask ;
Config : : Mask cmask ;
cmask . name = mask . attribute ( " name " ) ;
cmask . name = mask . attribute ( " name " ) ;
if ( ! Config : : hasMaskName ( cmask . name ) ) qFatal( TQString ( " Unknown mask name %1 " ) . arg ( cmask . name ) ) ;
if ( ! Config : : hasMaskName ( cmask . name ) ) t qFatal( TQString ( " Unknown mask name %1 " ) . arg ( cmask . name ) ) ;
cmask . value = fromHexLabel ( mask . attribute ( " value " ) , nbChars , & ok ) ;
cmask . value = fromHexLabel ( mask . attribute ( " value " ) , nbChars , & ok ) ;
if ( ! ok | | cmask . value = = 0 | | cmask . value > data ( ) - > mask ( MemoryRangeType : : Config ) )
if ( ! ok | | cmask . value = = 0 | | cmask . value > data ( ) - > mask ( MemoryRangeType : : Config ) )
qFatal( TQString ( " Malformed mask value in mask %1 " ) . arg ( mask . attribute ( " name " ) ) ) ;
t qFatal( TQString ( " Malformed mask value in mask %1 " ) . arg ( mask . attribute ( " name " ) ) ) ;
//TQStringList names;
//TQStringList names;
TQDomNode child = mask . firstChild ( ) ;
TQDomNode child = mask . firstChild ( ) ;
while ( ! child . isNull ( ) ) {
while ( ! child . isNull ( ) ) {
TQDomElement value = child . toElement ( ) ;
TQDomElement value = child . toElement ( ) ;
child = child . nextSibling ( ) ;
child = child . nextSibling ( ) ;
if ( value . isNull ( ) ) continue ;
if ( value . isNull ( ) ) continue ;
if ( value . nodeName ( ) ! = " value " ) qFatal( TQString ( " Non value child in mask %1 " ) . arg ( cmask . name ) ) ;
if ( value . nodeName ( ) ! = " value " ) t qFatal( TQString ( " Non value child in mask %1 " ) . arg ( cmask . name ) ) ;
if ( value . attribute ( " value " ) = = " default " ) {
if ( value . attribute ( " value " ) = = " default " ) {
if ( ! defName . isEmpty ( ) ) qFatal( TQString ( " Default value already defined for mask %1 " ) . arg ( cmask . name ) ) ;
if ( ! defName . isEmpty ( ) ) t qFatal( TQString ( " Default value already defined for mask %1 " ) . arg ( cmask . name ) ) ;
defName = value . attribute ( " name " ) ;
defName = value . attribute ( " name " ) ;
//if ( names.contains(defName) ) qFatal(TQString("Value name duplicated in mask %1").arg(cmask.name));
//if ( names.contains(defName) ) t qFatal(TQString("Value name duplicated in mask %1").arg(cmask.name));
//names.append(defName);
//names.append(defName);
FOR_EACH ( Pic : : ConfigNameType , type ) defConfigNames [ type ] = TQStringList : : split ( ' ' , value . attribute ( type . data ( ) . key ) ) ;
FOR_EACH ( Pic : : ConfigNameType , type ) defConfigNames [ type ] = TQStringList : : split ( ' ' , value . attribute ( type . data ( ) . key ) ) ;
continue ;
continue ;
}
}
Config : : Value cvalue ;
Config : : Value cvalue ;
cvalue . value = fromHexLabel ( value . attribute ( " value " ) , nbChars , & ok ) ;
cvalue . value = fromHexLabel ( value . attribute ( " value " ) , nbChars , & ok ) ;
if ( ! ok | | ! cvalue . value . isInside ( cmask . value ) ) qFatal( TQString ( " Malformed value in mask %1 " ) . arg ( cmask . name ) ) ;
if ( ! ok | | ! cvalue . value . isInside ( cmask . value ) ) t qFatal( TQString ( " Malformed value in mask %1 " ) . arg ( cmask . name ) ) ;
cvalue . name = value . attribute ( " name " ) ;
cvalue . name = value . attribute ( " name " ) ;
//if ( names.contains(cvalue.name) ) qFatal(TQString("Value name duplicated in mask %1").arg(cmask.name));
//if ( names.contains(cvalue.name) ) t qFatal(TQString("Value name duplicated in mask %1").arg(cmask.name));
//names.append(cvalue.name);
//names.append(cvalue.name);
FOR_EACH ( Pic : : ConfigNameType , type ) cvalue . configNames [ type ] = TQStringList : : split ( ' ' , value . attribute ( type . data ( ) . key ) ) ;
FOR_EACH ( Pic : : ConfigNameType , type ) cvalue . configNames [ type ] = TQStringList : : split ( ' ' , value . attribute ( type . data ( ) . key ) ) ;
processName ( cmask , pmask , cvalue ) ;
processName ( cmask , pmask , cvalue ) ;
@ -183,7 +183,7 @@ Pic::Config::Mask toConfigMask(TQDomElement mask, BitValue pmask)
processName ( cmask , pmask , cvalue ) ;
processName ( cmask , pmask , cvalue ) ;
cmask . values . append ( cvalue ) ;
cmask . values . append ( cvalue ) ;
}
}
if ( nb < = 1 ) qFatal( TQString ( " Default value used less than twice in mask %1 " ) . arg ( cmask . name ) ) ;
if ( nb < = 1 ) t qFatal( TQString ( " Default value used less than twice in mask %1 " ) . arg ( cmask . name ) ) ;
}
}
qHeapSort ( cmask . values ) ;
qHeapSort ( cmask . values ) ;
return cmask ;
return cmask ;
@ -194,34 +194,34 @@ Pic::Config::Word toConfigWord(TQDomElement config)
uint nbChars = data ( ) - > nbCharsWord ( MemoryRangeType : : Config ) ;
uint nbChars = data ( ) - > nbCharsWord ( MemoryRangeType : : Config ) ;
Config : : Word cword ;
Config : : Word cword ;
cword . name = config . attribute ( " name " ) ;
cword . name = config . attribute ( " name " ) ;
if ( cword . name . isNull ( ) ) qFatal( " Config word name not specified. " ) ;
if ( cword . name . isNull ( ) ) t qFatal( " Config word name not specified. " ) ;
bool ok ;
bool ok ;
cword . wmask = fromHexLabel ( config . attribute ( " wmask " ) , nbChars , & ok ) ;
cword . wmask = fromHexLabel ( config . attribute ( " wmask " ) , nbChars , & ok ) ;
BitValue gmask = data ( ) - > mask ( MemoryRangeType : : Config ) ;
BitValue gmask = data ( ) - > mask ( MemoryRangeType : : Config ) ;
if ( ! ok | | cword . wmask > gmask ) qFatal( TQString ( " Missing or malformed config wmask \" %1 \" " ) . arg ( config . attribute ( " wmask " ) ) ) ;
if ( ! ok | | cword . wmask > gmask ) t qFatal( TQString ( " Missing or malformed config wmask \" %1 \" " ) . arg ( config . attribute ( " wmask " ) ) ) ;
cword . bvalue = fromHexLabel ( config . attribute ( " bvalue " ) , nbChars , & ok ) ;
cword . bvalue = fromHexLabel ( config . attribute ( " bvalue " ) , nbChars , & ok ) ;
if ( ! ok ) qFatal( TQString ( " Missing or malformed config bvalue \" %1 \" " ) . arg ( config . attribute ( " bvalue " ) ) ) ;
if ( ! ok ) t qFatal( TQString ( " Missing or malformed config bvalue \" %1 \" " ) . arg ( config . attribute ( " bvalue " ) ) ) ;
if ( config . attribute ( " pmask " ) . isEmpty ( ) ) cword . pmask = 0 ;
if ( config . attribute ( " pmask " ) . isEmpty ( ) ) cword . pmask = 0 ;
else {
else {
bool ok ;
bool ok ;
cword . pmask = fromHexLabel ( config . attribute ( " pmask " ) , nbChars , & ok ) ;
cword . pmask = fromHexLabel ( config . attribute ( " pmask " ) , nbChars , & ok ) ;
if ( ! ok | | cword . pmask > gmask ) qFatal( " Missing or malformed config pmask " ) ;
if ( ! ok | | cword . pmask > gmask ) t qFatal( " Missing or malformed config pmask " ) ;
}
}
cword . ignoredCNames = TQStringList : : split ( ' ' , config . attribute ( " icnames " ) ) ;
cword . ignoredCNames = TQStringList : : split ( ' ' , config . attribute ( " icnames " ) ) ;
for ( uint i = 0 ; i < uint ( cword . ignoredCNames . count ( ) ) ; i + + )
for ( uint i = 0 ; i < uint ( cword . ignoredCNames . count ( ) ) ; i + + )
if ( cword . ignoredCNames [ i ] [ 0 ] ! = ' _ ' ) qFatal( TQString ( " Invalid ignored config name for %1 " ) . arg ( cword . name ) ) ;
if ( cword . ignoredCNames [ i ] [ 0 ] ! = ' _ ' ) t qFatal( TQString ( " Invalid ignored config name for %1 " ) . arg ( cword . name ) ) ;
TQDomNode child = config . firstChild ( ) ;
TQDomNode child = config . firstChild ( ) ;
while ( ! child . isNull ( ) ) {
while ( ! child . isNull ( ) ) {
TQDomElement mask = child . toElement ( ) ;
TQDomElement mask = child . toElement ( ) ;
child = child . nextSibling ( ) ;
child = child . nextSibling ( ) ;
if ( mask . isNull ( ) ) continue ;
if ( mask . isNull ( ) ) continue ;
if ( mask . nodeName ( ) ! = " mask " ) qFatal( TQString ( " Non mask child in config %1 " ) . arg ( cword . name ) ) ;
if ( mask . nodeName ( ) ! = " mask " ) t qFatal( TQString ( " Non mask child in config %1 " ) . arg ( cword . name ) ) ;
if ( mask . attribute ( " name " ) . isEmpty ( ) ) qFatal( TQString ( " Empty mask name in config %1 " ) . arg ( cword . name ) ) ;
if ( mask . attribute ( " name " ) . isEmpty ( ) ) t qFatal( TQString ( " Empty mask name in config %1 " ) . arg ( cword . name ) ) ;
Config : : Mask cmask = toConfigMask ( mask , cword . pmask ) ;
Config : : Mask cmask = toConfigMask ( mask , cword . pmask ) ;
if ( ! cmask . value . isInside ( gmask ) ) qFatal( TQString ( " Mask value not inside mask in config %1 " ) . arg ( cword . name ) ) ;
if ( ! cmask . value . isInside ( gmask ) ) t qFatal( TQString ( " Mask value not inside mask in config %1 " ) . arg ( cword . name ) ) ;
for ( uint i = 0 ; i < uint ( cword . masks . count ( ) ) ; i + + ) {
for ( uint i = 0 ; i < uint ( cword . masks . count ( ) ) ; i + + ) {
if ( cword . masks [ i ] . name = = cmask . name ) qFatal( TQString ( " Duplicated mask name %1 in config %2 " ) . arg ( cmask . name ) . arg ( cword . name ) ) ;
if ( cword . masks [ i ] . name = = cmask . name ) t qFatal( TQString ( " Duplicated mask name %1 in config %2 " ) . arg ( cmask . name ) . arg ( cword . name ) ) ;
if ( cmask . value . isOverlapping ( cword . masks [ i ] . value ) ) qFatal( TQString ( " Overlapping masks in config %1 " ) . arg ( cword . name ) ) ;
if ( cmask . value . isOverlapping ( cword . masks [ i ] . value ) ) t qFatal( TQString ( " Overlapping masks in config %1 " ) . arg ( cword . name ) ) ;
}
}
cword . masks . append ( cmask ) ;
cword . masks . append ( cmask ) ;
}
}
@ -233,11 +233,11 @@ Pic::Config::Word toConfigWord(TQDomElement config)
} else {
} else {
bool ok ;
bool ok ;
cword . cmask = fromHexLabel ( config . attribute ( " cmask " ) , nbChars , & ok ) ;
cword . cmask = fromHexLabel ( config . attribute ( " cmask " ) , nbChars , & ok ) ;
if ( ! ok | | cword . cmask > gmask ) qFatal( " Missing or malformed config cmask " ) ;
if ( ! ok | | cword . cmask > gmask ) t qFatal( " Missing or malformed config cmask " ) ;
//if ( data()->_architecture==Pic::Architecture::P30X &&cword.cmask==cword.wmask ) qFatal(TQString("Redundant cmask in %1").arg(cword.name));
//if ( data()->_architecture==Pic::Architecture::P30X &&cword.cmask==cword.wmask ) t qFatal(TQString("Redundant cmask in %1").arg(cword.name));
if ( cword . cmask = = mask ) qFatal( TQString ( " Redundant cmask in %1 " ) . arg ( cword . name ) ) ;
if ( cword . cmask = = mask ) t qFatal( TQString ( " Redundant cmask in %1 " ) . arg ( cword . name ) ) ;
}
}
if ( ! cword . pmask . isInside ( cword . usedMask ( ) ) ) qFatal( " pmask should be inside or'ed mask values. " ) ;
if ( ! cword . pmask . isInside ( cword . usedMask ( ) ) ) t qFatal( " pmask should be inside or'ed mask values. " ) ;
return cword ;
return cword ;
}
}
@ -252,14 +252,14 @@ TQValueVector<Pic::Config::Word> getConfigWords(TQDomElement element)
if ( config . isNull ( ) | | config . nodeName ( ) ! = " config " ) continue ;
if ( config . isNull ( ) | | config . nodeName ( ) ! = " config " ) continue ;
bool ok ;
bool ok ;
uint offset = fromHexLabel ( config . attribute ( " offset " ) , 1 , & ok ) ;
uint offset = fromHexLabel ( config . attribute ( " offset " ) , 1 , & ok ) ;
if ( ! ok ) qFatal( " Missing or malformed config offset " ) ;
if ( ! ok ) t qFatal( " Missing or malformed config offset " ) ;
if ( ( offset % data ( ) - > addressIncrement ( MemoryRangeType : : Config ) ) ! = 0 ) qFatal( " Config offset not aligned " ) ;
if ( ( offset % data ( ) - > addressIncrement ( MemoryRangeType : : Config ) ) ! = 0 ) t qFatal( " Config offset not aligned " ) ;
offset / = data ( ) - > addressIncrement ( MemoryRangeType : : Config ) ;
offset / = data ( ) - > addressIncrement ( MemoryRangeType : : Config ) ;
if ( offset > = nbWords ) qFatal( TQString ( " Offset too big %1/%2 " ) . arg ( offset ) . arg ( nbWords ) ) ;
if ( offset > = nbWords ) t qFatal( TQString ( " Offset too big %1/%2 " ) . arg ( offset ) . arg ( nbWords ) ) ;
if ( ! configWords [ offset ] . name . isNull ( ) ) qFatal( TQString ( " Config offset %1 is duplicated " ) . arg ( offset ) ) ;
if ( ! configWords [ offset ] . name . isNull ( ) ) t qFatal( TQString ( " Config offset %1 is duplicated " ) . arg ( offset ) ) ;
for ( uint i = 0 ; i < nbWords ; i + + ) {
for ( uint i = 0 ; i < nbWords ; i + + ) {
if ( ! configWords [ i ] . name . isNull ( ) & & configWords [ i ] . name = = config . attribute ( " name " ) )
if ( ! configWords [ i ] . name . isNull ( ) & & configWords [ i ] . name = = config . attribute ( " name " ) )
qFatal( TQString ( " Duplicated config name %1 " ) . arg ( configWords [ i ] . name ) ) ;
t qFatal( TQString ( " Duplicated config name %1 " ) . arg ( configWords [ i ] . name ) ) ;
}
}
configWords [ offset ] = toConfigWord ( config ) ;
configWords [ offset ] = toConfigWord ( config ) ;
}
}
@ -279,40 +279,40 @@ TQString getChecksumData(TQDomElement checksum)
bool ok ;
bool ok ;
uint nb = valueName . toUInt ( & ok ) ;
uint nb = valueName . toUInt ( & ok ) ;
uint max = ( protection . hasBootBlock ( ) ? 1 : 0 ) + protection . nbBlocks ( ) ;
uint max = ( protection . hasBootBlock ( ) ? 1 : 0 ) + protection . nbBlocks ( ) ;
if ( ! ok | | nb > max ) qFatal( " Invalid number of protected blocks for checksum " ) ;
if ( ! ok | | nb > max ) t qFatal( " Invalid number of protected blocks for checksum " ) ;
if ( nb > 0 ) cdata . protectedMaskNames + = " CPB " ;
if ( nb > 0 ) cdata . protectedMaskNames + = " CPB " ;
for ( uint i = 1 ; i < nb ; i + + ) cdata . protectedMaskNames + = " CP_ " + TQString : : number ( i - 1 ) ;
for ( uint i = 1 ; i < nb ; i + + ) cdata . protectedMaskNames + = " CP_ " + TQString : : number ( i - 1 ) ;
cdata . bbsize = checksum . attribute ( " bbsize " ) ;
cdata . bbsize = checksum . attribute ( " bbsize " ) ;
const Config : : Mask * mask = data ( ) - > _config - > findMask ( protection . bootSizeMaskName ( ) ) ;
const Config : : Mask * mask = data ( ) - > _config - > findMask ( protection . bootSizeMaskName ( ) ) ;
if ( mask = = 0 ) {
if ( mask = = 0 ) {
if ( ! cdata . bbsize . isEmpty ( ) ) qFatal( " Device does not have a variable boot size (no \" bbsize \" allowed in checksum) " ) ;
if ( ! cdata . bbsize . isEmpty ( ) ) t qFatal( " Device does not have a variable boot size (no \" bbsize \" allowed in checksum) " ) ;
} else if ( cdata . bbsize . isEmpty ( ) ) {
} else if ( cdata . bbsize . isEmpty ( ) ) {
if ( nb = = 1 ) qFatal( " \" bbsize \" should be define in checksum for \" protected_blocks \" ==1 " ) ;
if ( nb = = 1 ) t qFatal( " \" bbsize \" should be define in checksum for \" protected_blocks \" ==1 " ) ;
} else {
} else {
const Config : : Value * value = data ( ) - > _config - > findValue ( protection . bootSizeMaskName ( ) , cdata . bbsize ) ;
const Config : : Value * value = data ( ) - > _config - > findValue ( protection . bootSizeMaskName ( ) , cdata . bbsize ) ;
if ( value = = 0 ) qFatal( " Invalid \" bbsize \" in checksum " ) ;
if ( value = = 0 ) t qFatal( " Invalid \" bbsize \" in checksum " ) ;
valueName + = " _ " + cdata . bbsize ;
valueName + = " _ " + cdata . bbsize ;
}
}
} else {
} else {
valueName = checksum . attribute ( " protected " ) ;
valueName = checksum . attribute ( " protected " ) ;
if ( protection . family ( ) = = Protection : : NoProtection & & ! valueName . isEmpty ( ) )
if ( protection . family ( ) = = Protection : : NoProtection & & ! valueName . isEmpty ( ) )
qFatal( " Checksum protected attribute for device with no code protection " ) ;
t qFatal( " Checksum protected attribute for device with no code protection " ) ;
}
}
if ( data ( ) - > _checksums . contains ( valueName ) ) qFatal( " Duplicate checksum protected range " ) ;
if ( data ( ) - > _checksums . contains ( valueName ) ) t qFatal( " Duplicate checksum protected range " ) ;
TQString s = checksum . attribute ( " constant " ) ;
TQString s = checksum . attribute ( " constant " ) ;
if ( s . isEmpty ( ) ) cdata . constant = 0x0000 ;
if ( s . isEmpty ( ) ) cdata . constant = 0x0000 ;
else {
else {
bool ok ;
bool ok ;
cdata . constant = fromHexLabel ( s , 4 , & ok ) ;
cdata . constant = fromHexLabel ( s , 4 , & ok ) ;
if ( ! ok ) qFatal( " Malformed checksum constant " ) ;
if ( ! ok ) t qFatal( " Malformed checksum constant " ) ;
}
}
s = checksum . attribute ( " type " ) ;
s = checksum . attribute ( " type " ) ;
if ( s . isEmpty ( ) ) cdata . algorithm = Checksum : : Algorithm : : Normal ;
if ( s . isEmpty ( ) ) cdata . algorithm = Checksum : : Algorithm : : Normal ;
else {
else {
cdata . algorithm = Checksum : : Algorithm : : fromKey ( s ) ;
cdata . algorithm = Checksum : : Algorithm : : fromKey ( s ) ;
if ( cdata . algorithm = = Checksum : : Algorithm : : Nb_Types ) qFatal( " Unrecognized checksum algorithm " ) ;
if ( cdata . algorithm = = Checksum : : Algorithm : : Nb_Types ) t qFatal( " Unrecognized checksum algorithm " ) ;
}
}
s = checksum . attribute ( " mprotected " ) ;
s = checksum . attribute ( " mprotected " ) ;
@ -320,32 +320,32 @@ TQString getChecksumData(TQDomElement checksum)
TQStringList list = TQStringList : : split ( " " , s ) ;
TQStringList list = TQStringList : : split ( " " , s ) ;
for ( uint i = 0 ; i < uint ( list . count ( ) ) ; i + + ) {
for ( uint i = 0 ; i < uint ( list . count ( ) ) ; i + + ) {
const Config : : Mask * mask = data ( ) - > config ( ) . findMask ( list [ i ] ) ;
const Config : : Mask * mask = data ( ) - > config ( ) . findMask ( list [ i ] ) ;
if ( mask = = 0 ) qFatal( TQString ( " Not valid mask name for \" protected \" tag in checksum: %1 " ) . arg ( list [ i ] ) ) ;
if ( mask = = 0 ) t qFatal( TQString ( " Not valid mask name for \" protected \" tag in checksum: %1 " ) . arg ( list [ i ] ) ) ;
if ( mask - > values . count ( ) = = 2 ) continue ;
if ( mask - > values . count ( ) = = 2 ) continue ;
for ( uint k = 0 ; k < uint ( mask - > values . count ( ) ) ; k + + ) {
for ( uint k = 0 ; k < uint ( mask - > values . count ( ) ) ; k + + ) {
TQString valueName = mask - > values [ k ] . name ;
TQString valueName = mask - > values [ k ] . name ;
if ( valueName . isEmpty ( ) ) continue ;
if ( valueName . isEmpty ( ) ) continue ;
if ( ! protection . isNoneProtectedValueName ( valueName ) & & ! protection . isAllProtectedValueName ( valueName ) )
if ( ! protection . isNoneProtectedValueName ( valueName ) & & ! protection . isAllProtectedValueName ( valueName ) )
qFatal( TQString ( " Not switch protection from mask name for \" protected \" tag in checksum: %1 " ) . arg ( list [ i ] ) ) ;
t qFatal( TQString ( " Not switch protection from mask name for \" protected \" tag in checksum: %1 " ) . arg ( list [ i ] ) ) ;
}
}
}
}
cdata . protectedMaskNames = list ;
cdata . protectedMaskNames = list ;
}
}
s = checksum . attribute ( " bchecksum " ) ;
s = checksum . attribute ( " bchecksum " ) ;
if ( s . isEmpty ( ) ) qFatal( " No blank checksum " ) ;
if ( s . isEmpty ( ) ) t qFatal( " No blank checksum " ) ;
else {
else {
bool ok ;
bool ok ;
cdata . blankChecksum = fromHexLabel ( s , 4 , & ok ) ;
cdata . blankChecksum = fromHexLabel ( s , 4 , & ok ) ;
if ( ! ok ) qFatal( " Malformed blank checksum " ) ;
if ( ! ok ) t qFatal( " Malformed blank checksum " ) ;
}
}
s = checksum . attribute ( " cchecksum " ) ;
s = checksum . attribute ( " cchecksum " ) ;
if ( s . isEmpty ( ) ) qFatal( " No check checksum " ) ;
if ( s . isEmpty ( ) ) t qFatal( " No check checksum " ) ;
else {
else {
bool ok ;
bool ok ;
cdata . checkChecksum = fromHexLabel ( s , 4 , & ok ) ;
cdata . checkChecksum = fromHexLabel ( s , 4 , & ok ) ;
if ( ! ok ) qFatal( " Malformed check checksum " ) ;
if ( ! ok ) t qFatal( " Malformed check checksum " ) ;
}
}
data ( ) - > _checksums [ valueName ] = cdata ;
data ( ) - > _checksums [ valueName ] = cdata ;
@ -358,24 +358,24 @@ virtual void processDevice(TQDomElement device)
TQString arch = device . attribute ( " architecture " ) ;
TQString arch = device . attribute ( " architecture " ) ;
data ( ) - > _architecture = Architecture : : fromKey ( arch ) ;
data ( ) - > _architecture = Architecture : : fromKey ( arch ) ;
if ( data ( ) - > _architecture = = Architecture : : Nb_Types ) qFatal( TQString ( " Unrecognized architecture \" %1 \" " ) . arg ( arch ) ) ;
if ( data ( ) - > _architecture = = Architecture : : Nb_Types ) t qFatal( TQString ( " Unrecognized architecture \" %1 \" " ) . arg ( arch ) ) ;
if ( ( data ( ) - > _architecture = = Architecture : : P18F & & data ( ) - > _name . contains ( " C " ) )
if ( ( data ( ) - > _architecture = = Architecture : : P18F & & data ( ) - > _name . contains ( " C " ) )
| | ( data ( ) - > _architecture = = Architecture : : P18F & & data ( ) - > _name . contains ( " J " ) ) ) qFatal( " Not matching family " ) ;
| | ( data ( ) - > _architecture = = Architecture : : P18F & & data ( ) - > _name . contains ( " J " ) ) ) t qFatal( " Not matching family " ) ;
bool ok ;
bool ok ;
TQString pc = device . attribute ( " pc " ) ;
TQString pc = device . attribute ( " pc " ) ;
data ( ) - > _nbBitsPC = data ( ) - > _architecture . data ( ) . nbBitsPC ;
data ( ) - > _nbBitsPC = data ( ) - > _architecture . data ( ) . nbBitsPC ;
if ( data ( ) - > _nbBitsPC = = 0 ) {
if ( data ( ) - > _nbBitsPC = = 0 ) {
data ( ) - > _nbBitsPC = pc . toUInt ( & ok ) ;
data ( ) - > _nbBitsPC = pc . toUInt ( & ok ) ;
if ( ! ok | | data ( ) - > _nbBitsPC = = 0 ) qFatal( " Malformed or missing PC " ) ;
if ( ! ok | | data ( ) - > _nbBitsPC = = 0 ) t qFatal( " Malformed or missing PC " ) ;
} else if ( ! pc . isEmpty ( ) ) qFatal( " No PC should be provided for this device architecture " ) ;
} else if ( ! pc . isEmpty ( ) ) t qFatal( " No PC should be provided for this device architecture " ) ;
TQString sw = device . attribute ( " self_write " ) ;
TQString sw = device . attribute ( " self_write " ) ;
data ( ) - > _selfWrite = ( data ( ) - > _memoryTechnology ! = Device : : MemoryTechnology : : Flash ? SelfWrite : : No : data ( ) - > _architecture . data ( ) . selfWrite ) ;
data ( ) - > _selfWrite = ( data ( ) - > _memoryTechnology ! = Device : : MemoryTechnology : : Flash ? SelfWrite : : No : data ( ) - > _architecture . data ( ) . selfWrite ) ;
if ( data ( ) - > _selfWrite = = SelfWrite : : Nb_Types ) {
if ( data ( ) - > _selfWrite = = SelfWrite : : Nb_Types ) {
data ( ) - > _selfWrite = SelfWrite : : fromKey ( sw ) ;
data ( ) - > _selfWrite = SelfWrite : : fromKey ( sw ) ;
if ( data ( ) - > _selfWrite = = SelfWrite : : Nb_Types ) qFatal( " Malformed or missing self-write field " ) ;
if ( data ( ) - > _selfWrite = = SelfWrite : : Nb_Types ) t qFatal( " Malformed or missing self-write field " ) ;
} else if ( ! sw . isEmpty ( ) ) qFatal( " Self-write is set for the whole family or non-flash device " ) ;
} else if ( ! sw . isEmpty ( ) ) t qFatal( " Self-write is set for the whole family or non-flash device " ) ;
// device ids
// device ids
FOR_EACH ( Device : : Special , special ) {
FOR_EACH ( Device : : Special , special ) {
@ -385,7 +385,7 @@ virtual void processDevice(TQDomElement device)
if ( special = = Device : : Special : : Normal ) data ( ) - > _ids [ special ] = 0x0000 ;
if ( special = = Device : : Special : : Normal ) data ( ) - > _ids [ special ] = 0x0000 ;
} else {
} else {
data ( ) - > _ids [ special ] = fromHexLabel ( id , 4 , & ok ) ;
data ( ) - > _ids [ special ] = fromHexLabel ( id , 4 , & ok ) ;
if ( ! ok ) qFatal( " Malformed id " ) ;
if ( ! ok ) t qFatal( " Malformed id " ) ;
}
}
}
}
@ -396,16 +396,16 @@ virtual void processDevice(TQDomElement device)
if ( ! getVoltages ( vtype , device ) ) {
if ( ! getVoltages ( vtype , device ) ) {
switch ( vtype . type ( ) ) {
switch ( vtype . type ( ) ) {
case ProgVoltageType : : Vpp :
case ProgVoltageType : : Vpp :
case ProgVoltageType : : VddBulkErase : qFatal( TQString ( " Voltage \" %1 \" not defined " ) . arg ( vtype . key ( ) ) ) ;
case ProgVoltageType : : VddBulkErase : t qFatal( TQString ( " Voltage \" %1 \" not defined " ) . arg ( vtype . key ( ) ) ) ;
case ProgVoltageType : : VddWrite : data ( ) - > _voltages [ ProgVoltageType : : VddWrite ] = data ( ) - > _voltages [ ProgVoltageType : : VddBulkErase ] ; break ;
case ProgVoltageType : : VddWrite : data ( ) - > _voltages [ ProgVoltageType : : VddWrite ] = data ( ) - > _voltages [ ProgVoltageType : : VddBulkErase ] ; break ;
case ProgVoltageType : : Nb_Types : Q_ASSERT ( false ) ; break ;
case ProgVoltageType : : Nb_Types : Q_ASSERT ( false ) ; break ;
}
}
}
}
}
}
//if ( data()->vddMin()>data()->_voltages[ProgVoltageType::VddWrite].min ) qFatal("Vdd min higher than VddWrite min");
//if ( data()->vddMin()>data()->_voltages[ProgVoltageType::VddWrite].min ) t qFatal("Vdd min higher than VddWrite min");
//if ( data()->vddMax()<data()->_voltages[ProgVoltageType::VddWrite].max ) qFatal("Vdd max lower than VddWrite max");
//if ( data()->vddMax()<data()->_voltages[ProgVoltageType::VddWrite].max ) t qFatal("Vdd max lower than VddWrite max");
if ( data ( ) - > _voltages [ ProgVoltageType : : VddWrite ] . min > data ( ) - > _voltages [ ProgVoltageType : : VddBulkErase ] . min ) qFatal( " VddWrite min higher than VddBulkErase min " ) ;
if ( data ( ) - > _voltages [ ProgVoltageType : : VddWrite ] . min > data ( ) - > _voltages [ ProgVoltageType : : VddBulkErase ] . min ) t qFatal( " VddWrite min higher than VddBulkErase min " ) ;
if ( data ( ) - > _voltages [ ProgVoltageType : : VddWrite ] . max < data ( ) - > _voltages [ ProgVoltageType : : VddBulkErase ] . max ) qFatal( " VddWrite max lower than VddBulkErase max " ) ;
if ( data ( ) - > _voltages [ ProgVoltageType : : VddWrite ] . max < data ( ) - > _voltages [ ProgVoltageType : : VddBulkErase ] . max ) t qFatal( " VddWrite max lower than VddBulkErase max " ) ;
checkTagNames ( device , " voltages " , names ) ;
checkTagNames ( device , " voltages " , names ) ;
// memory ranges
// memory ranges
@ -426,12 +426,12 @@ virtual void processDevice(TQDomElement device)
Address start2 = data ( ) - > _ranges [ i ] . start + data ( ) - > _ranges [ i ] . hexFileOffset ;
Address start2 = data ( ) - > _ranges [ i ] . start + data ( ) - > _ranges [ i ] . hexFileOffset ;
Address end2 = data ( ) - > _ranges [ i ] . end + data ( ) - > _ranges [ i ] . hexFileOffset ;
Address end2 = data ( ) - > _ranges [ i ] . end + data ( ) - > _ranges [ i ] . hexFileOffset ;
if ( end1 > = start2 & & start1 < = end2 )
if ( end1 > = start2 & & start1 < = end2 )
qFatal( TQString ( " Overlapping memory ranges (%1 and %2) " ) . arg ( k . key ( ) ) . arg ( i . key ( ) ) ) ;
t qFatal( TQString ( " Overlapping memory ranges (%1 and %2) " ) . arg ( k . key ( ) ) . arg ( i . key ( ) ) ) ;
}
}
}
}
checkTagNames ( device , " memory " , names ) ;
checkTagNames ( device , " memory " , names ) ;
if ( XOR ( data ( ) - > _ids [ Device : : Special : : Normal ] ! = 0x0000 , ( data ( ) - > _ranges [ MemoryRangeType : : DeviceId ] . properties & Present ) ) )
if ( XOR ( data ( ) - > _ids [ Device : : Special : : Normal ] ! = 0x0000 , ( data ( ) - > _ranges [ MemoryRangeType : : DeviceId ] . properties & Present ) ) )
qFatal( " Id present and device id memory range absent or the opposite " ) ;
t qFatal( " Id present and device id memory range absent or the opposite " ) ;
// config words
// config words
TQValueVector < Config : : Word > cwords = getConfigWords ( device ) ;
TQValueVector < Config : : Word > cwords = getConfigWords ( device ) ;
@ -440,7 +440,7 @@ virtual void processDevice(TQDomElement device)
FOR_EACH ( Pic : : ConfigNameType , type ) {
FOR_EACH ( Pic : : ConfigNameType , type ) {
TQMap < TQString , TQString > cnames ; // cname -> mask name
TQMap < TQString , TQString > cnames ; // cname -> mask name
for ( uint i = 0 ; i < nbWords ; i + + ) {
for ( uint i = 0 ; i < nbWords ; i + + ) {
if ( cwords [ i ] . name . isNull ( ) ) qFatal( TQString ( " Config word #%1 not defined " ) . arg ( i ) ) ;
if ( cwords [ i ] . name . isNull ( ) ) t qFatal( TQString ( " Config word #%1 not defined " ) . arg ( i ) ) ;
data ( ) - > _config - > _words [ i ] = cwords [ i ] ;
data ( ) - > _config - > _words [ i ] = cwords [ i ] ;
const Config : : Word & word = data ( ) - > _config - > _words [ i ] ;
const Config : : Word & word = data ( ) - > _config - > _words [ i ] ;
for ( uint j = 0 ; j < uint ( word . masks . count ( ) ) ; j + + ) {
for ( uint j = 0 ; j < uint ( word . masks . count ( ) ) ; j + + ) {
@ -450,7 +450,7 @@ virtual void processDevice(TQDomElement device)
for ( uint l = 0 ; l < uint ( vcnames . count ( ) ) ; l + + ) {
for ( uint l = 0 ; l < uint ( vcnames . count ( ) ) ; l + + ) {
if ( vcnames [ l ] . startsWith ( " 0x " ) ) continue ;
if ( vcnames [ l ] . startsWith ( " 0x " ) ) continue ;
if ( cnames . contains ( vcnames [ l ] ) & & cnames [ vcnames [ l ] ] ! = mask . name )
if ( cnames . contains ( vcnames [ l ] ) & & cnames [ vcnames [ l ] ] ! = mask . name )
qFatal( TQString ( " Duplicated config name for %1/%2 " ) . arg ( mask . name ) . arg ( mask . values [ k ] . name ) ) ;
t qFatal( TQString ( " Duplicated config name for %1/%2 " ) . arg ( mask . name ) . arg ( mask . values [ k ] . name ) ) ;
cnames [ vcnames [ l ] ] = word . masks [ j ] . name ;
cnames [ vcnames [ l ] ] = word . masks [ j ] . name ;
}
}
}
}
@ -466,7 +466,7 @@ virtual void processDevice(TQDomElement device)
const Config : : Value & value = mask . values [ k ] ;
const Config : : Value & value = mask . values [ k ] ;
if ( ! value . isValid ( ) ) continue ;
if ( ! value . isValid ( ) ) continue ;
if ( ! data ( ) - > _config - > checkValueName ( mask . name , value . name ) )
if ( ! data ( ) - > _config - > checkValueName ( mask . name , value . name ) )
qFatal( TQString ( " Malformed value name \" %1 \" in mask %2 " ) . arg ( value . name ) . arg ( mask . name ) ) ;
t qFatal( TQString ( " Malformed value name \" %1 \" in mask %2 " ) . arg ( value . name ) . arg ( mask . name ) ) ;
}
}
}
}
}
}
@ -477,14 +477,14 @@ virtual void processDevice(TQDomElement device)
const Config : : Mask & mask = word . masks [ j ] ;
const Config : : Mask & mask = word . masks [ j ] ;
BitValue : : const_iterator it ;
BitValue : : const_iterator it ;
for ( it = mask . value . begin ( ) ; it ! = mask . value . end ( ) ; + + it )
for ( it = mask . value . begin ( ) ; it ! = mask . value . end ( ) ; + + it )
if ( ! hasValue ( mask , * it ) ) qFatal( TQString ( " Value %1 not defined in mask %2 " ) . arg ( toHexLabel ( * it , data ( ) - > nbCharsWord ( MemoryRangeType : : Config ) ) ) . arg ( mask . name ) ) ;
if ( ! hasValue ( mask , * it ) ) t qFatal( TQString ( " Value %1 not defined in mask %2 " ) . arg ( toHexLabel ( * it , data ( ) - > nbCharsWord ( MemoryRangeType : : Config ) ) ) . arg ( mask . name ) ) ;
}
}
}
}
// checksums (after config bits!)
// checksums (after config bits!)
TQDomElement checksums = findUniqueElement ( device , " checksums " , TQString ( ) , TQString ( ) ) ;
TQDomElement checksums = findUniqueElement ( device , " checksums " , TQString ( ) , TQString ( ) ) ;
if ( checksums . isNull ( ) ) {
if ( checksums . isNull ( ) ) {
// qFatal("No checksum defined"); // #### FIXME
// t qFatal("No checksum defined"); // #### FIXME
} else {
} else {
TQMap < TQString , bool > valueNames ;
TQMap < TQString , bool > valueNames ;
const Pic : : Protection & protection = data ( ) - > _config - > protection ( ) ;
const Pic : : Protection & protection = data ( ) - > _config - > protection ( ) ;
@ -497,17 +497,17 @@ virtual void processDevice(TQDomElement device)
TQDomNode child = checksums . firstChild ( ) ;
TQDomNode child = checksums . firstChild ( ) ;
while ( ! child . isNull ( ) ) {
while ( ! child . isNull ( ) ) {
if ( ! child . isElement ( ) ) continue ;
if ( ! child . isElement ( ) ) continue ;
if ( child . nodeName ( ) ! = " checksum " ) qFatal( " Childs of \" checksums \" should \" checksum \" " ) ;
if ( child . nodeName ( ) ! = " checksum " ) t qFatal( " Childs of \" checksums \" should \" checksum \" " ) ;
TQString valueName = getChecksumData ( child . toElement ( ) ) ;
TQString valueName = getChecksumData ( child . toElement ( ) ) ;
if ( protection . family ( ) = = Protection : : BasicProtection ) {
if ( protection . family ( ) = = Protection : : BasicProtection ) {
if ( ! valueNames . contains ( valueName ) ) qFatal( " Unknown protected attribute " ) ;
if ( ! valueNames . contains ( valueName ) ) t qFatal( " Unknown protected attribute " ) ;
valueNames [ valueName ] = true ;
valueNames [ valueName ] = true ;
}
}
child = child . nextSibling ( ) ;
child = child . nextSibling ( ) ;
}
}
TQMap < TQString , bool > : : const_iterator it ;
TQMap < TQString , bool > : : const_iterator it ;
for ( it = valueNames . begin ( ) ; it ! = valueNames . end ( ) ; + + it )
for ( it = valueNames . begin ( ) ; it ! = valueNames . end ( ) ; + + it )
if ( ! it . key ( ) . isEmpty ( ) & & ! it . data ( ) ) qFatal( TQString ( " Missing checksum \" %1 \" " ) . arg ( it . key ( ) ) ) ;
if ( ! it . key ( ) . isEmpty ( ) & & ! it . data ( ) ) t qFatal( TQString ( " Missing checksum \" %1 \" " ) . arg ( it . key ( ) ) ) ;
}
}
}
}
@ -516,16 +516,16 @@ void processMirrored(TQDomElement element)
TQValueVector < RangeData > mirrored ;
TQValueVector < RangeData > mirrored ;
TQDomNode child = element . firstChild ( ) ;
TQDomNode child = element . firstChild ( ) ;
while ( ! child . isNull ( ) ) {
while ( ! child . isNull ( ) ) {
if ( ! child . isElement ( ) ) qFatal( " \" mirror \" child should be an element " ) ;
if ( ! child . isElement ( ) ) t qFatal( " \" mirror \" child should be an element " ) ;
TQDomElement e = child . toElement ( ) ;
TQDomElement e = child . toElement ( ) ;
if ( e . nodeName ( ) ! = " range " ) qFatal( " \" mirror \" child should be \" range \" " ) ;
if ( e . nodeName ( ) ! = " range " ) t qFatal( " \" mirror \" child should be \" range \" " ) ;
RangeData rd ;
RangeData rd ;
bool ok ;
bool ok ;
rd . start = fromHexLabel ( e . attribute ( " start " ) , & ok ) ;
rd . start = fromHexLabel ( e . attribute ( " start " ) , & ok ) ;
Address end = fromHexLabel ( e . attribute ( " end " ) , & ok ) ;
Address end = fromHexLabel ( e . attribute ( " end " ) , & ok ) ;
rd . length = end - rd . start + 1 ;
rd . length = end - rd . start + 1 ;
if ( ! mirrored . isEmpty ( ) & & rd . length ! = mirrored [ 0 ] . length )
if ( ! mirrored . isEmpty ( ) & & rd . length ! = mirrored [ 0 ] . length )
qFatal( " Mirrored are not of the same length " ) ;
t qFatal( " Mirrored are not of the same length " ) ;
mirrored . append ( rd ) ;
mirrored . append ( rd ) ;
child = child . nextSibling ( ) ;
child = child . nextSibling ( ) ;
}
}
@ -537,43 +537,43 @@ void processUnused(TQDomElement e)
RangeData rd ;
RangeData rd ;
bool ok ;
bool ok ;
rd . start = fromHexLabel ( e . attribute ( " start " ) , & ok ) ;
rd . start = fromHexLabel ( e . attribute ( " start " ) , & ok ) ;
if ( ! ok ) qFatal( " Malformed start for unused register " ) ;
if ( ! ok ) t qFatal( " Malformed start for unused register " ) ;
Address end = fromHexLabel ( e . attribute ( " end " ) , & ok ) ;
Address end = fromHexLabel ( e . attribute ( " end " ) , & ok ) ;
rd . length = end - rd . start + 1 ;
rd . length = end - rd . start + 1 ;
if ( ! ok ) qFatal( " Malformed end for unused register " ) ;
if ( ! ok ) t qFatal( " Malformed end for unused register " ) ;
static_cast < RegistersData * > ( data ( ) - > _registersData ) - > unused . append ( rd ) ;
static_cast < RegistersData * > ( data ( ) - > _registersData ) - > unused . append ( rd ) ;
}
}
void processSfr ( TQDomElement e )
void processSfr ( TQDomElement e )
{
{
TQString name = e . attribute ( " name " ) ;
TQString name = e . attribute ( " name " ) ;
if ( name . isEmpty ( ) ) qFatal( " SFR cannot have empty name " ) ;
if ( name . isEmpty ( ) ) t qFatal( " SFR cannot have empty name " ) ;
if ( data ( ) - > registersData ( ) . sfrs . contains ( name ) | | data ( ) - > registersData ( ) . combined . contains ( name ) )
if ( data ( ) - > registersData ( ) . sfrs . contains ( name ) | | data ( ) - > registersData ( ) . combined . contains ( name ) )
qFatal( " SFR name is duplicated " ) ;
t qFatal( " SFR name is duplicated " ) ;
bool ok ;
bool ok ;
uint address = fromHexLabel ( e . attribute ( " address " ) , & ok ) ;
uint address = fromHexLabel ( e . attribute ( " address " ) , & ok ) ;
if ( ! ok ) qFatal( TQString ( " SFR %1 address %2 is malformed " ) . arg ( name ) . arg ( e . attribute ( " address " ) ) ) ;
if ( ! ok ) t qFatal( TQString ( " SFR %1 address %2 is malformed " ) . arg ( name ) . arg ( e . attribute ( " address " ) ) ) ;
uint rlength = data ( ) - > registersData ( ) . nbBanks * data ( ) - > architecture ( ) . data ( ) . registerBankLength ;
uint rlength = data ( ) - > registersData ( ) . nbBanks * data ( ) - > architecture ( ) . data ( ) . registerBankLength ;
if ( address > = rlength ) qFatal( TQString ( " Address %1 outside register range " ) . arg ( toHexLabel ( address , 3 ) ) ) ;
if ( address > = rlength ) t qFatal( TQString ( " Address %1 outside register range " ) . arg ( toHexLabel ( address , 3 ) ) ) ;
RegisterData rdata ;
RegisterData rdata ;
rdata . address = address ;
rdata . address = address ;
uint nb = data ( ) - > registersData ( ) . nbBits ( ) ;
uint nb = data ( ) - > registersData ( ) . nbBits ( ) ;
if ( nb > Device : : MAX_NB_PORT_BITS ) qFatal( TQString ( " Need higher MAX_NB_PORT_BITS: %1 " ) . arg ( nb ) ) ;
if ( nb > Device : : MAX_NB_PORT_BITS ) t qFatal( TQString ( " Need higher MAX_NB_PORT_BITS: %1 " ) . arg ( nb ) ) ;
TQString access = e . attribute ( " access " ) ;
TQString access = e . attribute ( " access " ) ;
if ( uint ( access . length ( ) ) ! = nb ) qFatal( " access is missing or malformed " ) ;
if ( uint ( access . length ( ) ) ! = nb ) t qFatal( " access is missing or malformed " ) ;
TQString mclr = e . attribute ( " mclr " ) ;
TQString mclr = e . attribute ( " mclr " ) ;
if ( uint ( mclr . length ( ) ) ! = nb ) qFatal( " mclr is missing or malformed " ) ;
if ( uint ( mclr . length ( ) ) ! = nb ) t qFatal( " mclr is missing or malformed " ) ;
TQString por = e . attribute ( " por " ) ;
TQString por = e . attribute ( " por " ) ;
if ( uint ( por . length ( ) ) ! = nb ) qFatal( " por is missing or malformed " ) ;
if ( uint ( por . length ( ) ) ! = nb ) t qFatal( " por is missing or malformed " ) ;
for ( uint i = 0 ; i < nb ; i + + ) {
for ( uint i = 0 ; i < nb ; i + + ) {
uint k = nb - i - 1 ;
uint k = nb - i - 1 ;
bool ok ;
bool ok ;
rdata . bits [ k ] . properties = RegisterBitProperties ( fromHex ( access [ i ] . latin1 ( ) , & ok ) ) ;
rdata . bits [ k ] . properties = RegisterBitProperties ( fromHex ( access [ i ] . latin1 ( ) , & ok ) ) ;
if ( ! ok | | rdata . bits [ k ] . properties > MaxRegisterBitProperty ) qFatal( TQString ( " Malformed access bit %1 " ) . arg ( k ) ) ;
if ( ! ok | | rdata . bits [ k ] . properties > MaxRegisterBitProperty ) t qFatal( TQString ( " Malformed access bit %1 " ) . arg ( k ) ) ;
rdata . bits [ k ] . mclr = RegisterBitState ( fromHex ( mclr [ i ] . latin1 ( ) , & ok ) ) ;
rdata . bits [ k ] . mclr = RegisterBitState ( fromHex ( mclr [ i ] . latin1 ( ) , & ok ) ) ;
if ( ! ok | | rdata . bits [ k ] . mclr > Nb_RegisterBitStates ) qFatal( TQString ( " Malformed mclr bit %1 " ) . arg ( k ) ) ;
if ( ! ok | | rdata . bits [ k ] . mclr > Nb_RegisterBitStates ) t qFatal( TQString ( " Malformed mclr bit %1 " ) . arg ( k ) ) ;
rdata . bits [ k ] . por = RegisterBitState ( fromHex ( por [ i ] . latin1 ( ) , & ok ) ) ;
rdata . bits [ k ] . por = RegisterBitState ( fromHex ( por [ i ] . latin1 ( ) , & ok ) ) ;
if ( ! ok | | rdata . bits [ k ] . por > Nb_RegisterBitStates ) qFatal( TQString ( " Malformed por bit %1 " ) . arg ( k ) ) ;
if ( ! ok | | rdata . bits [ k ] . por > Nb_RegisterBitStates ) t qFatal( TQString ( " Malformed por bit %1 " ) . arg ( k ) ) ;
}
}
static_cast < RegistersData * > ( data ( ) - > _registersData ) - > sfrs [ name ] = rdata ;
static_cast < RegistersData * > ( data ( ) - > _registersData ) - > sfrs [ name ] = rdata ;
}
}
@ -581,19 +581,19 @@ void processSfr(TQDomElement e)
void processCombined ( TQDomElement e )
void processCombined ( TQDomElement e )
{
{
TQString name = e . attribute ( " name " ) ;
TQString name = e . attribute ( " name " ) ;
if ( name . isEmpty ( ) ) qFatal( " Combined register cannot have empty name " ) ;
if ( name . isEmpty ( ) ) t qFatal( " Combined register cannot have empty name " ) ;
if ( data ( ) - > registersData ( ) . sfrs . contains ( name ) | | data ( ) - > registersData ( ) . combined . contains ( name ) )
if ( data ( ) - > registersData ( ) . sfrs . contains ( name ) | | data ( ) - > registersData ( ) . combined . contains ( name ) )
qFatal( " Combined register name is duplicated " ) ;
t qFatal( " Combined register name is duplicated " ) ;
bool ok ;
bool ok ;
CombinedData rdata ;
CombinedData rdata ;
rdata . address = fromHexLabel ( e . attribute ( " address " ) , & ok ) ;
rdata . address = fromHexLabel ( e . attribute ( " address " ) , & ok ) ;
if ( ! ok ) qFatal( TQString ( " Combined %1 address %2 is malformed " ) . arg ( name ) . arg ( e . attribute ( " address " ) ) ) ;
if ( ! ok ) t qFatal( TQString ( " Combined %1 address %2 is malformed " ) . arg ( name ) . arg ( e . attribute ( " address " ) ) ) ;
uint rlength = data ( ) - > registersData ( ) . nbBanks * data ( ) - > architecture ( ) . data ( ) . registerBankLength ;
uint rlength = data ( ) - > registersData ( ) . nbBanks * data ( ) - > architecture ( ) . data ( ) . registerBankLength ;
if ( rdata . address > = rlength ) qFatal( TQString ( " Address %1 outside register range " ) . arg ( toHexLabel ( rdata . address , 3 ) ) ) ;
if ( rdata . address > = rlength ) t qFatal( TQString ( " Address %1 outside register range " ) . arg ( toHexLabel ( rdata . address , 3 ) ) ) ;
rdata . nbChars = 2 * e . attribute ( " size " ) . toUInt ( & ok ) ;
rdata . nbChars = 2 * e . attribute ( " size " ) . toUInt ( & ok ) ;
if ( ! ok | | rdata . nbChars < 2 ) qFatal( TQString ( " Combined %1 size %2 is malformed " ) . arg ( name ) . arg ( e . attribute ( " size " ) ) ) ;
if ( ! ok | | rdata . nbChars < 2 ) t qFatal( TQString ( " Combined %1 size %2 is malformed " ) . arg ( name ) . arg ( e . attribute ( " size " ) ) ) ;
Address end = rdata . address + rdata . nbChars / 2 - 1 ;
Address end = rdata . address + rdata . nbChars / 2 - 1 ;
if ( end > = rlength ) qFatal( TQString ( " Address %1 outside register range " ) . arg ( toHexLabel ( end , 3 ) ) ) ;
if ( end > = rlength ) t qFatal( TQString ( " Address %1 outside register range " ) . arg ( toHexLabel ( end , 3 ) ) ) ;
static_cast < RegistersData * > ( data ( ) - > _registersData ) - > combined [ name ] = rdata ;
static_cast < RegistersData * > ( data ( ) - > _registersData ) - > combined [ name ] = rdata ;
}
}
@ -601,7 +601,7 @@ void processDeviceRegisters(TQDomElement element)
{
{
TQString s = element . attribute ( " same_as " ) ;
TQString s = element . attribute ( " same_as " ) ;
if ( ! s . isEmpty ( ) ) {
if ( ! s . isEmpty ( ) ) {
if ( ! _map . contains ( s ) ) qFatal( TQString ( " Registers same as unknown device %1 " ) . arg ( s ) ) ;
if ( ! _map . contains ( s ) ) t qFatal( TQString ( " Registers same as unknown device %1 " ) . arg ( s ) ) ;
const Pic : : Data * d = static_cast < const Pic : : Data * > ( _map [ s ] ) ;
const Pic : : Data * d = static_cast < const Pic : : Data * > ( _map [ s ] ) ;
data ( ) - > _registersData = d - > _registersData ;
data ( ) - > _registersData = d - > _registersData ;
return ;
return ;
@ -610,12 +610,12 @@ void processDeviceRegisters(TQDomElement element)
RegistersData & rdata = * static_cast < RegistersData * > ( data ( ) - > _registersData ) ;
RegistersData & rdata = * static_cast < RegistersData * > ( data ( ) - > _registersData ) ;
bool ok ;
bool ok ;
rdata . nbBanks = element . attribute ( " nb_banks " ) . toUInt ( & ok ) ;
rdata . nbBanks = element . attribute ( " nb_banks " ) . toUInt ( & ok ) ;
if ( ! ok | | data ( ) - > registersData ( ) . nbBanks = = 0 ) qFatal( " Malformed number of banks " ) ;
if ( ! ok | | data ( ) - > registersData ( ) . nbBanks = = 0 ) t qFatal( " Malformed number of banks " ) ;
if ( data ( ) - > is18Family ( ) ) {
if ( data ( ) - > is18Family ( ) ) {
rdata . accessBankSplit = fromHexLabel ( element . attribute ( " access_bank_split_offset " ) , & ok ) ;
rdata . accessBankSplit = fromHexLabel ( element . attribute ( " access_bank_split_offset " ) , & ok ) ;
if ( ! ok | | rdata . accessBankSplit = = 0 | | rdata . accessBankSplit > = 0xFF ) qFatal( " Malformed access bank split offset " ) ;
if ( ! ok | | rdata . accessBankSplit = = 0 | | rdata . accessBankSplit > = 0xFF ) t qFatal( " Malformed access bank split offset " ) ;
rdata . unusedBankMask = fromHexLabel ( element . attribute ( " unused_bank_mask " ) , & ok ) ;
rdata . unusedBankMask = fromHexLabel ( element . attribute ( " unused_bank_mask " ) , & ok ) ;
if ( ! ok | | rdata . unusedBankMask > = maxValue ( NumberBase : : Hex , rdata . nbBanks ) ) qFatal( " Malformed access unused bank mask " ) ;
if ( ! ok | | rdata . unusedBankMask > = maxValue ( NumberBase : : Hex , rdata . nbBanks ) ) t qFatal( " Malformed access unused bank mask " ) ;
} else {
} else {
rdata . accessBankSplit = 0 ;
rdata . accessBankSplit = 0 ;
rdata . unusedBankMask = 0 ;
rdata . unusedBankMask = 0 ;
@ -623,13 +623,13 @@ void processDeviceRegisters(TQDomElement element)
TQDomNode child = element . firstChild ( ) ;
TQDomNode child = element . firstChild ( ) ;
while ( ! child . isNull ( ) ) {
while ( ! child . isNull ( ) ) {
if ( ! child . isElement ( ) ) qFatal( " \" device \" child should be an element " ) ;
if ( ! child . isElement ( ) ) t qFatal( " \" device \" child should be an element " ) ;
TQDomElement e = child . toElement ( ) ;
TQDomElement e = child . toElement ( ) ;
if ( e . nodeName ( ) = = " mirror " ) processMirrored ( e ) ;
if ( e . nodeName ( ) = = " mirror " ) processMirrored ( e ) ;
else if ( e . nodeName ( ) = = " unused " ) processUnused ( e ) ;
else if ( e . nodeName ( ) = = " unused " ) processUnused ( e ) ;
else if ( e . nodeName ( ) = = " combined " ) processCombined ( e ) ;
else if ( e . nodeName ( ) = = " combined " ) processCombined ( e ) ;
else if ( e . nodeName ( ) = = " sfr " ) processSfr ( e ) ;
else if ( e . nodeName ( ) = = " sfr " ) processSfr ( e ) ;
else qFatal( TQString ( " Node name \" %1 \" is not recognized " ) . arg ( e . nodeName ( ) ) ) ;
else t qFatal( TQString ( " Node name \" %1 \" is not recognized " ) . arg ( e . nodeName ( ) ) ) ;
child = child . nextSibling ( ) ;
child = child . nextSibling ( ) ;
}
}
@ -640,11 +640,11 @@ void processDeviceRegisters(TQDomElement element)
TQString trisname = rdata . trisName ( i ) ;
TQString trisname = rdata . trisName ( i ) ;
if ( trisname . isEmpty ( ) ) continue ;
if ( trisname . isEmpty ( ) ) continue ;
bool hasTris = rdata . sfrs . contains ( trisname ) ;
bool hasTris = rdata . sfrs . contains ( trisname ) ;
if ( ! hasPort & & hasTris ) qFatal( TQString ( " %1 needs %2 to be present " ) . arg ( trisname ) . arg ( portname ) ) ;
if ( ! hasPort & & hasTris ) t qFatal( TQString ( " %1 needs %2 to be present " ) . arg ( trisname ) . arg ( portname ) ) ;
TQString latchname = rdata . latchName ( i ) ;
TQString latchname = rdata . latchName ( i ) ;
if ( latchname . isEmpty ( ) ) continue ;
if ( latchname . isEmpty ( ) ) continue ;
bool hasLatch = rdata . sfrs . contains ( latchname ) ;
bool hasLatch = rdata . sfrs . contains ( latchname ) ;
if ( ! hasPort & & hasLatch ) qFatal( TQString ( " %1 needs %2 to be present " ) . arg ( latchname ) . arg ( portname ) ) ;
if ( ! hasPort & & hasLatch ) t qFatal( TQString ( " %1 needs %2 to be present " ) . arg ( latchname ) . arg ( portname ) ) ;
}
}
}
}
@ -652,15 +652,15 @@ void processRegistersFile(const TQString &filename, TQStringList &devices)
{
{
TQDomDocument doc = parseFile ( filename ) ;
TQDomDocument doc = parseFile ( filename ) ;
TQDomElement root = doc . documentElement ( ) ;
TQDomElement root = doc . documentElement ( ) ;
if ( root . nodeName ( ) ! = " registers " ) qFatal( " root node should be \" registers \" " ) ;
if ( root . nodeName ( ) ! = " registers " ) t qFatal( " root node should be \" registers \" " ) ;
for ( TQDomNode child = root . firstChild ( ) ; ! child . isNull ( ) ; child = child . nextSibling ( ) ) {
for ( TQDomNode child = root . firstChild ( ) ; ! child . isNull ( ) ; child = child . nextSibling ( ) ) {
if ( child . isComment ( ) ) qDebug( " comment: %s " , child . toComment ( ) . data ( ) . latin1 ( ) ) ;
if ( child . isComment ( ) ) t qDebug( " comment: %s " , child . toComment ( ) . data ( ) . latin1 ( ) ) ;
else {
else {
if ( ! child . isElement ( ) ) qFatal( " \" registers \" child should be an element " ) ;
if ( ! child . isElement ( ) ) t qFatal( " \" registers \" child should be an element " ) ;
if ( child . nodeName ( ) ! = " device " ) qFatal( " Device node should be named \" device \" " ) ;
if ( child . nodeName ( ) ! = " device " ) t qFatal( " Device node should be named \" device \" " ) ;
TQDomElement device = child . toElement ( ) ;
TQDomElement device = child . toElement ( ) ;
TQString name = device . attribute ( " name " ) ;
TQString name = device . attribute ( " name " ) ;
if ( devices . contains ( name ) ) qFatal( TQString ( " Registers already defined for %1 " ) . arg ( name ) ) ;
if ( devices . contains ( name ) ) t qFatal( TQString ( " Registers already defined for %1 " ) . arg ( name ) ) ;
if ( _map . contains ( name ) ) {
if ( _map . contains ( name ) ) {
_data = _map [ name ] ;
_data = _map [ name ] ;
processDeviceRegisters ( device ) ;
processDeviceRegisters ( device ) ;
@ -680,18 +680,18 @@ void processRegisters()
TQMap < TQString , Device : : Data * > : : const_iterator it = _map . begin ( ) ;
TQMap < TQString , Device : : Data * > : : const_iterator it = _map . begin ( ) ;
for ( ; it ! = _map . end ( ) ; + + it ) {
for ( ; it ! = _map . end ( ) ; + + it ) {
_data = it . data ( ) ;
_data = it . data ( ) ;
if ( ! devices . contains ( it . key ( ) ) ) qWarning( " Register description not found for %s " , it . key ( ) . latin1 ( ) ) ;
if ( ! devices . contains ( it . key ( ) ) ) t qWarning( " Register description not found for %s " , it . key ( ) . latin1 ( ) ) ;
}
}
}
}
virtual void checkPins ( const TQMap < TQString , uint > & pinLabels ) const
virtual void checkPins ( const TQMap < TQString , uint > & pinLabels ) const
{
{
if ( ! pinLabels . contains ( " VDD " ) ) qFatal( " No VDD pin specified " ) ;
if ( ! pinLabels . contains ( " VDD " ) ) t qFatal( " No VDD pin specified " ) ;
if ( ! pinLabels . contains ( " VSS " ) ) qFatal( " No VSS pin specified " ) ;
if ( ! pinLabels . contains ( " VSS " ) ) t qFatal( " No VSS pin specified " ) ;
TQMap < TQString , uint > : : const_iterator it ;
TQMap < TQString , uint > : : const_iterator it ;
for ( it = pinLabels . begin ( ) ; it ! = pinLabels . end ( ) ; + + it ) {
for ( it = pinLabels . begin ( ) ; it ! = pinLabels . end ( ) ; + + it ) {
if ( it . key ( ) = = " VDD " | | it . key ( ) = = " VSS " | | it . key ( ) . startsWith ( " CCP " ) ) continue ;
if ( it . key ( ) = = " VDD " | | it . key ( ) = = " VSS " | | it . key ( ) . startsWith ( " CCP " ) ) continue ;
if ( it . data ( ) ! = 1 ) qFatal( TQString ( " Duplicated pin \" %1 \" " ) . arg ( it . key ( ) ) ) ;
if ( it . data ( ) ! = 1 ) t qFatal( TQString ( " Duplicated pin \" %1 \" " ) . arg ( it . key ( ) ) ) ;
}
}
const Pic : : RegistersData & rdata = static_cast < const Pic : : RegistersData & > ( * _data - > registersData ( ) ) ;
const Pic : : RegistersData & rdata = static_cast < const Pic : : RegistersData & > ( * _data - > registersData ( ) ) ;
for ( uint i = 0 ; i < Device : : MAX_NB_PORTS ; i + + ) {
for ( uint i = 0 ; i < Device : : MAX_NB_PORTS ; i + + ) {
@ -699,7 +699,7 @@ virtual void checkPins(const TQMap<TQString, uint> &pinLabels) const
for ( uint k = 0 ; k < Device : : MAX_NB_PORT_BITS ; k + + ) {
for ( uint k = 0 ; k < Device : : MAX_NB_PORT_BITS ; k + + ) {
if ( ! rdata . hasPortBit ( i , k ) ) continue ;
if ( ! rdata . hasPortBit ( i , k ) ) continue ;
TQString name = rdata . portBitName ( i , k ) ;
TQString name = rdata . portBitName ( i , k ) ;
if ( ! pinLabels . contains ( name ) ) qFatal( TQString ( " Pin \" %1 \" not present " ) . arg ( name ) ) ;
if ( ! pinLabels . contains ( name ) ) t qFatal( TQString ( " Pin \" %1 \" not present " ) . arg ( name ) ) ;
}
}
}
}
}
}