Search
lxdream.org :: lxdream/src/sh4/xltcache.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/xltcache.h
changeset 366:6fb0d05152d7
prev359:c588dce7ebde
next376:8c7587af5a5d
author nkeynes
date Tue Sep 04 08:32:44 2007 +0000 (14 years ago)
permissions -rw-r--r--
last change Add method to retrieve the size of a block, given the code pointer (useful
for eg disassembling the block)
file annotate diff log raw
nkeynes@359
     1
/**
nkeynes@366
     2
 * $Id: xltcache.h,v 1.2 2007-09-04 08:32:44 nkeynes Exp $
nkeynes@359
     3
 * 
nkeynes@359
     4
 * Translation cache support (architecture independent)
nkeynes@359
     5
 *
nkeynes@359
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@359
     7
 *
nkeynes@359
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@359
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@359
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@359
    11
 * (at your option) any later version.
nkeynes@359
    12
 *
nkeynes@359
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@359
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@359
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@359
    16
 * GNU General Public License for more details.
nkeynes@359
    17
 */
nkeynes@359
    18
nkeynes@359
    19
#include "dream.h"
nkeynes@359
    20
#include "mem.h"
nkeynes@359
    21
nkeynes@359
    22
typedef struct xlat_cache_block {
nkeynes@359
    23
    int active;  /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */
nkeynes@359
    24
    uint32_t size;
nkeynes@359
    25
    void **lut_entry; /* For deletion */
nkeynes@359
    26
    unsigned char code[0];
nkeynes@359
    27
} *xlat_cache_block_t;
nkeynes@359
    28
nkeynes@359
    29
/**
nkeynes@359
    30
 * Returns the next block in the new cache list that can be written to by the
nkeynes@359
    31
 * translator.
nkeynes@359
    32
 */
nkeynes@359
    33
xlat_cache_block_t xlat_start_block(sh4addr_t address);
nkeynes@359
    34
nkeynes@359
    35
/**
nkeynes@359
    36
 * Increases the current block size (only valid between calls to xlat_start_block()
nkeynes@359
    37
 * and xlat_commit_block()). 
nkeynes@359
    38
 * @return the new block, which may be different from the old block.
nkeynes@359
    39
 */
nkeynes@359
    40
xlat_cache_block_t xlat_extend_block();
nkeynes@359
    41
nkeynes@359
    42
/**
nkeynes@359
    43
 * Commit the current translation block
nkeynes@359
    44
 * @param addr target address (for the lookup table)
nkeynes@359
    45
 * @param destsize final size of the translation in bytes.
nkeynes@359
    46
 * @param srcsize size of the original data that was translated in bytes
nkeynes@359
    47
 */
nkeynes@359
    48
void xlat_commit_block( uint32_t destsize, uint32_t srcsize );
nkeynes@359
    49
nkeynes@359
    50
/**
nkeynes@359
    51
 * Delete (deactivate) the specified block from the cache. Caller is responsible
nkeynes@359
    52
 * for ensuring that there really is a block there.
nkeynes@359
    53
 */
nkeynes@359
    54
void xlat_delete_block( xlat_cache_block_t block );
nkeynes@359
    55
nkeynes@359
    56
/**
nkeynes@359
    57
 * Retrieve the entry point for the translated code corresponding to the given
nkeynes@359
    58
 * SH4 address, or NULL if there is no code for that address.
nkeynes@359
    59
 */
nkeynes@359
    60
void *xlat_get_code( sh4addr_t address );
nkeynes@359
    61
nkeynes@359
    62
/**
nkeynes@366
    63
 * Retrieve the size of the code block starting at the specified pointer. If the
nkeynes@366
    64
 * pointer is not a valid code block, the return value is undefined.
nkeynes@366
    65
 */
nkeynes@366
    66
uint32_t xlat_get_block_size( void *ptr );
nkeynes@366
    67
nkeynes@366
    68
/**
nkeynes@359
    69
 * Flush the code cache for the page containing the given address
nkeynes@359
    70
 */
nkeynes@359
    71
void xlat_flush_page( sh4addr_t address );
nkeynes@359
    72
nkeynes@359
    73
/**
nkeynes@359
    74
 * Flush the entire code cache. This isn't as cheap as one might like
nkeynes@359
    75
 */
nkeynes@359
    76
void xlat_flush_cache();
nkeynes@359
    77
nkeynes@359
    78
/**
nkeynes@359
    79
 * Check the internal integrity of the cache
nkeynes@359
    80
 */
nkeynes@359
    81
void xlat_check_integrity();
.