Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed May 16, 2024
1 parent b2190b9 commit f2ac06b
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 25 deletions.
24 changes: 19 additions & 5 deletions bus.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// (C) 2018-2024 by Folkert van Heusden
// Released under MIT license

#include "gen.h"
#include <ArduinoJson.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>

#include "bus.h"
#include "gen.h"
#include "cpu.h"
#include "dc11.h"
#include "kw11-l.h"
Expand Down Expand Up @@ -45,34 +45,48 @@ bus::~bus()
delete dc11_;
}

JsonVariant bus::serialize() const
void dump(JsonVariantConst j)
{
std::string temp;
printf("%zu\n", serializeJson(j, temp));

printf("%s\r\n", temp.c_str());
}

JsonDocument bus::serialize() const
{
JsonVariant j_out;
JsonDocument doc;
JsonVariant j_out = doc.to<JsonVariant>();

if (m)
j_out["memory"] = m->serialize();

if (kw11_l_)
j_out["kw11-l"] = kw11_l_->serialize();
dump(kw11_l_->serialize());

if (tty_)
j_out["tty"] = tty_->serialize();
dump(tty_->serialize());

if (mmu_)
j_out["mmu"] = mmu_->serialize();
dump(mmu_->serialize());

if (c)
j_out["cpu"] = c->serialize();
c->serialize(j_out["cpu"]);

if (rl02_)
j_out["rl02"] = rl02_->serialize();
dump(rl02_->serialize());

if (rk05_)
j_out["rk05"] = rk05_->serialize();
dump(rk05_->serialize());

// TODO: tm11, dc11

return j_out;
return doc;
}

bus *bus::deserialize(const JsonDocument j, console *const cnsl, std::atomic_uint32_t *const event)
Expand Down
4 changes: 2 additions & 2 deletions bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#pragma once

#include "gen.h"
#include <ArduinoJson.h>
#include <assert.h>
#include <mutex>
#include <stdint.h>
#include <stdio.h>

#include "gen.h"
#include "device.h"
#include "dc11.h"
#include "mmu.h"
Expand Down Expand Up @@ -80,7 +80,7 @@ class bus: public device
bus();
~bus();

JsonVariant serialize() const;
JsonDocument serialize() const;
static bus *deserialize(const JsonDocument j, console *const cnsl, std::atomic_uint32_t *const event);

void reset() override;
Expand Down
6 changes: 2 additions & 4 deletions cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2434,9 +2434,9 @@ void cpu::step()
}
}

JsonVariant cpu::serialize()
void cpu::serialize(JsonVariant j_in)
{
JsonVariant j;
JsonVariant j = j_in["cpu"].to<JsonVariant>();

for(int set=0; set<2; set++) {
for(int regnr=0; regnr<6; regnr++)
Expand Down Expand Up @@ -2473,8 +2473,6 @@ JsonVariant cpu::serialize()
j["queued_interrupts"] = j_queued_interrupts;

j["any_queued_interrupts"] = bool(any_queued_interrupts);

return j;
}

cpu *cpu::deserialize(const JsonVariantConst j, bus *const b, std::atomic_uint32_t *const event)
Expand Down
5 changes: 2 additions & 3 deletions cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "gen.h"
#include <ArduinoJson.h>
#include <atomic>
#include <cassert>
Expand All @@ -14,8 +15,6 @@
#include <stdint.h>
#include <vector>

#include "gen.h"


class breakpoint;
class bus;
Expand Down Expand Up @@ -115,7 +114,7 @@ class cpu
explicit cpu(bus *const b, std::atomic_uint32_t *const event);
~cpu();

JsonVariant serialize();
void serialize(JsonVariant j);
static cpu *deserialize(const JsonVariantConst j, bus *const b, std::atomic_uint32_t *const event);

std::optional<std::string> check_breakpoint();
Expand Down
2 changes: 1 addition & 1 deletion debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ struct state_writer {

void serialize_state(console *const cnsl, const bus *const b, const std::string & filename)
{
JsonVariant j = b->serialize();
JsonDocument j = b->serialize();

bool ok = false;

Expand Down
3 changes: 1 addition & 2 deletions disk_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "gen.h"
#include <ArduinoJson.h>
#include <map>
#include <optional>
Expand All @@ -11,8 +12,6 @@
#include <vector>
#include <sys/types.h>

#include "gen.h"


class disk_backend
{
Expand Down
1 change: 1 addition & 0 deletions disk_backend_file.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// (C) 2018-2024 by Folkert van Heusden
// Released under MIT license

#include "gen.h"
#include <ArduinoJson.h>
#include <string>

Expand Down
2 changes: 2 additions & 0 deletions gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#define ARDUINOJSON_DEBUG 1

// #define TURBO

typedef enum { EVENT_NONE = 0, EVENT_HALT, EVENT_INTERRUPT, EVENT_TERMINATE } stop_event_t;
Expand Down
2 changes: 1 addition & 1 deletion kw11-l.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// (C) 2018-2024 by Folkert van Heusden
// Released under MIT license

#include "gen.h"
#include <ArduinoJson.h>
#include <atomic>
#include <thread>

#include "bus.h"
#include "console.h"
#include "device.h"
#include "gen.h"


class kw11_l: public device
Expand Down
4 changes: 2 additions & 2 deletions memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Released under MIT license

#pragma once
#include <ArduinoJson.h>
#include <cstdint>

#include "gen.h"
#include <ArduinoJson.h>
#include <cstdint>


class memory
Expand Down
3 changes: 1 addition & 2 deletions mmu.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#pragma once

#include "gen.h"
#include <ArduinoJson.h>
#include <cstdint>
#include <string>

#include "gen.h"
#include "cpu.h"
#include "device.h"
#include "memory.h"
Expand Down
2 changes: 1 addition & 1 deletion rk05.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "gen.h"
#include <ArduinoJson.h>
#include <atomic>
#include <stdint.h>
Expand All @@ -12,7 +13,6 @@

#include "disk_device.h"
#include "disk_backend.h"
#include "gen.h"


#define RK05_DS 0177400 // drive status
Expand Down
2 changes: 1 addition & 1 deletion rl02.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "gen.h"
#include <ArduinoJson.h>
#include <atomic>
#include <stdint.h>
Expand All @@ -12,7 +13,6 @@

#include "disk_device.h"
#include "disk_backend.h"
#include "gen.h"


#define RL02_CSR 0174400 // control status register
Expand Down
2 changes: 1 addition & 1 deletion tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "gen.h"
#include <ArduinoJson.h>
#include <atomic>
#include <mutex>
Expand All @@ -14,7 +15,6 @@

#include "bus.h"
#include "console.h"
#include "gen.h"


#define PDP11TTY_TKS 0177560 // reader status
Expand Down

0 comments on commit f2ac06b

Please sign in to comment.