Search
lxdream.org :: lxdream/src/sh4/sh4.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4.h
changeset 564:dc7b5ffb0535
next566:59be465e5f01
author nkeynes
date Tue Jan 01 08:37:26 2008 +0000 (12 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change Refactor sh4core.h to extract the "public" material into a new sh4.h
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 01 08:37:26 2008 +0000
1.3 @@ -0,0 +1,125 @@
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 +
1.28 +#ifdef __cplusplus
1.29 +extern "C" {
1.30 +#endif
1.31 +
1.32 +
1.33 +/**
1.34 + * SH4 is running normally
1.35 + */
1.36 +#define SH4_STATE_RUNNING 1
1.37 +/**
1.38 + * SH4 is not executing instructions but all peripheral modules are still
1.39 + * running
1.40 + */
1.41 +#define SH4_STATE_SLEEP 2
1.42 +/**
1.43 + * SH4 is not executing instructions, DMAC is halted, but all other peripheral
1.44 + * modules are still running
1.45 + */
1.46 +#define SH4_STATE_DEEP_SLEEP 3
1.47 +/**
1.48 + * SH4 is not executing instructions and all peripheral modules are also
1.49 + * stopped. As close as you can get to powered-off without actually being
1.50 + * off.
1.51 + */
1.52 +#define SH4_STATE_STANDBY 4
1.53 +
1.54 +/**
1.55 + * sh4r.event_types flag indicating a pending IRQ
1.56 + */
1.57 +#define PENDING_IRQ 1
1.58 +
1.59 +/**
1.60 + * sh4r.event_types flag indicating a pending event (from the event queue)
1.61 + */
1.62 +#define PENDING_EVENT 2
1.63 +
1.64 +/**
1.65 + * SH4 register structure
1.66 + */
1.67 +struct sh4_registers {
1.68 + uint32_t r[16];
1.69 + uint32_t sr, pr, pc, fpscr;
1.70 + uint32_t t, m, q, s; /* really boolean - 0 or 1 */
1.71 + int32_t fpul;
1.72 + float *fr_bank;
1.73 + float fr[2][16];
1.74 + uint64_t mac;
1.75 + uint32_t gbr, ssr, spc, sgr, dbr, vbr;
1.76 +
1.77 + uint32_t r_bank[8]; /* hidden banked registers */
1.78 + int32_t store_queue[16]; /* technically 2 banks of 32 bytes */
1.79 +
1.80 + uint32_t new_pc; /* Not a real register, but used to handle delay slots */
1.81 + uint32_t event_pending; /* slice cycle time of the next pending event, or FFFFFFFF
1.82 + when no events are pending */
1.83 + uint32_t event_types; /* bit 0 = IRQ pending, bit 1 = general event pending */
1.84 + int in_delay_slot; /* flag to indicate the current instruction is in
1.85 + * a delay slot (certain rules apply) */
1.86 + uint32_t slice_cycle; /* Current nanosecond within the timeslice */
1.87 + int sh4_state; /* Current power-on state (one of the SH4_STATE_* values ) */
1.88 +};
1.89 +
1.90 +extern struct sh4_registers sh4r;
1.91 +
1.92 +/**
1.93 + * Switch between translation and emulation execution modes. Note that this
1.94 + * should only be used while the system is stopped. If the system was built
1.95 + * without translation support, this method has no effect.
1.96 + *
1.97 + * @param use TRUE for translation mode, FALSE for emulation mode.
1.98 + */
1.99 +void sh4_set_use_xlat( gboolean use );
1.100 +
1.101 +/**
1.102 + * Explicitly set the SH4 PC to the supplied value - this will be the next
1.103 + * instruction executed. This should only be called while the system is stopped.
1.104 + */
1.105 +void sh4_set_pc( int pc );
1.106 +
1.107 +/**
1.108 + * Execute (using the emulator) a single instruction (in other words, perform a
1.109 + * single-step operation).
1.110 + */
1.111 +gboolean sh4_execute_instruction( void );
1.112 +
1.113 +/* SH4 breakpoints */
1.114 +
1.115 +#define BREAK_ONESHOT 1
1.116 +#define BREAK_PERM 2
1.117 +
1.118 +void sh4_set_breakpoint( uint32_t pc, int type );
1.119 +gboolean sh4_clear_breakpoint( uint32_t pc, int type );
1.120 +int sh4_get_breakpoint( uint32_t pc );
1.121 +
1.122 +
1.123 +
1.124 +
1.125 +#ifdef __cplusplus
1.126 +}
1.127 +#endif
1.128 +#endif /* !lxdream_sh4_H */
.