logging facility - remove \n & reduce logging when not needed

This commit is contained in:
folkert van heusden 2022-06-11 09:44:00 +02:00
parent 92d96a4d43
commit 7a9ccc651b
11 changed files with 139 additions and 137 deletions

154
bus.cpp
View file

@ -57,36 +57,36 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
if (a >= 0160000) {
if (word_mode)
DOLOG(debug, false, "READ I/O %06o in byte mode\n", a);
DOLOG(debug, false, "READ I/O %06o in byte mode", a);
if (a == 0177750) { // MAINT
DOLOG(debug, !peek_only, "read MAINT\n");
DOLOG(debug, !peek_only, "read MAINT");
return 1; // POWER OK
}
if (a == 0177570) { // console switch & display register
DOLOG(debug, !peek_only, "read console switch\n");
DOLOG(debug, !peek_only, "read console switch");
return debug_mode ? 128 : 0;
}
if (a == 0172540) { // KW11P programmable clock
DOLOG(debug, !peek_only, "read programmable clock\n");
DOLOG(debug, !peek_only, "read programmable clock");
return 128;
}
if (a == 0177772) { // PIR
DOLOG(debug, !peek_only, "read PIT\n");
DOLOG(debug, !peek_only, "read PIT");
return PIR;
}
if (a == 0177546) { // line frequency clock and status register
DOLOG(debug, !peek_only, "read line freq clock\n");
DOLOG(debug, !peek_only, "read line freq clock");
return lf_csr;
}
if (a == 0177514) { // printer, CSR register, LP11
DOLOG(debug, !peek_only, "read LP11 CSR\n");
DOLOG(debug, !peek_only, "read LP11 CSR");
return 0x80;
}
@ -94,150 +94,150 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
if (a >= 0172200 && a < 0172220) {
int page = (a >> 1) & 7;
uint16_t t = pages[001][0][page].pdr;
DOLOG(debug, !peek_only, "read supervisor I PDR for %d: %o\n", page, t);
DOLOG(debug, !peek_only, "read supervisor I PDR for %d: %o", page, t);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0172220 && a < 0172240) {
int page = (a >> 1) & 7;
uint16_t t = pages[001][1][page].pdr;
DOLOG(debug, !peek_only, "read supervisor D PDR for %d: %o\n", page, t);
DOLOG(debug, !peek_only, "read supervisor D PDR for %d: %o", page, t);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0172240 && a < 0172260) {
int page = (a >> 1) & 7;
uint16_t t = pages[001][0][page].par;
DOLOG(debug, !peek_only, "read supervisor I PAR for %d: %o (phys: %07o)\n", page, t, t * 64);
DOLOG(debug, !peek_only, "read supervisor I PAR for %d: %o (phys: %07o)", page, t, t * 64);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0172260 && a < 0172300) {
int page = (a >> 1) & 7;
uint16_t t = pages[001][1][page].par;
DOLOG(debug, !peek_only, "read supervisor D PAR for %d: %o (phys: %07o)\n", page, t, t * 64);
DOLOG(debug, !peek_only, "read supervisor D PAR for %d: %o (phys: %07o)", page, t, t * 64);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0172300 && a < 0172320) {
int page = (a >> 1) & 7;
uint16_t t = pages[000][0][page].pdr;
DOLOG(debug, !peek_only, "read kernel I PDR for %d: %o\n", page, t);
DOLOG(debug, !peek_only, "read kernel I PDR for %d: %o", page, t);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0172320 && a < 0172340) {
int page = (a >> 1) & 7;
uint16_t t = pages[000][1][page].pdr;
DOLOG(debug, !peek_only, "read kernel D PDR for %d: %o\n", page, t);
DOLOG(debug, !peek_only, "read kernel D PDR for %d: %o", page, t);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0172340 && a < 0172360) {
int page = (a >> 1) & 7;
uint16_t t = pages[000][0][page].par;
DOLOG(debug, !peek_only, "read kernel I PAR for %d: %o (phys: %07o)\n", page, t, t * 64);
DOLOG(debug, !peek_only, "read kernel I PAR for %d: %o (phys: %07o)", page, t, t * 64);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0172360 && a < 0172400) {
int page = (a >> 1) & 7;
uint16_t t = pages[000][1][page].par;
DOLOG(debug, !peek_only, "read kernel D PAR for %d: %o (phys: %07o)\n", page, t, t * 64);
DOLOG(debug, !peek_only, "read kernel D PAR for %d: %o (phys: %07o)", page, t, t * 64);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0177600 && a < 0177620) {
int page = (a >> 1) & 7;
uint16_t t = pages[003][0][page].pdr;
DOLOG(debug, !peek_only, "read userspace I PDR for %d: %o\n", page, t);
DOLOG(debug, !peek_only, "read userspace I PDR for %d: %o", page, t);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0177620 && a < 0177640) {
int page = (a >> 1) & 7;
uint16_t t = pages[003][1][page].pdr;
DOLOG(debug, !peek_only, "read userspace D PDR for %d: %o\n", page, t);
DOLOG(debug, !peek_only, "read userspace D PDR for %d: %o", page, t);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0177640 && a < 0177660) {
int page = (a >> 1) & 7;
uint16_t t = pages[003][0][page].par;
DOLOG(debug, !peek_only, "read userspace I PAR for %d: %o (phys: %07o)\n", page, t, t * 64);
DOLOG(debug, !peek_only, "read userspace I PAR for %d: %o (phys: %07o)", page, t, t * 64);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
else if (a >= 0177660 && a < 0177700) {
int page = (a >> 1) & 7;
uint16_t t = pages[003][1][page].par;
DOLOG(debug, !peek_only, "read userspace D PAR for %d: %o (phys: %07o)\n", page, t, t * 64);
DOLOG(debug, !peek_only, "read userspace D PAR for %d: %o (phys: %07o)", page, t, t * 64);
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
///////////
if (word_mode) {
if (a == 0177776) { // PSW
DOLOG(debug, !peek_only, "readb PSW LSB\n");
DOLOG(debug, !peek_only, "readb PSW LSB");
return c -> getPSW() & 255;
}
if (a == 0177777) {
DOLOG(debug, !peek_only, "readb PSW MSB\n");
DOLOG(debug, !peek_only, "readb PSW MSB");
return c -> getPSW() >> 8;
}
if (a == 0177774) { // stack limit register
DOLOG(debug, !peek_only, "readb stack limit register\n");
DOLOG(debug, !peek_only, "readb stack limit register");
return c -> getStackLimitRegister() & 0xff;
}
if (a == 0177775) { // stack limit register
DOLOG(debug, !peek_only, "readb stack limit register\n");
DOLOG(debug, !peek_only, "readb stack limit register");
return c -> getStackLimitRegister() >> 8;
}
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5
DOLOG(debug, !peek_only, "readb kernel R%d\n", a - 0177700);
DOLOG(debug, !peek_only, "readb kernel R%d", a - 0177700);
return c -> getRegister(false, a - 0177700) & 0xff;
}
if (a >= 0177710 && a <= 0177715) { // user R0-R5
DOLOG(debug, !peek_only, "readb user R%d\n", a - 0177710);
DOLOG(debug, !peek_only, "readb user R%d", a - 0177710);
return c -> getRegister(true, a - 0177710) & 0xff;
}
if (a == 0177706) { // kernel SP
DOLOG(debug, !peek_only, "readb kernel sp\n");
DOLOG(debug, !peek_only, "readb kernel sp");
return c -> getStackPointer(0) & 0xff;
}
if (a == 0177707) { // PC
DOLOG(debug, !peek_only, "readb pc\n");
DOLOG(debug, !peek_only, "readb pc");
return c -> getPC() & 0xff;
}
if (a == 0177716) { // supervisor SP
DOLOG(debug, !peek_only, "readb supervisor sp\n");
DOLOG(debug, !peek_only, "readb supervisor sp");
return c -> getStackPointer(1) & 0xff;
}
if (a == 0177717) { // user SP
DOLOG(debug, !peek_only, "readb user sp\n");
DOLOG(debug, !peek_only, "readb user sp");
return c -> getStackPointer(3) & 0xff;
}
if (a == 0177766) { // cpu error register
DOLOG(debug, !peek_only, "readb cpuerr\n");
DOLOG(debug, !peek_only, "readb cpuerr");
return CPUERR & 0xff;
}
}
else {
if (a == 0177572) {
DOLOG(debug, !peek_only, "read MMR0\n");
DOLOG(debug, !peek_only, "read MMR0");
return MMR0;
}
if (a == 0177574) { // MMR1
DOLOG(debug, !peek_only, "read MMR1\n");
DOLOG(debug, !peek_only, "read MMR1");
return MMR1;
}
if (a == 0177576) { // MMR2
DOLOG(debug, !peek_only, "read MMR2\n");
DOLOG(debug, !peek_only, "read MMR2");
return MMR2;
}
if (a == 0172516) { // MMR3
DOLOG(debug, !peek_only, "read MMR3\n");
DOLOG(debug, !peek_only, "read MMR3");
return MMR3;
}
if (a == 0177776) { // PSW
DOLOG(debug, !peek_only, "read PSW\n");
DOLOG(debug, !peek_only, "read PSW");
return c -> getPSW();
}
@ -246,32 +246,32 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
}
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5
DOLOG(debug, !peek_only, "read kernel R%d\n", a - 0177700);
DOLOG(debug, !peek_only, "read kernel R%d", a - 0177700);
return c -> getRegister(false, a - 0177700);
}
if (a >= 0177710 && a <= 0177715) { // user R0-R5
DOLOG(debug, !peek_only, "read user R%d\n", a - 0177710);
DOLOG(debug, !peek_only, "read user R%d", a - 0177710);
return c -> getRegister(true, a - 0177710);
}
if (a == 0177706) { // kernel SP
DOLOG(debug, !peek_only, "read kernel sp\n");
DOLOG(debug, !peek_only, "read kernel sp");
return c -> getStackPointer(0);
}
if (a == 0177707) { // PC
DOLOG(debug, !peek_only, "read pc\n");
DOLOG(debug, !peek_only, "read pc");
return c -> getPC();
}
if (a == 0177716) { // supervisor SP
DOLOG(debug, !peek_only, "read supervisor sp\n");
DOLOG(debug, !peek_only, "read supervisor sp");
return c -> getStackPointer(1);
}
if (a == 0177717) { // user SP
DOLOG(debug, !peek_only, "read user sp\n");
DOLOG(debug, !peek_only, "read user sp");
return c -> getStackPointer(3);
}
if (a == 0177766) { // cpu error register
DOLOG(debug, !peek_only, "read CPUERR\n");
DOLOG(debug, !peek_only, "read CPUERR");
return CPUERR;
}
}
@ -298,9 +298,9 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
return system_size & 65535;
if (a & 1)
DOLOG(debug, !peek_only, "bus::readWord: odd address UNHANDLED %o\n", a);
DOLOG(debug, !peek_only, "bus::readWord: odd address UNHANDLED %o", a);
DOLOG(debug, !peek_only, "UNHANDLED read %o(%c)\n", a, word_mode ? 'B' : ' ');
DOLOG(debug, !peek_only, "UNHANDLED read %o(%c)", a, word_mode ? 'B' : ' ');
// c -> busError();
@ -309,19 +309,19 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
int run_mode = (c->getPSW() >> (use_prev ? 12 : 14)) & 3;
uint32_t m_offset = calculate_physical_address(run_mode, a, !peek_only, false);
uint32_t m_offset = calculate_physical_address(run_mode, a, !peek_only, false, peek_only);
if (word_mode)
temp = m -> readByte(m_offset);
else
temp = m -> readWord(m_offset);
DOLOG(debug, !peek_only, "READ from %06o/%07o: %o\n", a, m_offset, temp);
DOLOG(debug, !peek_only, "READ from %06o/%07o: %o", a, m_offset, temp);
return temp;
}
uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, const bool trap_on_failure, const bool is_write)
uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, const bool trap_on_failure, const bool is_write, const bool peek_only)
{
uint32_t m_offset = 0;
@ -376,7 +376,7 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
bool direction = pages[run_mode][0][apf].pdr & 8; // TODO: D/I
if (m_offset >= n_pages * 8192) {
DOLOG(debug, true, "bus::calculate_physical_address %o >= %o\n", m_offset, n_pages * 8192);
DOLOG(debug, !peek_only, "bus::calculate_physical_address %o >= %o", m_offset, n_pages * 8192);
c->schedule_trap(04); // invalid address
MMR0 |= 1 << 15; // non-resident
@ -387,7 +387,7 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
}
if ((p_offset >= pdr_len && direction == false) || (p_offset < pdr_len && direction == true)) {
DOLOG(debug, true, "bus::calculate_physical_address::p_offset %o >= %o\n", p_offset, pdr_len);
DOLOG(debug, !peek_only, "bus::calculate_physical_address::p_offset %o >= %o", p_offset, pdr_len);
c->schedule_trap(0250); // invalid access
MMR0 |= 1 << 14; // length
@ -398,11 +398,11 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
}
}
DOLOG(debug, true, "virtual address %06o maps to physical address %07o (run_mode: %d, par: %07o)\n", a, m_offset, run_mode, pages[run_mode][0][apf].par * 64); // TODO: D/I
DOLOG(debug, !peek_only, "virtual address %06o maps to physical address %07o (run_mode: %d, par: %07o)", a, m_offset, run_mode, pages[run_mode][0][apf].par * 64); // TODO: D/I
}
else {
m_offset = a;
DOLOG(debug, true, "virtual address %06o maps to physical address %07o\n", a, m_offset);
DOLOG(debug, !peek_only, "virtual address %06o maps to physical address %07o", a, m_offset);
}
return m_offset;
@ -426,12 +426,12 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
if (a >= 0160000) {
if (word_mode) {
assert(value < 256);
DOLOG(debug, true, "WRITE I/O %06o in byte mode\n", a);
DOLOG(debug, true, "WRITE I/O %06o in byte mode", a);
}
if (word_mode) {
if (a == 0177776 || a == 0177777) { // PSW
DOLOG(debug, true, "writeb PSW %s\n", a & 1 ? "MSB" : "LSB");
DOLOG(debug, true, "writeb PSW %s", a & 1 ? "MSB" : "LSB");
uint16_t vtemp = c -> getPSW();
if (a & 1)
@ -445,7 +445,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
}
if (a == 0177774 || a == 0177775) { // stack limit register
DOLOG(debug, true, "writeb Set stack limit register: %o\n", value);
DOLOG(debug, true, "writeb Set stack limit register: %o", value);
uint16_t v = c -> getStackLimitRegister();
if (a & 1)
@ -459,44 +459,44 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
}
else {
if (a == 0177776) { // PSW
DOLOG(debug, true, "write PSW %o\n", value);
DOLOG(debug, true, "write PSW %o", value);
c -> setPSW(value, false);
return value;
}
if (a == 0177774) { // stack limit register
DOLOG(debug, true, "write Set stack limit register: %o\n", value);
DOLOG(debug, true, "write Set stack limit register: %o", value);
c -> setStackLimitRegister(value);
return value;
}
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5
DOLOG(debug, true, "write kernel R%d: %o\n", a - 01777700, value);
DOLOG(debug, true, "write kernel R%d: %o", a - 01777700, value);
c -> setRegister(false, a - 0177700, value);
return value;
}
if (a >= 0177710 && a <= 0177715) { // user R0-R5
DOLOG(debug, true, "write user R%d: %o\n", a - 01777710, value);
DOLOG(debug, true, "write user R%d: %o", a - 01777710, value);
c -> setRegister(true, a - 0177710, value);
return value;
}
if (a == 0177706) { // kernel SP
DOLOG(debug, true, "write kernel SP: %o\n", value);
DOLOG(debug, true, "write kernel SP: %o", value);
c -> setStackPointer(0, value);
return value;
}
if (a == 0177707) { // PC
DOLOG(debug, true, "write PC: %o\n", value);
DOLOG(debug, true, "write PC: %o", value);
c -> setPC(value);
return value;
}
if (a == 0177716) { // supervisor SP
DOLOG(debug, true, "write supervisor sp: %o\n", value);
DOLOG(debug, true, "write supervisor sp: %o", value);
c -> setStackPointer(1, value);
return value;
}
if (a == 0177717) { // user SP
DOLOG(debug, true, "write user sp: %o\n", value);
DOLOG(debug, true, "write user sp: %o", value);
c -> setStackPointer(3, value);
return value;
}
@ -507,19 +507,19 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
}
if (a == 0177766) { // cpu error register
DOLOG(debug, true, "write CPUERR: %o\n", value);
DOLOG(debug, true, "write CPUERR: %o", value);
CPUERR = 0;
return CPUERR;
}
if (a == 0172516) { // MMR3
DOLOG(debug, true, "write set MMR3: %o\n", value);
DOLOG(debug, true, "write set MMR3: %o", value);
MMR3 = value & 067;
return MMR3;
}
if (a == 0177572) { // MMR0
DOLOG(debug, true, "write set MMR0: %o\n", value);
DOLOG(debug, true, "write set MMR0: %o", value);
MMR0 = value & ~(3 << 10); // bit 10 & 11 always read as 0
@ -530,13 +530,13 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
}
if (a == 0177772) { // PIR
DOLOG(debug, true, "write set PIR: %o\n", value);
DOLOG(debug, true, "write set PIR: %o", value);
PIR = value; // TODO
return PIR;
}
if (a == 0177546) { // line frequency clock and status register
DOLOG(debug, true, "write set LFC/SR: %o\n", value);
DOLOG(debug, true, "write set LFC/SR: %o", value);
lf_csr = value;
return lf_csr;
}
@ -575,7 +575,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
pages[001][is_d][page].pdr = value;
}
DOLOG(debug, true, "write supervisor %c PDR for %d: %o\n", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value);
DOLOG(debug, true, "write supervisor %c PDR for %d: %o", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value);
return value;
}
@ -591,7 +591,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
pages[001][is_d][page].par = value;
}
DOLOG(debug, true, "write supervisor %c PAR for %d: %o (%07o)\n", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value, pages[001][is_d][page].par * 64);
DOLOG(debug, true, "write supervisor %c PAR for %d: %o (%07o)", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value, pages[001][is_d][page].par * 64);
return value;
}
@ -609,7 +609,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
pages[000][is_d][page].pdr = value;
}
DOLOG(debug, true, "write kernel %c PDR for %d: %o\n", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value);
DOLOG(debug, true, "write kernel %c PDR for %d: %o", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value);
return value;
}
@ -625,7 +625,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
pages[000][is_d][page].par = value;
}
DOLOG(debug, true, "write kernel %c PAR for %d: %o (%07o)\n", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value, pages[000][is_d][page].par * 64);
DOLOG(debug, true, "write kernel %c PAR for %d: %o (%07o)", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value, pages[000][is_d][page].par * 64);
return value;
}
@ -643,7 +643,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
pages[003][is_d][page].pdr = value;
}
DOLOG(debug, true, "write user %c PDR for %d: %o\n", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value);
DOLOG(debug, true, "write user %c PDR for %d: %o", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value);
return value;
}
@ -659,7 +659,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
pages[003][is_d][page].par = value;
}
DOLOG(debug, true, "write user %c PAR for %d: %o (%07o)\n", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value, pages[003][is_d][page].par * 64);
DOLOG(debug, true, "write user %c PAR for %d: %o (%07o)", is_d ? 'D' : 'I', page, word_mode ? value & 0xff : value, pages[003][is_d][page].par * 64);
return value;
}
@ -683,9 +683,9 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
}
if (a & 1)
DOLOG(info, true, "bus::writeWord: odd address UNHANDLED\n");
DOLOG(info, true, "bus::writeWord: odd address UNHANDLED");
DOLOG(info, true, "UNHANDLED write %o(%c): %o\n", a, word_mode ? 'B' : ' ', value);
DOLOG(info, true, "UNHANDLED write %o(%c): %o", a, word_mode ? 'B' : ' ', value);
// c -> busError();
@ -694,9 +694,9 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
int run_mode = (c->getPSW() >> (use_prev ? 12 : 14)) & 3;
uint32_t m_offset = calculate_physical_address(run_mode, a, true, true);
uint32_t m_offset = calculate_physical_address(run_mode, a, true, true, true);
DOLOG(debug, true, "WRITE to %06o/%07o: %o\n", a, m_offset, value);
DOLOG(debug, true, "WRITE to %06o/%07o: %o", a, m_offset, value);
if (word_mode)
m->writeByte(m_offset, value);

