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)
file annotate diff log raw
nkeynes@10
     1
/**
nkeynes@586
     2
 * $Id$
nkeynes@939
     3
 * 
nkeynes@939
     4
 * This is a deprecated module that is not yet completely extricated from the
nkeynes@939
     5
 * surrounding code.
nkeynes@10
     6
 *
nkeynes@10
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@10
     8
 *
nkeynes@10
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@10
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@10
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@10
    12
 * (at your option) any later version.
nkeynes@10
    13
 *
nkeynes@10
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@10
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@10
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@10
    17
 * GNU General Public License for more details.
nkeynes@10
    18
 */
nkeynes@10
    19
nkeynes@35
    20
#define MODULE sh4_module
nkeynes@35
    21
nkeynes@10
    22
#include <string.h>
nkeynes@10
    23
#include <zlib.h>
nkeynes@10
    24
#include "dream.h"
nkeynes@10
    25
#include "mem.h"
nkeynes@10
    26
#include "mmio.h"
nkeynes@10
    27
#include "dreamcast.h"
nkeynes@422
    28
#include "sh4/sh4core.h"
nkeynes@422
    29
#include "sh4/sh4mmio.h"
nkeynes@945
    30
#include "sh4/mmu.h"
nkeynes@100
    31
#include "pvr2/pvr2.h"
nkeynes@991
    32
#include "xlat/xltcache.h"
nkeynes@10
    33
nkeynes@939
    34
/************** Obsolete methods ***************/
nkeynes@931
    35
nkeynes@10
    36
/* FIXME: Handle all the many special cases when the range doesn't fall cleanly
nkeynes@400
    37
 * into the same memory block
nkeynes@10
    38
 */
nkeynes@912
    39
void mem_copy_from_sh4( sh4ptr_t dest, sh4addr_t srcaddr, size_t count ) {
nkeynes@103
    40
    if( srcaddr >= 0x04000000 && srcaddr < 0x05000000 ) {
nkeynes@736
    41
        pvr2_vram64_read( dest, srcaddr, count );
nkeynes@103
    42
    } else {
nkeynes@736
    43
        sh4ptr_t src = mem_get_region(srcaddr);
nkeynes@736
    44
        if( src == NULL ) {
nkeynes@736
    45
            WARN( "Attempted block read from unknown address %08X", srcaddr );
nkeynes@736
    46
        } else {
nkeynes@736
    47
            memcpy( dest, src, count );
nkeynes@736
    48
        }
nkeynes@103
    49
    }
nkeynes@10
    50
}
nkeynes@10
    51
nkeynes@912
    52
void mem_copy_to_sh4( sh4addr_t destaddr, sh4ptr_t src, size_t count ) {
nkeynes@325
    53
    if( destaddr >= 0x10000000 && destaddr < 0x14000000 ) {
nkeynes@736
    54
        pvr2_dma_write( destaddr, src, count );
nkeynes@736
    55
        return;
nkeynes@325
    56
    } else if( (destaddr & 0x1F800000) == 0x05000000 ) {
nkeynes@736
    57
        pvr2_render_buffer_invalidate( destaddr, TRUE );
nkeynes@325
    58
    } else if( (destaddr & 0x1F800000) == 0x04000000 ) {
nkeynes@736
    59
        pvr2_vram64_write( destaddr, src, count );
nkeynes@736
    60
        return;
nkeynes@325
    61
    }
nkeynes@502
    62
    sh4ptr_t dest = mem_get_region(destaddr);
nkeynes@325
    63
    if( dest == NULL )
nkeynes@736
    64
        WARN( "Attempted block write to unknown address %08X", destaddr );
nkeynes@325
    65
    else {
nkeynes@736
    66
        xlat_invalidate_block( destaddr, count );
nkeynes@736
    67
        memcpy( dest, src, count );
nkeynes@90
    68
    }
nkeynes@10
    69
}
.