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 2

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

Line No. Rev Author Line
1 2 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2017 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      Read target's status register.
6
 */
7
 
8
#include "cmd_status.h"
9
 
10
namespace debugger {
11
 
12
CmdStatus::CmdStatus(ITap *tap, ISocInfo *info)
13
    : ICommand ("status", tap, info) {
14
 
15
    briefDescr_.make_string("Read target's status register");
16
    detailedDescr_.make_string(
17
        "Description:\n"
18
        "    Read target's status register as a uint64_t value.\n"
19
        "    Status register bits:\n"
20
        "        [0]     - Halt bit. 0 = running; 1 = is halted.\n"
21
        "        [1]     - Stepping mode enable bit.\n"
22
        "        [2]     - Breakpoint hit signaling bit.\n"
23
        "        [19:4]  - Core ID hardwired value.\n"
24
        "Example:\n"
25
        "    status\n");
26
}
27
 
28
bool CmdStatus::isValid(AttributeType *args) {
29
    if ((*args)[0u].is_equal(cmdName_.to_string()) && args->size() == 1) {
30
        return CMD_VALID;
31
    }
32
    return CMD_INVALID;
33
}
34
 
35
void CmdStatus::exec(AttributeType *args, AttributeType *res) {
36
    if (!isValid(args)) {
37
        generateError(res, "Wrong argument list");
38
        return;
39
    }
40
    res->make_nil();
41
 
42
    Reg64Type t1;
43
    DsuMapType *pdsu = info_->getpDsu();
44
    uint64_t addr = reinterpret_cast<uint64_t>(&pdsu->udbg.v.control);
45
    if (tap_->read(addr, 8, t1.buf) == TAP_ERROR) {
46
        return;
47
    }
48
    res->make_uint64(t1.val);
49
 
50
#if 0
51
    // Instr trace info
52
    addr = reinterpret_cast<uint64_t>(pdsu->ureg.v.instr_buf);
53
    AttributeType t2;
54
    t2.make_data(4*8);
55
    if (tap_->read(addr, 4*8, t2.data()) == TAP_ERROR) {
56
        return;
57
    }
58
    Reg64Type *instr = reinterpret_cast<Reg64Type *>(t2.data());
59
    RISCV_printf(0, 0, "    3. [%08x] %08x", instr[3].buf32[1], instr[3].buf32[0]);
60
    RISCV_printf(0, 0, "    2. [%08x] %08x", instr[2].buf32[1], instr[2].buf32[0]);
61
    RISCV_printf(0, 0, "    1. [%08x] %08x", instr[1].buf32[1], instr[1].buf32[0]);
62
    RISCV_printf(0, 0, "    0. [%08x] %08x", instr[0].buf32[1], instr[0].buf32[0]);
63
#endif
64
}
65
 
66
}  // namespace debugger

powered by: WebSVN 2.1.0

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