예제 #1
0
BIT_STRING_CLASS * RegDataCache::queryCache(
                            ExtensibleChip* i_pChip,
                            const SCAN_COMM_REGISTER_CLASS * i_pRegister )const
{
    ScomRegisterAccess l_scomAccessKey ( *i_pRegister,i_pChip );
    return queryCache( l_scomAccessKey );
}
예제 #2
0
QDateTime Database::replaceCacheRecordByServerRecord(const QSqlDatabase& dbCache, const QString& table, const QSqlQuery& queryMaster)
{
    QDateTime updated;    
    QSqlRecord record = queryMaster.record();
    int fieldUpdated = record.indexOf("updated");
    if (fieldUpdated == -1)
    {
        fieldUpdated = record.indexOf("created");
    }

    Q_ASSERT(fieldUpdated > -1);
    updated = record.value(fieldUpdated).toDateTime();

    int n = record.count();
    if (n > 1)
    {
        QString sql = QString("REPLACE INTO %1 (").arg(table);
        bool first = true;
        for (int i = 0; i < n; i++)
        {
            if (first)
                first = false;
            else
                sql += ", ";

            sql += record.fieldName(i);
        }
        sql += ") VALUES (";

        first = true;
        for (int i = 0; i < n; i++)
        {
            if (first)
                first = false;
            else
                sql += ", ";

            sql += "?";
        }
        sql += ")";

        QSqlQuery queryCache(dbCache);
        queryCache.setForwardOnly(true);
        queryCache.prepare(sql);

        for (int i = 0; i < n; i++)
        {
            QVariant v(record.value(i));
            if (v.type() == QVariant::DateTime)
                queryCache.bindValue(i, datetimeToString(v.toDateTime()));
            else
                queryCache.bindValue(i, v);
        }

        if (!queryCache.exec())
            throw DatabaseException(queryCache);
    }

    return updated;
}
예제 #3
0
uint32_t ScomRegister::Read() const
{
    uint32_t o_rc = SUCCESS;

    // First query the cache for an existing entry.
    if ( !queryCache() )
    {
        // There was not a previous entry in the cache, so do a ForceRead() to
        // sync the cache with hardware.
        o_rc = ForceRead();
    }

    return o_rc;
}
예제 #4
0
static KFileMetaInfo cachedMetaInfo(const KFileItem& file)
{
    QString dbName="metainfocache";
    if (!QSqlDatabase::contains(dbName))
    {
        QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE",dbName);
        db.setDatabaseName(KStandardDirs::locateLocal("appdata", dbName+".sqlite"));
        if (KDE_ISUNLIKELY( !db.open() ))
            return KFileMetaInfo(file.url());
        initDataBase(db);
    }
    QSqlDatabase db=QSqlDatabase::database(dbName);
    if (!db.isOpen())
        return KFileMetaInfo(file.url());

    static const QString fields[]={
        "translation.translated",
        "translation.untranslated",
        "translation.fuzzy",
        "translation.last_translator",
        "translation.source_date",
        "translation.translation_date",
        "translation.translated_reviewer",
        "translation.translated_approver",
        "translation.fuzzy_reviewer",
        "translation.fuzzy_approver"
    };
    static const int nFields = sizeof(fields) / sizeof(fields[0]);

    QByteArray result;

    QSqlQuery queryCache(db);
    queryCache.prepare("SELECT * from metainfo where filepath=?");
    queryCache.bindValue(0, qHash(file.localPath()));
    queryCache.exec();
    if (queryCache.next() && file.time(KFileItem::ModificationTime).dateTime()==queryCache.value(2).toDateTime())
    {
        result=queryCache.value(1).toByteArray();
        QDataStream stream(&result,QIODevice::ReadOnly);

        //unfortunately direct KFileMetaInfo << operator doesn't work
        KFileMetaInfo info;
        QVector<QVariant> keys;
        stream>>keys;
        for(int i=0;i<keys.count();i++)
            info.item(fields[i]).setValue(keys.at(i));
        return info;
    }
예제 #5
0
BIT_STRING_CLASS & RegDataCache::read( ExtensibleChip * i_chip,
                                       const SCAN_COMM_REGISTER_CLASS * i_reg )
{
    ScomRegisterAccess l_scomAccessKey ( *i_reg, i_chip );
    BIT_STRING_CLASS * l_pBitString = queryCache( l_scomAccessKey );

    if ( NULL == l_pBitString )
    {
        // Creating new entry
        l_pBitString = new BitStringBuffer( i_reg->GetBitLength() );
        // Adding register in the cache
        iv_cachedRead[l_scomAccessKey] = l_pBitString;
    }

    return *l_pBitString;
}
예제 #6
0
/******************************************************************************************************
 * Access L2 cache to get reference
 ******************************************************************************************************/
void queryL2( struct state* state ) {
    
    // Decompose the address for the L2 cache
    struct L2_Reference L2_Ref;
    constructL2Ref( &L2_Ref, state->L1_Index, state->L1_Tag );
    
    // Update index and tag for L2 cache
    state->L2_Tag = L2_Ref.L2_Tag;
    state->L2_Index = L2_Ref.L2_Index;

    // Query L2 cache
    bool hit = queryCache( L2_Ref.L2_Index, L2_Ref.L2_Tag, &L2_unified );

    // Transition based on result
    if( (hit == TRUE) && (state->type == 'W') ) {
        runResults.l2_hit++;
        runResults.numWriteCycles += config.L2_hit_time;
        state->next = HANDLE_WRITE;
        return;
    } else if( hit == TRUE ) {
        if ( state->type == 'R') {
            runResults.numReadCycles += config.L2_hit_time;
        } else {
            runResults.numInstCycles += config.L2_hit_time;
        }
        runResults.l2_hit++;
        state->next = IDLE;
        return;
    } else {
        if ( state->type == 'R') {
            runResults.numReadCycles += config.L2_miss_time + config.L2_hit_time + config.L2_transfer_cycles;
        } else if ( state->type == 'W') {
            runResults.numWriteCycles += config.L2_miss_time + config.L2_hit_time + config.L2_transfer_cycles;
        } else {
            runResults.numInstCycles += config.L2_miss_time + config.L2_hit_time + config.L2_transfer_cycles;
        }

        runResults.l2_miss++;
        state->next = ADD_L2;
        return;
    }
}
예제 #7
0
/******************************************************************************************************
 * Query L1 cache to get reference
 ******************************************************************************************************/
void queryL1( struct state* state, struct cache* cache ) {

    // Query L1 cache
    bool hit = queryCache( state->L1_Index, state->L1_Tag, cache );

    // Transition based on result
    if( (hit == TRUE) && (state->type == 'W') ) {
        runResults.l1d_hit++;
        runResults.numWriteCycles += config.L1_hit_time;
        state->next = HANDLE_WRITE;
        return;
    } 
    else if( hit == TRUE) {
        if (state-> type == 'R') {
            runResults.l1d_hit++;
            runResults.numReadCycles += config.L1_hit_time;
        } else {
            runResults.l1i_hit++;
            runResults.numInstCycles += config.L1_hit_time;
        }
        state->next = IDLE;
        return;
    } 
    else {
        if (state->type == 'I') {
            runResults.l1i_miss++;
            runResults.numInstCycles += config.L1_miss_time + config.L1_hit_time + config.L1_transfer_cycles;

        } else if (state->type == 'W') {
            runResults.l1d_miss++;
            runResults.numWriteCycles += config.L1_miss_time + config.L1_hit_time + config.L1_transfer_cycles;
        } else {
            runResults.l1d_miss++;
            runResults.numReadCycles += config.L1_miss_time + config.L1_hit_time + config.L1_transfer_cycles;
        }
        // state->next = QUERY_L2;
        state->next = ADD_L1;
        return;
    }
}
예제 #8
0
uint32_t ScomRegister::Write()
{
    #define PRDF_FUNC "[ScomRegister::Write] "

    uint32_t o_rc = FAIL;

    do
    {
        // No write allowed if register access attribute is read-only or no
        // access.
        if ( ( ACCESS_NONE == iv_operationType ) &&
                 ( ACCESS_RO == iv_operationType ) )
        {
            PRDF_ERR( PRDF_FUNC"Read-only register: 0x%08x 0x%016llx",
                      getChip()->GetId(), iv_scomAddress );
            break;
        }

        // Query the cache for an existing entry.
        if ( !queryCache() )
        {
            // Something bad happened and there was nothing in the cache to
            // write to hardware.
            PRDF_ERR( PRDF_FUNC"No entry found in cache: 0x%08x 0x%016llx",
                      getChip()->GetId(), iv_scomAddress );
            break;
        }

        // Write hardware.
        o_rc = Access( readCache(), MopRegisterAccess::WRITE );

    } while (0);

    return o_rc;

    #undef PRDF_FUNC
}