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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [libdbg64g/] [services/] [exec/] [cmd/] [cmd_status.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 3 sergeykhbr
 */
16
 
17
#include "cmd_status.h"
18
 
19
namespace debugger {
20
 
21
CmdStatus::CmdStatus(ITap *tap, ISocInfo *info)
22
    : ICommand ("status", tap, info) {
23
 
24
    briefDescr_.make_string("Read target's status register");
25
    detailedDescr_.make_string(
26
        "Description:\n"
27
        "    Read target's status register as a uint64_t value.\n"
28
        "    Status register bits:\n"
29
        "        [0]     - Halt bit. 0 = running; 1 = is halted.\n"
30
        "        [1]     - Stepping mode enable bit.\n"
31
        "        [2]     - Breakpoint hit signaling bit.\n"
32
        "        [19:4]  - Core ID hardwired value.\n"
33
        "Example:\n"
34
        "    status\n");
35
}
36
 
37
bool CmdStatus::isValid(AttributeType *args) {
38
    if ((*args)[0u].is_equal(cmdName_.to_string()) && args->size() == 1) {
39
        return CMD_VALID;
40
    }
41
    return CMD_INVALID;
42
}
43
 
44
void CmdStatus::exec(AttributeType *args, AttributeType *res) {
45
    if (!isValid(args)) {
46
        generateError(res, "Wrong argument list");
47
        return;
48
    }
49
    res->make_nil();
50
 
51
    Reg64Type t1;
52
    DsuMapType *pdsu = info_->getpDsu();
53
    uint64_t addr = reinterpret_cast<uint64_t>(&pdsu->udbg.v.control);
54
    if (tap_->read(addr, 8, t1.buf) == TAP_ERROR) {
55
        return;
56
    }
57
    res->make_uint64(t1.val);
58
 
59
#if 0
60
    // Instr trace info
61
    addr = reinterpret_cast<uint64_t>(pdsu->ureg.v.instr_buf);
62
    AttributeType t2;
63
    t2.make_data(4*8);
64
    if (tap_->read(addr, 4*8, t2.data()) == TAP_ERROR) {
65
        return;
66
    }
67
    Reg64Type *instr = reinterpret_cast<Reg64Type *>(t2.data());
68
    RISCV_printf(0, 0, "    3. [%08x] %08x", instr[3].buf32[1], instr[3].buf32[0]);
69
    RISCV_printf(0, 0, "    2. [%08x] %08x", instr[2].buf32[1], instr[2].buf32[0]);
70
    RISCV_printf(0, 0, "    1. [%08x] %08x", instr[1].buf32[1], instr[1].buf32[0]);
71
    RISCV_printf(0, 0, "    0. [%08x] %08x", instr[0].buf32[1], instr[0].buf32[0]);
72
#endif
73
}
74
 
75
}  // namespace debugger

powered by: WebSVN 2.1.0

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