diff options
author | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 02:39:32 +0100 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2024-04-16 02:28:53 +0200 |
commit | 5daf52d92c472ebf2a675cb2d27ca3e3fbdf0034 (patch) | |
tree | 36f58b9fd17f38724ff5a5263ac9a326a857f76e /src/arch |
Initial
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/dummy.c | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/src/arch/dummy.c b/src/arch/dummy.c new file mode 100644 index 0000000..b440be3 --- /dev/null +++ b/src/arch/dummy.c @@ -0,0 +1,147 @@ +// Project: Salis +// Author: Paul Oliver +// Email: contact@pauloliver.dev + +/* + * Defines a minimal viable architecture for the Salis VM. Useful for + * debugging and benchmarking. Also, this file can be used as a template when + * implementing a real architecture. + */ + +bool proc_is_live(const Core *core, u64 pix); + +#define PROC_FIELDS \ + PROC_FIELD(u64, dmmy) + +struct Proc { +#define PROC_FIELD(type, name) type name; + PROC_FIELDS +#undef PROC_FIELD +}; + +#define MNEMONIC_BUFF_SIZE (0x10) + +const wchar_t *g_arch_byte_symbols = ( + L"⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟" + L"⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿" + L"⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟" + L"⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿" +); + +u64 arch_proc_mb0_addr(const Core *core, u64 pix) { + assert(core); + assert(proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return 0; +} + +u64 arch_proc_mb0_size(const Core *core, u64 pix) { + assert(core); + assert(proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return 0; +} + +u64 arch_proc_mb1_addr(const Core *core, u64 pix) { + assert(core); + assert(proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return 0; +} + +u64 arch_proc_mb1_size(const Core *core, u64 pix) { + assert(core); + assert(proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return 0; +} + +u64 arch_proc_ip_addr(const Core *core, u64 pix) { + assert(core); + assert(proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return 0; +} + +u64 arch_proc_sp_addr(const Core *core, u64 pix) { + assert(core); + assert(proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return 0; +} + +u64 arch_proc_slice(const Core *core, u64 pix) { + assert(core); + assert(proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return 1; +} + +void arch_on_proc_kill(Core *core) { + assert(core); + assert(core->pnum > 1); + + (void)core; +} + +#if ACTION == ACT_BENCH || ACTION == ACT_NEW +void arch_anc_init(Core *core, u64 size) { + assert(core); + + (void)core; + (void)size; +} +#endif + +void arch_proc_step(Core *core, u64 pix) { + assert(core); + assert(proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return; +} + +#ifndef NDEBUG +void arch_validate_proc(const Core *core, u64 pix) { + assert(core); + assert(proc_is_live(core, pix)); + + (void)core; + (void)pix; + + assert(true); +} +#endif + +wchar_t arch_symbol(u8 inst) { + return g_arch_byte_symbols[inst]; +} + +void arch_mnemonic(u8 inst, char *buff) { + assert(buff); + + snprintf(buff, MNEMONIC_BUFF_SIZE, "dummy %#x", inst); +} |