Add return value descriptions to syscall definitions
MODIFY
src/syscall/ripes_syscall.h
src/syscall/ripes_syscall.h
@@ -16,21 +16,39 @@ namespace Ripes {
class Syscall {
public:
Syscall(const QString& name, const QString& description = QString(),
- const std::map<unsigned, QString>& argumentDescriptions = std::map<unsigned, QString>())
- : m_name(name), m_description(description), m_argumentDescriptions(argumentDescriptions) {}
+ const std::map<unsigned, QString>& argumentDescriptions = std::map<unsigned, QString>(),
+ const std::map<unsigned, QString>& returnDescriptions = std::map<unsigned, QString>())
+ : m_name(name),
+ m_description(description),
+ m_argumentDescriptions(argumentDescriptions),
+ m_returnDescriptions(returnDescriptions) {}
virtual ~Syscall() {}
const QString& name() const { return m_name; }
const QString& description() const { return m_description; }
const std::map<unsigned, QString>& argumentDescriptions() const { return m_argumentDescriptions; }
+ const std::map<unsigned, QString>& returnDescriptions() const { return m_returnDescriptions; }
virtual void execute() = 0;
+ /**
+ * @brief getArg
+ * ABI/ISA specific specialization of returning an argument register value.
+ * Argument index @p i is 0-indexed. @returns value of the specified argument register.
+ */
+
virtual uint32_t getArg(unsigned i) const = 0;
+ /**
+ * @brief setRet
+ * ABI/ISA specific specialization of setting an argument register return value.
+ * Argument index @p i is 0-indexed.
+ */
+ virtual void setRet(unsigned i, uint32_t value) const = 0;
protected:
const QString m_name;
const QString m_description;
const std::map<unsigned, QString> m_argumentDescriptions;
+ const std::map<unsigned, QString> m_returnDescriptions;
};
class SyscallManager {

MODIFY
src/syscall/riscv_syscall.h
src/syscall/riscv_syscall.h
// Syscall headers
#include "control.h"
+#include "file.h"
#include "print.h"
namespace Ripes {
@@ -12,15 +13,24 @@ namespace Ripes {
class RISCVSyscall : public Syscall {
public:
RISCVSyscall(const QString& name, const QString& description = QString(),
- const std::map<unsigned, QString>& argumentDescriptions = std::map<unsigned, QString>())
- : Syscall(name, description, argumentDescriptions) {}
+ const std::map<unsigned, QString>& argumentDescriptions = std::map<unsigned, QString>(),
+ const std::map<unsigned, QString>& returnDescriptions = std::map<unsigned, QString>())
+ : Syscall(name, description, argumentDescriptions, returnDescriptions) {}
~RISCVSyscall() override {}
+
uint32_t getArg(unsigned i) const override {
// RISC-V arguments range from a0-a6
assert(i < 7);
const int regIdx = 10 + i; // a0 = x10
return ProcessorHandler::get()->getRegisterValue(regIdx);
}
+
+ void setRet(unsigned i, uint32_t value) const override {
+ // RISC-V arguments range from a0-a6
+ assert(i < 7);
+ const int regIdx = 10 + i; // a0 = x10
+ ProcessorHandler::get()->setRegisterValue(regIdx, value);
+ }
};
class RISCVSyscallManager : public SyscallManagerT<RISCVSyscall> {
@@ -38,6 +48,13 @@ public:
// Control syscalls
emplace<ExitSyscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::Exit);
emplace<Exit2Syscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::Exit2);
+
+ // File syscalls
+ emplace<CloseSyscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::Close);
+ emplace<LSeekSyscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::LSeek);
+ emplace<ReadSyscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::Read);
+ emplace<OpenSyscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::Open);
+ emplace<WriteSyscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::Write);
}
};