2
bus.h
View file

@ -84,5 +84,5 @@ public:
uint16_t get_switch_register() const { return switch_register; }
uint32_t calculate_physical_address(const int run_mode, const uint16_t a, const bool trap_on_failure, const bool is_write);
uint32_t calculate_physical_address(const int run_mode, const uint16_t a, const bool trap_on_failure, const bool is_write, const bool peek_only);
};

View file

@ -169,7 +169,7 @@ void console::put_char(const char c)
tx = 0;
else if (c == 10) {
if (debug_buffer.empty() == false) {
DOLOG(::debug, true, "TTY: %s\n", debug_buffer.c_str());
DOLOG(::debug, true, "TTY: %s", debug_buffer.c_str());
debug_buffer.clear();
}
@ -210,7 +210,7 @@ void console::put_string(const std::string & what)
void console::operator()()
{
DOLOG(::debug, true, "Console thread started\n");
DOLOG(::debug, true, "Console thread started");
set_thread_name("kek::console");
@ -235,5 +235,5 @@ void console::operator()()
}
}
DOLOG(::debug, true, "Console thread terminating\n");
DOLOG(::debug, true, "Console thread terminating");
}

View file

@ -139,7 +139,7 @@ void console_ncurses::panel_update_thread()
int run_mode = current_PSW >> 14;
uint16_t current_PC = c->getPC();
uint32_t full_addr = b->calculate_physical_address(run_mode, current_PC, false, false);
uint32_t full_addr = b->calculate_physical_address(run_mode, current_PC, false, false, true);
uint16_t current_instr = b->readWord(current_PC);

