POC
This commit is contained in:
parent
c9ed7cfd7b
commit
5184c100d9
5 changed files with 94 additions and 210 deletions
229
ESP32/main.ino
229
ESP32/main.ino
|
@ -9,213 +9,38 @@
|
|||
#include "utils.h"
|
||||
#include "error.h"
|
||||
|
||||
|
||||
bus *b = nullptr;
|
||||
cpu *c = nullptr;
|
||||
tty *tty_ = nullptr;
|
||||
|
||||
uint16_t loadbin(bus *const b)
|
||||
{
|
||||
#define PROGRAM 1
|
||||
|
||||
#if PROGRAM == 1
|
||||
// xxd -i tester <-- raw, not the .bin!
|
||||
constexpr unsigned char tester[] = {
|
||||
0xc6, 0x15, 0x00, 0x02, 0x77, 0x00, 0xb6, 0x05, 0xc0, 0x15, 0xcf, 0x03,
|
||||
0xf7, 0x09, 0xe0, 0x05, 0xc1, 0x15, 0x5d, 0x6b, 0x01, 0x8d, 0xa1, 0x00,
|
||||
0xa2, 0x00, 0xa4, 0x00, 0xa8, 0x00, 0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0x00,
|
||||
0xc2, 0x8b, 0x01, 0x02, 0x87, 0x00, 0x80, 0x10, 0xf7, 0x09, 0xde, 0x05,
|
||||
0xc0, 0x15, 0xa0, 0x03, 0xf7, 0x09, 0xb8, 0x05, 0x87, 0x00, 0xa1, 0x00,
|
||||
0xa2, 0x00, 0xa4, 0x00, 0xa8, 0x00, 0x87, 0x00, 0xf7, 0x09, 0xf2, 0xff,
|
||||
0xc1, 0x15, 0x00, 0x80, 0xc1, 0x8b, 0x04, 0x03, 0xc2, 0x15, 0x01, 0x00,
|
||||
0x77, 0x00, 0x2e, 0x01, 0xf7, 0x09, 0xde, 0xff, 0xc1, 0x15, 0x80, 0x00,
|
||||
0xc1, 0x8b, 0x04, 0x02, 0xc2, 0x15, 0x02, 0x00, 0x77, 0x00, 0x1a, 0x01,
|
||||
0xf7, 0x09, 0xca, 0xff, 0xc1, 0x15, 0x7f, 0x00, 0x81, 0x8a, 0x04, 0x85,
|
||||
0xc2, 0x15, 0x03, 0x00, 0x77, 0x00, 0x06, 0x01, 0xf7, 0x09, 0xb6, 0xff,
|
||||
0xc1, 0x15, 0x80, 0xff, 0xc1, 0x8a, 0x04, 0x85, 0xc2, 0x15, 0x04, 0x00,
|
||||
0x77, 0x00, 0xf2, 0x00, 0xf7, 0x09, 0xa2, 0xff, 0xc1, 0x15, 0x7f, 0x00,
|
||||
0x81, 0x8a, 0x04, 0x81, 0xc2, 0x15, 0x05, 0x00, 0x77, 0x00, 0xde, 0x00,
|
||||
0xf7, 0x09, 0x8e, 0xff, 0xc1, 0x15, 0x80, 0x00, 0xc1, 0x8a, 0x04, 0x80,
|
||||
0xc2, 0x15, 0x06, 0x00, 0x77, 0x00, 0xca, 0x00, 0xf7, 0x09, 0x7a, 0xff,
|
||||
0xc1, 0x15, 0x80, 0x00, 0xc1, 0x8c, 0x04, 0x87, 0xc2, 0x15, 0x07, 0x00,
|
||||
0x77, 0x00, 0xb6, 0x00, 0xf7, 0x09, 0x66, 0xff, 0xc1, 0x15, 0x40, 0x00,
|
||||
0xc1, 0x8c, 0x04, 0x86, 0xc2, 0x15, 0x08, 0x00, 0x77, 0x00, 0xa2, 0x00,
|
||||
0xf7, 0x09, 0x52, 0xff, 0xc1, 0x15, 0x00, 0x00, 0xc1, 0x0b, 0x04, 0x03,
|
||||
0xc2, 0x15, 0x09, 0x00, 0x77, 0x00, 0x8e, 0x00, 0xf7, 0x09, 0x3e, 0xff,
|
||||
0xc1, 0x15, 0x00, 0x80, 0xc1, 0x0b, 0x04, 0x02, 0xc2, 0x15, 0x0a, 0x00,
|
||||
0x77, 0x00, 0x7a, 0x00, 0xf7, 0x09, 0x2a, 0xff, 0xc1, 0x15, 0xff, 0x7f,
|
||||
0x81, 0x0a, 0x04, 0x85, 0xc2, 0x15, 0x0b, 0x00, 0x77, 0x00, 0x66, 0x00,
|
||||
0xf7, 0x09, 0x16, 0xff, 0xc1, 0x15, 0x00, 0x80, 0xc1, 0x0a, 0x04, 0x85,
|
||||
0xc2, 0x15, 0x0c, 0x00, 0x77, 0x00, 0x52, 0x00, 0xf7, 0x09, 0x02, 0xff,
|
||||
0xc1, 0x15, 0xff, 0x7f, 0x81, 0x0a, 0x04, 0x81, 0xc2, 0x15, 0x0d, 0x00,
|
||||
0x77, 0x00, 0x3e, 0x00, 0xf7, 0x09, 0xee, 0xfe, 0xc1, 0x15, 0x00, 0x80,
|
||||
0xc1, 0x0a, 0x04, 0x80, 0xc2, 0x15, 0x0e, 0x00, 0x77, 0x00, 0x2a, 0x00,
|
||||
0xf7, 0x09, 0xda, 0xfe, 0xc1, 0x15, 0x00, 0x80, 0xc1, 0x0c, 0x04, 0x87,
|
||||
0xc2, 0x15, 0x0f, 0x00, 0x77, 0x00, 0x16, 0x00, 0xf7, 0x09, 0xc6, 0xfe,
|
||||
0xc1, 0x15, 0x00, 0x40, 0xc1, 0x0c, 0x04, 0x86, 0xc2, 0x15, 0x10, 0x00,
|
||||
0x77, 0x00, 0x02, 0x00, 0x87, 0x00, 0xf7, 0x09, 0xb0, 0xfe, 0x80, 0x10,
|
||||
0xf7, 0x09, 0x7e, 0x04, 0xc0, 0x8d, 0xf7, 0x09, 0x78, 0x04, 0xc0, 0x15,
|
||||
0xbc, 0x03, 0xf7, 0x09, 0x52, 0x04, 0x87, 0x00, 0x4d, 0x46, 0x50, 0x53,
|
||||
0x20, 0x2f, 0x20, 0x4d, 0x54, 0x50, 0x53, 0x20, 0x68, 0x61, 0x6e, 0x64,
|
||||
0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00,
|
||||
0x50, 0x53, 0x57, 0x20, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x20,
|
||||
0x66, 0x61, 0x69, 0x6c, 0x0d, 0x0a, 0x00, 0x50, 0x53, 0x57, 0x20, 0x68,
|
||||
0x61, 0x6e, 0x64, 0x6c, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x65, 0x73, 0x74,
|
||||
0x0d, 0x0a, 0x00, 0x00, 0xc0, 0x15, 0xb4, 0x04, 0xf7, 0x09, 0x04, 0x04,
|
||||
0xc0, 0x15, 0x01, 0x80, 0xc1, 0x15, 0x01, 0x01, 0xc0, 0x65, 0xeb, 0x03,
|
||||
0x40, 0x0b, 0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0xff, 0x80, 0x60, 0xc1, 0x0a,
|
||||
0xc1, 0x0b, 0xf6, 0x02, 0xc0, 0x25, 0xf0, 0x72, 0x12, 0x02, 0xc0, 0x15,
|
||||
0x01, 0x80, 0xc1, 0x15, 0x01, 0x01, 0xc0, 0x65, 0x0d, 0x00, 0x40, 0x8b,
|
||||
0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0xff, 0x80, 0x60, 0xc1, 0x0a, 0xc1, 0x0b,
|
||||
0xf6, 0x02, 0xc0, 0x25, 0x0e, 0x90, 0x01, 0x02, 0x87, 0x00, 0xc0, 0x15,
|
||||
0x3c, 0x04, 0xf7, 0x09, 0xb6, 0x03, 0x87, 0x00, 0x41, 0x44, 0x43, 0x20,
|
||||
0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x41, 0x49,
|
||||
0x4c, 0x0d, 0x0a, 0x00, 0xc0, 0x15, 0x01, 0x80, 0xc1, 0x15, 0x01, 0x01,
|
||||
0xc0, 0xe5, 0xeb, 0x03, 0x80, 0x0b, 0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0xff,
|
||||
0x80, 0xe0, 0xc1, 0x0a, 0xc1, 0x0b, 0xf6, 0x02, 0xc0, 0x25, 0x0a, 0x8d,
|
||||
0x12, 0x02, 0xc0, 0x15, 0x01, 0x80, 0xc1, 0x15, 0x01, 0x01, 0xc0, 0xe5,
|
||||
0x0d, 0x00, 0x80, 0x8b, 0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0xff, 0x80, 0xe0,
|
||||
0xc1, 0x0a, 0xc1, 0x0b, 0xf6, 0x02, 0xc0, 0x25, 0xec, 0x6f, 0x01, 0x02,
|
||||
0x87, 0x00, 0xc0, 0x15, 0xa0, 0x04, 0xf7, 0x09, 0x52, 0x03, 0x87, 0x00,
|
||||
0x53, 0x42, 0x43, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69, 0x6e, 0x67,
|
||||
0x20, 0x46, 0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00, 0x41, 0x44, 0x43, 0x2f,
|
||||
0x53, 0x42, 0x43, 0x20, 0x74, 0x65, 0x73, 0x74, 0x0d, 0x0a, 0x00, 0x00,
|
||||
0xc0, 0x15, 0x3d, 0x06, 0xf7, 0x09, 0x24, 0x03, 0xc0, 0x15, 0x55, 0xaa,
|
||||
0xc0, 0x25, 0x55, 0xaa, 0x04, 0x03, 0xc0, 0x15, 0x01, 0x00, 0x77, 0x00,
|
||||
0x36, 0x01, 0xc0, 0x95, 0xf0, 0x00, 0xc0, 0x25, 0xf0, 0xff, 0x04, 0x03,
|
||||
0xc0, 0x15, 0x02, 0x00, 0x77, 0x00, 0x24, 0x01, 0xc0, 0x95, 0x7f, 0x00,
|
||||
0xc0, 0x25, 0x7f, 0x00, 0x04, 0x03, 0xc0, 0x15, 0x03, 0x00, 0x77, 0x00,
|
||||
0x12, 0x01, 0xc0, 0x15, 0x52, 0x06, 0x01, 0x12, 0xc1, 0x25, 0xd2, 0x04,
|
||||
0x04, 0x03, 0xc0, 0x15, 0x04, 0x00, 0x77, 0x00, 0xfe, 0x00, 0xc0, 0x15,
|
||||
0x52, 0x06, 0x01, 0x92, 0xc1, 0x25, 0xd2, 0xff, 0x04, 0x03, 0xc0, 0x15,
|
||||
0x05, 0x00, 0x77, 0x00, 0xea, 0x00, 0xc0, 0x15, 0x52, 0x06, 0x01, 0x92,
|
||||
0xc1, 0x25, 0xd2, 0x04, 0x04, 0x02, 0xc0, 0x15, 0x06, 0x00, 0x77, 0x00,
|
||||
0xd6, 0x00, 0xc0, 0x15, 0x52, 0x06, 0x01, 0x14, 0xc1, 0x25, 0xd2, 0x04,
|
||||
0x04, 0x03, 0xc0, 0x15, 0x07, 0x00, 0x77, 0x00, 0xc2, 0x00, 0xc2, 0x15,
|
||||
0x54, 0x06, 0x02, 0x20, 0x04, 0x03, 0xc0, 0x15, 0x08, 0x00, 0x77, 0x00,
|
||||
0xb2, 0x00, 0xc0, 0x15, 0x52, 0x06, 0x01, 0x94, 0xc1, 0xa5, 0xd2, 0x00,
|
||||
0x04, 0x03, 0xc0, 0x15, 0x09, 0x00, 0x77, 0x00, 0x9e, 0x00, 0xc0, 0x15,
|
||||
0x52, 0x06, 0x00, 0x14, 0xc0, 0x25, 0xd2, 0x04, 0x04, 0x03, 0xc0, 0x15,
|
||||
0x0a, 0x00, 0x77, 0x00, 0x8a, 0x00, 0xc0, 0x1d, 0xc8, 0x00, 0xc8, 0x25,
|
||||
0xd2, 0x04, 0x04, 0x03, 0xc0, 0x15, 0x0c, 0x00, 0x77, 0x00, 0x78, 0x00,
|
||||
0x01, 0x16, 0xc2, 0x15, 0x54, 0x06, 0x02, 0x20, 0x04, 0x03, 0xc0, 0x15,
|
||||
0x0d, 0x00, 0x77, 0x00, 0x66, 0x00, 0xc0, 0x15, 0x52, 0x06, 0x01, 0x18,
|
||||
0xc1, 0x25, 0x67, 0x11, 0x04, 0x03, 0xc0, 0x15, 0x0e, 0x00, 0x77, 0x00,
|
||||
0x52, 0x00, 0xc2, 0x15, 0x50, 0x06, 0x02, 0x20, 0x04, 0x03, 0xc0, 0x15,
|
||||
0x0f, 0x00, 0x77, 0x00, 0x42, 0x00, 0xc0, 0x15, 0x52, 0x06, 0x01, 0x98,
|
||||
0xc1, 0xa5, 0x11, 0x00, 0x04, 0x03, 0xc0, 0x15, 0x10, 0x00, 0x77, 0x00,
|
||||
0x2e, 0x00, 0xc0, 0x15, 0x52, 0x06, 0x01, 0x1c, 0x02, 0x00, 0xc1, 0x25,
|
||||
0xe1, 0x10, 0x04, 0x03, 0xc0, 0x15, 0x11, 0x00, 0x77, 0x00, 0x18, 0x00,
|
||||
0xc0, 0x15, 0x56, 0x06, 0x01, 0x1e, 0x02, 0x00, 0xc1, 0x25, 0xe1, 0x10,
|
||||
0x04, 0x03, 0xc0, 0x15, 0x12, 0x00, 0x77, 0x00, 0x02, 0x00, 0x87, 0x00,
|
||||
0xf7, 0x09, 0xf6, 0x01, 0xc0, 0x15, 0x22, 0x06, 0xf7, 0x09, 0xd0, 0x01,
|
||||
0x87, 0x00, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6e, 0x67,
|
||||
0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x41,
|
||||
0x49, 0x4c, 0x0d, 0x0a, 0x00, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
|
||||
0x69, 0x6e, 0x67, 0x20, 0x74, 0x65, 0x73, 0x74, 0x73, 0x0d, 0x0a, 0x00,
|
||||
0x67, 0x11, 0xd2, 0x04, 0xe1, 0x10, 0x52, 0x06, 0x54, 0x06, 0xf7, 0x09,
|
||||
0x66, 0xfe, 0x87, 0x00, 0xc0, 0x15, 0xce, 0x06, 0xf7, 0x09, 0x88, 0x01,
|
||||
0xc0, 0x15, 0x03, 0x00, 0x00, 0x8d, 0xc0, 0x15, 0x00, 0x00, 0xc1, 0x8d,
|
||||
0xc1, 0x45, 0xf0, 0xff, 0xc1, 0x25, 0x05, 0x00, 0x04, 0x03, 0xc0, 0x15,
|
||||
0x01, 0x00, 0x77, 0x00, 0x20, 0x00, 0xc0, 0x15, 0x00, 0x00, 0x00, 0x8d,
|
||||
0xc0, 0x15, 0x00, 0x80, 0xc1, 0x8d, 0xc1, 0x45, 0xf0, 0xff, 0xc1, 0xa5,
|
||||
0x08, 0x00, 0x04, 0x03, 0xc0, 0x15, 0x02, 0x00, 0x77, 0x00, 0x02, 0x00,
|
||||
0x87, 0x00, 0xf7, 0x09, 0x64, 0x01, 0x40, 0x10, 0xf7, 0x09, 0x5e, 0x01,
|
||||
0xc0, 0x15, 0xba, 0x06, 0xf7, 0x09, 0x38, 0x01, 0x87, 0x00, 0x4d, 0x4f,
|
||||
0x56, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46,
|
||||
0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00, 0x4d, 0x4f, 0x56, 0x20, 0x66, 0x6c,
|
||||
0x61, 0x67, 0x20, 0x74, 0x65, 0x73, 0x74, 0x0d, 0x0a, 0x00, 0xc0, 0x15,
|
||||
0x50, 0x07, 0xf7, 0x09, 0x0a, 0x01, 0xc0, 0x15, 0x0f, 0x00, 0x00, 0x8d,
|
||||
0xc1, 0x15, 0x00, 0x00, 0xc1, 0x0b, 0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0xff,
|
||||
0xc2, 0x25, 0x04, 0x00, 0x04, 0x03, 0xc0, 0x15, 0x01, 0x00, 0x77, 0x00,
|
||||
0x22, 0x00, 0xc0, 0x15, 0x0f, 0x00, 0x00, 0x8d, 0xc1, 0x15, 0x00, 0x80,
|
||||
0xc1, 0x0b, 0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0xff, 0xc2, 0x25, 0x08, 0x00,
|
||||
0x04, 0x03, 0xc0, 0x15, 0x02, 0x00, 0x77, 0x00, 0x02, 0x00, 0x87, 0x00,
|
||||
0xf7, 0x09, 0xe2, 0x00, 0x80, 0x10, 0xf7, 0x09, 0xdc, 0x00, 0xc0, 0x15,
|
||||
0x3c, 0x07, 0xf7, 0x09, 0xb6, 0x00, 0x87, 0x00, 0x54, 0x53, 0x54, 0x20,
|
||||
0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x41, 0x49,
|
||||
0x4c, 0x0d, 0x0a, 0x00, 0x54, 0x53, 0x54, 0x20, 0x74, 0x65, 0x73, 0x74,
|
||||
0x0d, 0x0a, 0x00, 0x00, 0xc0, 0x15, 0xb2, 0x07, 0xf7, 0x09, 0x8c, 0x00,
|
||||
0xc0, 0x15, 0x08, 0x00, 0x00, 0x8d, 0x02, 0x04, 0x77, 0x00, 0x08, 0x00,
|
||||
0xc0, 0x15, 0x01, 0x00, 0x77, 0x00, 0x12, 0x00, 0xc0, 0x15, 0x0a, 0x00,
|
||||
0x00, 0x8d, 0x04, 0x04, 0xc0, 0x15, 0x02, 0x00, 0x77, 0x00, 0x02, 0x00,
|
||||
0x87, 0x00, 0xf7, 0x09, 0x80, 0x00, 0x80, 0x10, 0xf7, 0x09, 0x7a, 0x00,
|
||||
0xc0, 0x15, 0x9e, 0x07, 0xf7, 0x09, 0x54, 0x00, 0x87, 0x00, 0x42, 0x47,
|
||||
0x45, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46,
|
||||
0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00, 0x42, 0x47, 0x45, 0x20, 0x74, 0x65,
|
||||
0x73, 0x74, 0x0d, 0x0a, 0x00, 0x00, 0xc0, 0x15, 0x5e, 0x08, 0xf7, 0x09,
|
||||
0x2a, 0x00, 0xf7, 0x09, 0x3e, 0xfa, 0xf7, 0x09, 0x76, 0xfa, 0xf7, 0x09,
|
||||
0x12, 0xfc, 0xf7, 0x09, 0x7a, 0xfc, 0xf7, 0x09, 0x80, 0xfe, 0xf7, 0x09,
|
||||
0x82, 0xfe, 0xf7, 0x09, 0xfc, 0xfe, 0xf7, 0x09, 0x76, 0xff, 0xc0, 0x15,
|
||||
0x72, 0x08, 0xf7, 0x09, 0x02, 0x00, 0x07, 0x89, 0x26, 0x10, 0xe6, 0x8d,
|
||||
0xc8, 0x8b, 0x08, 0x03, 0x1f, 0x92, 0x76, 0xff, 0xdf, 0x8b, 0x74, 0xff,
|
||||
0xfd, 0x80, 0x80, 0x0a, 0x77, 0x00, 0xec, 0xff, 0x16, 0x8d, 0x80, 0x15,
|
||||
0x87, 0x00, 0xe6, 0x8d, 0x26, 0x10, 0x66, 0x10, 0xc1, 0x15, 0x10, 0x00,
|
||||
0xc0, 0x0c, 0x07, 0x87, 0xdf, 0x8b, 0x74, 0xff, 0xfd, 0x80, 0xdf, 0x95,
|
||||
0x30, 0x00, 0x76, 0xff, 0x07, 0x01, 0xdf, 0x8b, 0x74, 0xff, 0xfd, 0x80,
|
||||
0xdf, 0x95, 0x31, 0x00, 0x76, 0xff, 0x00, 0x01, 0xc1, 0x0a, 0xc1, 0x0b,
|
||||
0xed, 0x02, 0xdf, 0x8b, 0x74, 0xff, 0xfd, 0x80, 0xdf, 0x95, 0x20, 0x00,
|
||||
0x76, 0xff, 0xdf, 0x8b, 0x74, 0xff, 0xfd, 0x80, 0xdf, 0x95, 0x20, 0x00,
|
||||
0x76, 0xff, 0x81, 0x15, 0x80, 0x15, 0x16, 0x8d, 0x87, 0x00, 0x74, 0x65,
|
||||
0x73, 0x74, 0x65, 0x72, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67,
|
||||
0x2e, 0x2e, 0x2e, 0x0d, 0x0a, 0x00, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72,
|
||||
0x20, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x0d, 0x0a, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
constexpr unsigned int tester_len = 1924;
|
||||
|
||||
uint16_t base = 512;
|
||||
uint16_t exec = 512;
|
||||
const unsigned char *code = tester;
|
||||
unsigned int code_len = tester_len;
|
||||
#endif
|
||||
|
||||
#if PROGRAM == 2
|
||||
constexpr unsigned char test2[] = {
|
||||
0xc6, 0x15, 0x00, 0x02, 0xc0, 0x15, 0x24, 0x02, 0xdf, 0x09, 0x0e, 0x02,
|
||||
0x07, 0x89, 0x66, 0x10, 0x05, 0x01, 0xdf, 0x8b, 0x74, 0xff, 0xfd, 0x03,
|
||||
0x5f, 0x90, 0x76, 0xff, 0x01, 0x94, 0xf9, 0x02, 0x81, 0x15, 0x87, 0x00,
|
||||
0x74, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x20, 0x62, 0x72,
|
||||
0x6f, 0x77, 0x6e, 0x20, 0x2e, 0x2e, 0x2e, 0x00
|
||||
};
|
||||
constexpr unsigned int test2_len = 56;
|
||||
|
||||
uint16_t base = 512;
|
||||
uint16_t exec = 512;
|
||||
const unsigned char *code = test2;
|
||||
unsigned int code_len = test2_len;
|
||||
#endif
|
||||
|
||||
for(int i=0; i<code_len; i++)
|
||||
b -> writeByte(base++, code[i]);
|
||||
|
||||
return exec;
|
||||
}
|
||||
|
||||
uint16_t exec_addr = 0;
|
||||
|
||||
uint32_t start_ts = 0;
|
||||
|
||||
void setBootLoader(bus *const b)
|
||||
{
|
||||
cpu *const c = b->getCpu();
|
||||
|
||||
const uint16_t offset = 01000;
|
||||
|
||||
constexpr uint16_t bootrom[] = {
|
||||
0012700,
|
||||
0177406,
|
||||
0012710,
|
||||
0177400,
|
||||
0012740,
|
||||
0000005,
|
||||
0105710,
|
||||
0100376,
|
||||
0005007
|
||||
};
|
||||
|
||||
for(size_t i=0; i<sizeof bootrom / 2; i++)
|
||||
b->writeWord(offset + i * 2, bootrom[i]);
|
||||
|
||||
c->setRegister(7, offset);
|
||||
}
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
|
@ -246,9 +71,9 @@ void setup() {
|
|||
Serial.println(F("Connect TTY to bus"));
|
||||
b->add_tty(tty_);
|
||||
|
||||
Serial.println(F("Load program"));
|
||||
exec_addr = loadbin(b);
|
||||
c->setRegister(7, exec_addr);
|
||||
Serial.println(F("Load RK05"));
|
||||
b->add_rk05(new rk05("xxdp+.rk", b));
|
||||
setBootLoader(b);
|
||||
|
||||
Serial.print(F("Free RAM after init: "));
|
||||
Serial.println(ESP.getFreeHeap());
|
||||
|
|
|
@ -14,6 +14,6 @@ board = wemos_d1_mini32
|
|||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
upload_speed = 1000000
|
||||
lib_deps =
|
||||
build_flags = -std=c++17 -Ofast
|
||||
lib_deps = greiman/SdFat@^2.1.2
|
||||
build_flags = -std=c++14 -Ofast -DESP32=1
|
||||
build_unflags = -std=gnu++11 -Os
|
||||
|
|
53
rk05.cpp
53
rk05.cpp
|
@ -9,6 +9,7 @@
|
|||
#include "rk05.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
const char * const regnames[] = {
|
||||
"RK05_DS drivestatus",
|
||||
"RK05_ERROR ",
|
||||
|
@ -24,14 +25,38 @@ rk05::rk05(const std::string & file, bus *const b) : b(b)
|
|||
memset(registers, 0x00, sizeof registers);
|
||||
memset(xfer_buffer, 0x00, sizeof xfer_buffer);
|
||||
|
||||
#if defined(ESP32)
|
||||
Serial.print(F("MISO: "));
|
||||
Serial.println(int(MISO));
|
||||
Serial.print(F("MOSI: "));
|
||||
Serial.println(int(MOSI));
|
||||
Serial.print(F("SCK : "));
|
||||
Serial.println(int(SCK));
|
||||
Serial.print(F("SS : "));
|
||||
Serial.println(int(SS));
|
||||
|
||||
if (!sd.begin(SS, SD_SCK_MHZ(15)))
|
||||
sd.initErrorHalt();
|
||||
|
||||
Serial.print(F("Opening: "));
|
||||
Serial.println(file.c_str());
|
||||
|
||||
if (!fh.open(file.c_str(), O_RDWR))
|
||||
sd.errorHalt(F("rk05: open failed"));
|
||||
#else
|
||||
fh = fopen(file.c_str(), "rb");
|
||||
if (!fh)
|
||||
error_exit(true, "rk05: cannot open \"%s\"", file.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
rk05::~rk05()
|
||||
{
|
||||
#if defined(ESP32)
|
||||
fh.close();
|
||||
#else
|
||||
fclose(fh);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t rk05::readByte(const uint16_t addr)
|
||||
|
@ -124,10 +149,19 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
|
|||
for(size_t i=0; i<reclen; i++)
|
||||
xfer_buffer[i] = b -> readByte(memoff + i);
|
||||
|
||||
#if defined(ESP32)
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
if (!fh.seek(diskoffb))
|
||||
fprintf(stderr, "RK05 seek error %s\n", strerror(errno));
|
||||
if (fh.write(xfer_buffer, reclen) != reclen)
|
||||
fprintf(stderr, "RK05 fwrite error %s\n", strerror(errno));
|
||||
#else
|
||||
if (fseek(fh, diskoffb, SEEK_SET) == -1)
|
||||
fprintf(stderr, "RK05 seek error %s\n", strerror(errno));
|
||||
if (fwrite(xfer_buffer, 1, reclen, fh) != reclen)
|
||||
fprintf(stderr, "RK05 fwrite error %s\n", strerror(errno));
|
||||
#endif
|
||||
|
||||
if (v & 2048)
|
||||
fprintf(stderr, "RK05 inhibit BA increase\n");
|
||||
|
@ -143,20 +177,35 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
|
|||
}
|
||||
|
||||
registers[(RK05_DA - RK05_BASE) / 2] = sector | (surface << 4) | (cylinder << 5);
|
||||
|
||||
#if defined(ESP32)
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
#endif
|
||||
}
|
||||
else if (func == 2) { // read
|
||||
fprintf(stderr, "RK05 reading %zo bytes from offset %o (%d dec) to %o\n", reclen, diskoffb, diskoffb, memoff);
|
||||
|
||||
#if defined(ESP32)
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
if (!fh.seek(diskoffb))
|
||||
fprintf(stderr, "RK05 seek error %s\n", strerror(errno));
|
||||
#else
|
||||
if (fseek(fh, diskoffb, SEEK_SET) == -1)
|
||||
fprintf(stderr, "RK05 seek error %s\n", strerror(errno));
|
||||
#endif
|
||||
|
||||
uint32_t temp = reclen;
|
||||
uint32_t p = memoff;
|
||||
while(temp > 0) {
|
||||
uint32_t cur = std::min(uint32_t(sizeof xfer_buffer), temp);
|
||||
|
||||
#if defined(ESP32)
|
||||
if (fh.read(xfer_buffer, cur) != size_t(cur))
|
||||
D(fprintf(stderr, "RK05 fread error: %s\n", strerror(errno));)
|
||||
#else
|
||||
if (fread(xfer_buffer, 1, cur, fh) != size_t(cur))
|
||||
D(fprintf(stderr, "RK05 fread error: %s\n", strerror(errno));)
|
||||
#endif
|
||||
|
||||
for(uint32_t i=0; i<cur; i++) {
|
||||
if (p < 0160000)
|
||||
|
@ -179,7 +228,11 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
|
|||
cylinder++;
|
||||
}
|
||||
}
|
||||
|
||||
registers[(RK05_DA - RK05_BASE) / 2] = sector | (surface << 4) | (cylinder << 5);
|
||||
#if defined(ESP32)
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
#endif
|
||||
}
|
||||
else if (func == 4) {
|
||||
fprintf(stderr, "RK05 seek to offset %o\n", diskoffb);
|
||||
|
|
12
rk05.h
12
rk05.h
|
@ -6,6 +6,13 @@
|
|||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#if defined(ESP32)
|
||||
#include <SPI.h>
|
||||
#define USE_SDFAT
|
||||
#define SD_FAT_TYPE 1
|
||||
#include <SdFat.h>
|
||||
#endif
|
||||
|
||||
// FIXME namen van defines
|
||||
#define RK05_DS 0177400 // drive status
|
||||
#define RK05_ERROR 0177402 // error
|
||||
|
@ -25,7 +32,12 @@ private:
|
|||
bus *const b;
|
||||
uint16_t registers[7];
|
||||
uint8_t xfer_buffer[512];
|
||||
#if defined(ESP32)
|
||||
SdFat32 sd;
|
||||
File32 fh;
|
||||
#else
|
||||
FILE *fh;
|
||||
#endif
|
||||
|
||||
public:
|
||||
rk05(const std::string & file, bus *const b);
|
||||
|
|
6
tty.cpp
6
tty.cpp
|
@ -52,12 +52,6 @@ uint16_t tty::readWord(const uint16_t addr)
|
|||
|
||||
if (addr == PDP11TTY_TKS) {
|
||||
vtemp = c ? 128 : 0;
|
||||
|
||||
#if defined(ESP32)
|
||||
static bool led_state = true;
|
||||
digitalWrite(LED_BUILTIN, led_state);
|
||||
led_state = !led_state;
|
||||
#endif
|
||||
}
|
||||
else if (addr == PDP11TTY_TKB) {
|
||||
vtemp = c | (parity(c) << 7);
|
||||
|
|
Loading…
Add table
Reference in a new issue