debugger runs
This commit is contained in:
parent
8432ba3ea1
commit
1d87ecc570
9 changed files with 54 additions and 56 deletions
|
@ -84,13 +84,6 @@ void console_thread_wrapper_panel(void *const c)
|
|||
cnsl->panel_update_thread();
|
||||
}
|
||||
|
||||
void console_thread_wrapper_io(void *const c)
|
||||
{
|
||||
console *const cnsl = reinterpret_cast<console *>(c);
|
||||
|
||||
cnsl->operator()();
|
||||
}
|
||||
|
||||
uint32_t load_serial_speed_configuration()
|
||||
{
|
||||
File dataFile = LittleFS.open(SERIAL_CFG_FILE, "r");
|
||||
|
@ -516,8 +509,6 @@ void setup() {
|
|||
while(!Serial)
|
||||
delay(100);
|
||||
|
||||
Serial.println("...");
|
||||
|
||||
Serial.println(F("This PDP-11 emulator is called \"kek\" (reason for that is forgotten) and was written by Folkert van Heusden."));
|
||||
|
||||
Serial.println(F("Build on: " __DATE__ " " __TIME__));
|
||||
|
@ -590,9 +581,6 @@ void setup() {
|
|||
xTaskCreate(&console_thread_wrapper_panel, "panel", 2048, cnsl, 1, nullptr);
|
||||
#endif
|
||||
|
||||
Serial.println(F("Starting I/O"));
|
||||
xTaskCreate(&console_thread_wrapper_io, "c-io", 2048, cnsl, 1, nullptr);
|
||||
|
||||
#if !defined(BUILD_FOR_RP2040)
|
||||
Serial.print(F("Free RAM after init: "));
|
||||
Serial.println(ESP.getFreeHeap());
|
||||
|
@ -604,6 +592,7 @@ void setup() {
|
|||
|
||||
Serial.flush();
|
||||
|
||||
Serial.println(F("Starting I/O"));
|
||||
cnsl->start_thread();
|
||||
|
||||
cnsl->put_string_lf("PDP-11/70 emulator, (C) Folkert van Heusden");
|
||||
|
|
|
@ -12,5 +12,5 @@ board_build.core = earlephilhower
|
|||
board_build.filesystem_size = 0.2m
|
||||
lib_deps = bblanchon/ArduinoJson@^6.19.4
|
||||
adafruit/Adafruit NeoPixel@^1.10.4
|
||||
build_flags = -Ofast -DBUILD_FOR_RP2040=1 -DPIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS -DPICO_STDIO_USB=1 -DDEBUG_RP2040_PORT=Serial -DDEBUG_RP2040_CORE
|
||||
build_flags = -Ofast -DBUILD_FOR_RP2040=1 -DPIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS -DPICO_STDIO_USB=1 -DDEBUG_RP2040_PORT=Serial -DDEBUG_RP2040_CORE -ggdb3
|
||||
build_unflags = -Os
|
||||
|
|
4
bus.cpp
4
bus.cpp
|
@ -34,6 +34,10 @@ bus::bus()
|
|||
memset(pages, 0x00, sizeof pages);
|
||||
|
||||
CPUERR = MMR0 = MMR1 = MMR2 = MMR3 = PIR = CSR = 0;
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xSemaphoreGive(lf_csr_lock); // initialize
|
||||
#endif
|
||||
}
|
||||
|
||||
bus::~bus()
|
||||
|
|
48
console.cpp
48
console.cpp
|
@ -9,13 +9,14 @@
|
|||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
#include "rp2040.h"
|
||||
#include "console.h"
|
||||
#include "gen.h"
|
||||
#include "log.h"
|
||||
#include "utils.h"
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
#include "rp2040.h"
|
||||
|
||||
void thread_wrapper_console(void *p)
|
||||
{
|
||||
console *const consolel = reinterpret_cast<console *>(p);
|
||||
|
@ -31,6 +32,10 @@ console::console(std::atomic_uint32_t *const stop_event, bus *const b, const int
|
|||
t_height(t_height)
|
||||
{
|
||||
screen_buffer = new char[t_width * t_height]();
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xSemaphoreGive(input_lock); // initialize
|
||||
#endif
|
||||
}
|
||||
|
||||
console::~console()
|
||||
|
@ -47,7 +52,7 @@ void console::start_thread()
|
|||
stop_thread_flag = false;
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xTaskCreate(&thread_wrapper_console, "console-l", 2048, this, 1, nullptr);
|
||||
xTaskCreate(&thread_wrapper_console, "console", 2048, this, 1, nullptr);
|
||||
#elif !defined(ESP32)
|
||||
th = new std::thread(std::ref(*this));
|
||||
#endif
|
||||
|
@ -109,38 +114,23 @@ int console::get_char()
|
|||
std::optional<char> console::wait_char(const int timeout_ms)
|
||||
{
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
uint8_t rc = 0;
|
||||
if (xQueueReceive(have_data, &rc, timeout_ms / portTICK_PERIOD_MS) == pdFALSE || rc == 0)
|
||||
return { };
|
||||
|
||||
std::optional<char> c { };
|
||||
|
||||
xSemaphoreTake(input_lock, portMAX_DELAY);
|
||||
|
||||
bool triggered = input_buffer.empty() == false;
|
||||
|
||||
if (!triggered) {
|
||||
uint32_t start = millis();
|
||||
|
||||
while(!have_data && millis() - start < timeout_ms) {
|
||||
}
|
||||
|
||||
have_data = false; // FIXME
|
||||
|
||||
triggered = input_buffer.empty() == false;
|
||||
}
|
||||
|
||||
if (triggered) {
|
||||
int c = input_buffer.at(0);
|
||||
if (input_buffer.empty() == false) {
|
||||
c = input_buffer.at(0);
|
||||
|
||||
input_buffer.erase(input_buffer.begin() + 0);
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xSemaphoreGive(input_lock);
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xSemaphoreGive(input_lock);
|
||||
#endif
|
||||
|
||||
return { };
|
||||
return c;
|
||||
#else
|
||||
std::unique_lock<std::mutex> lck(input_lock);
|
||||
|
||||
|
@ -333,9 +323,11 @@ void console::operator()()
|
|||
input_buffer.push_back(c);
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
have_data = true;
|
||||
|
||||
xSemaphoreGive(input_lock);
|
||||
|
||||
uint8_t value = 1;
|
||||
if (xQueueSend(have_data, &value, portMAX_DELAY) == pdFALSE)
|
||||
Serial.println("xQueueSend failed");
|
||||
#else
|
||||
have_data.notify_all();
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,7 @@ class console
|
|||
private:
|
||||
std::vector<char> input_buffer;
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
volatile bool have_data { false };
|
||||
QueueHandle_t have_data { xQueueCreate(16, 1) };
|
||||
SemaphoreHandle_t input_lock { xSemaphoreCreateBinary() };
|
||||
#else
|
||||
std::condition_variable have_data;
|
||||
|
|
15
cpu.cpp
15
cpu.cpp
|
@ -18,6 +18,10 @@
|
|||
cpu::cpu(bus *const b, std::atomic_uint32_t *const event) : b(b), event(event)
|
||||
{
|
||||
reset();
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xSemaphoreGive(qi_lock); // initialize
|
||||
#endif
|
||||
}
|
||||
|
||||
cpu::~cpu()
|
||||
|
@ -309,9 +313,10 @@ void cpu::queue_interrupt(const uint8_t level, const uint8_t vector)
|
|||
it->second.insert(vector);
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
qi_cv = true;
|
||||
|
||||
xSemaphoreGive(qi_lock);
|
||||
|
||||
uint8_t value = 1;
|
||||
xQueueSend(qi_q, &value, portMAX_DELAY);
|
||||
#else
|
||||
|
||||
qi_cv.notify_all();
|
||||
|
@ -1520,10 +1525,8 @@ bool cpu::misc_operations(const uint16_t instr)
|
|||
case 0b0000000000000001: // WAIT
|
||||
{
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
while(!qi_cv)
|
||||
vTaskDelay(10);
|
||||
|
||||
qi_cv = false; // FIXME
|
||||
uint8_t rc = 0;
|
||||
xQueueReceive(qi_q, &rc, 0);
|
||||
#else
|
||||
std::unique_lock<std::mutex> lck(qi_lock);
|
||||
|
||||
|
|
2
cpu.h
2
cpu.h
|
@ -44,7 +44,7 @@ private:
|
|||
std::map<uint8_t, std::set<uint8_t> > queued_interrupts;
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
SemaphoreHandle_t qi_lock { xSemaphoreCreateBinary() };
|
||||
volatile bool qi_cv { false };
|
||||
QueueHandle_t qi_q { xQueueCreate(16, 1) };
|
||||
#else
|
||||
std::mutex qi_lock;
|
||||
std::condition_variable qi_cv;
|
||||
|
|
22
tty.cpp
22
tty.cpp
|
@ -34,7 +34,11 @@ tty::tty(console *const c, bus *const b) :
|
|||
b(b)
|
||||
{
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xTaskCreate(&thread_wrapper_tty, "tty-l", 2048, this, 1, nullptr);
|
||||
xSemaphoreGive(chars_lock); // initialize
|
||||
#endif
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xTaskCreate(&thread_wrapper_tty, "tty", 2048, this, 1, nullptr);
|
||||
#else
|
||||
th = new std::thread(std::ref(*this));
|
||||
#endif
|
||||
|
@ -43,6 +47,7 @@ tty::tty(console *const c, bus *const b) :
|
|||
tty::~tty()
|
||||
{
|
||||
stop_flag = true;
|
||||
|
||||
#if !defined(BUILD_FOR_RP2040)
|
||||
th->join();
|
||||
delete th;
|
||||
|
@ -69,8 +74,9 @@ void tty::notify_rx()
|
|||
|
||||
uint16_t tty::readWord(const uint16_t addr)
|
||||
{
|
||||
const int reg = (addr - PDP11TTY_BASE) / 2;
|
||||
uint16_t vtemp = registers[reg];
|
||||
const int reg = (addr - PDP11TTY_BASE) / 2;
|
||||
uint16_t vtemp = registers[reg];
|
||||
bool notify = false;
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xSemaphoreTake(chars_lock, portMAX_DELAY);
|
||||
|
@ -94,7 +100,7 @@ uint16_t tty::readWord(const uint16_t addr)
|
|||
vtemp = ch | (parity(ch) << 7);
|
||||
|
||||
if (chars.empty() == false)
|
||||
notify_rx();
|
||||
notify = true;
|
||||
}
|
||||
}
|
||||
else if (addr == PDP11TTY_TPS) {
|
||||
|
@ -109,6 +115,9 @@ uint16_t tty::readWord(const uint16_t addr)
|
|||
|
||||
registers[reg] = vtemp;
|
||||
|
||||
if (notify)
|
||||
notify_rx();
|
||||
|
||||
return vtemp;
|
||||
}
|
||||
|
||||
|
@ -117,6 +126,7 @@ void tty::operator()()
|
|||
while(!stop_flag) {
|
||||
if (c->poll_char()) {
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
xSemaphoreTake(chars_lock, portMAX_DELAY);
|
||||
#else
|
||||
std::unique_lock<std::mutex> lck(chars_lock);
|
||||
|
@ -124,11 +134,11 @@ void tty::operator()()
|
|||
|
||||
chars.push_back(c->get_char());
|
||||
|
||||
notify_rx();
|
||||
|
||||
#if defined(BUILD_FOR_RP2040)
|
||||
xSemaphoreGive(chars_lock);
|
||||
#endif
|
||||
|
||||
notify_rx();
|
||||
}
|
||||
else {
|
||||
myusleep(100000);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#if defined(ESP32) || defined(BUILD_FOR_RP2040)
|
||||
#include <Arduino.h>
|
||||
#include "rp2040.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -16,7 +17,6 @@
|
|||
#include <vector>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "rp2040.h"
|
||||
#include "win32.h"
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue