1 /**************************************************************************\ 2 * Texas Instruments TMS32010 DSP Emulator * 3 * * 4 * Copyright (C) 1999-2002+ Tony La Porta * 5 * You are not allowed to distribute this software commercially. * 6 * Written for the MAME project. * 7 * * 8 * * 9 * Note : This is a word based microcontroller, with addressing * 10 * architecture based on the Harvard addressing scheme. * 11 * * 12 \**************************************************************************/ 13 14 #ifndef _TMS32010_H 15 #define _TMS32010_H 16 17 18 #include "osd_cpu.h" 19 #include "cpuintrf.h" 20 #include "memory.h" 21 22 23 /**************************************************************************** 24 * Use this in the I/O port address fields of your driver for the BIO pin 25 * i.e, 26 * { TMS32010_PORT_RANGE(TMS32010_BIO, TMS32010_BIO), tms32010_bio_line_r }, 27 */ 28 29 #define TMS32010_BIO 0x100 /* BIO input */ 30 31 32 #define TMS32010_DATA_OFFSET 0x0000 33 #define TMS32010_PGM_OFFSET 0x8000 34 35 #define TMS32010_INT_PENDING 0x80000000 36 #define TMS32010_INT_NONE 0 37 38 #define TMS32010_ADDR_MASK 0x0fff /* TMS32010 can only address 0x0fff */ 39 /* however other TMS3201x devices */ 40 /* can address up to 0xffff (incase */ 41 /* their support is ever added). */ 42 43 44 enum { 45 TMS32010_PC=1, TMS32010_SP, TMS32010_STR, TMS32010_ACC, 46 TMS32010_PREG, TMS32010_TREG, TMS32010_AR0, TMS32010_AR1, 47 TMS32010_STK0, TMS32010_STK1, TMS32010_STK2, TMS32010_STK3 48 }; 49 50 51 /**************************************************************************** 52 * Public Functions 53 */ 54 55 void tms32010_init(void); 56 void tms32010_reset(void *param); /* Reset processor & registers */ 57 void tms32010_exit(void); /* Shutdown CPU core */ 58 int tms32010_execute(int cycles); /* Execute cycles T-States */ 59 unsigned tms32010_get_context(void *dst); /* Get registers */ 60 void tms32010_set_context(void *src); /* Set registers */ 61 unsigned tms32010_get_reg(int regnum); /* Get specific register */ 62 void tms32010_set_reg(int regnum, unsigned val);/* Set specific register */ 63 void tms32010_set_irq_line(int irqline, int state); 64 void tms32010_set_irq_callback(int (*callback)(int irqline)); 65 const char *tms32010_info(void *context, int regnum); 66 unsigned tms32010_dasm(char *buffer, unsigned pc); 67 68 extern int tms32010_icount; /* T-state count */ 69 70 71 72 /**************************************************************************** 73 * Helpers for memory ranges 74 */ 75 76 #define TMS32010_DATA_ADDR_RANGE(start, end) (TMS32010_DATA_OFFSET + ((start) << 1)), (TMS32010_DATA_OFFSET + ((end) << 1) + 1) 77 #define TMS32010_PGM_ADDR_RANGE(start, end) (TMS32010_PGM_OFFSET + ((start) << 1)), (TMS32010_PGM_OFFSET + ((end) << 1) + 1) 78 #define TMS32010_PORT_RANGE(start, end) ((start) << 1), (((end) << 1) + 1) 79 80 81 82 /**************************************************************************** 83 * Read the state of the BIO pin 84 */ 85 86 #define TMS32010_BIO_In (cpu_readport16bew_word(TMS32010_BIO<<1)) 87 88 89 /**************************************************************************** 90 * Input a word from given I/O port 91 */ 92 93 #define TMS32010_In(Port) (cpu_readport16bew_word((Port)<<1)) 94 95 96 /**************************************************************************** 97 * Output a word to given I/O port 98 */ 99 100 #define TMS32010_Out(Port,Value) (cpu_writeport16bew_word((Port)<<1,Value)) 101 102 103 104 /**************************************************************************** 105 * Read a word from given ROM memory location 106 */ 107 108 #define TMS32010_ROM_RDMEM(A) (cpu_readmem16bew_word(((A)<<1)+TMS32010_PGM_OFFSET)) 109 110 111 /**************************************************************************** 112 * Write a word to given ROM memory location 113 */ 114 115 #define TMS32010_ROM_WRMEM(A,V) (cpu_writemem16bew_word(((A)<<1)+TMS32010_PGM_OFFSET,V)) 116 117 118 119 /**************************************************************************** 120 * Read a word from given RAM memory location 121 * The following adds 8000h to the address, since MAME doesnt support 122 * RAM and ROM living in the same address space. RAM really starts at 123 * address 0 and are word entities. 124 */ 125 126 #define TMS32010_RAM_RDMEM(A) (cpu_readmem16bew_word(((A)<<1)+TMS32010_DATA_OFFSET)) 127 128 129 /**************************************************************************** 130 * Write a word to given RAM memory location 131 * The following adds 8000h to the address, since MAME doesnt support 132 * RAM and ROM living in the same address space. RAM really starts at 133 * address 0 and word entities. 134 */ 135 136 #define TMS32010_RAM_WRMEM(A,V) (cpu_writemem16bew_word(((A)<<1)+TMS32010_DATA_OFFSET,V)) 137 138 139 140 /**************************************************************************** 141 * TMS32010_RDOP() is identical to TMS32010_RDMEM() except it is used for reading 142 * opcodes. In case of system with memory mapped I/O, this function can be 143 * used to greatly speed up emulation 144 */ 145 146 #define TMS32010_RDOP(A) (cpu_readop16(((A)<<1)+TMS32010_PGM_OFFSET)) 147 148 149 /**************************************************************************** 150 * TMS32010_RDOP_ARG() is identical to TMS32010_RDOP() except it is used 151 * for reading opcode arguments. This difference can be used to support systems 152 * that use different encoding mechanisms for opcodes and opcode arguments 153 */ 154 155 #define TMS32010_RDOP_ARG(A) (cpu_readop_arg16(((A)<<1)+TMS32010_PGM_OFFSET)) 156 157 158 159 #ifdef MAME_DEBUG 160 extern unsigned Dasm32010(char *buffer, unsigned pc); 161 #endif 162 163 #endif /* _TMS32010_H */ 164