KW11-L
This commit is contained in:
parent
3466cefbed
commit
94181e94bd
8 changed files with 79 additions and 4 deletions
|
@ -15,6 +15,7 @@ add_executable(
|
||||||
cpu.cpp
|
cpu.cpp
|
||||||
debugger.cpp
|
debugger.cpp
|
||||||
error.cpp
|
error.cpp
|
||||||
|
kw11-l.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
memory.cpp
|
memory.cpp
|
||||||
rk05.cpp
|
rk05.cpp
|
||||||
|
|
17
bus.cpp
17
bus.cpp
|
@ -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
|
if (a == 0177546) { // line frequency clock and status register
|
||||||
D(fprintf(stderr, "read line freq clock\n");)
|
D(fprintf(stderr, "read line freq clock\n");)
|
||||||
CSR |= 128;
|
return lf_csr;
|
||||||
return CSR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177514) { // printer, CSR register, LP11
|
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
|
if (a == 0177546) { // line frequency clock and status register
|
||||||
D(fprintf(stderr, "write set LFC/SR: %o\n", value);)
|
D(fprintf(stderr, "write set LFC/SR: %o\n", value);)
|
||||||
CSR = value;
|
lf_csr = value;
|
||||||
return CSR;
|
return lf_csr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tm11 && a >= TM_11_BASE && a < TM_11_END) {
|
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);
|
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
5
bus.h
|
@ -36,6 +36,8 @@ private:
|
||||||
|
|
||||||
uint16_t switch_register { 0 };
|
uint16_t switch_register { 0 };
|
||||||
|
|
||||||
|
uint16_t lf_csr { 0 };
|
||||||
|
|
||||||
bool debug_mode { false };
|
bool debug_mode { false };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -58,6 +60,9 @@ public:
|
||||||
|
|
||||||
void init(); // invoked by 'RESET' command
|
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 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 readByte(const uint16_t a) { return read(a, true, false); }
|
||||||
uint16_t readWord(const uint16_t a);
|
uint16_t readWord(const uint16_t a);
|
||||||
|
|
4
cpu.cpp
4
cpu.cpp
|
@ -247,6 +247,8 @@ void cpu::setPSW(const uint16_t v, const bool limited)
|
||||||
|
|
||||||
bool cpu::check_queued_interrupts()
|
bool cpu::check_queued_interrupts()
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> lck(qi_lock);
|
||||||
|
|
||||||
uint8_t current_level = getPSW_spl();
|
uint8_t current_level = getPSW_spl();
|
||||||
|
|
||||||
// uint8_t start_level = current_level <= 3 ? 0 : current_level + 1;
|
// 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)
|
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);
|
auto it = queued_interrupts.find(level);
|
||||||
|
|
||||||
it->second.insert(vector);
|
it->second.insert(vector);
|
||||||
|
|
2
cpu.h
2
cpu.h
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -27,6 +28,7 @@ private:
|
||||||
|
|
||||||
// level, vector
|
// level, vector
|
||||||
std::map<uint8_t, std::set<uint8_t> > queued_interrupts;
|
std::map<uint8_t, std::set<uint8_t> > queued_interrupts;
|
||||||
|
std::mutex qi_lock;
|
||||||
|
|
||||||
std::set<uint16_t> breakpoints;
|
std::set<uint16_t> breakpoints;
|
||||||
|
|
||||||
|
|
31
kw11-l.cpp
Normal file
31
kw11-l.cpp
Normal 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
19
kw11-l.h
Normal 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()();
|
||||||
|
};
|
4
main.cpp
4
main.cpp
|
@ -13,6 +13,7 @@
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "gen.h"
|
#include "gen.h"
|
||||||
|
#include "kw11-l.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
@ -160,9 +161,12 @@ int main(int argc, char *argv[])
|
||||||
//setlocale(LC_ALL, "");
|
//setlocale(LC_ALL, "");
|
||||||
|
|
||||||
bus *b = new bus();
|
bus *b = new bus();
|
||||||
|
|
||||||
cpu *c = new cpu(b, &event);
|
cpu *c = new cpu(b, &event);
|
||||||
b->add_cpu(c);
|
b->add_cpu(c);
|
||||||
|
|
||||||
|
kw11_l *lf = new kw11_l(b);
|
||||||
|
|
||||||
c -> setEmulateMFPT(true);
|
c -> setEmulateMFPT(true);
|
||||||
|
|
||||||
std::vector<std::string> rk05_files;
|
std::vector<std::string> rk05_files;
|
||||||
|
|
Loading…
Add table
Reference in a new issue