diff options
| author | Paul Oliver <contact@pauloliver.dev> | 2026-07-14 17:29:02 +0200 |
|---|---|---|
| committer | Paul Oliver <contact@pauloliver.dev> | 2026-07-30 04:47:22 +0200 |
| commit | f2c34b1d2c18270a0327fb4896fa307fae098770 (patch) | |
| tree | af3b7fb569d6b0a702a5a6e3b3bf8773513d21f1 /arch/null | |
Initial
Diffstat (limited to 'arch/null')
| -rw-r--r-- | arch/null/arch.c | 164 | ||||
| -rw-r--r-- | arch/null/arch_inst.c | 67 | ||||
| -rw-r--r-- | arch/null/arch_inst.h | 21 | ||||
| -rw-r--r-- | arch/null/arch_spec.h | 16 |
4 files changed, 268 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; +} diff --git a/arch/null/arch_inst.c b/arch/null/arch_inst.c new file mode 100644 index 0000000..43f5d0c --- /dev/null +++ b/arch/null/arch_inst.c @@ -0,0 +1,67 @@ +// file : arch/null/arch_inst.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +// index: +// [section] includes +// [section] macros +// [section] globals +// [section] definitions + +// ---------------------------------------------------------------------------- +// [section] includes +// ---------------------------------------------------------------------------- +#include <assert.h> +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +#include "arch_inst.h" + +// ---------------------------------------------------------------------------- +// [section] macros +// ---------------------------------------------------------------------------- +#define INST_LOOP \ + INST(00) INST(01) INST(02) INST(03) INST(04) INST(05) INST(06) INST(07) INST(08) INST(09) INST(0a) INST(0b) INST(0c) INST(0d) INST(0e) INST(0f) \ + INST(10) INST(11) INST(12) INST(13) INST(14) INST(15) INST(16) INST(17) INST(18) INST(19) INST(1a) INST(1b) INST(1c) INST(1d) INST(1e) INST(1f) \ + INST(20) INST(21) INST(22) INST(23) INST(24) INST(25) INST(26) INST(27) INST(28) INST(29) INST(2a) INST(2b) INST(2c) INST(2d) INST(2e) INST(2f) \ + INST(30) INST(31) INST(32) INST(33) INST(34) INST(35) INST(36) INST(37) INST(38) INST(39) INST(3a) INST(3b) INST(3c) INST(3d) INST(3e) INST(3f) \ + INST(40) INST(41) INST(42) INST(43) INST(44) INST(45) INST(46) INST(47) INST(48) INST(49) INST(4a) INST(4b) INST(4c) INST(4d) INST(4e) INST(4f) \ + INST(50) INST(51) INST(52) INST(53) INST(54) INST(55) INST(56) INST(57) INST(58) INST(59) INST(5a) INST(5b) INST(5c) INST(5d) INST(5e) INST(5f) \ + INST(60) INST(61) INST(62) INST(63) INST(64) INST(65) INST(66) INST(67) INST(68) INST(69) INST(6a) INST(6b) INST(6c) INST(6d) INST(6e) INST(6f) \ + INST(70) INST(71) INST(72) INST(73) INST(74) INST(75) INST(76) INST(77) INST(78) INST(79) INST(7a) INST(7b) INST(7c) INST(7d) INST(7e) INST(7f) + +// ---------------------------------------------------------------------------- +// [section] globals +// ---------------------------------------------------------------------------- +wchar_t *g_arch_inst_symbols = ( + L"⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟" + L"⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿" + L"⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟" + L"⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿" +); + +// ---------------------------------------------------------------------------- +// [section] definitions +// ---------------------------------------------------------------------------- +int arch_inst_cap(void) { + return ARCH_INST_CAP; +} + +wchar_t arch_inst_symbol(uint8_t inst) { + assert(inst < ARCH_INST_CAP); + return g_arch_inst_symbols[inst]; +} + +const char *arch_inst_mnemonic(uint8_t inst) { + assert(inst < ARCH_INST_CAP); + + switch (inst) { +#define INST(code) case 0x##code: return "null " #code; + INST_LOOP +#undef INST + } + + assert(false); + return NULL; +} diff --git a/arch/null/arch_inst.h b/arch/null/arch_inst.h new file mode 100644 index 0000000..f9d85ff --- /dev/null +++ b/arch/null/arch_inst.h @@ -0,0 +1,21 @@ +// file : arch/null/arch_inst.h +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#pragma once + +// index: +// [section] macros +// [section] definitions + +// ---------------------------------------------------------------------------- +// [section] macros +// ---------------------------------------------------------------------------- +#define ARCH_INST_CAP 0x80 + +// ---------------------------------------------------------------------------- +// [section] definitions +// ---------------------------------------------------------------------------- +int arch_inst_cap(void); +wchar_t arch_inst_symbol(uint8_t inst); +const char *arch_inst_mnemonic(uint8_t inst); diff --git a/arch/null/arch_spec.h b/arch/null/arch_spec.h new file mode 100644 index 0000000..eeb6d44 --- /dev/null +++ b/arch/null/arch_spec.h @@ -0,0 +1,16 @@ +// file : arch/null/arch_spec.h +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#pragma once + +//#define ARCH_SPEC_MVEC_LOOP +#define ARCH_SPEC_CORE_FIELDS + +#define ARCH_SPEC_PROC_FIELDS \ + ARCH_SPEC_PROC_FIELD(uint64_t, ip) \ + ARCH_SPEC_PROC_FIELD(uint64_t, sp) \ + ARCH_SPEC_PROC_FIELD(uint64_t, mb0a) \ + ARCH_SPEC_PROC_FIELD(uint64_t, mb0s) \ + ARCH_SPEC_PROC_FIELD(uint64_t, mb1a) \ + ARCH_SPEC_PROC_FIELD(uint64_t, mb1s) |