16
cpu.cpp
View file

@ -265,7 +265,7 @@ bool cpu::check_queued_interrupts()
interrupts->second.erase(vector);
DOLOG(debug, true, "Invoking interrupt vector %o (IPL %d, current: %d)\n", v, i, current_level);
DOLOG(debug, true, "Invoking interrupt vector %o (IPL %d, current: %d)", v, i, current_level);
trap(v, i);
@ -284,7 +284,7 @@ void cpu::queue_interrupt(const uint8_t level, const uint8_t vector)
it->second.insert(vector);
DOLOG(debug, true, "Queueing interrupt vector %o (IPL %d, current: %d), n: %zu\n", vector, level, getPSW_spl(), it->second.size());
DOLOG(debug, true, "Queueing interrupt vector %o (IPL %d, current: %d), n: %zu", vector, level, getPSW_spl(), it->second.size());
}
void cpu::addToMMR1(const uint8_t mode, const uint8_t reg, const bool word_mode)
@ -1493,13 +1493,15 @@ bool cpu::condition_code_operations(const uint16_t instr)
void cpu::pushStack(const uint16_t v)
{
if (getRegister(6) == stackLimitRegister) {
printf("stackLimitRegister reached\n"); // TODO
exit(1);
}
DOLOG(debug, true, "stackLimitRegister reached");
trap(123, 7); // TODO
}
else {
uint16_t a = addRegister(6, false, -2);
b -> writeWord(a, v);
}
}
uint16_t cpu::popStack()
@ -2167,11 +2169,11 @@ void cpu::step_b()
if (misc_operations(instr))
return;
DOLOG(warning, true, "UNHANDLED instruction %o\n", instr);
DOLOG(warning, true, "UNHANDLED instruction %o", instr);
trap(010);
}
catch(const int exception) {
DOLOG(debug, true, "bus-trap during execution of command\n");
DOLOG(debug, true, "bus-trap during execution of command");
}
}