MODIFY
src/syscall/syscallviewer.cpp
src/syscall/syscallviewer.cpp
@@ -28,7 +28,6 @@ SyscallViewer::SyscallViewer(QWidget* parent) : QDialog(parent), m_ui(new Ui::Sy
for (const auto& iter : syscallManager.getSyscalls()) {
addSyscall(iter.first, iter.second.get());
}
- m_ui->syscallList->setSortingEnabled(true);
m_ui->syscallList->setSelectionBehavior(QAbstractItemView::SelectRows);
m_ui->syscallList->verticalHeader()->hide();
m_ui->syscallList->setHorizontalHeaderLabels({"Call number", "Name"});
@@ -42,6 +41,13 @@ SyscallViewer::SyscallViewer(QWidget* parent) : QDialog(parent), m_ui(new Ui::Sy
m_ui->syscallArguments->setHorizontalHeaderLabels({"Arg. #", "Description"});
m_ui->syscallArguments->verticalHeader()->hide();
+ // Setup syscall returns styling
+ m_ui->syscallReturns->setColumnCount(2);
+ m_ui->syscallReturns->setSelectionBehavior(QAbstractItemView::SelectRows);
+ m_ui->syscallReturns->horizontalHeader()->setStretchLastSection(true);
+ m_ui->syscallReturns->setHorizontalHeaderLabels({"Ret. #", "Description"});
+ m_ui->syscallReturns->verticalHeader()->hide();
+
// Select first row to set the initial state
m_ui->syscallList->selectRow(0);
}
@@ -59,15 +65,21 @@ void SyscallViewer::setCurrentSyscall(const Syscall* syscall) {
m_ui->syscallArguments->clearContents();
m_ui->syscallArguments->setRowCount(0);
+ m_ui->syscallReturns->clearContents();
+ m_ui->syscallReturns->setRowCount(0);
+
m_ui->syscallTitle->setText(syscall->name());
m_ui->syscallDescription->setText(syscall->description());
for (const auto& iter : syscall->argumentDescriptions()) {
- addArgument(iter.first, iter.second);
+ addItemToTable(m_ui->syscallArguments, iter.first, iter.second);
+ }
+ for (const auto& iter : syscall->returnDescriptions()) {
+ addItemToTable(m_ui->syscallReturns, iter.first, iter.second);
}
}
-void SyscallViewer::addArgument(unsigned int idx, const QString& description) {
- m_ui->syscallArguments->setRowCount(m_ui->syscallArguments->rowCount() + 1);
+void SyscallViewer::addItemToTable(QTableWidget* table, unsigned int idx, const QString& description) {
+ table->setRowCount(table->rowCount() + 1);
QTableWidgetItem* idxItem = new QTableWidgetItem();
QTableWidgetItem* textItem = new QTableWidgetItem();
@@ -77,9 +89,9 @@ void SyscallViewer::addArgument(unsigned int idx, const QString& description) {
idxItem->setFlags(idxItem->flags() ^ Qt::ItemIsEditable);
textItem->setFlags(textItem->flags() ^ Qt::ItemIsEditable);
- const int row = m_ui->syscallArguments->rowCount() - 1;
- m_ui->syscallArguments->setItem(row, 0, idxItem);
- m_ui->syscallArguments->setItem(row, 1, textItem);
+ const int row = table->rowCount() - 1;
+ table->setItem(row, 0, idxItem);
+ table->setItem(row, 1, textItem);
}
void SyscallViewer::addSyscall(unsigned id, const Syscall* syscall) {

MODIFY
src/syscall/syscallviewer.h
src/syscall/syscallviewer.h
@@ -20,7 +20,7 @@ public:
private:
void handleItemChanged(QTableWidgetItem* current, QTableWidgetItem* previous);
void addSyscall(unsigned id, const Syscall* syscall);
- void addArgument(unsigned idx, const QString& description);
+ void addItemToTable(QTableWidget* table, unsigned idx, const QString& description);
void setCurrentSyscall(const Syscall* syscall);
Ui::SyscallViewer* m_ui;

MODIFY
src/syscall/syscallviewer.ui
src/syscall/syscallviewer.ui
</property>
</widget>
</item>
+ <item>
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Arguments:</string>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QTableWidget" name="syscallArguments"/>
</item>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Returns:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTableWidget" name="syscallReturns"/>
+ </item>
</layout>
</widget>
</widget>

Add return value descriptions to syscall definitions