Add brk syscall
MODIFY
src/isainfo.h
src/isainfo.h
@@ -137,6 +137,7 @@ public:
Write = 64,
FStat = 80,
Exit2 = 93,
+ brk = 214,
Open = 1024
};
static const ISAInfo<ISA::RV32IM>* instance() {

MODIFY
src/syscall/control.h
src/syscall/control.h
@@ -36,4 +36,23 @@ public:
}
};
+template <typename BaseSyscall>
+class BrkSyscall : public BaseSyscall {
+ static_assert(std::is_base_of<Syscall, BaseSyscall>::value);
+
+public:
+ BrkSyscall()
+ : BaseSyscall(
+ "brk",
+ "Change the location of the program break, which defines the end of the process's data segment (i.e., "
+ "the program break is the first location after the end of the uninitialized data segment).",
+ {{0, "sets the end of the data segment to the specified address"}},
+ {{0, "On success, brk() returns zero. On error, -1 is returned, and errno is set to ENOMEM"}}) {}
+
+ void execute() {
+ // Nothing to do
+ return;
+ }
+};
+
} // namespace Ripes

MODIFY
src/syscall/riscv_syscall.h
src/syscall/riscv_syscall.h
@@ -48,6 +48,7 @@ public:
// Control syscalls
emplace<ExitSyscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::Exit);
emplace<Exit2Syscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::Exit2);
+ emplace<BrkSyscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::brk);
// File syscalls
emplace<CloseSyscall<RISCVSyscall>>(ISAInfo<ISA::RV32IM>::Close);

Add brk syscall