Merge branch 'master' into psram
This commit is contained in:
commit
a78fb22516
11 changed files with 42 additions and 20 deletions
|
@ -18,6 +18,9 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(ESP32)
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(SHA2017)
|
#if defined(SHA2017)
|
||||||
#include "console_shabadge.h"
|
#include "console_shabadge.h"
|
||||||
|
@ -210,6 +213,14 @@ void set_tty_serial_speed(console *const c, const uint32_t bps)
|
||||||
c->put_string_lf("Failed to store configuration file with serial settings");
|
c->put_string_lf("Failed to store configuration file with serial settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
void heap_caps_alloc_failed_hook(size_t requested_size, uint32_t caps, const char *function_name)
|
||||||
|
{
|
||||||
|
printf("%s was called but failed to allocate %d bytes with 0x%X capabilities\r\n", function_name, requested_size, caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
@ -224,6 +235,10 @@ void setup() {
|
||||||
Serial.print(F("Size of int: "));
|
Serial.print(F("Size of int: "));
|
||||||
Serial.println(sizeof(int));
|
Serial.println(sizeof(int));
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
heap_caps_register_failed_alloc_callback(heap_caps_alloc_failed_hook);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(BUILD_FOR_RP2040)
|
#if !defined(BUILD_FOR_RP2040)
|
||||||
Serial.print(F("CPU clock frequency (MHz): "));
|
Serial.print(F("CPU clock frequency (MHz): "));
|
||||||
Serial.println(getCpuFrequencyMhz());
|
Serial.println(getCpuFrequencyMhz());
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../win32.cpp
|
|
|
@ -1 +0,0 @@
|
||||||
../win32.h
|
|
16
bus.cpp
16
bus.cpp
|
@ -120,8 +120,6 @@ bus *bus::deserialize(const json_t *const j, console *const cnsl, std::atomic_ui
|
||||||
|
|
||||||
void bus::set_memory_size(const int n_pages)
|
void bus::set_memory_size(const int n_pages)
|
||||||
{
|
{
|
||||||
this->n_pages = n_pages;
|
|
||||||
|
|
||||||
uint32_t n_bytes = n_pages * 8192l;
|
uint32_t n_bytes = n_pages * 8192l;
|
||||||
|
|
||||||
delete m;
|
delete m;
|
||||||
|
@ -474,7 +472,7 @@ uint16_t bus::read(const uint16_t addr_in, const word_mode_t word_mode, const rm
|
||||||
}
|
}
|
||||||
|
|
||||||
// LO size register field must be all 1s, so subtract 1
|
// LO size register field must be all 1s, so subtract 1
|
||||||
uint32_t system_size = n_pages * 8192l / 64 - 1;
|
uint32_t system_size = m->get_memory_size() / 64 - 1;
|
||||||
|
|
||||||
if (a == ADDR_SYSSIZE + 2) { // system size HI
|
if (a == ADDR_SYSSIZE + 2) { // system size HI
|
||||||
uint16_t temp = system_size >> 16;
|
uint16_t temp = system_size >> 16;
|
||||||
|
@ -505,7 +503,7 @@ uint16_t bus::read(const uint16_t addr_in, const word_mode_t word_mode, const rm
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_offset >= uint32_t(n_pages * 8192)) {
|
if (m_offset >= m->get_memory_size()) {
|
||||||
if (peek_only) {
|
if (peek_only) {
|
||||||
DOLOG(debug, false, "READ from %06o - out of range!", addr_in);
|
DOLOG(debug, false, "READ from %06o - out of range!", addr_in);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -696,8 +694,8 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_offset >= n_pages * 8192l && !is_io) [[unlikely]] {
|
if (m_offset >= m->get_memory_size() && !is_io) [[unlikely]] {
|
||||||
DOLOG(debug, !peek_only, "bus::calculate_physical_address %o >= %o", m_offset, n_pages * 8192l);
|
DOLOG(debug, !peek_only, "bus::calculate_physical_address %o >= %o", m_offset, m->get_memory_size());
|
||||||
DOLOG(debug, false, "TRAP(04) (throw 6) on address %06o", a);
|
DOLOG(debug, false, "TRAP(04) (throw 6) on address %06o", a);
|
||||||
|
|
||||||
if (mmu_->is_locked() == false) {
|
if (mmu_->is_locked() == false) {
|
||||||
|
@ -1025,7 +1023,7 @@ write_rc_t bus::write(const uint16_t addr_in, const word_mode_t word_mode, uint1
|
||||||
|
|
||||||
DOLOG(debug, false, "WRITE to %06o/%07o %c %c: %06o", addr_in, m_offset, space == d_space ? 'D' : 'I', word_mode == wm_byte ? 'B' : 'W', value);
|
DOLOG(debug, false, "WRITE to %06o/%07o %c %c: %06o", addr_in, m_offset, space == d_space ? 'D' : 'I', word_mode == wm_byte ? 'B' : 'W', value);
|
||||||
|
|
||||||
if (m_offset >= uint32_t(n_pages * 8192)) {
|
if (m_offset >= m->get_memory_size()) {
|
||||||
c->trap(004); // no such RAM
|
c->trap(004); // no such RAM
|
||||||
throw 1;
|
throw 1;
|
||||||
}
|
}
|
||||||
|
@ -1042,7 +1040,7 @@ void bus::writePhysical(const uint32_t a, const uint16_t value)
|
||||||
{
|
{
|
||||||
DOLOG(debug, false, "physicalWRITE %06o to %o", value, a);
|
DOLOG(debug, false, "physicalWRITE %06o to %o", value, a);
|
||||||
|
|
||||||
if (a >= n_pages * 8192l) {
|
if (a >= m->get_memory_size()) {
|
||||||
DOLOG(debug, false, "physicalWRITE to %o: trap 004", a);
|
DOLOG(debug, false, "physicalWRITE to %o: trap 004", a);
|
||||||
c->trap(004);
|
c->trap(004);
|
||||||
throw 12;
|
throw 12;
|
||||||
|
@ -1054,7 +1052,7 @@ void bus::writePhysical(const uint32_t a, const uint16_t value)
|
||||||
|
|
||||||
uint16_t bus::readPhysical(const uint32_t a)
|
uint16_t bus::readPhysical(const uint32_t a)
|
||||||
{
|
{
|
||||||
if (a >= n_pages * 8192l) {
|
if (a >= m->get_memory_size()) {
|
||||||
DOLOG(debug, false, "physicalREAD from %o: trap 004", a);
|
DOLOG(debug, false, "physicalREAD from %o: trap 004", a);
|
||||||
c->trap(004);
|
c->trap(004);
|
||||||
throw 13;
|
throw 13;
|
||||||
|
|
4
bus.h
4
bus.h
|
@ -75,10 +75,7 @@ private:
|
||||||
rl02 *rl02_ { nullptr };
|
rl02 *rl02_ { nullptr };
|
||||||
tty *tty_ { nullptr };
|
tty *tty_ { nullptr };
|
||||||
kw11_l *kw11_l_ { nullptr };
|
kw11_l *kw11_l_ { nullptr };
|
||||||
|
|
||||||
mmu *mmu_ { nullptr };
|
mmu *mmu_ { nullptr };
|
||||||
|
|
||||||
int n_pages { DEFAULT_N_PAGES };
|
|
||||||
memory *m { nullptr };
|
memory *m { nullptr };
|
||||||
|
|
||||||
uint16_t microprogram_break_register { 0 };
|
uint16_t microprogram_break_register { 0 };
|
||||||
|
@ -104,7 +101,6 @@ public:
|
||||||
void set_debug_mode() { console_switches |= 128; }
|
void set_debug_mode() { console_switches |= 128; }
|
||||||
uint16_t get_console_leds() { return console_leds; }
|
uint16_t get_console_leds() { return console_leds; }
|
||||||
|
|
||||||
int get_memory_size() const { return n_pages; }
|
|
||||||
void set_memory_size(const int n_pages);
|
void set_memory_size(const int n_pages);
|
||||||
|
|
||||||
void mmudebug(const uint16_t a);
|
void mmudebug(const uint16_t a);
|
||||||
|
|
10
debugger.cpp
10
debugger.cpp
|
@ -26,6 +26,7 @@
|
||||||
#include "disk_backend_nbd.h"
|
#include "disk_backend_nbd.h"
|
||||||
#include "loaders.h"
|
#include "loaders.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "memory.h"
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
@ -821,6 +822,12 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
|
else if (cmd == "debug") {
|
||||||
|
if (heap_caps_check_integrity_all(true) == false)
|
||||||
|
cnsl->put_string_lf("HEAP corruption!");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else if (cmd == "cfgnet") {
|
else if (cmd == "cfgnet") {
|
||||||
configure_network(cnsl);
|
configure_network(cnsl);
|
||||||
|
|
||||||
|
@ -859,7 +866,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
if (parts.size() == 2)
|
if (parts.size() == 2)
|
||||||
b->set_memory_size(std::stoi(parts.at(1)));
|
b->set_memory_size(std::stoi(parts.at(1)));
|
||||||
else {
|
else {
|
||||||
int n_pages = b->get_memory_size();
|
int n_pages = b->getRAM()->get_memory_size();
|
||||||
|
|
||||||
cnsl->put_string_lf(format("Memory size: %u pages or %u kB (decimal)", n_pages, n_pages * 8192 / 1024));
|
cnsl->put_string_lf(format("Memory size: %u pages or %u kB (decimal)", n_pages, n_pages * 8192 / 1024));
|
||||||
}
|
}
|
||||||
|
@ -1016,6 +1023,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
"startnet - start network",
|
"startnet - start network",
|
||||||
"chknet - check network status",
|
"chknet - check network status",
|
||||||
"serspd - set serial speed in bps (8N1 are default)",
|
"serspd - set serial speed in bps (8N1 are default)",
|
||||||
|
"debug - debugging info",
|
||||||
#endif
|
#endif
|
||||||
"cfgdisk - configure disk",
|
"cfgdisk - configure disk",
|
||||||
nullptr
|
nullptr
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "disk_backend.h"
|
#include "disk_backend.h"
|
||||||
|
#include "gen.h"
|
||||||
#if IS_POSIX
|
#if IS_POSIX
|
||||||
#include "disk_backend_file.h"
|
#include "disk_backend_file.h"
|
||||||
#include "disk_backend_nbd.h"
|
#include "disk_backend_nbd.h"
|
||||||
|
|
|
@ -91,10 +91,10 @@ bool disk_backend_nbd::connect(const bool retry)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
// LOOP until connected, logging message, exponential backoff?
|
// LOOP until connected, logging message, exponential backoff?
|
||||||
addrinfo *res = nullptr;
|
addrinfo *res = nullptr;
|
||||||
|
|
||||||
addrinfo hints { 0 };
|
addrinfo hints { 0 };
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
char port_str[8] { 0 };
|
char port_str[8] { 0 };
|
||||||
|
@ -137,7 +137,7 @@ bool disk_backend_nbd::connect(const bool retry)
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint8_t padding[124];
|
uint8_t padding[124];
|
||||||
} nbd_hello;
|
} nbd_hello { };
|
||||||
|
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
if (READ(fd, reinterpret_cast<char *>(&nbd_hello), sizeof nbd_hello) != sizeof nbd_hello) {
|
if (READ(fd, reinterpret_cast<char *>(&nbd_hello), sizeof nbd_hello) != sizeof nbd_hello) {
|
||||||
|
@ -194,7 +194,7 @@ bool disk_backend_nbd::read(const off_t offset_in, const size_t n, uint8_t *cons
|
||||||
uint64_t handle;
|
uint64_t handle;
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
} nbd_request { 0 };
|
} nbd_request { };
|
||||||
|
|
||||||
nbd_request.magic = ntohl(0x25609513);
|
nbd_request.magic = ntohl(0x25609513);
|
||||||
nbd_request.type = 0; // READ
|
nbd_request.type = 0; // READ
|
||||||
|
|
2
log.cpp
2
log.cpp
|
@ -15,7 +15,9 @@
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#if defined(_WIN32)
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const char *logfile = strdup("/tmp/kek.log");
|
static const char *logfile = strdup("/tmp/kek.log");
|
||||||
|
|
2
memory.h
2
memory.h
|
@ -18,6 +18,8 @@ public:
|
||||||
memory(const uint32_t size);
|
memory(const uint32_t size);
|
||||||
~memory();
|
~memory();
|
||||||
|
|
||||||
|
uint32_t get_memory_size() const { return size; }
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
#if IS_POSIX
|
#if IS_POSIX
|
||||||
json_t *serialize() const;
|
json_t *serialize() const;
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void setBit(uint16_t & v, const int bit, const bool vb)
|
void setBit(uint16_t & v, const int bit, const bool vb)
|
||||||
|
|
Loading…
Add table
Reference in a new issue