View file

@ -108,7 +108,7 @@ uint16_t loadTape(bus *const b, const char *const file)
{
FILE *fh = fopen(file, "rb");
if (!fh) {
DOLOG(ll_error, true, "Cannot open %s\n", file);
DOLOG(ll_error, true, "Cannot open %s", file);
return -1;
}
@ -129,16 +129,16 @@ uint16_t loadTape(bus *const b, const char *const file)
if (count == 6) { // eg no data
if (p != 1) {
DOLOG(info, true, "Setting start address to %o\n", p);
DOLOG(info, true, "Setting start address to %o", p);
start = p;
}
}
DOLOG(debug, true, "%ld] reading %d (dec) bytes to %o (oct)\n", ftell(fh), count - 6, p);
DOLOG(debug, true, "%ld] reading %d (dec) bytes to %o (oct)", ftell(fh), count - 6, p);
for(int i=0; i<count - 6; i++) {
if (feof(fh)) {
DOLOG(warning, true, "short read\n");
DOLOG(warning, true, "short read");
break;
}
uint8_t c = fgetc(fh);
@ -154,7 +154,7 @@ uint16_t loadTape(bus *const b, const char *const file)
csum += fcs;
if (csum != 255)
DOLOG(warning, true, "checksum error %d\n", csum);
DOLOG(warning, true, "checksum error %d", csum);
}
fclose(fh);

View file

@ -150,16 +150,16 @@ int main(int argc, char *argv[])
console *cnsl = nullptr;
setlog(logfile, logfile ? debug : ll_error, withUI ? ll_error : debug);
setlog(logfile, logfile ? ((tracing || run_debugger) ? debug : info) : ll_error, ll_error);
std::atomic_bool interrupt_emulation { false };
if (withUI)
cnsl = new console_ncurses(&event, b);
else {
DOLOG(info, true, "This PDP-11 emulator is called \"kek\" (reason for that is forgotten) and was written by Folkert van Heusden.\n");
DOLOG(info, true, "This PDP-11 emulator is called \"kek\" (reason for that is forgotten) and was written by Folkert van Heusden.");
DOLOG(info, true, "Built on: " __DATE__ " " __TIME__ "\n");
DOLOG(info, true, "Built on: " __DATE__ " " __TIME__);
cnsl = new console_posix(&event, b);
}
@ -182,7 +182,7 @@ int main(int argc, char *argv[])
if (testCases)
tests(c);
DOLOG(info, true, "Start running at %o\n", c->getRegister(7));
DOLOG(info, true, "Start running at %o", c->getRegister(7));
struct sigaction sa { };
sa.sa_handler = sw_handler;

View file

@ -94,7 +94,7 @@ uint16_t rk05::readWord(const uint16_t addr)
if (addr == RK05_CS)
setBit(registers[reg], 0, false); // clear go
DOLOG(debug, true, "RK05 read %s/%o: %06o\n", reg[regnames], addr, vtemp);
DOLOG(debug, true, "RK05 read %s/%o: %06o", reg[regnames], addr, vtemp);
return vtemp;
}
@ -146,13 +146,13 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
registers[(RK05_CS - RK05_BASE) / 2] &= ~(1 << 13); // reset search complete
if (func == 0) { // controller reset
DOLOG(debug, true, "RK05 invoke %d (controller reset)\n", func);
DOLOG(debug, true, "RK05 invoke %d (controller reset)", func);
}
else if (func == 1) { // write
*disk_write_acitivity = true;
DOLOG(debug, true, "RK05 drive %d position sec %d surf %d cyl %d, reclen %zo, WRITE to %o, mem: %o\n", device, sector, surface, cylinder, reclen, diskoffb, memoff);
DOLOG(debug, true, "RK05 drive %d position sec %d surf %d cyl %d, reclen %zo, WRITE to %o, mem: %o", device, sector, surface, cylinder, reclen, diskoffb, memoff);
uint32_t p = reclen;
for(size_t i=0; i<reclen; i++)
@ -161,19 +161,19 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
#if defined(ESP32)
File32 *fh = fhs.at(device);
if (!fh->seek(diskoffb))
DOLOG(ll_error, true, "RK05 seek error %s\n", strerror(errno));
DOLOG(ll_error, true, "RK05 seek error %s", strerror(errno));
if (fh->write(xfer_buffer, reclen) != reclen)
DOLOG(ll_error, true, "RK05 fwrite error %s\n", strerror(errno));
DOLOG(ll_error, true, "RK05 fwrite error %s", strerror(errno));
#else
FILE *fh = fhs.at(device);
if (fseek(fh, diskoffb, SEEK_SET) == -1)
DOLOG(ll_error, true, "RK05 seek error %s\n", strerror(errno));
DOLOG(ll_error, true, "RK05 seek error %s", strerror(errno));
if (fwrite(xfer_buffer, 1, reclen, fh) != reclen)
DOLOG(ll_error, true, "RK05 fwrite error %s\n", strerror(errno));
DOLOG(ll_error, true, "RK05 fwrite error %s", strerror(errno));
#endif
if (v & 2048)
DOLOG(debug, true, "RK05 inhibit BA increase\n");
DOLOG(debug, true, "RK05 inhibit BA increase");
else
registers[(RK05_BA - RK05_BASE) / 2] += p;
@ -192,14 +192,14 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
else if (func == 2) { // read
*disk_read_acitivity = true;
DOLOG(debug, true, "RK05 drive %d position sec %d surf %d cyl %d, reclen %zo, READ from %o, mem: %o\n", device, sector, surface, cylinder, reclen, diskoffb, memoff);
DOLOG(debug, true, "RK05 drive %d position sec %d surf %d cyl %d, reclen %zo, READ from %o, mem: %o", device, sector, surface, cylinder, reclen, diskoffb, memoff);
bool proceed = true;
#if defined(ESP32)
File32 *fh = fhs.at(device);
if (!fh->seek(diskoffb)) {
DOLOG(ll_error, true, "RK05 seek error %s\n", strerror(errno));
DOLOG(ll_error, true, "RK05 seek error %s", strerror(errno));
proceed = false;
}
#else
@ -211,7 +211,7 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
fh = fhs.at(device);
if (fseek(fh, diskoffb, SEEK_SET) == -1) {
DOLOG(ll_error, true, "RK05 seek error %s\n", strerror(errno));
DOLOG(ll_error, true, "RK05 seek error %s", strerror(errno));
proceed = false;
}
}
@ -226,10 +226,10 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
yield();
if (fh->read(xfer_buffer, cur) != size_t(cur))
DOLOG(debug, true, "RK05 fread error: %s\n", strerror(errno));
DOLOG(debug, true, "RK05 fread error: %s", strerror(errno));
#else
if (fread(xfer_buffer, 1, cur, fh) != size_t(cur))
DOLOG(debug, true, "RK05 fread error: %s\n", strerror(errno));
DOLOG(debug, true, "RK05 fread error: %s", strerror(errno));
#endif
for(uint32_t i=0; i<cur; i++) {
@ -242,7 +242,7 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
}
if (v & 2048)
DOLOG(debug, true, "RK05 inhibit BA increase\n");
DOLOG(debug, true, "RK05 inhibit BA increase");
else
registers[(RK05_BA - RK05_BASE) / 2] += p;
@ -259,15 +259,15 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
*disk_read_acitivity = false;
}
else if (func == 4) {
DOLOG(debug, true, "RK05 invoke %d (seek) to %o\n", func, diskoffb);
DOLOG(debug, true, "RK05 invoke %d (seek) to %o", func, diskoffb);
registers[(RK05_CS - RK05_BASE) / 2] |= 1 << 13; // search complete
}
else if (func == 7) {
DOLOG(debug, true, "RK05 invoke %d (write lock)\n", func);
DOLOG(debug, true, "RK05 invoke %d (write lock)", func);
}
else {
DOLOG(debug, true, "RK05 command %d UNHANDLED\n", func);
DOLOG(debug, true, "RK05 command %d UNHANDLED", func);
}
registers[(RK05_WC - RK05_BASE) / 2] = 0;

