Search
lxdream.org :: lxdream/src/sh4/sh4mem.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4mem.c
changeset 1067:d3c00ffccfcd
prev1065:bc1cc0c54917
prev945:787729653236
author nkeynes
date Sun Jul 05 13:54:48 2009 +1000 (10 years ago)
permissions -rw-r--r--
last change No-op merge lxdream-mem to tip to remove head (Long since merged in
actuality)
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/mmu.h"
    31 #include "pvr2/pvr2.h"
    32 #include "xlat/xltcache.h"
    34 /************** Obsolete methods ***************/
    36 /* FIXME: Handle all the many special cases when the range doesn't fall cleanly
    37  * into the same memory block
    38  */
    39 void mem_copy_from_sh4( sh4ptr_t dest, sh4addr_t srcaddr, size_t count ) {
    40     if( srcaddr >= 0x04000000 && srcaddr < 0x05000000 ) {
    41         pvr2_vram64_read( dest, srcaddr, count );
    42     } else {
    43         sh4ptr_t src = mem_get_region(srcaddr);
    44         if( src == NULL ) {
    45             WARN( "Attempted block read from unknown address %08X", srcaddr );
    46         } else {
    47             memcpy( dest, src, count );
    48         }
    49     }
    50 }
    52 void mem_copy_to_sh4( sh4addr_t destaddr, sh4ptr_t src, size_t count ) {
    53     if( destaddr >= 0x10000000 && destaddr < 0x14000000 ) {
    54         pvr2_dma_write( destaddr, src, count );
    55         return;
    56     } else if( (destaddr & 0x1F800000) == 0x05000000 ) {
    57         pvr2_render_buffer_invalidate( destaddr, TRUE );
    58     } else if( (destaddr & 0x1F800000) == 0x04000000 ) {
    59         pvr2_vram64_write( destaddr, src, count );
    60         return;
    61     }
    62     sh4ptr_t dest = mem_get_region(destaddr);
    63     if( dest == NULL )
    64         WARN( "Attempted block write to unknown address %08X", destaddr );
    65     else {
    66         xlat_invalidate_block( destaddr, count );
    67         memcpy( dest, src, count );
    68     }
    69 }
.