Line 9... |
Line 9... |
#include <iostream>
|
#include <iostream>
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <string.h>
|
#include <string.h>
|
#include "api_types.h"
|
#include "api_types.h"
|
#include "coreservices/iserial.h"
|
#include "coreservices/iserial.h"
|
#include "coreservices/isignal.h"
|
|
|
|
namespace debugger {
|
namespace debugger {
|
|
|
/** Class registration in the Core */
|
/** Class registration in the Core */
|
REGISTER_CLASS(ConsoleService)
|
REGISTER_CLASS(ConsoleService)
|
Line 26... |
Line 25... |
: IService(name), IHap(HAP_ConfigDone),
|
: IService(name), IHap(HAP_ConfigDone),
|
portSerial_(this, "serialconsole", true) {
|
portSerial_(this, "serialconsole", true) {
|
registerInterface(static_cast<IThread *>(this));
|
registerInterface(static_cast<IThread *>(this));
|
registerInterface(static_cast<IHap *>(this));
|
registerInterface(static_cast<IHap *>(this));
|
registerInterface(static_cast<IRawListener *>(this));
|
registerInterface(static_cast<IRawListener *>(this));
|
registerInterface(static_cast<ISignalListener *>(this));
|
|
registerInterface(static_cast<IClockListener *>(this));
|
registerInterface(static_cast<IClockListener *>(this));
|
registerAttribute("Enable", &isEnable_);
|
registerAttribute("Enable", &isEnable_);
|
registerAttribute("StepQueue", &stepQueue_);
|
registerAttribute("StepQueue", &stepQueue_);
|
registerAttribute("AutoComplete", &autoComplete_);
|
registerAttribute("AutoComplete", &autoComplete_);
|
registerAttribute("CommandExecutor", &commandExecutor_);
|
registerAttribute("CommandExecutor", &commandExecutor_);
|
Line 123... |
Line 121... |
if (!iexec_) {
|
if (!iexec_) {
|
RISCV_error("Can't get ICmdExecutor interface %s",
|
RISCV_error("Can't get ICmdExecutor interface %s",
|
commandExecutor_.to_string());
|
commandExecutor_.to_string());
|
}
|
}
|
|
|
ISignal *itmp = static_cast<ISignal *>
|
|
(RISCV_get_service_iface(signals_.to_string(), IFACE_SIGNAL));
|
|
if (itmp) {
|
|
itmp->registerSignalListener(static_cast<ISignalListener *>(this));
|
|
}
|
|
|
|
AttributeType src_list;
|
AttributeType src_list;
|
RISCV_get_services_with_iface(IFACE_SOURCE_CODE, &src_list);
|
RISCV_get_services_with_iface(IFACE_SOURCE_CODE, &src_list);
|
if (src_list.is_list() && src_list.size()) {
|
if (src_list.is_list() && src_list.size()) {
|
IService *iserv = static_cast<IService *>(src_list[0u].to_iface());
|
IService *iserv = static_cast<IService *>(src_list[0u].to_iface());
|
isrc_ = static_cast<ISourceCode *>(
|
isrc_ = static_cast<ISourceCode *>(
|
Line 205... |
Line 197... |
cmd += defaultLogFile_.to_string();
|
cmd += defaultLogFile_.to_string();
|
iexec_->exec(cmd.c_str(), &res, true);
|
iexec_->exec(cmd.c_str(), &res, true);
|
}
|
}
|
}
|
}
|
|
|
void ConsoleService::updateSignal(int start, int width, uint64_t value) {
|
|
char sx[128];
|
|
RISCV_sprintf(sx, sizeof(sx), "<led[%d:%d]> %02" RV_PRI64 "xh\n",
|
|
start + width - 1, start, value);
|
|
writeBuffer(sx);
|
|
}
|
|
|
|
void ConsoleService::updateData(const char *buf, int buflen) {
|
void ConsoleService::updateData(const char *buf, int buflen) {
|
writeBuffer(buf);
|
writeBuffer(buf);
|
}
|
}
|
|
|
void ConsoleService::busyLoop() {
|
void ConsoleService::busyLoop() {
|
Line 240... |
Line 225... |
RISCV_printf0("%s%s", ENTRYSYMBOLS, cmd.to_string());
|
RISCV_printf0("%s%s", ENTRYSYMBOLS, cmd.to_string());
|
|
|
iexec_->exec(cmd.to_string(), &cmdres, false);
|
iexec_->exec(cmd.to_string(), &cmdres, false);
|
|
|
if (!cmdres.is_nil() && !cmdres.is_invalid()) {
|
if (!cmdres.is_nil() && !cmdres.is_invalid()) {
|
RISCV_printf0("%s", cmdres.to_config());
|
RISCV_printf0("%s", cmdres.to_config().to_string());
|
}
|
}
|
} else {
|
} else {
|
RISCV_mutex_lock(&mutexConsoleOutput_);
|
RISCV_mutex_lock(&mutexConsoleOutput_);
|
std::cout << '\r' << ENTRYSYMBOLS << cmd.to_string();
|
std::cout << '\r' << ENTRYSYMBOLS << cmd.to_string();
|
if (cmdSizePrev_ > cmd.size()) {
|
if (cmdSizePrev_ > cmd.size()) {
|
Line 358... |
Line 343... |
return bytesWaiting != 0;
|
return bytesWaiting != 0;
|
#endif
|
#endif
|
}
|
}
|
|
|
uint32_t ConsoleService::getData() {
|
uint32_t ConsoleService::getData() {
|
Reg64Type tbuf = {0};
|
Reg64Type tbuf;
|
|
tbuf.val = 0;
|
int pos = 0;
|
int pos = 0;
|
while (isData()) {
|
while (isData()) {
|
tbuf.val <<= 8;
|
tbuf.val <<= 8;
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
tbuf.buf[pos++] = static_cast<uint8_t>(_getch());
|
tbuf.buf[pos++] = static_cast<uint8_t>(_getch());
|