Search
lxdream.org :: lxdream/src/sh4/sh4mmio.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4mmio.c
changeset 830:73637b9624e4
prev736:a02d1475ccfd
next929:fd8cb0c82f5f
author nkeynes
date Thu Dec 11 23:26:03 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Disable the generational translation cache - I've got no evidence that it
actually helps performance, and it simplifies things to get rid of it (in
particular, translated code doesn't have to worry about being moved now).
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 int32_t mmio_region_BSC_read( uint32_t reg )
    76 {
    77     int32_t val;
    78     switch( reg ) {
    79     case PDTRA:
    80         val = bsc_read_pdtra();
    81         break;
    82     case PDTRB:
    83         val = bsc_read_pdtrb();
    84         break;
    85     default:
    86         val = MMIO_READ( BSC, reg );
    87     }
    88     return val;
    89 }
    91 /********************************* UBC *************************************/
    93 int32_t mmio_region_UBC_read( uint32_t reg )
    94 {
    95     return MMIO_READ( UBC, reg );
    96 }
    98 void mmio_region_UBC_write( uint32_t reg, uint32_t val )
    99 {
   100     switch( reg ) {
   101     case BAMRA:
   102     case BAMRB:
   103         val &= 0x0F;
   104         break;
   105     case BBRA:
   106     case BBRB:
   107         val &= 0x07F;
   108         if( val != 0 ) { 
   109             WARN( "UBC not implemented" );
   110         }
   111         break;
   112     case BRCR:
   113         val &= 0xC4C9;
   114         break;
   115     }
   116     MMIO_WRITE( UBC, reg, val );
   117 }
   120 /********************************** SCI *************************************/
   122 MMIO_REGION_STUBFNS( SCI )
.