OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [libdbg64g/] [services/] [info/] [soc_info.cpp] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 sergeykhbr
#include "soc_info.h"
2
 
3
namespace debugger {
4
 
5
/** Class registration in the Core */
6
REGISTER_CLASS(SocInfo)
7
 
8
SocInfo::SocInfo(const char *name)
9
    : IService(name) {
10
    registerInterface(static_cast<ISocInfo *>(this));
11
    registerAttribute("PnpBaseAddress", &pnpBase_);
12
    registerAttribute("DsuBaseAddress", &dsuBase_);
13
    registerAttribute("GpioBaseAddress", &gpioBase_);
14
    registerAttribute("ListCSR", &listCSR_);
15
    registerAttribute("ListRegs", &listRegs_);
16
 
17
    dsuBase_.make_uint64(0);
18
    listCSR_.make_list(0);
19
    listRegs_.make_list(0);
20
}
21
 
22
void SocInfo::postinitService() {
23
}
24
 
25
unsigned SocInfo::getMastersTotal() {
26
    // todo: via reading PNP configuration
27
    return CFG_NASTI_MASTER_TOTAL;
28
}
29
 
30
unsigned SocInfo::getSlavesTotal() {
31
    // todo: via reading PNP configuration
32
    return 0;
33
}
34
 
35
unsigned SocInfo::getRegsTotal() {
36
    return listRegs_.size();
37
}
38
 
39
void SocInfo::getRegsList(AttributeType *lst) {
40
    lst->make_list(listRegs_.size());
41
    for (unsigned i = 0; i < listRegs_.size(); i++) {
42
        (*lst)[i] = listRegs_[i][0u];
43
    }
44
}
45
 
46
unsigned SocInfo::getCsrTotal() {
47
    return listCSR_.size();
48
}
49
 
50
void SocInfo::getCsrList(AttributeType *lst) {
51
    lst->make_list(listCSR_.size());
52
    for (unsigned i = 0; i < listCSR_.size(); i++) {
53
        (*lst)[i] = listCSR_[i][0u];
54
    }
55
}
56
 
57
uint64_t SocInfo::csr2addr(const char *name) {
58
    DsuMapType *dsu = reinterpret_cast<DsuMapType *>(dsuBase_.to_uint64());
59
    AttributeType id(name);
60
    for (unsigned i = 0; i < listCSR_.size(); i++) {
61
        if (strcmp(id.to_upper(), listCSR_[i][0u].to_string()) == 0) {
62
            return reinterpret_cast<uint64_t>(
63
                &dsu->csr[listCSR_[i][2].to_uint64()]);
64
        }
65
    }
66
    return REG_ADDR_ERROR;
67
}
68
 
69
uint64_t SocInfo::reg2addr(const char *name) {
70
    DsuMapType *dsu = reinterpret_cast<DsuMapType *>(dsuBase_.to_uint64());
71
    for (unsigned i = 0; i < listRegs_.size(); i++) {
72
        if (strcmp(name, listRegs_[i][0u].to_string()) == 0) {
73
            return reinterpret_cast<uint64_t>(
74
                &dsu->ureg.v.iregs[listRegs_[i][2].to_uint64()]);
75
        }
76
    }
77
    return REG_ADDR_ERROR;
78
}
79
 
80
uint64_t SocInfo::addressPlugAndPlay() {
81
    return pnpBase_.to_uint64();
82
}
83
 
84
uint64_t SocInfo::addressGpio() {
85
    return gpioBase_.to_uint64();
86
}
87
 
88
}  // namespace debugger

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.