Search
lxdream.org :: lxdream/src/sh4/sh4.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4.h
changeset 1065:bc1cc0c54917
prev1021:848db285a184
prev571:9bc09948d0f2
next1067:d3c00ffccfcd
author nkeynes
date Sun Jul 05 13:52:50 2009 +1000 (12 years ago)
permissions -rw-r--r--
last change No-op merge lxdream-mmu to remove head (actually merged long ago)
file annotate diff log raw
nkeynes@564
     1
/**
nkeynes@1021
     2
 * $Id$
nkeynes@564
     3
 * 
nkeynes@564
     4
 * This file defines the public functions and definitions exported by the SH4
nkeynes@564
     5
 * modules.
nkeynes@564
     6
 *
nkeynes@564
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@564
     8
 *
nkeynes@564
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@564
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@564
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@564
    12
 * (at your option) any later version.
nkeynes@564
    13
 *
nkeynes@564
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@564
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@564
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@564
    17
 * GNU General Public License for more details.
nkeynes@564
    18
 */
nkeynes@564
    19
nkeynes@564
    20
#ifndef lxdream_sh4_H
nkeynes@564
    21
#define lxdream_sh4_H 1
nkeynes@564
    22
nkeynes@564
    23
#include "lxdream.h"
nkeynes@566
    24
#include "mem.h"
nkeynes@564
    25
nkeynes@564
    26
#ifdef __cplusplus
nkeynes@564
    27
