@ -58,7 +58,7 @@ Device::Array Pic::Memory::arrayForWriting(MemoryRangeType type) const
{
Device : : Array data = _ranges [ type ] ;
for ( uint i = 0 ; i < data . count ( ) ; i + + )
data [ i ] = data [ i ] . tq maskWith( type = = MemoryRangeType : : Config ? device ( ) . config ( ) . _words [ i ] . wtqmask : device ( ) . tqmask ( type ) ) ;
data [ i ] = data [ i ] . maskWith( type = = MemoryRangeType : : Config ? device ( ) . config ( ) . _words [ i ] . wtqmask : device ( ) . tqmask ( type ) ) ;
return data ;
}
@ -72,10 +72,10 @@ BitValue Pic::Memory::normalizeWord(MemoryRangeType type, uint offset, BitValue
{
if ( type = = MemoryRangeType : : Config ) {
const Config : : Word & cword = device ( ) . config ( ) . _words [ offset ] ;
return value . tq maskWith( cword . usedMask ( ) ) ;
return value . maskWith( cword . usedMask ( ) ) ;
}
if ( type = = MemoryRangeType : : UserId ) return value . tq maskWith( device ( ) . userIdRecommendedMask ( ) ) ;
return value . tq maskWith( device ( ) . tqmask ( type ) ) ;
if ( type = = MemoryRangeType : : UserId ) return value . maskWith( device ( ) . userIdRecommendedMask ( ) ) ;
return value . maskWith( device ( ) . tqmask ( type ) ) ;
}
BitValue Pic : : Memory : : normalizedWord ( MemoryRangeType type , uint offset ) const
@ -96,13 +96,13 @@ void Pic::Memory::setArray(MemoryRangeType type, const Device::Array &data)
_ranges [ type ] = data ;
}
TQString Pic : : Memory : : findValue ( const TQString & tq maskName) const
TQString Pic : : Memory : : findValue ( const TQString & maskName) const
{
if ( tq maskName. isEmpty ( ) ) return TQString ( ) ;
if ( maskName. isEmpty ( ) ) return TQString ( ) ;
uint i ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( tq maskName, & i ) ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( maskName, & i ) ;
if ( tqmask = = 0 ) return TQString ( ) ;
BitValue v = word ( MemoryRangeType : : Config , i ) . tq maskWith( tqmask - > value ) ;
BitValue v = word ( MemoryRangeType : : Config , i ) . maskWith( tqmask - > value ) ;
for ( uint k = 0 ; k < uint ( tqmask - > values . count ( ) ) ; k + + )
if ( v . isInside ( tqmask - > values [ k ] . value ) ) return tqmask - > values [ k ] . name ;
Q_ASSERT ( false ) ;
@ -122,8 +122,8 @@ AddressRange Pic::Memory::bootRange() const
return AddressRange ( start , 2 * size - 1 ) ; // instruction words
}
// only CPB
TQString tq maskName = protection . bootMaskName ( Protection : : ProgramProtected ) ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( tq maskName) ;
TQString maskName = protection . bootMaskName ( Protection : : ProgramProtected ) ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( maskName) ;
for ( uint k = 0 ; k < uint ( tqmask - > values . count ( ) ) ; k + + ) {
AddressRangeVector rv = protection . extractRanges ( tqmask - > values [ k ] . name , MemoryRangeType : : Code ) ;
if ( ! rv . isEmpty ( ) ) return rv [ 0 ] ;
@ -142,9 +142,9 @@ AddressRange Pic::Memory::blockRange(uint i) const
Address start = ( previous . isEmpty ( ) ? device ( ) . range ( MemoryRangeType : : Code ) . start : previous . end + 1 ) ;
return AddressRange ( start , device ( ) . range ( MemoryRangeType : : Code ) . end ) ;
}
TQString tq maskName = protection . blockSizeMaskName ( i ) ;
TQString maskName = protection . blockSizeMaskName ( i ) ;
if ( protection . family ( ) = = Protection : : CodeGuard ) { // secure segment
TQString value = findValue ( tq maskName) ;
TQString value = findValue ( maskName) ;
Q_ASSERT ( ! value . isEmpty ( ) ) ;
uint size = value . toUInt ( ) ;
if ( size = = 0 ) return AddressRange ( ) ;
@ -153,7 +153,7 @@ AddressRange Pic::Memory::blockRange(uint i) const
return AddressRange ( start , 2 * size - 1 ) ;
}
AddressRange previous = ( i = = 0 ? bootRange ( ) : blockRange ( i - 1 ) ) ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( tq maskName) ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( maskName) ;
for ( uint k = 0 ; k < uint ( tqmask - > values . count ( ) ) ; k + + ) {
AddressRangeVector rv = protection . extractRanges ( tqmask - > values [ k ] . name , MemoryRangeType : : Code ) ;
if ( ! rv . isEmpty ( ) ) return AddressRange ( previous . end + 1 , rv [ 0 ] . end ) ;
@ -165,8 +165,8 @@ AddressRange Pic::Memory::blockRange(uint i) const
AddressRange Pic : : Memory : : bootProtectedRange ( Protection : : Type ptype ) const
{
const Protection & protection = device ( ) . config ( ) . protection ( ) ;
TQString tq maskName = protection . bootMaskName ( ptype ) ;
TQString value = findValue ( tq maskName) ;
TQString maskName = protection . bootMaskName ( ptype ) ;
TQString value = findValue ( maskName) ;
if ( value . isEmpty ( ) ) return AddressRange ( ) ;
if ( protection . family ( ) ! = Protection : : CodeGuard ) {
if ( protection . extractRanges ( value , MemoryRangeType : : Code ) . isEmpty ( ) ) return AddressRange ( ) ;
@ -179,8 +179,8 @@ AddressRange Pic::Memory::bootProtectedRange(Protection::Type ptype) const
AddressRange Pic : : Memory : : blockProtectedRange ( Protection : : Type ptype , uint i ) const
{
const Protection & protection = device ( ) . config ( ) . protection ( ) ;
TQString tq maskName = protection . blockMaskName ( ptype , i ) ;
TQString value = findValue ( tq maskName) ;
TQString maskName = protection . blockMaskName ( ptype , i ) ;
TQString value = findValue ( maskName) ;
if ( value . isEmpty ( ) ) return AddressRange ( ) ;
if ( protection . family ( ) ! = Protection : : CodeGuard ) {
if ( protection . extractRanges ( value , MemoryRangeType : : Code ) . isEmpty ( ) ) return AddressRange ( ) ;
@ -202,9 +202,9 @@ AddressRangeVector Pic::Memory::protectedRanges(Protection::Type ptype, MemoryRa
}
}
if ( protection . family ( ) ! = Protection : : CodeGuard ) {
TQString tq maskName = protection . tq maskName( ptype , type ) ;
TQString value = findValue ( tq maskName) ;
//qDebug("%s %s", tq maskName.latin1(), value.latin1());
TQString maskName = protection . maskName( ptype , type ) ;
TQString value = findValue ( maskName) ;
//qDebug("%s %s", maskName.latin1(), value.latin1());
if ( ! value . isEmpty ( ) ) {
AddressRangeVector tmp = protection . extractRanges ( value , type ) ;
Q_ASSERT ( tmp . count ( ) = = 1 ) ;
@ -216,14 +216,14 @@ AddressRangeVector Pic::Memory::protectedRanges(Protection::Type ptype, MemoryRa
void Pic : : Memory : : setBootProtection ( bool on , Protection : : Type ptype )
{
TQString tq maskName = device ( ) . config ( ) . protection ( ) . bootMaskName ( ptype ) ;
setProtection ( on , tq maskName, ptype ) ;
TQString maskName = device ( ) . config ( ) . protection ( ) . bootMaskName ( ptype ) ;
setProtection ( on , maskName, ptype ) ;
}
void Pic : : Memory : : setBlockProtection ( bool on , Protection : : Type ptype , uint block )
{
TQString tq maskName = device ( ) . config ( ) . protection ( ) . blockMaskName ( ptype , block ) ;
setProtection ( on , tq maskName, ptype ) ;
TQString maskName = device ( ) . config ( ) . protection ( ) . blockMaskName ( ptype , block ) ;
setProtection ( on , maskName, ptype ) ;
}
void Pic : : Memory : : setProtection ( bool on , Protection : : Type ptype , MemoryRangeType type )
@ -236,13 +236,13 @@ void Pic::Memory::setProtection(bool on, Protection::Type ptype, MemoryRangeType
return ;
}
}
setProtection ( on , protection . tq maskName( ptype , type ) , ptype ) ;
setProtection ( on , protection . maskName( ptype , type ) , ptype ) ;
}
void Pic : : Memory : : setConfigValue ( const TQString & tq maskName, const TQString & valueName )
void Pic : : Memory : : setConfigValue ( const TQString & maskName, const TQString & valueName )
{
uint i ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( tq maskName, & i ) ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( maskName, & i ) ;
Q_ASSERT ( tqmask ) ;
BitValue v = word ( MemoryRangeType : : Config , i ) ;
v = v . clearMaskBits ( tqmask - > value ) ;
@ -254,9 +254,9 @@ void Pic::Memory::setConfigValue(const TQString &tqmaskName, const TQString &val
Q_ASSERT ( false ) ;
}
void Pic : : Memory : : setProtection ( bool on , const TQString & tq maskName, Protection : : Type ptype )
void Pic : : Memory : : setProtection ( bool on , const TQString & maskName, Protection : : Type ptype )
{
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( tq maskName, 0 ) ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( maskName, 0 ) ;
if ( tqmask = = 0 ) return ;
const Protection & protection = device ( ) . config ( ) . protection ( ) ;
TQString valueName ;
@ -268,25 +268,25 @@ void Pic::Memory::setProtection(bool on, const TQString &tqmaskName, Protection:
| | ( ! on & & protection . isNoneProtectedValueName ( tqmask - > values [ k ] . name ) ) ) valueName = tqmask - > values [ k ] . name ;
}
}
setConfigValue ( tq maskName, valueName ) ;
setConfigValue ( maskName, valueName ) ;
}
bool Pic : : Memory : : hasFlagOn ( const TQString & tq maskName, bool valueIfNotPresent ) const
bool Pic : : Memory : : hasFlagOn ( const TQString & maskName, bool valueIfNotPresent ) const
{
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( tq maskName, 0 ) ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( maskName, 0 ) ;
if ( tqmask = = 0 ) return valueIfNotPresent ;
Q_ASSERT ( tqmask ) ;
Q_ASSERT ( tqmask - > values . count ( ) = = 2 ) ;
return ( findValue ( tq maskName) = = " On " ) ;
return ( findValue ( maskName) = = " On " ) ;
}
void Pic : : Memory : : setFlagOn ( const TQString & tq maskName, bool on )
void Pic : : Memory : : setFlagOn ( const TQString & maskName, bool on )
{
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( tq maskName, 0 ) ;
const Config : : Mask * tqmask = device ( ) . config ( ) . findMask ( maskName, 0 ) ;
Q_UNUSED ( tqmask ) ;
Q_ASSERT ( tqmask ) ;
Q_ASSERT ( tqmask - > values . count ( ) = = 2 ) ;
setConfigValue ( tq maskName, on ? " On " : " Off " ) ;
setConfigValue ( maskName, on ? " On " : " Off " ) ;
}
void Pic : : Memory : : checksumCheckFill ( )
@ -345,8 +345,8 @@ BitValue Pic::Memory::checksum() const
BitValue cs = 0x0000 ;
const Protection & protection = device ( ) . config ( ) . protection ( ) ;
if ( protection . family ( ) = = Protection : : BasicProtection ) {
TQString tq maskName = protection . tq maskName( Protection : : ProgramProtected , MemoryRangeType : : Code ) ;
TQString valueName = findValue ( tq maskName) ;
TQString maskName = protection . maskName( Protection : : ProgramProtected , MemoryRangeType : : Code ) ;
TQString valueName = findValue ( maskName) ;
const TQMap < TQString , Checksum : : Data > & checksums = device ( ) . checksums ( ) ;
if ( checksums . tqcontains ( valueName ) ) { // #### REMOVE ME !!
algorithm = checksums [ valueName ] . algorithm ;
@ -357,7 +357,7 @@ BitValue Pic::Memory::checksum() const
//qDebug("algo: %s", Checksum::ALGORITHM_DATA[algorithm].name);
for ( uint i = 0 ; i < device ( ) . nbWords ( MemoryRangeType : : Code ) ; i + + ) {
if ( algorithm = = Checksum : : Algorithm : : Normal & & rv . tqcontains ( inc * i ) ) continue ;
BitValue v = word ( MemoryRangeType : : Code , i ) . tq maskWith( tqmask ) ;
BitValue v = word ( MemoryRangeType : : Code , i ) . maskWith( tqmask ) ;
//if ( i==0 || i==device().nbWords(MemoryRangeType::Code)-1 ) qDebug("%s %s", toHexLabel(i, 4).latin1(), toHexLabel(v, 4).latin1());
switch ( device ( ) . architecture ( ) . type ( ) ) {
case Architecture : : P10X :
@ -392,7 +392,7 @@ BitValue Pic::Memory::checksum() const
const Config & config = device ( ) . config ( ) ;
for ( uint i = 0 ; i < uint ( config . _words . count ( ) ) ; i + + ) {
const Config : : Word & cword = config . _words [ i ] ;
BitValue v = word ( MemoryRangeType : : Config , i ) . tq maskWith( cword . ctqmask ) ;
BitValue v = word ( MemoryRangeType : : Config , i ) . maskWith( cword . ctqmask ) ;
//uint nbChars = device().nbCharsWord(MemoryRangeType::Config);
// qDebug("%i: %s %s", i, toHex(word(MemoryRangeType::Config, i), nbChars).latin1(), toHex(cword.ctqmask, nbChars).latin1());
if ( ( device ( ) . name ( ) = = " 16C61 " | | device ( ) . name ( ) = = " 16C71 " ) & & isProtected ) cs + = v | 0x0060 ;
@ -405,7 +405,7 @@ BitValue Pic::Memory::checksum() const
BitValue id = 0x0 ;
uint nb = device ( ) . nbWords ( MemoryRangeType : : UserId ) ;
for ( uint i = 0 ; i < nb ; i + + ) {
BitValue v = word ( MemoryRangeType : : UserId , nb - i - 1 ) . tq maskWith( 0xF ) ;
BitValue v = word ( MemoryRangeType : : UserId , nb - i - 1 ) . maskWith( 0xF ) ;
if ( device ( ) . is18Family ( ) ) id + = v ;
else {
// qDebug("id %i (%i): %s %s", i, nbb, toHex(v, 4).latin1(), toHex(v << (nbb*i), 9).latin1());
@ -416,7 +416,7 @@ BitValue Pic::Memory::checksum() const
cs + = id ;
}
//qDebug("checksum: %s %s", toHexLabelAbs(cs).latin1(), toHex(cs & 0xFFFF, 4).latin1());
return cs . tq maskWith( 0xFFFF ) ;
return cs . maskWith( 0xFFFF ) ;
}
BitValue Pic : : Memory : : unprotectedChecksum ( ) const
@ -474,7 +474,7 @@ void Pic::Memory::toHexBuffer(MemoryRangeType type, HexBuffer &hb) const
//qDebug("%s wnb=%i snb=%i div=%i", MEMORY_RANGE_TYPE_DATA[type].label, wNbBytes, sNbBytes, div);
for ( uint k = 0 ; k < wNbBytes * device ( ) . nbWords ( type ) ; k + + ) {
// set byte
BitValue s = _ranges [ type ] [ wOffset ] . tq maskWith( tqmask ) ;
BitValue s = _ranges [ type ] [ wOffset ] . maskWith( tqmask ) ;
//if ( k<4 ) qDebug("s=%s so=%s sb=%i wo=%i wb=%i", toHex(s, 8).data(), toHex(sOffset, 8).data(), sByte, wOffset, wByte);
s = s . byte ( wByte ) ;
if ( ( byte % 2 ) = = 0 ) hb . insert ( offset , s ) ;
@ -540,12 +540,12 @@ void Pic::Memory::fromHexBuffer(MemoryRangeType type, const HexBuffer &hb, Warni
wByte + + ;
if ( ( wByte % wNbBytes ) = = 0 ) {
if ( _ranges [ type ] [ wOffset ] . isInitialized ( ) ) {
if ( ! ( result & ValueTooLarge ) & & _ranges [ type ] [ wOffset ] . tq maskWith( tqmask ) ! = _ranges [ type ] [ wOffset ] ) {
if ( ! ( result & ValueTooLarge ) & & _ranges [ type ] [ wOffset ] . maskWith( tqmask ) ! = _ranges [ type ] [ wOffset ] ) {
result | = ValueTooLarge ;
warnings + = i18n ( " At least one word (at offset %1) is larger (%2) than the corresponding tqmask (%3). " )
. tqarg ( toHexLabel ( offset , 8 ) ) . tqarg ( toHexLabel ( _ranges [ type ] [ wOffset ] , 8 ) ) . tqarg ( toHexLabel ( tqmask , 8 ) ) ;
}
_ranges [ type ] [ wOffset ] = _ranges [ type ] [ wOffset ] . tq maskWith( tqmask ) ;
_ranges [ type ] [ wOffset ] = _ranges [ type ] [ wOffset ] . maskWith( tqmask ) ;
}
wByte = 0 ;
wOffset + + ;