From fc3571602f19d86ca86c25dd204f8662782e62d6 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Sat, 9 Mar 2019 20:37:54 +0100 Subject: 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 --- qtmips_gui/NewDialog.ui | 21 +++++++++++++++++++++ qtmips_gui/mainwindow.cpp | 3 ++- qtmips_gui/newdialog.cpp | 22 ++++++++++++++++++++++ qtmips_gui/newdialog.h | 3 +++ 4 files changed, 48 insertions(+), 1 deletion(-) (limited to 'qtmips_gui') diff --git a/qtmips_gui/NewDialog.ui b/qtmips_gui/NewDialog.ui index 1189e21..b494ffa 100644 --- a/qtmips_gui/NewDialog.ui +++ b/qtmips_gui/NewDialog.ui @@ -354,6 +354,27 @@ + + + + + + Filesystem root: + + + + + + + + + + Browse + + + + + diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index d6d0b35..2c9883d 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -156,7 +156,8 @@ void MainWindow::create_core(const machine::MachineConfig &config) { if (config.osemu_enable()) { osemu::OsSyscallExceptionHandler *osemu_handler = new osemu::OsSyscallExceptionHandler(config.osemu_known_syscall_stop(), - config.osemu_unknown_syscall_stop()); + config.osemu_unknown_syscall_stop(), + config.osemu_fs_root()); machine->register_exception_handler(machine::EXCAUSE_SYSCALL, osemu_handler); connect(osemu_handler, SIGNAL(char_written(int,uint)), terminal, SLOT(tx_byte(int,uint))); connect(osemu_handler, SIGNAL(rx_byte_pool(int,uint&,bool&)), diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp index 53b2a05..67d3f1d 100644 --- a/qtmips_gui/newdialog.cpp +++ b/qtmips_gui/newdialog.cpp @@ -55,6 +55,7 @@ NewDialog::NewDialog(QWidget *parent, QSettings *settings) : QDialog(parent) { connect(ui->pushButton_load, SIGNAL(clicked(bool)), this, SLOT(create())); connect(ui->pushButton_cancel, SIGNAL(clicked(bool)), this, SLOT(cancel())); connect(ui->pushButton_browse, SIGNAL(clicked(bool)), this, SLOT(browse_elf())); + connect(ui->elf_file, SIGNAL(textChanged(QString)), this, SLOT(elf_change(QString))); connect(ui->preset_no_pipeline, SIGNAL(toggled(bool)), this, SLOT(set_preset())); connect(ui->preset_no_pipeline_cache, SIGNAL(toggled(bool)), this, SLOT(set_preset())); connect(ui->preset_pipelined_bare, SIGNAL(toggled(bool)), this, SLOT(set_preset())); @@ -77,6 +78,8 @@ NewDialog::NewDialog(QWidget *parent, QSettings *settings) : QDialog(parent) { connect(ui->osemu_unknown_syscall_stop, SIGNAL(clicked(bool)), this, SLOT(osemu_unknown_syscall_stop_change(bool))); connect(ui->osemu_interrupt_stop, SIGNAL(clicked(bool)), this, SLOT(osemu_interrupt_stop_change(bool))); connect(ui->osemu_exception_stop, SIGNAL(clicked(bool)), this, SLOT(osemu_exception_stop_change(bool))); + connect(ui->osemu_fs_root_browse, SIGNAL(clicked(bool)), this, SLOT(browse_osemu_fs_root())); + connect(ui->osemu_fs_root, SIGNAL(textChanged(QString)), this, SLOT(osemu_fs_root_change(QString))); cache_handler_d = new NewDialogCacheHandler(this, ui_cache_d); cache_handler_p = new NewDialogCacheHandler(this, ui_cache_p); @@ -144,6 +147,10 @@ void NewDialog::browse_elf() { // Elf shouldn't have any other effect so we skip config_gui here } +void NewDialog::elf_change(QString val) { + config->set_elf(val); +} + void NewDialog::set_preset() { unsigned pres_n = preset_number(); if (pres_n > 0) { @@ -222,6 +229,20 @@ void NewDialog::osemu_exception_stop_change(bool v) { config->set_osemu_exception_stop(v); } +void NewDialog::browse_osemu_fs_root() { + QFileDialog osemu_fs_root_dialog(this); + osemu_fs_root_dialog.setFileMode(QFileDialog::DirectoryOnly); + if (osemu_fs_root_dialog.exec()) { + QString path = osemu_fs_root_dialog.selectedFiles()[0]; + ui->osemu_fs_root->setText(path); + config->set_osemu_fs_root(path); + } +} + +void NewDialog::osemu_fs_root_change(QString val) { + config->set_osemu_fs_root(val); +} + void NewDialog::config_gui() { // Basic ui->elf_file->setText(config->elf()); @@ -246,6 +267,7 @@ void NewDialog::config_gui() { ui->osemu_unknown_syscall_stop->setChecked(config->osemu_unknown_syscall_stop()); ui->osemu_interrupt_stop->setChecked(config->osemu_interrupt_stop()); ui->osemu_exception_stop->setChecked(config->osemu_exception_stop()); + ui->osemu_fs_root->setText(config->osemu_fs_root()); // Disable various sections according to configuration ui->delay_slot->setEnabled(!config->pipelined()); diff --git a/qtmips_gui/newdialog.h b/qtmips_gui/newdialog.h index edd633e..6e6ed8a 100644 --- a/qtmips_gui/newdialog.h +++ b/qtmips_gui/newdialog.h @@ -61,6 +61,7 @@ private slots: void cancel(); void create(); void browse_elf(); + void elf_change(QString val); void set_preset(); void pipelined_change(bool); void delay_slot_change(bool); @@ -75,6 +76,8 @@ private slots: void osemu_unknown_syscall_stop_change(bool); void osemu_interrupt_stop_change(bool); void osemu_exception_stop_change(bool); + void browse_osemu_fs_root(); + void osemu_fs_root_change(QString val); private: Ui::NewDialog *ui; -- cgit v1.2.3