// file : core/salis.h // project : Salis-VM // author : Paul Oliver #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);