Search
lxdream.org :: lxdream/src/sh4/sh4.h
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 (13 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change Refactor sh4core.h to extract the "public" material into a new sh4.h
view annotate diff log raw
     1 /**
     2  * $Id: sh4.h 577 2008-01-01 05:08:38Z nkeynes $
     3  * 
     4  * This file defines the public functions and definitions exported by the SH4
     5  * modules.
     6  *
     7  * Copyright (c) 2005 Nathan Keynes.
     8  *
     9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  */
    20 #ifndef lxdream_sh4_H
    21 #define lxdream_sh4_H 1
    23 #include "lxdream.h"
    25 #ifdef __cplusplus
    26 extern "C" {
    27 #endif
    30 /**
    31  * SH4 is running normally 
    32  */
    33 #define SH4_STATE_RUNNING 1
    34 /**
    35  * SH4 is not executing instructions but all peripheral modules are still
    36  * running
    37  */
    38 #define SH4_STATE_SLEEP 2
    39 /**
    40  * SH4 is not executing instructions, DMAC is halted, but all other peripheral
    41  * modules are still running
    42  */
    43 #define SH4_STATE_DEEP_SLEEP 3
    44 /**
    45  * SH4 is not executing instructions and all peripheral modules are also
    46  * stopped. As close as you can get to powered-off without actually being
    47  * off.
    48  */
    49 #define SH4_STATE_STANDBY 4
    51 /**
    52  * sh4r.event_types flag indicating a pending IRQ
    53  */
    54 #define PENDING_IRQ 1
    56 /**
    57  * sh4r.event_types flag indicating a pending event (from the event queue)
    58  */
    59 #define PENDING_EVENT 2
    61 /**
    62  * SH4 register structure
    63  */
    64 struct sh4_registers {
    65     uint32_t r[16];
    66     uint32_t sr, pr, pc, fpscr;
    67     uint32_t t, m, q, s; /* really boolean - 0 or 1 */
    68     int32_t fpul;
    69     float *fr_bank;
    70     float fr[2][16];
    71     uint64_t mac;
    72     uint32_t gbr, ssr, spc, sgr, dbr, vbr;
    74     uint32_t r_bank[8]; /* hidden banked registers */
    75     int32_t store_queue[16]; /* technically 2 banks of 32 bytes */
    77     uint32_t new_pc; /* Not a real register, but used to handle delay slots */
    78     uint32_t event_pending; /* slice cycle time of the next pending event, or FFFFFFFF
    79                              when no events are pending */
    80     uint32_t event_types; /* bit 0 = IRQ pending, bit 1 = general event pending */
    81     int in_delay_slot; /* flag to indicate the current instruction is in
    82                              * a delay slot (certain rules apply) */
    83     uint32_t slice_cycle; /* Current nanosecond within the timeslice */
    84     int sh4_state; /* Current power-on state (one of the SH4_STATE_* values ) */
    85 };
    87 extern struct sh4_registers sh4r;
    89 /**
    90  * Switch between translation and emulation execution modes. Note that this
    91  * should only be used while the system is stopped. If the system was built
    92  * without translation support, this method has no effect.
    93  *
    94  * @param use TRUE for translation mode, FALSE for emulation mode.
    95  */
    96 void sh4_set_use_xlat( gboolean use );
    98 /**
    99  * Explicitly set the SH4 PC to the supplied value - this will be the next
   100  * instruction executed. This should only be called while the system is stopped.
   101  */
   102 void sh4_set_pc( int pc );
   104 /**
   105  * Execute (using the emulator) a single instruction (in other words, perform a
   106  * single-step operation). 
   107  */
   108 gboolean sh4_execute_instruction( void );
   110 /* SH4 breakpoints */
   112 #define BREAK_ONESHOT 1
   113 #define BREAK_PERM 2
   115 void sh4_set_breakpoint( uint32_t pc, int type );
   116 gboolean sh4_clear_breakpoint( uint32_t pc, int type );
   117 int sh4_get_breakpoint( uint32_t pc );
   122 #ifdef __cplusplus
   123 }
   124 #endif
   125 #endif /* !lxdream_sh4_H */
.