Ejemplo n.º 1
0
extern "C" IFace *RISCV_get_service_iface(const char *servname,
                                          const char *facename) {
    IService *iserv = static_cast<IService *>(RISCV_get_service(servname));
    if (iserv == NULL) {
        return NULL;
    }
    return iserv->getInterface(facename);
}
Ejemplo n.º 2
0
extern "C" void RISCV_get_services_with_iface(const char *iname,  
                                             AttributeType *list) {
    IClass *icls;
    IService *iserv;
    IFace *iface;
    const AttributeType *tlist;
    list->make_list(0);
    
    for (unsigned i = 0; i < listClasses_.size(); i++) {
        icls = static_cast<IClass *>(listClasses_[i].to_iface());
        tlist = icls->getInstanceList();
        if (tlist->size()) {
            iserv = static_cast<IService *>((*tlist)[0u].to_iface());
            iface = iserv->getInterface(iname);
            if (iface) {
                AttributeType t1(iface);
                list->add_to_list(&t1);
            }
        }
    }
}
Ejemplo n.º 3
0
void CpuRiscV_Functional::executeInstruction(IInstruction *instr,
                                             uint32_t *rpayload) {

    CpuContextType *pContext = getpContext();
    if (pContext->reg_trace_file) {
        /** Save previous reg values to find modification after exec() */
        for (int i = 0; i < Reg_Total; i++) {
            iregs_prev[i] = pContext->regs[i];
        }
    }

    instr->exec(cacheline_, pContext);
#if 0
    //if (pContext->pc >= 0x10000000) {
    //if ((pContext->pc >= 0x100000b4 && pContext->pc <= 0x10000130)
    //|| (pContext->pc >= 0x10001ef4)
    //) 
    {
    //if (pContext->pc >= 0x10001928 && pContext->pc <= 0x10001960) {
        RISCV_debug("[%" RV_PRI64 "d] %08x: %08x \t %4s <prv=%d; mstatus=%016" RV_PRI64 "x; mcause=%016" RV_PRI64 "x; ra=%016" RV_PRI64 "x; sp=%016" RV_PRI64 "x; tp=%016" RV_PRI64 "x>", 
            getStepCounter(),
            static_cast<uint32_t>(pContext->pc),
            rpayload[0], instr->name(),
            pContext->cur_prv_level,
            pContext->csr[CSR_mstatus],
            pContext->csr[CSR_mcause],
            pContext->regs[Reg_ra],
            pContext->regs[Reg_sp],
            pContext->regs[Reg_tp]
            );
    }
#endif
    if (pContext->reg_trace_file) {
        int sz;
        sz = RISCV_sprintf(tstr, sizeof(tstr),"%8I64d [%08x] %08x: ",
            pContext->step_cnt, static_cast<uint32_t>(pContext->pc), rpayload[0]);

        bool reg_changed = false;
        for (int i = 0; i < 32; i++) {
            if (iregs_prev[i] != pContext->regs[i]) {
                reg_changed = true;
                sz += RISCV_sprintf(&tstr[sz], sizeof(tstr) - sz,
                        "%3s <= %016I64x\n", IREGS_NAMES[i], pContext->regs[i]);
            }
        }
        if (!reg_changed) {
            sz += RISCV_sprintf(&tstr[sz], sizeof(tstr) - sz, "%s", "-\n");
        }
        (*pContext->reg_trace_file) << tstr;
        pContext->reg_trace_file->flush();
    }

    if (generateRegTraceFile_.to_bool()) {
        char msg[16];
        int msg_len = 0;
        IService *uart = NULL;
        switch (pContext->step_cnt) {
        case 6000:
            uart = static_cast<IService *>(RISCV_get_service("uart0"));
            msg[0] = 'h';
            msg[1] = 'i';
            msg_len = 2;
            break;
        case 6500:
            uart = static_cast<IService *>(RISCV_get_service("uart0"));
            msg[0] = 'g';
            msg[1] = 'h';
            msg[2] = 't';
            msg_len = 3;
            break;
        case 8200:
            uart = static_cast<IService *>(RISCV_get_service("uart0"));
            msg[0] = 'i';
            msg[1] = 'c';
            msg_len = 2;
            break;
        case 8300:
            uart = static_cast<IService *>(RISCV_get_service("uart0"));
            msg[0] = 'k';
            msg[1] = 's';
            msg[2] = '\r';
            msg[3] = '\n';
            msg_len = 4;
            break;
        default:;
        }

        if (uart) {
            ISerial *iserial = static_cast<ISerial *>(
                        uart->getInterface(IFACE_SERIAL));
            //iserial->writeData("pnp\r\n", 6);
            //iserial->writeData("highticks\r\n", 11);
            iserial->writeData(msg, msg_len);
        }
    }


    if (pContext->regs[0] != 0) {
        RISCV_error("Register x0 was modificated (not equal to zero)", NULL);
    }
}