extern "C" {
nkeynes@564
    28
#endif
nkeynes@564
    29
nkeynes@564
    30
nkeynes@564
    31
/**
nkeynes@564
    32
 * SH4 is running normally 
nkeynes@564
    33
 */
nkeynes@564
    34
#define SH4_STATE_RUNNING 1
nkeynes@564
    35
/**
nkeynes@564
    36
 * SH4 is not executing instructions but all peripheral modules are still
nkeynes@564
    37
 * running
nkeynes@564
    38
 */
nkeynes@564
    39
#define SH4_STATE_SLEEP 2
nkeynes@564
    40
/**
nkeynes@564
    41
 * SH4 is not executing instructions, DMAC is halted, but all other peripheral
nkeynes@564
    42
 * modules are still running
nkeynes@564
    43
 */
nkeynes@564
    44
#define SH4_STATE_DEEP_SLEEP 3
nkeynes@564
    45
/**
nkeynes@564
    46
 * SH4 is not executing instructions and all peripheral modules are also
nkeynes@564
    47
 * stopped. As close as you can get to powered-off without actually being
nkeynes@564
    48
 * off.
nkeynes@564
    49
 */
nkeynes@564
    50
#define SH4_STATE_STANDBY 4
nkeynes@564
    51
nkeynes@564
    52
/**
nkeynes@564
    53
 * sh4r.event_types flag indicating a pending IRQ
nkeynes@564
    54
 */
nkeynes@564
    55
#define PENDING_IRQ 1
nkeynes@564
    56
nkeynes@564
    57
/**
nkeynes@564
    58
 * sh4r.event_types flag indicating a pending event (from the event queue)
nkeynes@564
    59
 */
nkeynes@564
    60
#define PENDING_EVENT 2
nkeynes@564
    61
nkeynes@564
    62
/**
nkeynes@564
    63
 * SH4 register structure
nkeynes@564
    64
 */
nkeynes@564
    65
struct sh4_registers {
nkeynes@564
    66
    uint32_t r[16];
nkeynes@903
    67
    uint32_t sr, pr, pc;
nkeynes@669
    68
    union {
nkeynes@736
    69
        int32_t i;
nkeynes@736
    70
        float f;
nkeynes@669
    71
    } fpul;
nkeynes@564
    72
    uint32_t t, m, q, s; /* really boolean - 0 or 1 */
nkeynes@904
    73
    float fr[2][16]; /* Must be aligned on 16-byte boundary */
nkeynes@903
    74
    uint32_t fpscr;
nkeynes@883
    75
    uint32_t pad; /* Pad up to 64-bit boundaries */
nkeynes@564
    76
    uint64_t mac;
nkeynes@564
    77
    uint32_t gbr, ssr, spc, sgr, dbr, vbr;
nkeynes@564
    78
nkeynes@564
    79
    uint32_t r_bank[8]; /* hidden banked registers */
nkeynes@564
    80
    int32_t store_queue[16]; /* technically 2 banks of 32 bytes */
nkeynes@736
    81
nkeynes@564
    82
    uint32_t new_pc; /* Not a real register, but used to handle delay slots */
nkeynes@564
    83
    uint32_t event_pending; /* slice cycle time of the next pending event, or FFFFFFFF
nkeynes@564
    84
                             when no events are pending */
nkeynes@564
    85
    uint32_t event_types; /* bit 0 = IRQ pending, bit 1 = general event pending */
nkeynes@564
    86
    int in_delay_slot; /* flag to indicate the current instruction is in
nkeynes@736
    87
     * a delay slot (certain rules apply) */
nkeynes@564
    88
    uint32_t slice_cycle; /* Current nanosecond within the timeslice */
nkeynes@958
    89
    uint32_t bus_cycle; /* Nanosecond within the timeslice that the bus will be free */
nkeynes@564
    90
    int sh4_state; /* Current power-on state (one of the SH4_STATE_* values ) */
nkeynes@953
    91
    
nkeynes@953
    92
    /* Not saved */
nkeynes@953
    93
    int xlat_sh4_mode; /* Collection of execution mode flags (derived) from fpscr, sr, etc */
nkeynes@564
    94
};
nkeynes@564
    95
nkeynes@564
    96
extern struct sh4_registers sh4r;
nkeynes@564
    97
nkeynes@998
    98
extern const struct cpu_desc_struct sh4_cpu_desc;
nkeynes@998
    99
nkeynes@564
   100
/**
nkeynes@564
   101
 * Switch between translation and emulation execution modes. Note that this
nkeynes@564
   102
 * should only be used while the system is stopped. If the system was built
nkeynes@564
   103
 * without translation support, this method has no effect.
nkeynes@564
   104
 *
nkeynes@564
   105
 * @param use TRUE for translation mode, FALSE for emulation mode.
nkeynes@564
   106
 */
nkeynes@740
   107
void sh4_translate_set_enabled( gboolean use );
nkeynes@564
   108
nkeynes@564
   109
/**
nkeynes@571
   110
 * Test if system is currently using the translation engine.
nkeynes@571
   111
 */
nkeynes@740
   112
gboolean sh4_translate_is_enabled();
nkeynes@571
   113
nkeynes@571
   114
/**
nkeynes@564
   115
 * Explicitly set the SH4 PC to the supplied value - this will be the next
nkeynes@564
   116
 * instruction executed. This should only be called while the system is stopped.
nkeynes@564
   117
 */
nkeynes@564
   118
void sh4_set_pc( int pc );
nkeynes@564
   119
nkeynes@564
   120
/**
nkeynes@564
   121
 * Execute (using the emulator) a single instruction (in other words, perform a
nkeynes@564
   122
 * single-step operation). 
nkeynes@564
   123
 */
nkeynes@564
   124
gboolean sh4_execute_instruction( void );
nkeynes@564
   125
nkeynes@564
   126
/* SH4 breakpoints */
nkeynes@566
   127
void sh4_set_breakpoint( uint32_t pc, breakpoint_type_t type );
nkeynes@566
   128
gboolean sh4_clear_breakpoint( uint32_t pc, breakpoint_type_t type );
nkeynes@564
   129
int sh4_get_breakpoint( uint32_t pc );
nkeynes@564
   130
nkeynes@564
   131
#ifdef __cplusplus
nkeynes@564
   132
}
nkeynes@564
   133
#endif
nkeynes@564
   134
#endif /* !lxdream_sh4_H */
.