Merge branch 'master' into psram
This commit is contained in:
commit
e1102c69d6
6 changed files with 23 additions and 171 deletions
|
@ -70,6 +70,9 @@ std::atomic_bool *running { nullptr };
|
||||||
|
|
||||||
bool trace_output { false };
|
bool trace_output { false };
|
||||||
|
|
||||||
|
std::vector<disk_backend *> rk05_files;
|
||||||
|
std::vector<disk_backend *> rl02_files;
|
||||||
|
|
||||||
void console_thread_wrapper_panel(void *const c)
|
void console_thread_wrapper_panel(void *const c)
|
||||||
{
|
{
|
||||||
console *const cnsl = reinterpret_cast<console *>(c);
|
console *const cnsl = reinterpret_cast<console *>(c);
|
||||||
|
@ -193,12 +196,7 @@ void recall_configuration(console *const cnsl)
|
||||||
cnsl->put_string_lf("Starting network...");
|
cnsl->put_string_lf("Starting network...");
|
||||||
start_network(cnsl);
|
start_network(cnsl);
|
||||||
|
|
||||||
auto disk_configuration = load_disk_configuration(cnsl);
|
// TODO
|
||||||
|
|
||||||
if (disk_configuration.has_value()) {
|
|
||||||
cnsl->put_string_lf("Starting disk...");
|
|
||||||
set_disk_configuration(b, cnsl, disk_configuration.value());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -268,6 +266,9 @@ void setup() {
|
||||||
Serial.println(F("Init bus"));
|
Serial.println(F("Init bus"));
|
||||||
b = new bus();
|
b = new bus();
|
||||||
|
|
||||||
|
Serial.println(F("Allocate memory"));
|
||||||
|
b->set_memory_size(DEFAULT_N_PAGES);
|
||||||
|
|
||||||
Serial.println(F("Init CPU"));
|
Serial.println(F("Init CPU"));
|
||||||
c = new cpu(b, &stop_event);
|
c = new cpu(b, &stop_event);
|
||||||
|
|
||||||
|
@ -298,6 +299,11 @@ void setup() {
|
||||||
|
|
||||||
running = cnsl->get_running_flag();
|
running = cnsl->get_running_flag();
|
||||||
|
|
||||||
|
Serial.println(F("Connect RK05 and RL02 to BUS"));
|
||||||
|
b->add_rk05(new rk05(rk05_files, b, cnsl->get_disk_read_activity_flag(), cnsl->get_disk_write_activity_flag()));
|
||||||
|
|
||||||
|
b->add_rl02(new rl02(rl02_files, b, cnsl->get_disk_read_activity_flag(), cnsl->get_disk_write_activity_flag()));
|
||||||
|
|
||||||
Serial.println(F("Init TTY"));
|
Serial.println(F("Init TTY"));
|
||||||
tty_ = new tty(cnsl, b);
|
tty_ = new tty(cnsl, b);
|
||||||
Serial.println(F("Connect TTY to bus"));
|
Serial.println(F("Connect TTY to bus"));
|
||||||
|
|
150
debugger.cpp
150
debugger.cpp
|
@ -10,7 +10,6 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#else
|
#else
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <ArduinoJson.h>
|
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -47,155 +46,12 @@ void check_network(console *const c);
|
||||||
void start_network(console *const c);
|
void start_network(console *const c);
|
||||||
|
|
||||||
void set_tty_serial_speed(console *const c, const uint32_t bps);
|
void set_tty_serial_speed(console *const c, const uint32_t bps);
|
||||||
|
|
||||||
void recall_configuration(console *const c);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NET_DISK_CFG_FILE "net-disk.json"
|
|
||||||
|
|
||||||
#if !defined(BUILD_FOR_RP2040) && !defined(linux)
|
#if !defined(BUILD_FOR_RP2040) && !defined(linux)
|
||||||
extern SdFs SD;
|
extern SdFs SD;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef linux
|
|
||||||
#define MAX_CFG_SIZE 1024
|
|
||||||
StaticJsonDocument<MAX_CFG_SIZE> json_doc;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum { BE_NETWORK, BE_SD } disk_backend_t;
|
|
||||||
|
|
||||||
#if !defined(BUILD_FOR_RP2040)
|
|
||||||
std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *>, std::string> > load_disk_configuration(console *const c)
|
|
||||||
{
|
|
||||||
#if IS_POSIX
|
|
||||||
json_error_t error;
|
|
||||||
json_t *json = json_load_file("." NET_DISK_CFG_FILE, JSON_REJECT_DUPLICATES, &error);
|
|
||||||
if (!json) {
|
|
||||||
c->put_string_lf(format("Cannot load ." NET_DISK_CFG_FILE ": %s", error.text));
|
|
||||||
|
|
||||||
return { };
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string nbd_host = json_string_value (json_object_get(json, "NBD-host"));
|
|
||||||
int nbd_port = json_integer_value(json_object_get(json, "NBD-port"));
|
|
||||||
|
|
||||||
std::string disk_type_temp = json_string_value (json_object_get(json, "disk-type"));
|
|
||||||
|
|
||||||
std::string tape_file = json_string_value (json_object_get(json, "tape-file"));
|
|
||||||
|
|
||||||
json_decref(json);
|
|
||||||
#else
|
|
||||||
File dataFile = LittleFS.open("/" NET_DISK_CFG_FILE, "r");
|
|
||||||
if (!dataFile)
|
|
||||||
return { };
|
|
||||||
|
|
||||||
size_t size = dataFile.size();
|
|
||||||
|
|
||||||
char buffer[MAX_CFG_SIZE];
|
|
||||||
|
|
||||||
if (size > sizeof buffer) { // this should not happen
|
|
||||||
dataFile.close();
|
|
||||||
|
|
||||||
return { };
|
|
||||||
}
|
|
||||||
|
|
||||||
dataFile.read(reinterpret_cast<uint8_t *>(buffer), size);
|
|
||||||
buffer[(sizeof buffer) - 1] = 0x00;
|
|
||||||
|
|
||||||
dataFile.close();
|
|
||||||
|
|
||||||
auto error = deserializeJson(json_doc, buffer);
|
|
||||||
if (error) // this should not happen
|
|
||||||
return { };
|
|
||||||
|
|
||||||
String nbd_host = json_doc["NBD-host"];
|
|
||||||
int nbd_port = json_doc["NBD-port"];
|
|
||||||
|
|
||||||
String disk_type_temp = json_doc["disk-type"];
|
|
||||||
|
|
||||||
String tape_file = json_doc["tape-file"];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
disk_type_t disk_type = DT_RK05;
|
|
||||||
|
|
||||||
if (disk_type_temp == "rl02")
|
|
||||||
disk_type = DT_RL02;
|
|
||||||
else if (disk_type_temp == "tape")
|
|
||||||
disk_type = DT_TAPE;
|
|
||||||
|
|
||||||
disk_backend *d = new disk_backend_nbd(nbd_host.c_str(), nbd_port);
|
|
||||||
|
|
||||||
if (d->begin(false) == false) {
|
|
||||||
c->put_string_lf("Cannot initialize NBD client from configuration file");
|
|
||||||
delete d;
|
|
||||||
return { };
|
|
||||||
}
|
|
||||||
|
|
||||||
c->put_string_lf(format("Connection to NBD server at %s:%d success", nbd_host.c_str(), nbd_port));
|
|
||||||
|
|
||||||
if (disk_type == DT_RK05)
|
|
||||||
return { { { d }, { }, "" } };
|
|
||||||
|
|
||||||
if (disk_type == DT_RL02)
|
|
||||||
return { { { }, { d }, "" } };
|
|
||||||
|
|
||||||
if (disk_type == DT_TAPE)
|
|
||||||
return { { { }, { }, tape_file.c_str() } };
|
|
||||||
|
|
||||||
return { };
|
|
||||||
}
|
|
||||||
|
|
||||||
bool save_disk_configuration(const std::string & nbd_host, const int nbd_port, const std::optional<std::string> & tape_file, const disk_type_t dt, console *const cnsl)
|
|
||||||
{
|
|
||||||
#if IS_POSIX
|
|
||||||
json_t *json = json_object();
|
|
||||||
|
|
||||||
json_object_set(json, "NBD-host", json_string(nbd_host.c_str()));
|
|
||||||
json_object_set(json, "NBD-port", json_integer(nbd_port));
|
|
||||||
|
|
||||||
if (dt == DT_RK05)
|
|
||||||
json_object_set(json, "disk-type", json_string("rk05"));
|
|
||||||
else if (dt == DT_RL02)
|
|
||||||
json_object_set(json, "disk-type", json_string("rl02"));
|
|
||||||
else
|
|
||||||
json_object_set(json, "disk-type", json_string("tape"));
|
|
||||||
|
|
||||||
json_object_set(json, "tape-file", json_string(tape_file.has_value() ? tape_file.value().c_str() : ""));
|
|
||||||
|
|
||||||
bool succeeded = json_dump_file(json, "." NET_DISK_CFG_FILE, 0) == 0;
|
|
||||||
json_decref(json);
|
|
||||||
|
|
||||||
if (succeeded == false) {
|
|
||||||
cnsl->put_string_lf(format("Cannot write ." NET_DISK_CFG_FILE));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
json_doc["NBD-host"] = nbd_host;
|
|
||||||
json_doc["NBD-port"] = nbd_port;
|
|
||||||
|
|
||||||
if (dt == DT_RK05)
|
|
||||||
json_doc["disk-type"] = "rk05";
|
|
||||||
else if (dt == DT_RL02)
|
|
||||||
json_doc["disk-type"] = "rl02";
|
|
||||||
else
|
|
||||||
json_doc["disk-type"] = "tape";
|
|
||||||
|
|
||||||
json_doc["tape-file"] = tape_file.has_value() ? tape_file.value() : "";
|
|
||||||
|
|
||||||
File dataFile = LittleFS.open("/" NET_DISK_CFG_FILE, "w");
|
|
||||||
if (!dataFile)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
serializeJson(json_doc, dataFile);
|
|
||||||
|
|
||||||
dataFile.close();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(BUILD_FOR_RP2040)
|
#if !defined(BUILD_FOR_RP2040)
|
||||||
std::optional<disk_backend *> select_nbd_server(console *const cnsl)
|
std::optional<disk_backend *> select_nbd_server(console *const cnsl)
|
||||||
{
|
{
|
||||||
|
@ -995,11 +851,6 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
cnsl->put_string_lf("serspd requires an (decimal) parameter");
|
cnsl->put_string_lf("serspd requires an (decimal) parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (cmd == "init") {
|
|
||||||
recall_configuration(cnsl);
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1160,7 +1011,6 @@ 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)",
|
||||||
"init - reload (disk-)configuration from flash",
|
|
||||||
#endif
|
#endif
|
||||||
"cfgdisk - configure disk",
|
"cfgdisk - configure disk",
|
||||||
nullptr
|
nullptr
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
#include "gen.h"
|
#include "gen.h"
|
||||||
|
|
||||||
|
|
||||||
std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *>, std::string> > load_disk_configuration(console *const c);
|
|
||||||
bool save_disk_configuration(const std::string & nbd_host, const int nbd_port, const disk_type_t dt);
|
|
||||||
void set_disk_configuration(bus *const b, console *const cnsl, std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *>, std::string> & disk_files);
|
|
||||||
|
|
||||||
int disassemble(cpu *const c, console *const cnsl, const uint16_t pc, const bool instruction_only);
|
int disassemble(cpu *const c, console *const cnsl, const uint16_t pc, const bool instruction_only);
|
||||||
void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const stop_event, const bool tracing);
|
void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const stop_event, const bool tracing);
|
||||||
|
|
||||||
|
|
16
loaders.cpp
16
loaders.cpp
|
@ -23,14 +23,14 @@ void loadbin(bus *const b, uint16_t base, const char *const file)
|
||||||
FILE *fh = fopen(file, "rb");
|
FILE *fh = fopen(file, "rb");
|
||||||
|
|
||||||
while(!feof(fh))
|
while(!feof(fh))
|
||||||
b -> writeByte(base++, fgetc(fh));
|
b->writeByte(base++, fgetc(fh));
|
||||||
|
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_boot_loader(bus *const b, const bootloader_t which)
|
void set_boot_loader(bus *const b, const bootloader_t which)
|
||||||
{
|
{
|
||||||
cpu *const c = b -> getCpu();
|
cpu *const c = b->getCpu();
|
||||||
|
|
||||||
uint16_t offset = 0;
|
uint16_t offset = 0;
|
||||||
uint16_t start = 0;
|
uint16_t start = 0;
|
||||||
|
@ -139,12 +139,12 @@ void set_boot_loader(bus *const b, const bootloader_t which)
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<size; i++)
|
for(int i=0; i<size; i++)
|
||||||
b -> writeWord(offset + i * 2, bl[i]);
|
b->writeWord(offset + i * 2, bl[i]);
|
||||||
|
|
||||||
c -> setRegister(7, start);
|
c->setRegister(7, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<uint16_t> loadTape(bus *const b, const std::string & file)
|
std::optional<uint16_t> load_tape(bus *const b, const std::string & file)
|
||||||
{
|
{
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
File32 fh;
|
File32 fh;
|
||||||
|
@ -211,7 +211,7 @@ std::optional<uint16_t> loadTape(bus *const b, const std::string & file)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
csum += c;
|
csum += c;
|
||||||
b -> writeByte(p++, c);
|
b->writeByte(p++, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
|
@ -271,6 +271,6 @@ void load_p11_x11(bus *const b, const std::string & file)
|
||||||
|
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
|
|
||||||
cpu *const c = b -> getCpu();
|
cpu *const c = b->getCpu();
|
||||||
c -> setRegister(7, 0);
|
c->setRegister(7, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// (C) 2018-2023 by Folkert van Heusden
|
// (C) 2018-2024 by Folkert van Heusden
|
||||||
// Released under MIT license
|
// Released under MIT license
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -12,5 +12,5 @@ typedef enum { BL_NONE, BL_RK05, BL_RL02 } bootloader_t;
|
||||||
|
|
||||||
void loadbin(bus *const b, uint16_t base, const char *const file);
|
void loadbin(bus *const b, uint16_t base, const char *const file);
|
||||||
void set_boot_loader(bus *const b, const bootloader_t which);
|
void set_boot_loader(bus *const b, const bootloader_t which);
|
||||||
std::optional<uint16_t> loadTape(bus *const b, const std::string & file);
|
std::optional<uint16_t> load_tape(bus *const b, const std::string & file);
|
||||||
void load_p11_x11(bus *const b, const std::string & file);
|
void load_p11_x11(bus *const b, const std::string & file);
|
||||||
|
|
2
main.cpp
2
main.cpp
|
@ -574,7 +574,7 @@ int main(int argc, char *argv[])
|
||||||
std::optional<uint16_t> bic_start;
|
std::optional<uint16_t> bic_start;
|
||||||
|
|
||||||
if (tape.empty() == false) {
|
if (tape.empty() == false) {
|
||||||
bic_start = loadTape(b, tape);
|
bic_start = load_tape(b, tape);
|
||||||
|
|
||||||
if (bic_start.has_value() == false)
|
if (bic_start.has_value() == false)
|
||||||
return 1; // fail
|
return 1; // fail
|
||||||
|
|
Loading…
Add table
Reference in a new issue