mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
114 lines
2.1 KiB
C
114 lines
2.1 KiB
C
// The OS/K Team licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
#ifndef _ARCH_H
|
|
#define _ARCH_H
|
|
|
|
//#define NDEBUG 1
|
|
|
|
#define dev_t stddev_t
|
|
|
|
#include <ctype.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <setjmp.h>
|
|
#include <assert.h>
|
|
#include <stdarg.h>
|
|
#include <limits.h>
|
|
|
|
#undef dev_t
|
|
#define static_assert _Static_assert
|
|
#define alignof _Alignof
|
|
|
|
typedef unsigned int bool;
|
|
typedef unsigned char uchar;
|
|
typedef unsigned short ushort;
|
|
typedef unsigned int uint;
|
|
typedef unsigned long ulong;
|
|
|
|
typedef struct reg_t reg_t;
|
|
typedef struct ctx_t ctx_t;
|
|
typedef struct instr_t instr_t;
|
|
typedef struct acc_t acc_t;
|
|
typedef struct arch_t arch_t;
|
|
typedef struct dev_t dev_t;
|
|
|
|
void logerr(const char *, ...);
|
|
void vlog(const char *, va_list);
|
|
|
|
// void trace(const char *, ...);
|
|
#define trace printf
|
|
|
|
#define KARCH_MAJOR 0
|
|
#define KARCH_MINOR 1
|
|
#define KARCH_REVIS 0
|
|
|
|
struct ctx_t
|
|
{
|
|
// Array of NREGS ulong's
|
|
ulong *rf;
|
|
|
|
// Register (names & types) table
|
|
reg_t *r;
|
|
|
|
// Instruction table
|
|
instr_t *i;
|
|
|
|
// Instruction currently executing
|
|
instr_t *cur_in;
|
|
|
|
// Starting address of instruction currently executing
|
|
ulong cur_pc;
|
|
|
|
// Memory and memory size
|
|
uchar *mp;
|
|
ulong mz;
|
|
|
|
// Devices list head
|
|
dev_t *dh;
|
|
|
|
// Instructions executed
|
|
ulong ninstrs; // totally
|
|
ulong ni_thisfr; // this frame
|
|
|
|
// Last COND field
|
|
uint cond;
|
|
|
|
// Dumpinstr switch
|
|
bool dumpsw;
|
|
};
|
|
|
|
#define ctx (&main_ctx)
|
|
extern ctx_t main_ctx;
|
|
|
|
#define R(X) ctx->rf[X]
|
|
|
|
void die(int code) __attribute__((__noreturn__));
|
|
|
|
void dumpregs(void);
|
|
void dumpinstr(ulong, uint, ushort, acc_t *, acc_t *);
|
|
void dumpmem(ulong, ulong);
|
|
|
|
void decode(void);
|
|
|
|
void enable_stdin_echoing(void);
|
|
void disable_stdin_echoing(void);
|
|
|
|
extern void do_hlt(void);
|
|
|
|
#include <pc/mem.h>
|
|
#include <pc/sym.h>
|
|
#include <pc/regs.h>
|
|
#include <pc/decode.h>
|
|
#include <pc/except.h>
|
|
#include <ob/arch_i.h>
|
|
|
|
extern reg_t arch_r[NREGS];
|
|
extern instr_t arch_i[NINSTRS];
|
|
|
|
extern size_t rfs_current_idx;
|
|
|
|
#endif
|
|
|