aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qtmips_gui/NewDialog.ui10
-rw-r--r--qtmips_gui/mainwindow.cpp11
-rw-r--r--qtmips_gui/mainwindow.h2
-rw-r--r--qtmips_gui/newdialog.cpp9
-rw-r--r--qtmips_gui/newdialog.h1
-rw-r--r--qtmips_machine/qtmipsmachine.cpp33
-rw-r--r--qtmips_machine/qtmipsmachine.h3
7 files changed, 53 insertions, 16 deletions
diff --git a/qtmips_gui/NewDialog.ui b/qtmips_gui/NewDialog.ui
index b494ffa..03f364f 100644
--- a/qtmips_gui/NewDialog.ui
+++ b/qtmips_gui/NewDialog.ui
@@ -420,10 +420,20 @@
</spacer>
</item>
<item>
+ <widget class="QPushButton" name="pushButton_start_empty">
+ <property name="text">
+ <string>Start empty</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="pushButton_load">
<property name="text">
<string>Load machine</string>
</property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item>
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 32bdd5b..0dc6bd5 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -139,9 +139,13 @@ void MainWindow::start() {
ndialog->show();
}
-void MainWindow::create_core(const machine::MachineConfig &config) {
+void MainWindow::create_core(const machine::MachineConfig &config, bool load_executable) {
// Create machine
- machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config, true);
+ machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config, true, load_executable);
+
+ if (!load_executable && (machine != nullptr)) {
+ new_machine->memory_rw()->reset(*machine->memory());
+ }
// Remove old machine
if (machine != nullptr)
@@ -233,9 +237,10 @@ void MainWindow::new_machine() {
}
void MainWindow::machine_reload() {
+ bool load_executable = machine->executable_loaded();
machine::MachineConfig cnf(&machine->config()); // We have to make local copy as create_core will delete current machine
try {
- create_core(cnf);
+ create_core(cnf, load_executable);
} catch (const machine::QtMipsExceptionInput &e) {
QMessageBox msg(this);
msg.setText(e.msg(false));
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index cbbc9ec..8a63bd8 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -60,7 +60,7 @@ public:
~MainWindow();
void start();
- void create_core(const machine::MachineConfig &config);
+ void create_core(const machine::MachineConfig &config, bool load_executable = true);
bool configured();
diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp
index 67d3f1d..0e1c5dc 100644
--- a/qtmips_gui/newdialog.cpp
+++ b/qtmips_gui/newdialog.cpp
@@ -52,6 +52,7 @@ NewDialog::NewDialog(QWidget *parent, QSettings *settings) : QDialog(parent) {
ui_cache_d = new Ui::NewDialogCache();
ui_cache_d->setupUi(ui->tab_cache_data);
+ connect(ui->pushButton_start_empty, SIGNAL(clicked(bool)), this, SLOT(create_empty()));
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()));
@@ -136,6 +137,14 @@ void NewDialog::create() {
this->close();
}
+void NewDialog::create_empty() {
+ MainWindow *prnt = (MainWindow*)parent();
+ prnt->create_core(*config, false);
+ store_settings(); // Save to settings
+ this->close();
+}
+
+
void NewDialog::browse_elf() {
QFileDialog elf_dialog(this);
elf_dialog.setFileMode(QFileDialog::ExistingFile);
diff --git a/qtmips_gui/newdialog.h b/qtmips_gui/newdialog.h
index 6e6ed8a..077b1ab 100644
--- a/qtmips_gui/newdialog.h
+++ b/qtmips_gui/newdialog.h
@@ -60,6 +60,7 @@ protected:
private slots:
void cancel();
void create();
+ void create_empty();
void browse_elf();
void elf_change(QString val);
void set_preset();
diff --git a/qtmips_machine/qtmipsmachine.cpp b/qtmips_machine/qtmipsmachine.cpp
index 35843f4..362b243 100644
--- a/qtmips_machine/qtmipsmachine.cpp
+++ b/qtmips_machine/qtmipsmachine.cpp
@@ -39,22 +39,28 @@
using namespace machine;
-QtMipsMachine::QtMipsMachine(const MachineConfig &cc, bool load_symtab) :
+QtMipsMachine::QtMipsMachine(const MachineConfig &cc, bool load_symtab, bool load_executable) :
QObject(), mcnf(&cc) {
MemoryAccess *cpu_mem;
stat = ST_READY;
symtab = nullptr;
- ProgramLoader program(cc.elf());
- mem_program_only = new Memory();
- program.to_memory(mem_program_only);
- if (load_symtab)
- symtab = program.get_symbol_table();
- program_end = program.end();
regs = new Registers();
- if (program.get_executable_entry())
- regs->pc_abs_jmp(program.get_executable_entry());
- mem = new Memory(*mem_program_only);
+ if (load_executable) {
+ ProgramLoader program(cc.elf());
+ mem_program_only = new Memory();
+ program.to_memory(mem_program_only);
+ if (load_symtab)
+ symtab = program.get_symbol_table();
+ program_end = program.end();
+ if (program.get_executable_entry())
+ regs->pc_abs_jmp(program.get_executable_entry());
+ mem = new Memory(*mem_program_only);
+ } else {
+ program_end = 0xf0000000;
+ mem_program_only = nullptr;
+ mem = new Memory();
+ }
physaddrspace = new PhysAddrSpace();
physaddrspace->insert_range(mem, 0x00000000, 0xefffffff, false);
@@ -201,6 +207,10 @@ const CorePipelined *QtMipsMachine::core_pipelined() {
return mcnf.pipelined() ? (const CorePipelined*)cr : nullptr;
}
+bool QtMipsMachine::executable_loaded() const {
+ return (mem_program_only != nullptr);
+}
+
enum QtMipsMachine::Status QtMipsMachine::status() {
return stat;
}
@@ -266,7 +276,8 @@ void QtMipsMachine::step_timer() {
void QtMipsMachine::restart() {
pause();
regs->reset();
- mem->reset(*mem_program_only);
+ if (mem_program_only != nullptr)
+ mem->reset(*mem_program_only);
cch_program->reset();
cch_data->reset();
cr->reset();
diff --git a/qtmips_machine/qtmipsmachine.h b/qtmips_machine/qtmipsmachine.h
index 5cb4100..6c0c007 100644
--- a/qtmips_machine/qtmipsmachine.h
+++ b/qtmips_machine/qtmipsmachine.h
@@ -56,7 +56,7 @@ namespace machine {
class QtMipsMachine : public QObject {
Q_OBJECT
public:
- QtMipsMachine(const MachineConfig &cc, bool load_symtab = false);
+ QtMipsMachine(const MachineConfig &cc, bool load_symtab = false, bool load_executable = true);
~QtMipsMachine();
const MachineConfig &config();
@@ -75,6 +75,7 @@ public:
const Core *core();
const CoreSingle *core_singe();
const CorePipelined *core_pipelined();
+ bool executable_loaded() const;
enum Status {
ST_READY, // Machine is ready to be started or step to be called