View file

@ -83,7 +83,7 @@ uint16_t rl02::readWord(const uint16_t addr)
// TODO
DOLOG(debug, true, "RL02 read %s/%o: %06o\n", regnames[reg], addr, value);
DOLOG(debug, true, "RL02 read %s/%o: %06o", regnames[reg], addr, value);
return value;
}
@ -120,7 +120,7 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
digitalWrite(LED_BUILTIN, LOW);
#endif
DOLOG(debug, true, "RL02 write %06o: %06o\n", addr, v);
DOLOG(debug, true, "RL02 write %06o: %06o", addr, v);
const int reg = (addr - RL02_BASE) / 2;
@ -131,7 +131,7 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
const bool do_exec = !(v & 128);
DOLOG(debug, true, "RL02 set command %d, exec: %d\n", command, do_exec);
DOLOG(debug, true, "RL02 set command %d, exec: %d", command, do_exec);
uint32_t disk_offset = calcOffset(registers[(RL02_DAR - RL02_BASE) / 2] & ~1);
int device = 0; // TODO
@ -145,7 +145,7 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
(1 << 7) | // this is an RL02
0;
DOLOG(debug, true, "RL02 set MPR for status to %06o\n", registers[(RL02_MPR - RL02_BASE) / 2]);
DOLOG(debug, true, "RL02 set MPR for status to %06o", registers[(RL02_MPR - RL02_BASE) / 2]);
}
#endif
}
@ -158,7 +158,7 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
File32 *fh = fhs.at(device);
if (!fh->seek(disk_offset)) {
DOLOG(ll_error, true, "RL02 seek to %d error %s\n", disk_offset, strerror(errno));
DOLOG(ll_error, true, "RL02 seek to %d error %s", disk_offset, strerror(errno));
proceed = false;
}
@ -171,7 +171,7 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
fh = fhs.at(device);
if (fseek(fh, disk_offset, SEEK_SET) == -1) {
DOLOG(ll_error, true, "RL02 seek error %s\n", strerror(errno));
DOLOG(ll_error, true, "RL02 seek error %s", strerror(errno));
proceed = false;
}
}
@ -181,7 +181,7 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
uint32_t count = (65536 - registers[(RL02_MPR - RL02_BASE) / 2]) * 2;
DOLOG(debug, true, "RL02 read %d bytes (dec) from %d (dec) to %06o (oct)\n", count, disk_offset, memory_address);
DOLOG(debug, true, "RL02 read %d bytes (dec) from %d (dec) to %06o (oct)", count, disk_offset, memory_address);
uint32_t p = memory_address;
while(proceed && count > 0) {
@ -191,10 +191,10 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
yield();
if (fh->read(xfer_buffer, cur) != size_t(cur))
DOLOG(info, true, "RL02 fread error: %s\n", strerror(errno));
DOLOG(info, true, "RL02 fread error: %s", strerror(errno));
#else
if (fread(xfer_buffer, 1, cur, fh) != size_t(cur))
DOLOG(info, true, "RL02 fread error: %s\n", strerror(errno));
DOLOG(info, true, "RL02 fread error: %s", strerror(errno));
#endif
for(uint32_t i=0; i<cur; i++, p++)
@ -204,7 +204,7 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
}
if (registers[(RL02_CSR - RL02_BASE) / 2] & 64) { // interrupt enable?
DOLOG(debug, true, "RL02 triggering interrupt\n");
DOLOG(debug, true, "RL02 triggering interrupt");
b->getCpu()->queue_interrupt(5, 0254);
}

