4 #if !defined(REGPARM) && defined(__i386__)
\r
5 #define REGPARM(x) __attribute__((regparm(x)))
\r
10 // registers - matches structure order
\r
12 SHR_R0 = 0, SHR_SP = 15,
\r
13 SHR_PC, SHR_PPC, SHR_PR, SHR_SR,
\r
14 SHR_GBR, SHR_VBR, SHR_MACH, SHR_MACL,
\r
19 unsigned int r[16]; // 00
\r
20 unsigned int pc; // 40
\r
24 unsigned int gbr, vbr; // 50
\r
25 unsigned int mach, macl; // 58
\r
28 const void *read8_map; // 60
\r
29 const void *read16_map;
\r
30 const void **write8_tab;
\r
31 const void **write16_tab;
\r
36 void *p_bios; // convenience pointers
\r
38 void *p_sdram; // 80
\r
40 unsigned int pdb_io_csum[2];
\r
42 #define SH2_STATE_RUN (1 << 0) // to prevent recursion
\r
43 #define SH2_STATE_SLEEP (1 << 1)
\r
44 #define SH2_STATE_CPOLL (1 << 2) // polling comm regs
\r
45 #define SH2_STATE_VPOLL (1 << 3) // polling VDP
\r
47 unsigned int poll_addr;
\r
51 // interpreter stuff
\r
52 int icount; // cycles left in current timeslice
\r
55 unsigned int test_irq;
\r
57 int pending_level; // MAX(pending_irl, pending_int_irq)
\r
59 int pending_int_irq; // internal irq
\r
60 int pending_int_vector;
\r
61 int REGPARM(2) (*irq_callback)(struct SH2_ *sh2, int level);
\r
64 unsigned int cycles_timeslice;
\r
66 struct SH2_ *other_sh2;
\r
68 // we use 68k reference cycles for easier sync
\r
69 unsigned int m68krcycles_done;
\r
70 unsigned int mult_m68k_to_sh2;
\r
71 unsigned int mult_sh2_to_m68k;
\r
73 unsigned char data_array[0x1000]; // cache (can be used as RAM)
\r
74 unsigned int peri_regs[0x200/4]; // periphereal regs
\r
77 #define CYCLE_MULT_SHIFT 10
\r
78 #define C_M68K_TO_SH2(xsh2, c) \
\r
79 ((int)((c) * (xsh2).mult_m68k_to_sh2) >> CYCLE_MULT_SHIFT)
\r
80 #define C_SH2_TO_M68K(xsh2, c) \
\r
81 ((int)((c + 3) * (xsh2).mult_sh2_to_m68k) >> CYCLE_MULT_SHIFT)
\r
83 int sh2_init(SH2 *sh2, int is_slave, SH2 *other_sh2);
\r
84 void sh2_finish(SH2 *sh2);
\r
85 void sh2_reset(SH2 *sh2);
\r
86 int sh2_irl_irq(SH2 *sh2, int level, int nested_call);
\r
87 void sh2_internal_irq(SH2 *sh2, int level, int vector);
\r
88 void sh2_do_irq(SH2 *sh2, int level, int vector);
\r
89 void sh2_pack(const SH2 *sh2, unsigned char *buff);
\r
90 void sh2_unpack(SH2 *sh2, const unsigned char *buff);
\r
92 int sh2_execute_drc(SH2 *sh2c, int cycles);
\r
93 int sh2_execute_interpreter(SH2 *sh2c, int cycles);
\r
95 static INLINE int sh2_execute(SH2 *sh2, int cycles, int use_drc)
\r
99 sh2->cycles_timeslice = cycles;
\r
102 ret = sh2_execute_drc(sh2, cycles);
\r
105 ret = sh2_execute_interpreter(sh2, cycles);
\r
107 return sh2->cycles_timeslice - ret;
\r
110 // regs, pending_int*, cycles, reserved
\r
111 #define SH2_STATE_SIZE ((24 + 2 + 2 + 12) * 4)
\r
113 // pico memhandlers
\r
114 // XXX: move somewhere else
\r
115 unsigned int REGPARM(2) p32x_sh2_read8(unsigned int a, SH2 *sh2);
\r
116 unsigned int REGPARM(2) p32x_sh2_read16(unsigned int a, SH2 *sh2);
\r
117 unsigned int REGPARM(2) p32x_sh2_read32(unsigned int a, SH2 *sh2);
\r
118 void REGPARM(3) p32x_sh2_write8 (unsigned int a, unsigned int d, SH2 *sh2);
\r
119 void REGPARM(3) p32x_sh2_write16(unsigned int a, unsigned int d, SH2 *sh2);
\r
120 void REGPARM(3) p32x_sh2_write32(unsigned int a, unsigned int d, SH2 *sh2);
\r
124 void do_sh2_trace(SH2 *current, int cycles);
\r
125 void do_sh2_cmp(SH2 *current);
\r
128 #endif /* __SH2_H__ */
\r