?? chipdefbase.cpp
字號:
bool RetVal = false;
UInt32 iFeatureValue;
UInt32 Value;
switch ( m_Features[iFeature].Type )
{
case FT_NUMB:
case FT_ADDR:
RetVal = SetFeatureNumValue( Keyname, atoi32(StrValue,m_Features[iFeature].Radix) );
break;
case FT_FREQ:
RetVal = SetFeatureNumValue( Keyname, atohz(StrValue,MHZ) );
break;
case FT_TEXT:
assert( false ); // The chip-specific class should have handled this!
break;
case FT_LIST:
if ( LookupFeatureValue(iFeature,StrValue,&iFeatureValue) )
RetVal = SetFeatureRawValue( Keyname, m_Features[iFeature].Values[iFeatureValue].Index );
break;
case FT_BOOL:
if ( stricmp(StrValue,"Enabled")==0 || stricmp(StrValue,"True")==0 || stricmp(StrValue,"T")==0 || stricmp(StrValue,"On")==0 || stricmp(StrValue,"1")==0 )
Value = 1;
else if ( stricmp(StrValue,"Disabled")==0 || stricmp(StrValue,"False")==0 || stricmp(StrValue,"F")==0 || stricmp(StrValue,"Off")==0 || stricmp(StrValue,"0")==0 )
Value = 0;
else
return false; // Unknown string.
if ( m_Features[iFeature].BoolInvert )
Value = Value ? 0 : 1;
RetVal = SetFeatureRawValue( Keyname, Value );
break;
case FT_SEQU:
{
int i = 0;
int iLabel = 0;
int nItems = 0;
UInt32 Type;
UInt32 Value;
char Label[256];
RetVal = true;
while ( StrValue[i] )
{
switch ( StrValue[i++] )
{
case 'c': Type=SEQ_COMMAND; break;
case 'p': Type=SEQ_PARAM; break;
case 'd': Type=SEQ_DELAY; break;
default: while (StrValue[i] && StrValue[i]!=';') i++; continue;
}
Value = atoi32( StrValue+i, (Type==SEQ_DELAY?10:16) );
while ( StrValue[i] && StrValue[i]!='(' && StrValue[i]!=' ' )
i++;
iLabel = 0;
if ( StrValue[i] == '(' )
{
i++;
while ( StrValue[i] && StrValue[i]!=')' && StrValue[i]!=';' && iLabel<sizeof(Label)-1 )
Label[iLabel++] = StrValue[i++];
if ( StrValue[i] == ')' )
i++;
}
Label[iLabel] = '\0';
RetVal = SetFeatureSeqValue(Keyname,nItems++,Type,Value,Label) && RetVal;
while ( StrValue[i] == ' ' )
i++;
}
SetFeatureSeqCount( Keyname, nItems );
}
break;
}
return RetVal;
}
assert( false ); // ERROR: either this keyname doesn't exist, or you should have called IsFeatureValid() first!
return false;
}
int ChipDefBase::GetFeatureAddrOffset( in const char* Keyname )
{
UInt32 iFeature;
if ( LookupFeature(Keyname,&iFeature) )
{
assert( m_Features[iFeature].Type==FT_ADDR );
return m_Features[iFeature].OffsetOf;
}
assert( false ); // ERROR: either this keyname doesn't exist, or you should have called IsFeatureValid() first!
return 0;
}
bool ChipDefBase::GetFeatureListValues( in const char* Keyname, in int ListIndex, out UInt32* RawValue, out UInt32* ToRawValue )
{
UInt32 iFeature;
if ( LookupFeature(Keyname,&iFeature) )
{
bool RetVal = false;
switch ( m_Features[iFeature].Type )
{
case FT_LIST:
case FT_BOOL:
if ( m_Features[iFeature].NumValues == 0 )
{
// Note: This is a LIST item with no items. We must assume that it's a NEEDSCODE item. Pretend that there is only one
// value. This is important, because we use this to fake a constant value that is not a TEXT feature. For instance,
// if we want to fake a 'PCLK Source = SYSCLK' even though no such register exists, we can use a LIST item with NEEDSCODE
// to fake it, because if we use a TEXT feature, double-quotes would show up: 'PCLK Source = "SYSCLK"'. [ROC SEP-10-2002]
if ( ListIndex == 0 )
{
if ( RawValue != NULL )
*RawValue = 0;
if ( ToRawValue != NULL )
*ToRawValue = 0;
RetVal = true;
}
}
else if ( ListIndex < (int)m_Features[iFeature].NumValues )
{
UInt32 RealIndex = GetFeatureValueRealIndex( Keyname, ListIndex );
if ( RawValue != NULL )
*RawValue = m_Features[iFeature].Values[RealIndex].Index;
if ( ToRawValue != NULL )
*ToRawValue = m_Features[iFeature].Values[RealIndex].ToIndex;
RetVal = true;
}
break;
default:
case FT_NUMB:
case FT_ADDR:
case FT_FREQ:
case FT_TEXT:
assert( false );
break;
}
return RetVal;
}
assert( false ); // ERROR: either this keyname doesn't exist, or you should have called IsFeatureValid() first!
return false;
}
bool ChipDefBase::IsFeatureListIndexValid( in const char* Keyname, in UInt32 ListIndex )
{
bool RetVal = false;
UInt32 iFeature;
if ( LookupFeature(Keyname,&iFeature) )
{
switch ( m_Features[iFeature].Type )
{
case FT_LIST:
case FT_BOOL:
if ( m_Features[iFeature].NumValues )
RetVal = MatchToCurrentProduct( m_Features[iFeature].Values[GetFeatureValueRealIndex(Keyname,ListIndex)].Product );
else
RetVal = true;
break;
default:
case FT_NUMB:
case FT_ADDR:
case FT_FREQ:
case FT_TEXT:
assert( false );
break;
}
}
return RetVal;
}
bool ChipDefBase::IsFeatureListIndexReserved( in const char* Keyname, in UInt32 ListIndex )
{
UInt32 iFeature;
if ( LookupFeature(Keyname,&iFeature) )
{
bool RetVal = false;
switch ( m_Features[iFeature].Type )
{
case FT_LIST:
case FT_BOOL:
if ( m_Features[iFeature].NumValues )
{
UInt32 RealIndex = GetFeatureValueRealIndex( Keyname, ListIndex );
RetVal = m_Features[iFeature].Values[RealIndex].Reserved && MatchToCurrentProduct( m_Features[iFeature].Values[RealIndex].Reserved );
}
else
RetVal = false;
break;
default:
case FT_NUMB:
case FT_ADDR:
case FT_FREQ:
case FT_TEXT:
assert( false );
break;
}
return RetVal;
}
assert( false ); // ERROR: either this keyname doesn't exist, or you should have called IsFeatureValid() first!
return false;
}
bool ChipDefBase::IsFeatureListIndexReadOnly( in const char* Keyname, in UInt32 ListIndex )
{
UInt32 iFeature;
if ( LookupFeature(Keyname,&iFeature) )
{
bool RetVal = false;
switch ( m_Features[iFeature].Type )
{
case FT_LIST:
case FT_BOOL:
if ( m_Features[iFeature].NumValues )
{
UInt32 iFeatureValue = GetFeatureValueRealIndex( Keyname, ListIndex );
RetVal = ( m_Features[iFeature].Values[iFeatureValue].ReadValueName!=NULL && m_Features[iFeature].Values[iFeatureValue].WriteValueName==NULL );
}
else
RetVal = false;
break;
default:
case FT_NUMB:
case FT_ADDR:
case FT_FREQ:
case FT_TEXT:
assert( false );
break;
}
return RetVal;
}
assert( false ); // ERROR: either this keyname doesn't exist, or you should have called IsFeatureValid() first!
return false;
}
bool ChipDefBase::IsFeatureListIndexWriteOnly( in const char* Keyname, in UInt32 ListIndex )
{
UInt32 iFeature;
if ( LookupFeature(Keyname,&iFeature) )
{
bool RetVal = false;
switch ( m_Features[iFeature].Type )
{
case FT_LIST:
case FT_BOOL:
if ( m_Features[iFeature].NumValues )
{
UInt32 iFeatureValue = GetFeatureValueRealIndex( Keyname, ListIndex );
RetVal = ( m_Features[iFeature].Values[iFeatureValue].ReadValueName==NULL && m_Features[iFeature].Values[iFeatureValue].WriteValueName!=NULL );
}
else
RetVal = false;
break;
default:
case FT_NUMB:
case FT_ADDR:
case FT_FREQ:
case FT_TEXT:
assert( false );
break;
}
return RetVal;
}
assert( false ); // ERROR: either this keyname doesn't exist, or you should have called IsFeatureValid() first!
return false;
}
bool ChipDefBase::IsFeatureListIndexRWDiff( in const char* Keyname, in UInt32 ListIndex )
{
UInt32 iFeature;
if ( LookupFeature(Keyname,&iFeature) )
{
bool RetVal = false;
switch ( m_Features[iFeature].Type )
{
case FT_LIST:
case FT_BOOL:
if ( m_Features[iFeature].NumValues )
{
UInt32 iFeatureValue = GetFeatureValueRealIndex( Keyname, ListIndex );
RetVal = ( m_Features[iFeature].Values[iFeatureValue].ReadValueName!=NULL || m_Features[iFeature].Values[iFeatureValue].WriteValueName!=NULL );
}
else
return false;
break;
default:
case FT_NUMB:
case FT_ADDR:
case FT_FREQ:
case FT_TEXT:
assert( false );
break;
}
return RetVal;
}
assert( false ); // ERROR: either this keyname doesn't exist, or you should have called IsFeatureValid() first!
return false;
}
bool ChipDefBase::GetFeatureListIndex( in const char* Keyname, out int* ListIndex )
{
UInt32 iFeature;
assert( ListIndex != NULL );
if ( LookupFeature(Keyname,&iFeature) )
{
UInt32 FromValue;
UInt32 ToValue;
UInt32 RawValue;
if ( m_Features[iFeature].NumValues )
{
RawValue = GetFeatureRawValue( Keyname );
for ( int i=0; GetFeatureListValues(Keyname,i,&FromValue,&ToValue); i++ )
{
if ( RawValue>=FromValue && RawValue<=ToValue )
{
*ListIndex = i;
return true;
}
}
}
else
{
*ListIndex = 0;
return true;
}
}
*ListIndex = 0;
return false;
}
bool ChipDefBase::SetFeatureListIndex( in const char* Keyname, in int ListIndex )
{
UInt32 iFeature;
if ( LookupFeature(Keyname,&iFeature) )
{
switch ( m_Features[iFeature].Type )
{
case FT_LIST:
case FT_BOOL:
if ( m_Features[iFeature].NumValues )
SetFeatureRawValue( Keyname, m_Features[iFeature].Values[GetFeatureValueRealIndex(Keyname,ListIndex)].Index );
break;
default:
case FT_NUMB:
case FT_ADDR:
case FT_FREQ:
case FT_TEXT:
assert( false );
break;
}
return true;
}
assert( false ); // ERROR: either this keyname doesn't exist, or you should have called IsFeatureValid() first!
return false;
}
bool ChipDefBase::GetFeatureSeqValue( in const char* Keyname, in int ListIndex, out UInt32* Type, out UInt32* Value, out char* *Label )
{
assert( false ); // The chip-specific class should have handled this!
return false;
}
bool ChipDefBase::SetFeatureSeqValue( in const char* Keyname, in int ListIndex, in UInt32 Type, in UInt32 Value, in char* Label )
{
assert( false ); // The chip-specific class should have handled this!
return false;
}
int ChipDefBase::GetFeatureSeqMax( in const char* Keyname )
{
assert( false ); // The chip-specific class should have handled this!
return 0;
}
int ChipDefBase::GetFeatureSeqCount( in const char* Keyname )
{
assert( false ); // The chip-specific class should have handled this!
return 0;
}
bool ChipDefBase::SetFeatureSeqCount( in const char* Keyname, in int nItems )
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -