summaryrefslogtreecommitdiff
path: root/arch/null/arch.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/null/arch.c')
-rw-r--r--arch/null/arch.c164
1 files changed, 164 insertions, 0 deletions
diff --git a/arch/null/arch.c b/arch/null/arch.c
new file mode 100644
index 0000000..9faf40d
--- /dev/null
+++ b/arch/null/arch.c
@@ -0,0 +1,164 @@
+// file : arch/null/arch.c
+// project : Salis-VM
+// author : Paul Oliver <contact@pauloliver.dev>
+
+// index:
+// [section] includes
+// [section] getters
+// [section] callbacks
+// [section] validation
+// [section] data
+// [section] main
+
+// ----------------------------------------------------------------------------
+// [section] includes
+// ----------------------------------------------------------------------------
+#include <assert.h>
+#include <sqlite3.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <threads.h>
+#include <zlib.h>
+
+#include "arch.h"
+#include "arch_spec.h"
+#include "compress.h"
+#include "logger.h"
+#include "salis.h"
+#include "sql.h"
+
+// ----------------------------------------------------------------------------
+// [section] getters
+// ----------------------------------------------------------------------------
+uint64_t arch_proc_get_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_get_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_get_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_get_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_get_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_get_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_get_slice(const struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+ (void)core;
+ (void)pix;
+ return 1;
+}
+
+// ----------------------------------------------------------------------------
+// [section] callbacks
+// ----------------------------------------------------------------------------
+void arch_on_proc_step(struct Core *core, uint64_t pix) {
+ assert(core);
+ assert(mvec_proc_is_live(core, pix));
+ (void)core;
+ (void)pix;
+ return;
+}
+
+void arch_on_proc_kill(struct Core *core) {
+ assert(core);
+ assert(core->pnum > 1);
+ (void)core;
+}
+
+// ----------------------------------------------------------------------------
+// [section] validation
+// ----------------------------------------------------------------------------
+#if !defined(NDEBUG)
+void arch_validate_core(struct Core *core) {
+ assert(core);
+ (void)core;
+}
+#endif
+
+// ----------------------------------------------------------------------------
+// [section] data
+// ----------------------------------------------------------------------------
+void arch_push_data_header(void) {
+ log_info("Creating arch table in SQLite database");
+ sql_exec(NULL, NULL, "create table arch (step int not null);");
+}
+
+void arch_prepare_data_line(void) {
+ log_info("Preparing arch data-line");
+ sql_exec(NULL, NULL, "insert into arch (step) values (%ld);", g_step);
+}
+
+void arch_push_data_line(FILE *eva_file) {
+ assert(eva_file);
+ (void)eva_file;
+ log_info("Pushing row to arch table in SQLite database");
+ sql_exec(NULL, NULL, "insert into arch (step) values (%ld);", g_step);
+}
+
+// ----------------------------------------------------------------------------
+// [section] main
+// ----------------------------------------------------------------------------
+void arch_core_init(struct Core *core) {
+ assert(core);
+
+#if defined(ARCH_SPEC_MVEC_LOOP)
+ uint64_t addr = SALIS_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;
+ }
+}
+
+void arch_core_free(struct Core *core) {
+ assert(core);
+ (void)core;
+}
+
+void arch_core_load(struct Core *core, FILE *f) {
+ assert(core);
+ assert(f);
+ (void)core;
+ (void)f;
+}
+
+void arch_core_save(const struct Core *core, FILE *f) {
+ assert(core);
+ assert(f);
+ (void)core;
+ (void)f;
+}