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 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sergeykhbr
/*
2
 *  Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
3
 *
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
 *  you may not use this file except in compliance with the License.
6
 *  You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *  Unless required by applicable law or agreed to in writing, software
11
 *  distributed under the License is distributed on an "AS IS" BASIS,
12
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *  See the License for the specific language governing permissions and
14
 *  limitations under the License.
15
 */
16
 
17 3 sergeykhbr
#include "soc_info.h"
18
 
19
namespace debugger {
20
 
21
/** Class registration in the Core */
22
REGISTER_CLASS(SocInfo)
23
 
24
SocInfo::SocInfo(const char *name)
25
    : IService(name) {
26
    registerInterface(static_cast<ISocInfo *>(this));
27
    registerAttribute("PnpBaseAddress", &pnpBase_);
28
    registerAttribute("DsuBaseAddress", &dsuBase_);
29
    registerAttribute("GpioBaseAddress", &gpioBase_);
30
    registerAttribute("ListCSR", &listCSR_);
31
    registerAttribute("ListRegs", &listRegs_);
32
 
33
    dsuBase_.make_uint64(0);
34
    listCSR_.make_list(0);
35
    listRegs_.make_list(0);
36
}
37
 
38
void SocInfo::postinitService() {
39
}
40
 
41
unsigned SocInfo::getMastersTotal() {
42
    // todo: via reading PNP configuration
43
    return CFG_NASTI_MASTER_TOTAL;
44
}
45
 
46
unsigned SocInfo::getSlavesTotal() {
47
    // todo: via reading PNP configuration
48
    return 0;
49
}
50
 
51
unsigned SocInfo::getRegsTotal() {
52
    return listRegs_.size();
53
}
54
 
55
void SocInfo::getRegsList(AttributeType *lst) {
56
    lst->make_list(listRegs_.size());
57
    for (unsigned i = 0; i < listRegs_.size(); i++) {
58 4 sergeykhbr
        const AttributeType &name = listRegs_[i][0u];
59
        if (name.size() == 0) {
60
            continue;
61
        }
62
        (*lst)[i] = name;
63 3 sergeykhbr
    }
64
}
65
 
66
unsigned SocInfo::getCsrTotal() {
67
    return listCSR_.size();
68
}
69
 
70
void SocInfo::getCsrList(AttributeType *lst) {
71
    lst->make_list(listCSR_.size());
72
    for (unsigned i = 0; i < listCSR_.size(); i++) {
73
        (*lst)[i] = listCSR_[i][0u];
74
    }
75
}
76
 
77
uint64_t SocInfo::csr2addr(const char *name) {
78
    DsuMapType *dsu = reinterpret_cast<DsuMapType *>(dsuBase_.to_uint64());
79
    AttributeType id(name);
80
    for (unsigned i = 0; i < listCSR_.size(); i++) {
81
        if (strcmp(id.to_upper(), listCSR_[i][0u].to_string()) == 0) {
82
            return reinterpret_cast<uint64_t>(
83
                &dsu->csr[listCSR_[i][2].to_uint64()]);
84
        }
85
    }
86
    return REG_ADDR_ERROR;
87
}
88
 
89
uint64_t SocInfo::reg2addr(const char *name) {
90
    for (unsigned i = 0; i < listRegs_.size(); i++) {
91
        if (strcmp(name, listRegs_[i][0u].to_string()) == 0) {
92 4 sergeykhbr
            return dsuBase_.to_uint64() + listRegs_[i][2].to_uint64();
93 3 sergeykhbr
        }
94
    }
95
    return REG_ADDR_ERROR;
96
}
97
 
98
uint64_t SocInfo::addressPlugAndPlay() {
99
    return pnpBase_.to_uint64();
100
}
101
 
102
uint64_t SocInfo::addressGpio() {
103
    return gpioBase_.to_uint64();
104
}
105
 
106
}  // namespace debugger

powered by: WebSVN 2.1.0

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