nkeynes@564: /** nkeynes@564: * $Id: sh4.h 577 2008-01-01 05:08:38Z nkeynes $ nkeynes@564: * nkeynes@564: * This file defines the public functions and definitions exported by the SH4 nkeynes@564: * modules. nkeynes@564: * nkeynes@564: * Copyright (c) 2005 Nathan Keynes. nkeynes@564: * nkeynes@564: * This program is free software; you can redistribute it and/or modify nkeynes@564: * it under the terms of the GNU General Public License as published by nkeynes@564: * the Free Software Foundation; either version 2 of the License, or nkeynes@564: * (at your option) any later version. nkeynes@564: * nkeynes@564: * This program is distributed in the hope that it will be useful, nkeynes@564: * but WITHOUT ANY WARRANTY; without even the implied warranty of nkeynes@564: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nkeynes@564: * GNU General Public License for more details. nkeynes@564: */ nkeynes@564: nkeynes@564: #ifndef lxdream_sh4_H nkeynes@564: #define lxdream_sh4_H 1 nkeynes@564: nkeynes@564: #include "lxdream.h" nkeynes@564: nkeynes@564: #ifdef __cplusplus nkeynes@564: extern "C" { nkeynes@564: #endif nkeynes@564: nkeynes@564: nkeynes@564: /** nkeynes@564: * SH4 is running normally nkeynes@564: */ nkeynes@564: #define SH4_STATE_RUNNING 1 nkeynes@564: /** nkeynes@564: * SH4 is not executing instructions but all peripheral modules are still nkeynes@564: * running nkeynes@564: */ nkeynes@564: #define SH4_STATE_SLEEP 2 nkeynes@564: /** nkeynes@564: * SH4 is not executing instructions, DMAC is halted, but all other peripheral nkeynes@564: * modules are still running nkeynes@564: */ nkeynes@564: #define SH4_STATE_DEEP_SLEEP 3 nkeynes@564: /** nkeynes@564: * SH4 is not executing instructions and all peripheral modules are also nkeynes@564: * stopped. As close as you can get to powered-off without actually being nkeynes@564: * off. nkeynes@564: */ nkeynes@564: #define SH4_STATE_STANDBY 4 nkeynes@564: nkeynes@564: /** nkeynes@564: * sh4r.event_types flag indicating a pending IRQ nkeynes@564: */ nkeynes@564: #define PENDING_IRQ 1 nkeynes@564: nkeynes@564: /** nkeynes@564: * sh4r.event_types flag indicating a pending event (from the event queue) nkeynes@564: */ nkeynes@564: #define PENDING_EVENT 2 nkeynes@564: nkeynes@564: /** nkeynes@564: * SH4 register structure nkeynes@564: */ nkeynes@564: struct sh4_registers { nkeynes@564: uint32_t r[16]; nkeynes@564: uint32_t sr, pr, pc, fpscr; nkeynes@564: uint32_t t, m, q, s; /* really boolean - 0 or 1 */ nkeynes@564: int32_t fpul; nkeynes@564: float *fr_bank; nkeynes@564: float fr[2][16]; nkeynes@564: uint64_t mac; nkeynes@564: uint32_t gbr, ssr, spc, sgr, dbr, vbr; nkeynes@564: nkeynes@564: uint32_t r_bank[8]; /* hidden banked registers */ nkeynes@564: int32_t store_queue[16]; /* technically 2 banks of 32 bytes */ nkeynes@564: nkeynes@564: uint32_t new_pc; /* Not a real register, but used to handle delay slots */ nkeynes@564: uint32_t event_pending; /* slice cycle time of the next pending event, or FFFFFFFF nkeynes@564: when no events are pending */ nkeynes@564: uint32_t event_types; /* bit 0 = IRQ pending, bit 1 = general event pending */ nkeynes@564: int in_delay_slot; /* flag to indicate the current instruction is in nkeynes@564: * a delay slot (certain rules apply) */ nkeynes@564: uint32_t slice_cycle; /* Current nanosecond within the timeslice */ nkeynes@564: int sh4_state; /* Current power-on state (one of the SH4_STATE_* values ) */ nkeynes@564: }; nkeynes@564: nkeynes@564: extern struct sh4_registers sh4r; nkeynes@564: nkeynes@564: /** nkeynes@564: * Switch between translation and emulation execution modes. Note that this nkeynes@564: * should only be used while the system is stopped. If the system was built nkeynes@564: * without translation support, this method has no effect. nkeynes@564: * nkeynes@564: * @param use TRUE for translation mode, FALSE for emulation mode. nkeynes@564: */ nkeynes@564: void sh4_set_use_xlat( gboolean use ); nkeynes@564: nkeynes@564: /** nkeynes@564: * Explicitly set the SH4 PC to the supplied value - this will be the next nkeynes@564: * instruction executed. This should only be called while the system is stopped. nkeynes@564: */ nkeynes@564: void sh4_set_pc( int pc ); nkeynes@564: nkeynes@564: /** nkeynes@564: * Execute (using the emulator) a single instruction (in other words, perform a nkeynes@564: * single-step operation). nkeynes@564: */ nkeynes@564: gboolean sh4_execute_instruction( void ); nkeynes@564: nkeynes@564: /* SH4 breakpoints */ nkeynes@564: nkeynes@564: #define BREAK_ONESHOT 1 nkeynes@564: #define BREAK_PERM 2 nkeynes@564: nkeynes@564: void sh4_set_breakpoint( uint32_t pc, int type ); nkeynes@564: gboolean sh4_clear_breakpoint( uint32_t pc, int type ); nkeynes@564: int sh4_get_breakpoint( uint32_t pc ); nkeynes@564: nkeynes@564: nkeynes@564: nkeynes@564: nkeynes@564: #ifdef __cplusplus nkeynes@564: } nkeynes@564: #endif nkeynes@564: #endif /* !lxdream_sh4_H */