Search
lxdream.org :: lxdream/src/sh4/sh4mem.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4mem.c
changeset 939:6f2302afeb89
prev934:3acd3b3ee6d1
next945:787729653236
author nkeynes
date Sat Jan 03 03:30:26 2009 +0000 (12 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change MMU work-in-progress
* Move SDRAM out into separate sdram.c
* Move all page-table management into mmu.c
* Convert UTLB management to use the new page-tables
* Rip out all calls to mmu_vma_to_phys_* and replace with direct access
view annotate diff log raw
     1 /**
     2  * $Id$
     3  * 
     4  * This is a deprecated module that is not yet completely extricated from the
     5  * surrounding code.
     6  *
     7  * Copyright (c) 2005 Nathan Keynes.
     8  *
     9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  */
    20 #define MODULE sh4_module
    22 #include <string.h>
    23 #include <zlib.h>
    24 #include "dream.h"
    25 #include "mem.h"
    26 #include "mmio.h"
    27 #include "dreamcast.h"
    28 #include "sh4/sh4core.h"
    29 #include "sh4/sh4mmio.h"
    30 #include "sh4/xltcache.h"
    31 #include "pvr2/pvr2.h"
    33 /************** Obsolete methods ***************/
    35 int32_t FASTCALL sh4_read_long( sh4addr_t addr )
    36 {
    37     return sh4_address_space[addr>>12]->read_long(addr);
    38 }
    40 int32_t FASTCALL sh4_read_word( sh4addr_t addr )
    41 {
    42     return sh4_address_space[addr>>12]->read_word(addr);
    43 }
    45 int32_t FASTCALL sh4_read_byte( sh4addr_t addr )
    46 {
    47     return sh4_address_space[addr>>12]->read_byte(addr);
    48 }
    50 void FASTCALL sh4_write_long( sh4addr_t addr, uint32_t val )
    51 {
    52     sh4_address_space[addr>>12]->write_long(addr, val);
    53 }
    55 void FASTCALL sh4_write_word( sh4addr_t addr, uint32_t val )
    56 {
    57     sh4_address_space[addr>>12]->write_word(addr,val);
    58 }
    60 void FASTCALL sh4_write_byte( sh4addr_t addr, uint32_t val )
    61 {
    62     sh4_address_space[addr>>12]->write_byte(addr, val);
    63 }
    65 /* FIXME: Handle all the many special cases when the range doesn't fall cleanly
    66  * into the same memory block
    67  */
    68 void mem_copy_from_sh4( sh4ptr_t dest, sh4addr_t srcaddr, size_t count ) {
    69     if( srcaddr >= 0x04000000 && srcaddr < 0x05000000 ) {
    70         pvr2_vram64_read( dest, srcaddr, count );
    71     } else {
    72         sh4ptr_t src = mem_get_region(srcaddr);
    73         if( src == NULL ) {
    74             WARN( "Attempted block read from unknown address %08X", srcaddr );
    75         } else {
    76             memcpy( dest, src, count );
    77         }
    78     }
    79 }
    81 void mem_copy_to_sh4( sh4addr_t destaddr, sh4ptr_t src, size_t count ) {
    82     if( destaddr >= 0x10000000 && destaddr < 0x14000000 ) {
    83         pvr2_dma_write( destaddr, src, count );
    84         return;
    85     } else if( (destaddr & 0x1F800000) == 0x05000000 ) {
    86         pvr2_render_buffer_invalidate( destaddr, TRUE );
    87     } else if( (destaddr & 0x1F800000) == 0x04000000 ) {
    88         pvr2_vram64_write( destaddr, src, count );
    89         return;
    90     }
    91     sh4ptr_t dest = mem_get_region(destaddr);
    92     if( dest == NULL )
    93         WARN( "Attempted block write to unknown address %08X", destaddr );
    94     else {
    95         xlat_invalidate_block( destaddr, count );
    96         memcpy( dest, src, count );
    97     }
    98 }
.