filename | src/sh4/sh4mmio.c |
changeset | 975:007bf7eb944f |
prev | 929:fd8cb0c82f5f |
author | nkeynes |
date | Fri Sep 10 08:50:55 2010 +1000 (13 years ago) |
permissions | -rw-r--r-- |
last change | Add missing sh4_translate_breakpoint_hit to the symbol table Change asm() to __asm__() as it's more likely to work |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * Miscellaneous and not-really-implemented SH4 peripheral modules. Also
5 * responsible for including the IMPL side of the SH4 MMIO pages.
6 * Most of these will eventually be split off into their own files.
7 *
8 * Copyright (c) 2005 Nathan Keynes.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 */
20 #define MODULE sh4_module
22 #include "dream.h"
23 #include "dreamcast.h"
24 #include "mem.h"
25 #include "clock.h"
26 #include "sh4/sh4core.h"
27 #include "sh4/sh4mmio.h"
28 #define MMIO_IMPL
29 #include "sh4/sh4mmio.h"
31 /********************************* BSC *************************************/
33 uint32_t bsc_input = 0x0300;
35 uint16_t bsc_read_pdtra()
36 {
37 int i;
38 uint32_t pctra = MMIO_READ( BSC, PCTRA );
39 uint16_t output = MMIO_READ( BSC, PDTRA );
40 uint16_t input_mask = 0, output_mask = 0;
41 for( i=0; i<16; i++ ) {
42 int bits = (pctra >> (i<<1)) & 0x03;
43 if( bits == 2 ) input_mask |= (1<<i);
44 else if( bits != 0 ) output_mask |= (1<<i);
45 }
47 /* ??? */
48 if( ((output | (~output_mask)) & 0x03) == 3 ) {
49 output |= 0x03;
50 } else {
51 output &= ~0x03;
52 }
54 return (bsc_input & input_mask) | output;
55 }
57 uint32_t bsc_read_pdtrb()
58 {
59 int i;
60 uint32_t pctrb = MMIO_READ( BSC, PCTRB );
61 uint16_t output = MMIO_READ( BSC, PDTRB );
62 uint16_t input_mask = 0, output_mask = 0;
63 for( i=0; i<4; i++ ) {
64 int bits = (pctrb >> (i<<1)) & 0x03;
65 if( bits == 2 ) input_mask |= (1<<i);
66 else if( bits != 0 ) output_mask |= (1<<i);
67 }
69 return ((bsc_input>>16) & input_mask) | output;
71 }
73 MMIO_REGION_WRITE_DEFFN(BSC)
75 MMIO_REGION_READ_FN( BSC, reg )
76 {
77 int32_t val;
78 reg &= 0xFFF;
79 switch( reg ) {
80 case PDTRA:
81 val = bsc_read_pdtra();
82 break;
83 case PDTRB:
84 val = bsc_read_pdtrb();
85 break;
86 default:
87 val = MMIO_READ( BSC, reg );
88 }
89 return val;
90 }
92 MMIO_REGION_READ_DEFSUBFNS(BSC)
94 /********************************* UBC *************************************/
96 MMIO_REGION_READ_FN( UBC, reg )
97 {
98 return MMIO_READ( UBC, reg & 0xFFF );
99 }
101 MMIO_REGION_WRITE_FN( UBC, reg, val )
102 {
103 reg &= 0xFFF;
104 switch( reg ) {
105 case BAMRA:
106 case BAMRB:
107 val &= 0x0F;
108 break;
109 case BBRA:
110 case BBRB:
111 val &= 0x07F;
112 if( val != 0 ) {
113 WARN( "UBC not implemented" );
114 }
115 break;
116 case BRCR:
117 val &= 0xC4C9;
118 break;
119 }
120 MMIO_WRITE( UBC, reg, val );
121 }
123 MMIO_REGION_READ_DEFSUBFNS(UBC)
125 /********************************** SCI *************************************/
127 MMIO_REGION_STUBFNS( SCI )
129 MMIO_REGION_READ_DEFSUBFNS(SCI)
.