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 /core/salis.h | |
Initial
Diffstat (limited to 'core/salis.h')
| -rw-r--r-- | core/salis.h | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/core/salis.h b/core/salis.h new file mode 100644 index 0000000..e61752b --- /dev/null +++ b/core/salis.h @@ -0,0 +1,147 @@ +// file : core/salis.h +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#pragma once + +// index: +// [section] structs +// [section] extern globals +// [section] memory vector declarations +// [section] mutator declarations +// [section] process declarations +// [section] core declarations +// [section] salis declarations + +// ---------------------------------------------------------------------------- +// [section] macros +// ---------------------------------------------------------------------------- +#define SALIS_UINT64_HALF 0x8000000000000000ul +#define SALIS_EVENT_ARRAY_SIZE_COL_MARKER "_evasize_" + +// ---------------------------------------------------------------------------- +// [section] structs +// ---------------------------------------------------------------------------- +struct Proc { +#define ARCH_SPEC_PROC_FIELD(type, name) type name; + ARCH_SPEC_PROC_FIELDS +#undef ARCH_SPEC_PROC_FIELD +}; + +struct EventArray { + uint64_t blob_size; + uint64_t data[MVEC_SIZE]; + uint64_t comp[MVEC_SIZE]; + struct DeflateParams params; + thrd_t thrd; +}; + +struct Core { + uint64_t step; + uint64_t cycl; + uint64_t mall; + uint64_t muta[4]; + + uint64_t pnum; + uint64_t pcap; + uint64_t pfst; + uint64_t plst; + uint64_t pcur; + uint64_t psli; + + uint64_t ivpt; + uint64_t *ivav; + uint8_t *iviv; + + uint8_t mvec[MVEC_SIZE]; // The World + struct Proc *pvec; // The organisms + + // Data aggregation fields + thrd_t amb_thrd; + double amb0; + double amb1; + + uint64_t emb0; + uint64_t emb1; + uint64_t eliv; + uint64_t edea; + + struct EventArray aeva; + struct EventArray eeva; + struct EventArray beva; + + // VM architecture specific fields +#define ARCH_SPEC_CORE_FIELD(type, name) type name; + ARCH_SPEC_CORE_FIELDS +#undef ARCH_SPEC_CORE_FIELD + + thrd_t thrd; +}; + +// ---------------------------------------------------------------------------- +// [section] extern globals +// ---------------------------------------------------------------------------- +extern struct Core g_cores[CORES]; +extern uint64_t g_step; + +// ---------------------------------------------------------------------------- +// [section] memory vector declarations +// ---------------------------------------------------------------------------- +#if defined(ARCH_SPEC_MVEC_LOOP) +uint64_t mvec_loop(uint64_t addr); +#endif + +bool mvec_is_alloc(const struct Core *core, uint64_t addr); +void mvec_alloc(struct Core *core, uint64_t addr); +void mvec_free(struct Core *core, uint64_t addr); + +uint8_t mvec_get_byte(const struct Core *core, uint64_t addr); +uint8_t mvec_get_inst(const struct Core *core, uint64_t addr); +void mvec_set_inst(struct Core *core, uint64_t addr, uint8_t inst); + +#if defined(ARCH_SPEC_MUTA_FLIP) +void mvec_flip_bit(struct Core *core, uint64_t addr, int bit); +#endif + +bool mvec_proc_is_live(const struct Core *core, uint64_t pix); +bool mvec_is_in_mb0_of_proc(const struct Core *core, uint64_t addr, uint64_t pix); +bool mvec_is_in_mb1_of_proc(const struct Core *core, uint64_t addr, uint64_t pix); +bool mvec_is_proc_owner(const struct Core *core, uint64_t addr, uint64_t pix); +uint64_t mvec_get_owner(const struct Core *core, uint64_t addr); + +// ---------------------------------------------------------------------------- +// [section] mutator declarations +// ---------------------------------------------------------------------------- +uint64_t muta_next(struct Core *core); +void muta_cosmic_ray(struct Core *core); + +// ---------------------------------------------------------------------------- +// [section] process declarations +// ---------------------------------------------------------------------------- +void proc_new(struct Core *core, const struct Proc *proc); +void proc_kill(struct Core *core); +const struct Proc *proc_get(const struct Core *core, uint64_t pix); +struct Proc *proc_fetch(struct Core *core, uint64_t pix); + +// ---------------------------------------------------------------------------- +// [section] core declarations +// ---------------------------------------------------------------------------- +void core_event_array_init(struct EventArray *eva); +void core_push_ipcm(struct Core *core, uint8_t inst, uint64_t addr); + +// ---------------------------------------------------------------------------- +// [section] salis declarations +// ---------------------------------------------------------------------------- +#if defined(COMMAND_NEW) +void salis_init(void); +#endif + +#if defined(COMMAND_LOAD) +void salis_load(void); +#endif + +void salis_start(void); +void salis_join(void); +void salis_signal_stop(void); +void salis_step(uint64_t steps); +void salis_free(void); |
