aboutsummaryrefslogtreecommitdiff
path: root/arch/null/arch.c
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2026-06-28 02:58:56 +0200
committerPaul Oliver <contact@pauloliver.dev>2026-06-28 02:58:56 +0200
commite422518afc868a1ad783c4208ea3a44f89f07687 (patch)
tree6428db20ef7a646443138bbcd1cc85d202cf8c46 /arch/null/arch.c
parent95fd6ae836ab5fee7387f4df46b727165a05b723 (diff)
Renames dummy VM architecture
Diffstat (limited to 'arch/null/arch.c')
-rw-r--r--arch/null/arch.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/arch/null/arch.c b/arch/null/arch.c
new file mode 100644
index 0000000..1fcfbc3
--- /dev/null
+++ b/arch/null/arch.c
@@ -0,0 +1,159 @@
+#if defined(COMMAND_NEW)
+void arch_core_init(struct Core *core) {
+ assert(core);
+
+#if defined(MVEC_LOOP)
+ uint64_t addr = UINT64_HALF;
+#else
+ uint64_t addr = 0;
+#endif
+
+ for (uint64_t i = 0; i < CLONES; ++i) {
+ uint64_t addr_clone = addr + (MVEC_SIZE / CLONES) * i;
+
+ struct Proc *panc = proc_fetch(core, i);
+
+ panc->mb0a = addr_clone;
+ panc->mb0s = ANC_SIZE;
+ panc->ip = addr_clone;
+ panc->sp = addr_clone;
+ }
+}
+#endif
+
+void arch_core_free(struct Core *core) {
+ assert(core);
+
+ (void)core;
+}
+
+#if defined(COMMAND_NEW) || defined(COMMAND_LOAD)
+void arch_core_save(FILE *f, const struct Core *core) {
+ assert(f);
+ assert(core);
+
+ (void)f;
+ (void)core;
+}
+#endif
+
+#if defined(COMMAND_LOAD)
+void arch_core_load(FILE *f, struct Core *core) {
+ assert(f);
+ assert(core);
+
+ (void)f;
+ (void)core;
+}
+#endif
+
+uint64_t arch_proc_mb0_addr(const struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+ return proc_get(core, pix)->mb0a;
+}
+
+uint64_t arch_proc_mb0_size(const struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+ return proc_get(core, pix)->mb0s;
+}
+
+uint64_t arch_proc_mb1_addr(const struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+ return proc_get(core, pix)->mb1a;
+}
+
+uint64_t arch_proc_mb1_size(const struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+ return proc_get(core, pix)->mb1s;
+}
+
+uint64_t arch_proc_ip_addr(const struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+ return proc_get(core, pix)->ip;
+}
+
+uint64_t arch_proc_sp_addr(const struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+ return proc_get(core, pix)->sp;
+}
+
+uint64_t arch_proc_slice(const struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+
+ (void)core;
+ (void)pix;
+
+ return 1;
+}
+
+void arch_on_proc_kill(struct Core *core) {
+ assert(core);
+ assert(core->pnum > 1);
+
+ (void)core;
+}
+
+void arch_proc_step(struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+
+ (void)core;
+ (void)pix;
+
+ return;
+}
+
+#if !defined(NDEBUG)
+void arch_validate_proc(const struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+
+ (void)core;
+ (void)pix;
+
+ assert(true);
+}
+#endif
+
+wchar_t arch_symbol(uint8_t inst) {
+ switch (inst) {
+#define INST(core, pref, index, label, mnemonic, symbol) case index: return symbol;
+ INST_SET(core, pref)
+#undef INST
+ }
+
+ assert(false);
+ return L'\0';
+}
+
+const char *arch_mnemonic(uint8_t inst) {
+ switch (inst) {
+#define INST(core, pref, index, label, mnemonic, symbol) case index: return mnemonic;
+ INST_SET(core, pref)
+#undef INST
+ }
+
+ assert(false);
+ return NULL;
+}
+
+#if defined(COMMAND_NEW)
+void arch_push_data_header(void) {
+ assert(g_sim_db);
+ log_info("Creating arch table in SQLite database");
+ sql_exec(0, NULL, NULL, NULL, NULL, "create table arch (step int not null);");
+}
+#endif
+
+void arch_push_data_line(void) {
+ assert(g_sim_db);
+ log_info("Pushing row to arch table in SQLite database");
+ sql_exec(0, NULL, NULL, NULL, NULL, "insert into arch (step) values (%ld);", g_steps);
+}