From 28958a9945e067b4d1bd803df6628d5a3e06c434 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sun, 20 Mar 2022 13:49:45 +0100 Subject: [PATCH] Compile fixes for ESP32 --- CMakeLists.txt | 4 ++-- ESP32/main.ino | 43 ++++++++++++++++++++++++++++--------------- cpu.cpp | 1 - cpu.h | 3 ++- main.cpp | 12 +++--------- tty.cpp | 11 ----------- tty.h | 3 --- 7 files changed, 35 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fee93a..29ceafa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,8 +24,8 @@ add_executable( include(CheckIPOSupported) check_ipo_supported(RESULT supported) -#set(CMAKE_BUILD_TYPE RelWithDebInfo) -set(CMAKE_BUILD_TYPE Debug) +set(CMAKE_BUILD_TYPE RelWithDebInfo) +#set(CMAKE_BUILD_TYPE Debug) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE) diff --git a/ESP32/main.ino b/ESP32/main.ino index a8e2ebc..409e32c 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -22,6 +22,8 @@ bus *b = nullptr; cpu *c = nullptr; tty *tty_ = nullptr; +uint32_t event = 0; + uint16_t exec_addr = 0; uint32_t start_ts = 0; @@ -113,6 +115,8 @@ void telnet_terminal(void *p) { xQueueReceive(tty_->getTerminalQueue(), &cc, portMAX_DELAY); + Serial.print(cc); + // update terminal buffer xSemaphoreTake(terminal_mutex, portMAX_DELAY); @@ -145,8 +149,6 @@ void telnet_terminal(void *p) { void wifi(void *p) { Serial.println(F("wifi task started")); - uint32_t ulNotifiedValue = 0; - int fd = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in server { 0 }; @@ -283,7 +285,7 @@ void setup() { b = new bus(); Serial.println(F("Init CPU")); - c = new cpu(b); + c = new cpu(b, &event); Serial.println(F("Connect CPU to BUS")); b->add_cpu(c); @@ -291,7 +293,7 @@ void setup() { c->setEmulateMFPT(true); Serial.println(F("Init TTY")); - tty_ = new tty(false); + tty_ = new tty(poll_char, get_char, put_char); Serial.println(F("Connect TTY to bus")); b->add_tty(tty_); @@ -365,21 +367,32 @@ void dump_state(bus *const b) { Serial.println(t_diff); } +bool poll_char() +{ + return Serial.available() > 0; +} + +char get_char() +{ + char c = Serial.read(); + + if (c == 5) + dump_state(b); + + return c; +} + +void put_char(char c) +{ + Serial.print(c); +} + void loop() { icount++; - if ((icount & 1023) == 0) { - if (Serial.available()) { - char c = Serial.read(); + c->step(); - if (c == 5) - dump_state(b); - else if (c > 0 && c < 127) - tty_->sendChar(c); - } - } - - if (c->step()) { + if (event) { Serial.println(F("")); Serial.println(F(" *** EMULATION STOPPED *** ")); dump_state(b); diff --git a/cpu.cpp b/cpu.cpp index 94045c0..d27a4a3 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -1081,7 +1081,6 @@ bool cpu::misc_operations(const uint16_t instr) // MOVE link, PC setPC(getRegister(link_reg, false)); - uint16_t temp = getPC(); // POP link setRegister(link_reg, false, popStack()); diff --git a/cpu.h b/cpu.h index e334b0b..0ece491 100644 --- a/cpu.h +++ b/cpu.h @@ -18,12 +18,13 @@ private: uint16_t stackLimitRegister { 0 }; bool haltFlag { false }, resetFlag { false }; bool runMode { false }; - uint32_t *const event { nullptr }; bool emulateMFPT { false }; bus *const b { nullptr }; + uint32_t *const event { nullptr }; + uint16_t getRegister(const int nr, const bool MF_MT) const; void setRegister(const int nr, const bool MF_MT, const uint16_t value); void addRegister(const int nr, const bool MF_MT, const uint16_t value); diff --git a/main.cpp b/main.cpp index 06a6641..a3dbf24 100644 --- a/main.cpp +++ b/main.cpp @@ -213,8 +213,7 @@ void put_char_ui(char c) void help() { printf("-h this help\n"); - printf("-m mode \"test\": for running xxdp (stop on bell)\n"); - printf(" \"tc\": run testcases\n"); + printf("-m mode \"tc\": run testcases\n"); printf("-T t.bin load file as a binary tape file (like simh \"load\" command)\n"); printf("-R d.rk load file as a RK05 disk device\n"); printf("-p 123 set CPU start pointer to decimal(!) value\n"); @@ -233,7 +232,7 @@ int main(int argc, char *argv[]) c -> setEmulateMFPT(true); - bool testMode = false, testCases = false; + bool testCases = false; int opt = -1; while((opt = getopt(argc, argv, "hm:T:R:p:ndL:")) != -1) { @@ -251,9 +250,7 @@ int main(int argc, char *argv[]) break; case 'm': - if (strcasecmp(optarg, "test") == 0) - testMode = true; - else if (strcasecmp(optarg, "tc") == 0) + if (strcasecmp(optarg, "tc") == 0) testCases = true; else { fprintf(stderr, "\"-m %s\" is not known\n", optarg); @@ -294,9 +291,6 @@ int main(int argc, char *argv[]) b->add_tty(tty_); - if (testMode) - tty_->setTest(); - if (testCases) tests(c); diff --git a/tty.cpp b/tty.cpp index d0e9634..8d6575e 100644 --- a/tty.cpp +++ b/tty.cpp @@ -109,21 +109,10 @@ void tty::writeWord(const uint16_t addr, uint16_t v) D(fprintf(stderr, "PDP11TTY write %o (%s): %o\n", addr, regnames[reg], v);) - if (v == 0207 && testMode) { - D(fprintf(stderr, "TestMode: TTY 0207 char\n");) - -#if !defined(ESP32) - exit(0); -#endif - } - - // FIXME if (addr == PDP11TTY_TPB) { char c = v & 127; #if defined(ESP32) - Serial.print(c); - if (xQueueSend(queue, &c, portMAX_DELAY) != pdTRUE) Serial.println(F("queue TTY character failed")); #else diff --git a/tty.h b/tty.h index 6b1f1fb..0a93ca7 100644 --- a/tty.h +++ b/tty.h @@ -24,7 +24,6 @@ private: std::function put_char; bool have_char { false }; uint16_t registers[4] { 0 }; - bool testMode { false }; bool withUI { false }; #if defined(ESP32) @@ -35,8 +34,6 @@ public: tty(std::function poll_char, std::function get_char, std::function put_char); virtual ~tty(); - void setTest() { testMode = true; } - #if defined(ESP32) QueueHandle_t & getTerminalQueue() { return queue; } #endif