aboutsummaryrefslogtreecommitdiff
path: root/qtmips_osemu/ossyscall.h
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-03-09 20:37:54 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-03-09 20:37:54 +0100
commitfc3571602f19d86ca86c25dd204f8662782e62d6 (patch)
treec9dad1178486fe87c4f452f08eb9de5e4998d40f /qtmips_osemu/ossyscall.h
parent3360c7a27865f16441d744fd4559a30e5b5dd7db (diff)
downloadqtmips-fc3571602f19d86ca86c25dd204f8662782e62d6.tar.gz
qtmips-fc3571602f19d86ca86c25dd204f8662782e62d6.tar.bz2
qtmips-fc3571602f19d86ca86c25dd204f8662782e62d6.zip
Updated read and write, added open, close, ftruncate syscalls and fs_root option.
When operating system emulation root directory (fs_root) are selected then open() syscall opens real host system files in this limited subtree. When fs_root is not set then console is mapped to all read, write, open and close calls. Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_osemu/ossyscall.h')
-rw-r--r--qtmips_osemu/ossyscall.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/qtmips_osemu/ossyscall.h b/qtmips_osemu/ossyscall.h
index bcb202f..2f8f54a 100644
--- a/qtmips_osemu/ossyscall.h
+++ b/qtmips_osemu/ossyscall.h
@@ -37,6 +37,8 @@
#define OSSYCALL_H
#include <QObject>
+#include <QString>
+#include <QVector>
#include <qtmipsexception.h>
#include <machineconfig.h>
#include <registers.h>
@@ -57,7 +59,8 @@ int name(std::uint32_t &result, machine::Core *core, \
class OsSyscallExceptionHandler : public machine::ExceptionHandler {
Q_OBJECT
public:
- OsSyscallExceptionHandler(bool known_syscall_stop = false, bool unknown_syscall_stop = false);
+ OsSyscallExceptionHandler(bool known_syscall_stop = false, bool unknown_syscall_stop = false,
+ QString fs_root = "");
bool handle_exception(machine::Core *core, machine::Registers *regs,
machine::ExceptionCause excause, std::uint32_t inst_addr,
std::uint32_t next_addr, std::uint32_t jump_branch_pc,
@@ -69,17 +72,39 @@ public:
OSSYCALL_HANDLER_DECLARE(do_sys_write);
OSSYCALL_HANDLER_DECLARE(do_sys_readv);
OSSYCALL_HANDLER_DECLARE(do_sys_read);
+ OSSYCALL_HANDLER_DECLARE(do_sys_open);
+ OSSYCALL_HANDLER_DECLARE(do_sys_close);
+ OSSYCALL_HANDLER_DECLARE(do_sys_ftruncate);
OSSYCALL_HANDLER_DECLARE(do_sys_brk);
OSSYCALL_HANDLER_DECLARE(do_sys_mmap2);
signals:
void char_written(int fd, unsigned int val);
void rx_byte_pool(int fd, unsigned int &data, bool &available);
private:
+ enum FdMapping {
+ FD_UNUSED = -1,
+ FD_INVALID = -1,
+ FD_TERMINAL = -2,
+ };
+ std::int32_t write_mem(machine::MemoryAccess *mem, std::uint32_t addr,
+ const QVector<std::uint8_t> &data, std::uint32_t count);
+ std::int32_t read_mem(machine::MemoryAccess *mem, std::uint32_t addr,
+ QVector<std::uint8_t> &data, std::uint32_t count);
+ std::int32_t write_io(int fd, const QVector<std::uint8_t> &data, std::uint32_t count);
+ std::int32_t read_io(int fd, QVector<std::uint8_t> &data, std::uint32_t count, bool add_nl_at_eof);
+ int allocate_fd(int val = FD_UNUSED);
+ int file_open(QString fname, int flags, int mode);
+ int targetfd_to_fd(int targetfd);
+ void close_fd(int targetfd);
+ QString filepath_to_host(QString path);
+
+ QVector<int> fd_mapping;
std::uint32_t brk_limit;
std::uint32_t anonymous_base;
std::uint32_t anonymous_last;
bool known_syscall_stop;
bool unknown_syscall_stop;
+ QString fs_root;
};
#undef OSSYCALL_HANDLER_DECLARE