View file

@ -85,22 +85,22 @@ void tm_11::writeByte(const uint16_t addr, const uint8_t v)
void tm_11::writeWord(const uint16_t addr, uint16_t v)
{
DOLOG(debug, true, "TM-11 write %o: %o\n", addr, v);
DOLOG(debug, true, "TM-11 write %o: %o", addr, v);
if (addr == TM_11_MTC) {
if (v & 1) { // GO
const int func = (v >> 1) & 7; // FUNCTION
const int reclen = 512;
DOLOG(debug, true, "invoke %d\n", func);
DOLOG(debug, true, "invoke %d", func);
if (func == 0) { // off-line
v = 128; // TODO set error if error
}
else if (func == 1) { // read
DOLOG(debug, true, "reading %d bytes from offset %d\n", reclen, offset);
DOLOG(debug, true, "reading %d bytes from offset %d", reclen, offset);
if (fread(xfer_buffer, 1, reclen, fh) != reclen)
DOLOG(info, true, "failed: %s\n", strerror(errno));
DOLOG(info, true, "failed: %s", strerror(errno));
for(int i=0; i<reclen; i++)
m -> writeByte(registers[(TM_11_MTCMA - TM_11_BASE) / 2] + i, xfer_buffer[i]);
offset += reclen;
@ -131,9 +131,9 @@ void tm_11::writeWord(const uint16_t addr, uint16_t v)
}
else if (addr == TM_11_MTCMA) {
v &= ~1;
DOLOG(debug, true, "Set DMA address to %o\n", v);
DOLOG(debug, true, "Set DMA address to %o", v);
}
DOLOG(debug, true, "set register %o to %o\n", addr, v);
DOLOG(debug, true, "set register %o to %o", addr, v);
registers[(addr - TM_11_BASE) / 2] = v;
}

View file

@ -68,7 +68,7 @@ uint16_t tty::readWord(const uint16_t addr)
vtemp = 128;
}
DOLOG(debug, true, "PDP11TTY read addr %o (%s): %d, 7bit: %d\n", addr, regnames[reg], vtemp, vtemp & 127);
DOLOG(debug, true, "PDP11TTY read addr %o (%s): %d, 7bit: %d", addr, regnames[reg], vtemp, vtemp & 127);
registers[reg] = vtemp;
@ -95,16 +95,16 @@ void tty::writeWord(const uint16_t addr, uint16_t v)
{
const int reg = (addr - PDP11TTY_BASE) / 2;
DOLOG(debug, true, "PDP11TTY write %o (%s): %o\n", addr, regnames[reg], v);
DOLOG(debug, true, "PDP11TTY write %o (%s): %o", addr, regnames[reg], v);
if (addr == PDP11TTY_TPB) {
char ch = v & 127;
DOLOG(debug, true, "PDP11TTY print '%c'\n", ch);
DOLOG(debug, true, "PDP11TTY print '%c'", ch);
c->put_char(ch);
}
DOLOG(debug, true, "set register %o to %o\n", addr, v);
DOLOG(debug, true, "set register %o to %o", addr, v);
registers[(addr - PDP11TTY_BASE) / 2] = v;
}