This commit is contained in:
folkert van heusden 2022-06-09 19:10:22 +02:00
parent 3466cefbed
commit 94181e94bd
8 changed files with 79 additions and 4 deletions

View file

@ -15,6 +15,7 @@ add_executable(
cpu.cpp
debugger.cpp
error.cpp
kw11-l.cpp
main.cpp
memory.cpp
rk05.cpp

17
bus.cpp
View file

@ -80,8 +80,7 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
if (a == 0177546) { // line frequency clock and status register
D(fprintf(stderr, "read line freq clock\n");)
CSR |= 128;
return CSR;
return lf_csr;
}
if (a == 0177514) { // printer, CSR register, LP11
@ -533,8 +532,8 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
if (a == 0177546) { // line frequency clock and status register
D(fprintf(stderr, "write set LFC/SR: %o\n", value);)
CSR = value;
return CSR;
lf_csr = value;
return lf_csr;
}
if (tm11 && a >= TM_11_BASE && a < TM_11_END) {
@ -721,3 +720,13 @@ void bus::writeUnibusByte(const uint16_t a, const uint8_t v)
{
m->writeByte(a, v);
}
void bus::set_lf_crs_b7()
{
lf_csr |= 128;
}
uint8_t bus::get_lf_crs()
{
return lf_csr;
}

5
bus.h
View file

@ -36,6 +36,8 @@ private:
uint16_t switch_register { 0 };
uint16_t lf_csr { 0 };
bool debug_mode { false };
public:
@ -58,6 +60,9 @@ public:
void init(); // invoked by 'RESET' command
void set_lf_crs_b7();
uint8_t get_lf_crs();
uint16_t read(const uint16_t a, const bool word_mode, const bool use_prev, const bool peek_only=false);
uint16_t readByte(const uint16_t a) { return read(a, true, false); }
uint16_t readWord(const uint16_t a);

View file

@ -247,6 +247,8 @@ void cpu::setPSW(const uint16_t v, const bool limited)
bool cpu::check_queued_interrupts()
{
std::unique_lock<std::mutex> lck(qi_lock);
uint8_t current_level = getPSW_spl();
// uint8_t start_level = current_level <= 3 ? 0 : current_level + 1;
@ -273,6 +275,8 @@ bool cpu::check_queued_interrupts()
void cpu::queue_interrupt(const uint8_t level, const uint8_t vector)
{
std::unique_lock<std::mutex> lck(qi_lock);
auto it = queued_interrupts.find(level);
it->second.insert(vector);

2
cpu.h
View file

@ -4,6 +4,7 @@
#include <assert.h>
#include <map>
#include <mutex>
#include <set>
#include <stdint.h>
#include <vector>
@ -27,6 +28,7 @@ private:
// level, vector
std::map<uint8_t, std::set<uint8_t> > queued_interrupts;
std::mutex qi_lock;
std::set<uint16_t> breakpoints;

31
kw11-l.cpp Normal file
View file

@ -0,0 +1,31 @@
#include <unistd.h>
#include "cpu.h"
#include "kw11-l.h"
kw11_l::kw11_l(bus *const b) : b(b)
{
th = new std::thread(std::ref(*this));
}
kw11_l::~kw11_l()
{
stop_flag = true;
th->join();
delete th;
}
void kw11_l::operator()()
{
while(!stop_flag) {
b->set_lf_crs_b7();
if (b->get_lf_crs() & 64)
b->getCpu()->queue_interrupt(6, 0100);
usleep(1000000 / 50);
}
}

19
kw11-l.h Normal file
View file

@ -0,0 +1,19 @@
#include <atomic>
#include <thread>
#include "bus.h"
class kw11_l
{
private:
bus *const b { nullptr };
std::thread * th { nullptr };
std::atomic_bool stop_flag { false };
public:
kw11_l(bus *const b);
virtual ~kw11_l();
void operator()();
};

View file

@ -13,6 +13,7 @@
#include "cpu.h"
#include "debugger.h"
#include "gen.h"
#include "kw11-l.h"
#include "memory.h"
#include "terminal.h"
#include "tests.h"
@ -160,9 +161,12 @@ int main(int argc, char *argv[])
//setlocale(LC_ALL, "");
bus *b = new bus();
cpu *c = new cpu(b, &event);
b->add_cpu(c);
kw11_l *lf = new kw11_l(b);
c -> setEmulateMFPT(true);
std::vector<std::string> rk05_files;