From: George Wright Date: Thu, 5 Dec 2024 03:43:14 +0000 (-0800) Subject: Bodge in a UART logger X-Git-Url: http://git.gwright.org.uk/?a=commitdiff_plain;h=410b34e6039c94f52728e34870df3e7f7e269ff8;p=WindEmu.git Bodge in a UART logger --- diff --git a/WindCore/arm710.h b/WindCore/arm710.h index 21d01ef..72fab7d 100644 --- a/WindCore/arm710.h +++ b/WindCore/arm710.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include @@ -118,10 +119,12 @@ public: } void setLogger(std::function newLogger) { logger = newLogger; } + void setSerialOutput(std::function newSerialOutput) { serialOutput = newSerialOutput; } uint32_t lastPcExecuted() const { return pcHistory[(pcHistoryIndex - 1) % PcHistoryCount].addr; } public: void log(const char *format, ...); void logPcHistory(); + std::function serialOutput; private: std::function logger; diff --git a/WindCore/sa1100.cpp b/WindCore/sa1100.cpp index 3e204ac..6de60c6 100644 --- a/WindCore/sa1100.cpp +++ b/WindCore/sa1100.cpp @@ -9,7 +9,7 @@ Emulator::Emulator() : EmuBase(true) { osTimer = new OsTimer(); lcdController = new LCDController(); gpioController = new GPIOController(); - serial3 = new Serial3(); + serial3 = new Serial3(serialOutput); resetController = new ResetController(); intController = new IntController(lcdController, osTimer, gpioController, serial3); powerManager = new PowerManager(); diff --git a/WindCore/sa1100/serial_3.h b/WindCore/sa1100/serial_3.h index d25d5d1..8335bed 100644 --- a/WindCore/sa1100/serial_3.h +++ b/WindCore/sa1100/serial_3.h @@ -34,7 +34,7 @@ class Serial3 { public: // Access - + Serial3(std::function& output) : m_UART(output) {} Uart const & get_UART() const { return m_UART; }; inline void reset() { m_UART.reset(); } diff --git a/WindCore/sa1100/uart.cpp b/WindCore/sa1100/uart.cpp index 66ab4b4..eb75e79 100644 --- a/WindCore/sa1100/uart.cpp +++ b/WindCore/sa1100/uart.cpp @@ -25,6 +25,44 @@ namespace SA1100 // Becuase of using fifo[0], fifo has to reside in a consecutive memory blocks. // This is why I use std::vector rather than std::deque for m_tx_fifo. // reinterpret_cast(mp_output_device)->put_char_to_serial_console(m_tx_fifo); + std::string output; + + for (std::vector::iterator iter = m_tx_fifo.begin(); + iter != m_tx_fifo.end(); + ++iter) + { + if ((*iter) & 0x80) + { + (*iter) = 0x20; + } + } + + if (0xd == m_tx_fifo.back()) + { + output.append(reinterpret_cast(&(m_tx_fifo[0])), m_tx_fifo.size()); + + m_need_append_more = true; + } + else + { + if (true == m_need_append_more) + { + output.append(reinterpret_cast(&(m_tx_fifo[0])), m_tx_fifo.size()); + + m_need_append_more = false; + } + else + { + if (false == output.empty()) + { + m_output(output.c_str()); + } + + std::string lala = std::string(reinterpret_cast(&(m_tx_fifo[0])), m_tx_fifo.size()); + m_output(lala.c_str()); + } + } + } inline void Uart::rx_data() { @@ -34,7 +72,7 @@ namespace SA1100 // reinterpret_cast(mp_output_device)->get_char_from_serial_console(); } - Uart::Uart() { + Uart::Uart(std::function& output) : m_output(output) { init_register(); } diff --git a/WindCore/sa1100/uart.h b/WindCore/sa1100/uart.h index 8a83cd8..e6d3f9e 100644 --- a/WindCore/sa1100/uart.h +++ b/WindCore/sa1100/uart.h @@ -21,7 +21,7 @@ #include #include #include - +#include #include namespace SA1100 @@ -95,7 +95,9 @@ class Uart { // thus I use std::vector here. std::vector m_tx_fifo; std::deque m_rx_fifo; - + bool m_need_append_more = false; + std::function& m_output; + // :NOTE: Wei 2004-Mar-22: // // For now, this mp_output_device is only used in Uart to output to SerialConsole. @@ -118,7 +120,7 @@ class Uart { void rx_data(); public: - Uart(); + Uart(std::function& output); void reset(); inline void register_output_device(void * const output_device) { diff --git a/WindQt/mainwindow.cpp b/WindQt/mainwindow.cpp index 3176ea1..f016f4b 100644 --- a/WindQt/mainwindow.cpp +++ b/WindQt/mainwindow.cpp @@ -19,6 +19,13 @@ MainWindow::MainWindow(EmuBase *emu, QWidget *parent) : ui->logView->appendPlainText(fullStr); }); + emu->setSerialOutput([&](const char *str) { + QString string(str); + ui->serialConsole->moveCursor(QTextCursor::End); + ui->serialConsole->insertPlainText(str); + ui->serialConsole->moveCursor(QTextCursor::End); + }); + timer = new QTimer(this); timer->setInterval(1000/64); connect(timer, SIGNAL(timeout()), SLOT(execTimer())); diff --git a/WindQt/mainwindow.ui b/WindQt/mainwindow.ui index d176e06..4bb4640 100644 --- a/WindQt/mainwindow.ui +++ b/WindQt/mainwindow.ui @@ -15,6 +15,63 @@ + + + + Qt::ClickFocus + + + + + + + + + + Start + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + Step (Tick) + + + + + + + false + + + Stop + + + @@ -22,10 +79,20 @@ + + + + Step (Insn) + + + + + + - 2 + 3 @@ -104,9 +171,7 @@ - - Courier New - + TextLabel @@ -183,9 +248,7 @@ - - Courier New - + TextLabel @@ -247,77 +310,18 @@ + + + UART + + + + + + + - - - - - Courier New - - - - - - - - - - - Start - - - - - - - Step (Tick) - - - - - - - Qt::ClickFocus - - - - - - - - - - Step (Insn) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - Stop - - - - - -