src/mess/drivers/pockstat.c
| r6267 | r6268 | |
| 29 | 29 | #include "driver.h" |
| 30 | 30 | #include "cpu/arm7/arm7.h" |
| 31 | 31 | |
| 32 | #define VERBOSE_LEVEL ( 99 ) |
| 33 | |
| 34 | INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level, const char *s_fmt, ... ) |
| 35 | { |
| 36 | if( VERBOSE_LEVEL >= n_level ) |
| 37 | { |
| 38 | va_list v; |
| 39 | char buf[ 32768 ]; |
| 40 | va_start( v, s_fmt ); |
| 41 | vsprintf( buf, s_fmt, v ); |
| 42 | va_end( v ); |
| 43 | logerror( "%s: %s", cpuexec_describe_context(machine), buf ); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | typedef struct |
| 48 | { |
| 49 | UINT32 control; |
| 50 | UINT32 stat; |
| 51 | UINT32 valid; |
| 52 | UINT32 wait1; |
| 53 | UINT32 wait2; |
| 54 | UINT32 entry[16]; |
| 55 | UINT32 serial; |
| 56 | } ps_ftlb_regs_t; |
| 57 | |
| 58 | static ps_ftlb_regs_t ftlb_regs; |
| 59 | |
| 60 | static READ32_HANDLER( ps_ftlb_r ) |
| 61 | { |
| 62 | switch(offset) |
| 63 | { |
| 64 | case 0x0000/4: |
| 65 | verboselog(space->machine, 0, "ps_ftlb_r: FlashROM TLB Control = %08x & %08x\n", ftlb_regs.control, mem_mask ); |
| 66 | return ftlb_regs.control; |
| 67 | case 0x0004/4: |
| 68 | verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_STAT) = %08x & %08x\n", ftlb_regs.stat, mem_mask ); |
| 69 | return ftlb_regs.stat; |
| 70 | case 0x0008/4: |
| 71 | verboselog(space->machine, 0, "ps_ftlb_r: FlashROM TLB Valid Tag = %08x & %08x\n", ftlb_regs.valid, mem_mask ); |
| 72 | return ftlb_regs.valid; |
| 73 | case 0x000c/4: |
| 74 | verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_WAIT1) = %08x & %08x\n", ftlb_regs.wait1, mem_mask ); |
| 75 | return ftlb_regs.wait1; |
| 76 | case 0x0010/4: |
| 77 | verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_WAIT2) = %08x & %08x\n", ftlb_regs.wait2, mem_mask ); |
| 78 | return ftlb_regs.wait2; |
| 79 | case 0x0100/4: |
| 80 | case 0x0104/4: |
| 81 | case 0x0108/4: |
| 82 | case 0x010c/4: |
| 83 | case 0x0110/4: |
| 84 | case 0x0114/4: |
| 85 | case 0x0118/4: |
| 86 | case 0x011c/4: |
| 87 | case 0x0120/4: |
| 88 | case 0x0124/4: |
| 89 | case 0x0128/4: |
| 90 | case 0x012c/4: |
| 91 | case 0x0130/4: |
| 92 | case 0x0134/4: |
| 93 | case 0x0138/4: |
| 94 | case 0x013c/4: |
| 95 | verboselog(space->machine, 0, "ps_ftlb_r: FlashROM TLB Entry %d = %08x & %08x\n", offset - 0x100/4, ftlb_regs.entry[offset - 0x100/4], mem_mask ); |
| 96 | return ftlb_regs.entry[offset - 0x100/4]; |
| 97 | case 0x0300/4: |
| 98 | verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_SN) = %08x & %08x\n", ftlb_regs.serial, mem_mask ); |
| 99 | return ftlb_regs.serial; |
| 100 | default: |
| 101 | verboselog(space->machine, 0, "ps_ftlb_r: Unknown Register %08x & %08x\n", 0x06000000 + (offset << 2), mem_mask ); |
| 102 | break; |
| 103 | } |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | static WRITE32_HANDLER( ps_ftlb_w ) |
| 108 | { |
| 109 | switch(offset) |
| 110 | { |
| 111 | case 0x0000/4: |
| 112 | verboselog(space->machine, 0, "ps_ftlb_w: FlashROM TLB Control = %08x & %08x\n", data, mem_mask ); |
| 113 | COMBINE_DATA(&ftlb_regs.control); |
| 114 | break; |
| 115 | case 0x0004/4: |
| 116 | verboselog(space->machine, 0, "ps_ftlb_w: Unknown (F_STAT) = %08x & %08x\n", data, mem_mask ); |
| 117 | COMBINE_DATA(&ftlb_regs.stat); |
| 118 | break; |
| 119 | case 0x0008/4: |
| 120 | verboselog(space->machine, 0, "ps_ftlb_w: FlashROM TLB Valid Tag = %08x & %08x\n", data, mem_mask ); |
| 121 | COMBINE_DATA(&ftlb_regs.valid); |
| 122 | break; |
| 123 | case 0x000c/4: |
| 124 | verboselog(space->machine, 0, "ps_ftlb_w: Unknown (F_WAIT1) = %08x & %08x\n", data, mem_mask ); |
| 125 | COMBINE_DATA(&ftlb_regs.wait1); |
| 126 | break; |
| 127 | case 0x0010/4: |
| 128 | verboselog(space->machine, 0, "ps_ftlb_w: Unknown (F_WAIT2) = %08x & %08x\n", data, mem_mask ); |
| 129 | COMBINE_DATA(&ftlb_regs.wait2); |
| 130 | break; |
| 131 | case 0x0100/4: |
| 132 | case 0x0104/4: |
| 133 | case 0x0108/4: |
| 134 | case 0x010c/4: |
| 135 | case 0x0110/4: |
| 136 | case 0x0114/4: |
| 137 | case 0x0118/4: |
| 138 | case 0x011c/4: |
| 139 | case 0x0120/4: |
| 140 | case 0x0124/4: |
| 141 | case 0x0128/4: |
| 142 | case 0x012c/4: |
| 143 | case 0x0130/4: |
| 144 | case 0x0134/4: |
| 145 | case 0x0138/4: |
| 146 | case 0x013c/4: |
| 147 | verboselog(space->machine, 0, "ps_ftlb_w: FlashROM TLB Entry %d = %08x & %08x\n", offset - 0x100/4, data, mem_mask ); |
| 148 | COMBINE_DATA(&ftlb_regs.entry[offset - 0x100/4]); |
| 149 | break; |
| 150 | case 0x0300/4: |
| 151 | verboselog(space->machine, 0, "ps_ftlb_w: Unknown (F_SN) = %08x & %08x\n", data, mem_mask ); |
| 152 | COMBINE_DATA(&ftlb_regs.serial); |
| 153 | break; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | typedef struct |
| 158 | { |
| 159 | UINT32 hold; |
| 160 | UINT32 status; |
| 161 | UINT32 enable; |
| 162 | UINT32 mask; |
| 163 | } ps_intc_regs_t; |
| 164 | |
| 165 | #define PS_INT_BTN_DECISION 0x00000001 // "Decision button" ??? |
| 166 | #define PS_INT_BTN_RIGHT 0x00000002 // "Right button" |
| 167 | #define PS_INT_BTN_LEFT 0x00000004 // "Left button" |
| 168 | #define PS_INT_BTN_DOWN 0x00000008 // "Down button" |
| 169 | #define PS_INT_BTN_ON 0x00000010 // "Button on" ??? |
| 170 | #define PS_INT_UNKNOWN 0x00000020 // "Unknown" |
| 171 | #define PS_INT_COM 0x00000040 // "COM" ??? |
| 172 | #define PS_INT_TIMER0 0x00000080 // "Timer 0" |
| 173 | #define PS_INT_TIMER1 0x00000100 // "Timer 1" |
| 174 | #define PS_INT_RTC 0x00000200 // "RTC" |
| 175 | #define PS_INT_BATTERY 0x00000400 // "Battery Monitor" |
| 176 | #define PS_INT_IOP 0x00000800 // "IOP" |
| 177 | #define PS_INT_IRDA 0x00001000 // "IrDA" |
| 178 | #define PS_INT_TIMER2 0x00002000 // "Timer 2" |
| 179 | |
| 180 | static ps_intc_regs_t intc_regs; |
| 181 | |
| 182 | static READ32_HANDLER( ps_intc_r ) |
| 183 | { |
| 184 | switch(offset) |
| 185 | { |
| 186 | case 0x0000/4: |
| 187 | verboselog(space->machine, 0, "ps_intc_r: Held Interrupt = %08x & %08x\n", intc_regs.hold, mem_mask ); |
| 188 | return intc_regs.hold; |
| 189 | case 0x0004/4: |
| 190 | verboselog(space->machine, 0, "ps_intc_r: Interrupt Status = %08x & %08x\n", intc_regs.status, mem_mask ); |
| 191 | return intc_regs.status; |
| 192 | case 0x0008/4: |
| 193 | verboselog(space->machine, 0, "ps_intc_r: Interrupt Enable = %08x & %08x\n", intc_regs.mask, mem_mask ); |
| 194 | return intc_regs.mask; |
| 195 | case 0x000c/4: |
| 196 | verboselog(space->machine, 0, "ps_intc_r: Interrupt Mask (Invalid Read) = %08x & %08x\n", 0, mem_mask ); |
| 197 | return 0; |
| 198 | case 0x0010/4: |
| 199 | verboselog(space->machine, 0, "ps_intc_r: Interrupt Acknowledge (Invalid Read) = %08x & %08x\n", 0, mem_mask ); |
| 200 | return 0; |
| 201 | default: |
| 202 | verboselog(space->machine, 0, "ps_intc_r: Unknown Register %08x & %08x\n", 0x0a000000 + (offset << 2), mem_mask ); |
| 203 | break; |
| 204 | } |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | static WRITE32_HANDLER( ps_intc_w ) |
| 209 | { |
| 210 | switch(offset) |
| 211 | { |
| 212 | case 0x0000/4: |
| 213 | verboselog(space->machine, 0, "ps_intc_w: Held Interrupt (Invalid Write) = %08x & %08x\n", data, mem_mask ); |
| 214 | break; |
| 215 | case 0x0004/4: |
| 216 | verboselog(space->machine, 0, "ps_intc_w: Interrupt Status (Invalid Write) = %08x & %08x\n", data, mem_mask ); |
| 217 | break; |
| 218 | case 0x0008/4: |
| 219 | verboselog(space->machine, 0, "ps_intc_w: Interrupt Enable = %08x & %08x\n", data, mem_mask ); |
| 220 | COMBINE_DATA(&intc_regs.enable); |
| 221 | break; |
| 222 | case 0x000c/4: |
| 223 | verboselog(space->machine, 0, "ps_intc_w: Interrupt Mask = %08x & %08x\n", data, mem_mask ); |
| 224 | COMBINE_DATA(&intc_regs.mask); |
| 225 | break; |
| 226 | case 0x0010/4: |
| 227 | verboselog(space->machine, 0, "ps_intc_w: Interrupt Acknowledge = %08x & %08x\n", data, mem_mask ); |
| 228 | //COMBINE_DATA(&intc_regs.acknowledge); |
| 229 | break; |
| 230 | default: |
| 231 | verboselog(space->machine, 0, "ps_intc_w: Unknown Register %08x & %08x\n", 0x0a000000 + (offset << 2), mem_mask ); |
| 232 | break; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | typedef struct |
| 237 | { |
| 238 | UINT32 timer0_period; |
| 239 | UINT32 timer0_count; |
| 240 | UINT32 timer0_control; |
| 241 | UINT32 timer1_period; |
| 242 | UINT32 timer1_count; |
| 243 | UINT32 timer1_control; |
| 244 | UINT32 timer2_period; |
| 245 | UINT32 timer2_count; |
| 246 | UINT32 timer2_control; |
| 247 | } ps_timer_regs_t; |
| 248 | |
| 249 | static ps_timer_regs_t timer_regs; |
| 250 | |
| 251 | static READ32_HANDLER( ps_timer_r ) |
| 252 | { |
| 253 | switch(offset) |
| 254 | { |
| 255 | case 0x0000/4: |
| 256 | verboselog(space->machine, 0, "ps_timer_r: Timer 0 Period = %08x & %08x\n", timer_regs.timer0_period, mem_mask ); |
| 257 | return timer_regs.timer0_period; |
| 258 | case 0x0004/4: |
| 259 | verboselog(space->machine, 0, "ps_timer_r: Timer 0 Count = %08x & %08x\n", timer_regs.timer0_count, mem_mask ); |
| 260 | return timer_regs.timer0_count; |
| 261 | case 0x0008/4: |
| 262 | verboselog(space->machine, 0, "ps_timer_r: Timer 0 Control = %08x & %08x\n", timer_regs.timer0_control, mem_mask ); |
| 263 | return timer_regs.timer0_control; |
| 264 | case 0x0010/4: |
| 265 | verboselog(space->machine, 0, "ps_timer_r: Timer 1 Period = %08x & %08x\n", timer_regs.timer1_period, mem_mask ); |
| 266 | return timer_regs.timer1_period; |
| 267 | case 0x0014/4: |
| 268 | verboselog(space->machine, 0, "ps_timer_r: Timer 1 Count = %08x & %08x\n", timer_regs.timer1_count, mem_mask ); |
| 269 | return timer_regs.timer1_count; |
| 270 | case 0x0018/4: |
| 271 | verboselog(space->machine, 0, "ps_timer_r: Timer 1 Control = %08x & %08x\n", timer_regs.timer1_control, mem_mask ); |
| 272 | return timer_regs.timer1_control; |
| 273 | case 0x0020/4: |
| 274 | verboselog(space->machine, 0, "ps_timer_r: Timer 2 Period = %08x & %08x\n", timer_regs.timer2_period, mem_mask ); |
| 275 | return timer_regs.timer2_period; |
| 276 | case 0x0024/4: |
| 277 | verboselog(space->machine, 0, "ps_timer_r: Timer 2 Count = %08x & %08x\n", timer_regs.timer2_count, mem_mask ); |
| 278 | return timer_regs.timer2_count; |
| 279 | case 0x0028/4: |
| 280 | verboselog(space->machine, 0, "ps_timer_r: Timer 2 Control = %08x & %08x\n", timer_regs.timer2_control, mem_mask ); |
| 281 | return timer_regs.timer2_control; |
| 282 | default: |
| 283 | verboselog(space->machine, 0, "ps_timer_r: Unknown Register %08x & %08x\n", 0x0a800000 + (offset << 2), mem_mask ); |
| 284 | break; |
| 285 | } |
| 286 | return 0; |
| 287 | } |
| 288 | |
| 289 | static WRITE32_HANDLER( ps_timer_w ) |
| 290 | { |
| 291 | switch(offset) |
| 292 | { |
| 293 | case 0x0000/4: |
| 294 | verboselog(space->machine, 0, "ps_timer_w: Timer 0 Period = %08x & %08x\n", data, mem_mask ); |
| 295 | COMBINE_DATA(&timer_regs.timer0_period); |
| 296 | break; |
| 297 | case 0x0004/4: |
| 298 | verboselog(space->machine, 0, "ps_timer_w: Timer 0 Count = %08x & %08x\n", data, mem_mask ); |
| 299 | COMBINE_DATA(&timer_regs.timer0_count); |
| 300 | break; |
| 301 | case 0x0008/4: |
| 302 | verboselog(space->machine, 0, "ps_timer_w: Timer 0 Control = %08x & %08x\n", data, mem_mask ); |
| 303 | COMBINE_DATA(&timer_regs.timer0_control); |
| 304 | break; |
| 305 | case 0x0010/4: |
| 306 | verboselog(space->machine, 0, "ps_timer_w: Timer 1 Period = %08x & %08x\n", data, mem_mask ); |
| 307 | COMBINE_DATA(&timer_regs.timer1_period); |
| 308 | break; |
| 309 | case 0x0014/4: |
| 310 | verboselog(space->machine, 0, "ps_timer_w: Timer 1 Count = %08x & %08x\n", data, mem_mask ); |
| 311 | COMBINE_DATA(&timer_regs.timer1_count); |
| 312 | break; |
| 313 | case 0x0018/4: |
| 314 | verboselog(space->machine, 0, "ps_timer_w: Timer 1 Control = %08x & %08x\n", data, mem_mask ); |
| 315 | COMBINE_DATA(&timer_regs.timer1_control); |
| 316 | break; |
| 317 | case 0x0020/4: |
| 318 | verboselog(space->machine, 0, "ps_timer_w: Timer 2 Period = %08x & %08x\n", data, mem_mask ); |
| 319 | COMBINE_DATA(&timer_regs.timer2_period); |
| 320 | break; |
| 321 | case 0x0024/4: |
| 322 | verboselog(space->machine, 0, "ps_timer_w: Timer 2 Count = %08x & %08x\n", data, mem_mask ); |
| 323 | COMBINE_DATA(&timer_regs.timer2_count); |
| 324 | break; |
| 325 | case 0x0028/4: |
| 326 | verboselog(space->machine, 0, "ps_timer_w: Timer 2 Control = %08x & %08x\n", data, mem_mask ); |
| 327 | COMBINE_DATA(&timer_regs.timer2_control); |
| 328 | break; |
| 329 | default: |
| 330 | verboselog(space->machine, 0, "ps_timer_w: Unknown Register %08x & %08x\n", 0x0a800000 + (offset << 2), mem_mask ); |
| 331 | break; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | static UINT32 ps_unknown1; |
| 336 | |
| 337 | static READ32_HANDLER( ps_unk1_r ) |
| 338 | { |
| 339 | verboselog(space->machine, 0, "ps_unk1_r: Unknown 1: %08x & %08x\n", ps_unknown1 | 0x10, mem_mask ); |
| 340 | return ps_unknown1 | 0x10; |
| 341 | } |
| 342 | |
| 343 | static WRITE32_HANDLER( ps_unk1_w ) |
| 344 | { |
| 345 | verboselog(space->machine, 0, "ps_unk1_w: Unknown 1: %08x & %08x\n", data, mem_mask ); |
| 346 | } |
| 347 | |
| 32 | 348 | static ADDRESS_MAP_START(pockstat_mem, ADDRESS_SPACE_PROGRAM, 32) |
| 33 | 349 | AM_RANGE(0x00000000, 0x000007ff) AM_RAM |
| 34 | 350 | AM_RANGE(0x04000000, 0x04003fff) AM_ROM AM_REGION("maincpu", 0) |
| 351 | AM_RANGE(0x06000000, 0x06000307) AM_READWRITE(ps_ftlb_r, ps_ftlb_w) |
| 352 | AM_RANGE(0x0a000000, 0x0a000013) AM_READWRITE(ps_intc_r, ps_intc_w) |
| 353 | AM_RANGE(0x0a800000, 0x0a80002b) AM_READWRITE(ps_timer_r, ps_timer_w) |
| 354 | AM_RANGE(0x0b000000, 0x0b000003) AM_READWRITE(ps_unk1_r, ps_unk1_w) |
| 35 | 355 | /* AM_RANGE(0x02000000, 0x0201ffff) Flash ROM |
| 36 | 356 | AM_RANGE(0x08000000, 0x0801ffff) Same as 0x02 above. Mirrors every 128KB. |
| 37 | | AM_RANGE(0x0a000000, 0x0a000003) IRQs currently triggered |
| 38 | | AM_RANGE(0x0a000004, 0x0a000007) Raw status |
| 39 | | AM_RANGE(0x0a000008, 0x0a00000b) Which IRQs are enabled |
| 40 | | AM_RANGE(0x0a00000c, 0x0a00000f) Disable IRQs (write only) |
| 41 | | AM_RANGE(0x0a000010, 0x0a000013) IRQ service signal (write only) |
| 42 | | AM_RANGE(0x0a800000, 0x0a800003) Timer 0 period |
| 43 | | AM_RANGE(0x0a800004, 0x0a800007) Timer 0 current value |
| 44 | | AM_RANGE(0x0a800008, 0x0a80000b) Timer 0 control |
| 45 | | AM_RANGE(0x0a800010, 0x0a800013) Timer 1 period |
| 46 | | AM_RANGE(0x0a800014, 0x0a800017) Timer 1 current value |
| 47 | | AM_RANGE(0x0a800018, 0x0a80001b) Timer 1 control |
| 48 | | AM_RANGE(0x0a800020, 0x0a800023) Timer 2 period |
| 49 | | AM_RANGE(0x0a800024, 0x0a800027) Timer 2 current value |
| 50 | | AM_RANGE(0x0a800028, 0x0a80002b) Timer 2 control |
| 51 | 357 | AM_RANGE(0x0b000000, 0x0b000003) Internal CPU Clock control |
| 52 | 358 | AM_RANGE(0x0b800000, 0x0b800003) RTC control word |
| 53 | 359 | AM_RANGE(0x0b800004, 0x0b800007) RTC Modify value (write only) |