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.
8 * Copyright (c) 2005 Nathan Keynes.
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.
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.
20 #define MODULE sh4_module
23 #include "dreamcast.h"
26 #include "sh4/sh4core.h"
27 #include "sh4/sh4mmio.h"
29 #include "sh4/sh4mmio.h"
31 /********************************* BSC *************************************/
33 uint32_t bsc_input = 0x0300;
35 uint16_t bsc_read_pdtra()
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);
48 if( ((output | (~output_mask)) & 0x03) == 3 ) {
54 return (bsc_input & input_mask) | output;
57 uint32_t bsc_read_pdtrb()
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);
69 return ((bsc_input>>16) & input_mask) | output;
73 MMIO_REGION_WRITE_DEFFN(BSC)
75 int32_t mmio_region_BSC_read( uint32_t reg )
80 val = bsc_read_pdtra();
83 val = bsc_read_pdtrb();
86 val = MMIO_READ( BSC, reg );
91 /********************************* UBC *************************************/
93 MMIO_REGION_STUBFNS( UBC )
96 /********************************** SCI *************************************/
98 MMIO_REGION_STUBFNS( SCI )
.