Annotation of nono/util/runx/runx.h, revision 1.1

1.1     ! root        1: // vi:set ts=4:
        !             2: 
        !             3: //
        !             4: // nono
        !             5: // Copyright (C) 2024 nono project
        !             6: // Licensed under nono-license.txt
        !             7: //
        !             8: 
        !             9: #ifndef runx_h
        !            10: #define runx_h
        !            11: 
        !            12: #include <err.h>
        !            13: #include <errno.h>
        !            14: #include <unistd.h>
        !            15: #include <stdio.h>
        !            16: #include <sys/ptrace.h>
        !            17: #include <machine/reg.h>
        !            18: 
        !            19: #define countof(x) (sizeof(x) / sizeof((x)[0]))
        !            20: 
        !            21: #define DEBUG(lv, fmt...)  do {    \
        !            22:    if (opt_debug >= (lv)) {    \
        !            23:        printf("\x1b[33m"); \
        !            24:        printf(fmt);    \
        !            25:        printf("\x1b[m");   \
        !            26:        printf("\n");   \
        !            27:    }   \
        !            28: } while (0)
        !            29: 
        !            30: #define TRACE(pc, fmt...)  do {    \
        !            31:    if (opt_trace) {    \
        !            32:        printf("\x1b[33m"); \
        !            33:        printf("%06x: ", pc);   \
        !            34:        printf(fmt);    \
        !            35:        printf("\x1b[m");   \
        !            36:        printf("\n");   \
        !            37:    }   \
        !            38: } while (0)
        !            39: 
        !            40: // struct reg *reg は固定。
        !            41: #define RegR(n)    (reg->r_regs[(n)])
        !            42: #define RegD(n)    (reg->r_regs[(n)])
        !            43: #define RegA(n)    (reg->r_regs[8 + (n)])
        !            44: #define RegPC  (reg->r_pc)
        !            45: #define RegCCR (reg->r_sr)
        !            46: 
        !            47: typedef uint8_t        uint8;
        !            48: typedef uint16_t   uint16;
        !            49: typedef uint32_t   uint32;
        !            50: typedef int8_t     int8;
        !            51: typedef int16_t        int16;
        !            52: typedef int32_t        int32;
        !            53: 
        !            54: struct reg_emul {
        !            55:    uint16 sr;      // SR の上位バイトのみ保持。下位(CCR) は持たない。
        !            56:    uint32 usp;
        !            57:    uint32 ssp;
        !            58:    uint32 vbr;
        !            59:    uint32 caar;
        !            60: };
        !            61: // SR+CCR を返す
        !            62: #define GetSR  (emul.sr | (RegCCR & 0x00ff))
        !            63: // SR+CCR をセットする
        !            64: #define SetSR(v_)  do {    \
        !            65:    uint32 v__ = (v_);  \
        !            66:    emul.sr = v__ & 0xff00; \
        !            67:    RegCCR  = v__ & 0x00ff; \
        !            68: } while (0)
        !            69: 
        !            70: /* runx.cpp */
        !            71: extern uint32 readmem1(uint32);
        !            72: extern uint32 readmem2(uint32);
        !            73: extern uint32 readmem4(uint32);
        !            74: extern void writemem1(uint32, uint32);
        !            75: extern void writemem2(uint32, uint32);
        !            76: extern void writemem4(uint32, uint32);
        !            77: 
        !            78: /* doscall.cpp */
        !            79: extern int  init_doscall();
        !            80: extern int  doscall(pid_t, uint32, struct reg *);
        !            81: 
        !            82: /* iocscall.cpp */
        !            83: extern int  iocscall(pid_t, struct reg *);
        !            84: 
        !            85: /* m680x0.cpp */
        !            86: extern uint32 exception_format0(struct reg *, uint32, uint32);
        !            87: extern uint32 exception_format2(struct reg *, uint32);
        !            88: extern uint32 exec_op(pid_t, struct reg *, int, uint32);
        !            89: 
        !            90: /* util.cpp */
        !            91: extern int  getpgsize();
        !            92: extern const char *signame(int);
        !            93: 
        !            94: extern int opt_debug;
        !            95: extern int opt_trace;
        !            96: extern struct reg_emul emul;
        !            97: 
        !            98: #endif /* !runx_h */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.