Search
lxdream.org :: lxdream/src/sh4/sh4.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4.h
changeset 586:2a3ba82cf243
next669:ab344e42bca9
author nkeynes
date Tue Jan 15 20:50:23 2008 +0000 (14 years ago)
permissions -rw-r--r--
last change Merged lxdream-mmu r570:596 to trunk
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/sh4/sh4.h Tue Jan 15 20:50:23 2008 +0000
1.3 @@ -0,0 +1,124 @@
1.4 +/**
1.5 + * $Id: sh4.h 577 2008-01-01 05:08:38Z nkeynes $
1.6 + *
1.7 + * This file defines the public functions and definitions exported by the SH4
1.8 + * modules.
1.9 + *
1.10 + * Copyright (c) 2005 Nathan Keynes.
1.11 + *
1.12 + * This program is free software; you can redistribute it and/or modify
1.13 + * it under the terms of the GNU General Public License as published by
1.14 + * the Free Software Foundation; either version 2 of the License, or
1.15 + * (at your option) any later version.
1.16 + *
1.17 + * This program is distributed in the hope that it will be useful,
1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.20 + * GNU General Public License for more details.
1.21 + */
1.22 +
1.23 +#ifndef lxdream_sh4_H
1.24 +#define lxdream_sh4_H 1
1.25 +
1.26 +#include "lxdream.h"
1.27 +#include "mem.h"
1.28 +
1.29 +#ifdef __cplusplus
1.30 +extern "C" {
1.31 +#endif
1.32 +
1.33 +
1.34 +/**
1.35 + * SH4 is running normally
1.36 + */
1.37 +#define SH4_STATE_RUNNING 1
1.38 +/**
1.39 + * SH4 is not executing instructions but all peripheral modules are still
1.40 + * running
1.41 + */
1.42 +#define SH4_STATE_SLEEP 2
1.43 +/**
1.44 + * SH4 is not executing instructions, DMAC is halted, but all other peripheral
1.45 + * modules are still running
1.46 + */
1.47 +#define SH4_STATE_DEEP_SLEEP 3
1.48 +/**
1.49 + * SH4 is not executing instructions and all peripheral modules are also
1.50 + * stopped. As close as you can get to powered-off without actually being
1.51 + * off.
1.52 + */
1.53 +#define SH4_STATE_STANDBY 4
1.54 +
1.55 +/**
1.56 + * sh4r.event_types flag indicating a pending IRQ
1.57 + */
1.58 +#define PENDING_IRQ 1
1.59 +
1.60 +/**
1.61 + * sh4r.event_types flag indicating a pending event (from the event queue)
1.62 + */
1.63 +#define PENDING_EVENT 2
1.64 +
1.65 +/**
1.66 + * SH4 register structure
1.67 + */
1.68 +struct sh4_registers {
1.69 + uint32_t r[16];
1.70 + uint32_t sr, pr, pc, fpscr;
1.71 + uint32_t t, m, q, s; /* really boolean - 0 or 1 */
1.72 + int32_t fpul;
1.73 + float *fr_bank;
1.74 + float fr[2][16];
1.75 + uint64_t mac;
1.76 + uint32_t gbr, ssr, spc, sgr, dbr, vbr;
1.77 +
1.78 + uint32_t r_bank[8]; /* hidden banked registers */
1.79 + int32_t store_queue[16]; /* technically 2 banks of 32 bytes */
1.80 +
1.81 + uint32_t new_pc; /* Not a real register, but used to handle delay slots */
1.82 + uint32_t event_pending; /* slice cycle time of the next pending event, or FFFFFFFF
1.83 + when no events are pending */
1.84 + uint32_t event_types; /* bit 0 = IRQ pending, bit 1 = general event pending */
1.85 + int in_delay_slot; /* flag to indicate the current instruction is in
1.86 + * a delay slot (certain rules apply) */
1.87 + uint32_t slice_cycle; /* Current nanosecond within the timeslice */
1.88 + int sh4_state; /* Current power-on state (one of the SH4_STATE_* values ) */
1.89 +};
1.90 +
1.91 +extern struct sh4_registers sh4r;
1.92 +
1.93 +/**
1.94 + * Switch between translation and emulation execution modes. Note that this
1.95 + * should only be used while the system is stopped. If the system was built
1.96 + * without translation support, this method has no effect.
1.97 + *
1.98 + * @param use TRUE for translation mode, FALSE for emulation mode.
1.99 + */
1.100 +void sh4_set_use_xlat( gboolean use );
1.101 +
1.102 +/**
1.103 + * Test if system is currently using the translation engine.
1.104 + */
1.105 +gboolean sh4_is_using_xlat();
1.106 +
1.107 +/**
1.108 + * Explicitly set the SH4 PC to the supplied value - this will be the next
1.109 + * instruction executed. This should only be called while the system is stopped.
1.110 + */
1.111 +void sh4_set_pc( int pc );
1.112 +
1.113 +/**
1.114 + * Execute (using the emulator) a single instruction (in other words, perform a
1.115 + * single-step operation).
1.116 + */
1.117 +gboolean sh4_execute_instruction( void );
1.118 +
1.119 +/* SH4 breakpoints */
1.120 +void sh4_set_breakpoint( uint32_t pc, breakpoint_type_t type );
1.121 +gboolean sh4_clear_breakpoint( uint32_t pc, breakpoint_type_t type );
1.122 +int sh4_get_breakpoint( uint32_t pc );
1.123 +
1.124 +#ifdef __cplusplus
1.125 +}
1.126 +#endif
1.127 +#endif /* !lxdream_sh4_H */
.