Search
lxdream.org :: lxdream/src/sh4/sh4mmio.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4mmio.c
changeset 561:533f6b478071
prev550:a27e31340147
next736:a02d1475ccfd
author nkeynes
date Mon Jan 21 11:59:46 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Fix MAC.L/MAC.W stack issues
Fix various recovery-table issues
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 MMIO_REGION_STUBFNS( UBC )
    96 /********************************** SCI *************************************/
    98 MMIO_REGION_STUBFNS( SCI )
.