revision 35:21a4be098304
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 35:21a4be098304 |
parent | 34:1dee8eb0b25e |
child | 36:f581f9c43c43 |
author | nkeynes |
date | Mon Dec 26 03:54:55 2005 +0000 (18 years ago) |
Remove modules.h - move definitions into dream.h
Add source string to output list (taken from module name)
ARM Work in progress
Add source string to output list (taken from module name)
ARM Work in progress
src/aica/aica.c | view | annotate | diff | log | ||
src/aica/armcore.c | view | annotate | diff | log | ||
src/aica/armcore.h | view | annotate | diff | log | ||
src/asic.c | view | annotate | diff | log | ||
src/bootstrap.c | view | annotate | diff | log | ||
src/dream.h | view | annotate | diff | log | ||
src/dreamcast.c | view | annotate | diff | log | ||
src/gdrom/ide.c | view | annotate | diff | log | ||
src/gui/debug_win.c | view | annotate | diff | log | ||
src/gui/gui.h | view | annotate | diff | log | ||
src/gui/interface.c | view | annotate | diff | log | ||
src/main.c | view | annotate | diff | log | ||
src/maple/maple.c | view | annotate | diff | log | ||
src/mem.c | view | annotate | diff | log | ||
src/modules.h | view | annotate | diff | log | ||
src/pvr2/pvr2.c | view | annotate | diff | log | ||
src/sh4/scif.c | view | annotate | diff | log | ||
src/sh4/sh4core.c | view | annotate | diff | log | ||
src/sh4/sh4mem.c | view | annotate | diff | log | ||
src/sh4/sh4mmio.c | view | annotate | diff | log | ||
src/util.c | view | annotate | diff | log |
1.1 --- a/src/aica/aica.c Mon Dec 26 03:11:14 2005 +00001.2 +++ b/src/aica/aica.c Mon Dec 26 03:54:55 2005 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: aica.c,v 1.5 2005-12-25 05:57:00 nkeynes Exp $1.6 + * $Id: aica.c,v 1.6 2005-12-26 03:54:55 nkeynes Exp $1.7 *1.8 * This is the core sound system (ie the bit which does the actual work)1.9 *1.10 @@ -16,8 +16,9 @@1.11 * GNU General Public License for more details.1.12 */1.14 +#define MODULE aica_module1.15 +1.16 #include "dream.h"1.17 -#include "modules.h"1.18 #include "mem.h"1.19 #include "aica.h"1.20 #define MMIO_IMPL1.21 @@ -31,12 +32,14 @@1.22 void aica_reset( void );1.23 void aica_start( void );1.24 void aica_stop( void );1.25 +void aica_save_state( FILE *f );1.26 +int aica_load_state( FILE *f );1.27 uint32_t aica_run_slice( uint32_t );1.30 struct dreamcast_module aica_module = { "AICA", aica_init, aica_reset,1.31 aica_start, aica_run_slice, aica_stop,1.32 - NULL, NULL, NULL };1.33 + aica_save_state, aica_load_state };1.35 /**1.36 * Initialize the AICA subsystem. Note requires that1.37 @@ -51,7 +54,7 @@1.39 void aica_reset( void )1.40 {1.41 -1.42 + arm_reset();1.43 }1.45 void aica_start( void )1.46 @@ -62,6 +65,11 @@1.47 uint32_t aica_run_slice( uint32_t nanosecs )1.48 {1.49 /* Run arm instructions */1.50 + int reset = MMIO_READ( AICA2, AICA_RESET );1.51 + if( reset & 1 == 0 ) {1.52 + /* Running */1.53 + /* nanosecs = arm_run_slice( nanosecs ); */1.54 + }1.55 /* Generate audio buffer */1.56 }1.58 @@ -70,6 +78,16 @@1.60 }1.62 +void aica_save_state( FILE *f )1.63 +{1.64 + arm_save_state( f );1.65 +}1.66 +1.67 +int aica_load_state( FILE *f )1.68 +{1.69 + return arm_load_state( f );1.70 +}1.71 +1.72 /** Channel register structure:1.73 * 001.74 * 041.75 @@ -94,6 +112,7 @@1.76 void mmio_region_AICA0_write( uint32_t reg, uint32_t val )1.77 {1.78 // aica_write_channel( reg >> 7, reg % 128, val );1.79 + MMIO_WRITE( AICA0, reg, val );1.81 }1.83 @@ -101,11 +120,25 @@1.84 void mmio_region_AICA1_write( uint32_t reg, uint32_t val )1.85 {1.86 // aica_write_channel( (reg >> 7) + 32, reg % 128, val );1.87 -1.88 + MMIO_WRITE( AICA1, reg, val );1.89 }1.91 /* General registers */1.92 void mmio_region_AICA2_write( uint32_t reg, uint32_t val )1.93 {1.94 -1.95 + uint32_t tmp;1.96 + switch( reg ) {1.97 + case AICA_RESET:1.98 + tmp = MMIO_READ( AICA2, AICA_RESET );1.99 + if( tmp & 1 == 1 && val & 1 == 0 ) {1.100 + /* ARM enabled - execute a core reset */1.101 + INFO( "ARM enabled" );1.102 + arm_reset();1.103 + }1.104 + MMIO_WRITE( AICA2, AICA_RESET, val );1.105 + break;1.106 + default:1.107 + MMIO_WRITE( AICA2, reg, val );1.108 + break;1.109 + }1.110 }
2.1 --- a/src/aica/armcore.c Mon Dec 26 03:11:14 2005 +00002.2 +++ b/src/aica/armcore.c Mon Dec 26 03:54:55 2005 +00002.3 @@ -1,5 +1,5 @@2.4 /**2.5 - * $Id: armcore.c,v 1.5 2005-12-25 05:57:00 nkeynes Exp $2.6 + * $Id: armcore.c,v 1.6 2005-12-26 03:54:55 nkeynes Exp $2.7 *2.8 * ARM7TDMI CPU emulation core.2.9 *2.10 @@ -20,7 +20,194 @@2.12 struct arm_registers armr;2.14 -/* NB: The arm has a different memory map, but for the meantime... */2.15 +void arm_set_mode( int mode );2.16 +2.17 +uint32_t arm_exceptions[][2] = {{ MODE_SVC, 0x00000000 },2.18 + { MODE_UND, 0x00000004 },2.19 + { MODE_SVC, 0x00000008 },2.20 + { MODE_ABT, 0x0000000C },2.21 + { MODE_ABT, 0x00000010 },2.22 + { MODE_IRQ, 0x00000018 },2.23 + { MODE_FIQ, 0x0000001C } };2.24 +2.25 +#define EXC_RESET 02.26 +#define EXC_UNDEFINED 12.27 +#define EXC_SOFTWARE 22.28 +#define EXC_PREFETCH_ABORT 32.29 +#define EXC_DATA_ABORT 42.30 +#define EXC_IRQ 52.31 +#define EXC_FAST_IRQ 62.32 +2.33 +uint32_t arm_cpu_freq = ARM_BASE_RATE;2.34 +uint32_t arm_cpu_period = 1000 / ARM_BASE_RATE;2.35 +2.36 +uint32_t arm_run_slice( uint32_t nanosecs )2.37 +{2.38 + uint32_t target = armr.icount + nanosecs / arm_cpu_period;2.39 + uint32_t start = armr.icount;2.40 + while( armr.icount < target ) {2.41 + armr.icount++;2.42 + if( !arm_execute_instruction() )2.43 + break;2.44 + }2.45 +2.46 + if( target != armr.icount ) {2.47 + /* Halted - compute time actually executed */2.48 + nanosecs = (armr.icount - start) * arm_cpu_period;2.49 + }2.50 + return nanosecs;2.51 +}2.52 +2.53 +void arm_save_state( FILE *f )2.54 +{2.55 + fwrite( &armr, sizeof(armr), 1, f );2.56 +}2.57 +2.58 +int arm_load_state( FILE *f )2.59 +{2.60 + fread( &armr, sizeof(armr), 1, f );2.61 + return 0;2.62 +}2.63 +2.64 +/* Exceptions */2.65 +void arm_reset( void )2.66 +{2.67 + /* Wipe all processor state */2.68 + memset( &armr, 0, sizeof(armr) );2.69 +2.70 + armr.cpsr = MODE_SVC | CPSR_I | CPSR_F;2.71 + armr.r[15] = 0x00000000;2.72 +}2.73 +2.74 +/**2.75 + * Raise an ARM exception (other than reset, which uses arm_reset().2.76 + * @param exception one of the EXC_* exception codes defined above.2.77 + */2.78 +void arm_raise_exception( int exception )2.79 +{2.80 + int mode = arm_exceptions[exception][0];2.81 + arm_set_mode( mode );2.82 + armr.spsr = armr.cpsr;2.83 + armr.r[14] = armr.r[15];2.84 + armr.cpsr = (armr.cpsr & (~CPSR_T)) | CPSR_I;2.85 + if( mode == MODE_FIQ )2.86 + armr.cpsr |= CPSR_F;2.87 + armr.r[15] = arm_exceptions[exception][1];2.88 +}2.89 +2.90 +/**2.91 + * Restore CPSR from SPSR, effectively (under most circumstances) executing2.92 + * a return-from-exception.2.93 + */2.94 +void arm_restore_cpsr()2.95 +{2.96 + int spsr = armr.spsr;2.97 + int mode = spsr & CPSR_MODE;2.98 +2.99 + arm_set_mode( mode );2.100 + armr.cpsr = spsr;2.101 +}2.102 +2.103 +2.104 +2.105 +/**2.106 + * Change the current executing ARM mode to the requested mode.2.107 + * Saves any required registers to banks and restores those for the2.108 + * correct mode. (Note does not actually update CPSR at the moment).2.109 + */2.110 +void arm_set_mode( int targetMode )2.111 +{2.112 + int currentMode = armr.cpsr & CPSR_MODE;2.113 + if( currentMode == targetMode )2.114 + return;2.115 +2.116 + switch( currentMode ) {2.117 + case MODE_USER:2.118 + case MODE_SYS:2.119 + armr.user_r[5] = armr.r[13];2.120 + armr.user_r[6] = armr.r[14];2.121 + break;2.122 + case MODE_SVC:2.123 + armr.svc_r[0] = armr.r[13];2.124 + armr.svc_r[1] = armr.r[14];2.125 + armr.svc_r[2] = armr.spsr;2.126 + break;2.127 + case MODE_ABT:2.128 + armr.abt_r[0] = armr.r[13];2.129 + armr.abt_r[1] = armr.r[14];2.130 + armr.abt_r[2] = armr.spsr;2.131 + break;2.132 + case MODE_UND:2.133 + armr.und_r[0] = armr.r[13];2.134 + armr.und_r[1] = armr.r[14];2.135 + armr.und_r[2] = armr.spsr;2.136 + break;2.137 + case MODE_IRQ:2.138 + armr.irq_r[0] = armr.r[13];2.139 + armr.irq_r[1] = armr.r[14];2.140 + armr.irq_r[2] = armr.spsr;2.141 + break;2.142 + case MODE_FIQ:2.143 + armr.fiq_r[0] = armr.r[8];2.144 + armr.fiq_r[1] = armr.r[9];2.145 + armr.fiq_r[2] = armr.r[10];2.146 + armr.fiq_r[3] = armr.r[11];2.147 + armr.fiq_r[4] = armr.r[12];2.148 + armr.fiq_r[5] = armr.r[13];2.149 + armr.fiq_r[6] = armr.r[14];2.150 + armr.fiq_r[7] = armr.spsr;2.151 + armr.r[8] = armr.user_r[0];2.152 + armr.r[9] = armr.user_r[1];2.153 + armr.r[10] = armr.user_r[2];2.154 + armr.r[11] = armr.user_r[3];2.155 + armr.r[12] = armr.user_r[4];2.156 + break;2.157 + }2.158 +2.159 + switch( targetMode ) {2.160 + case MODE_USER:2.161 + case MODE_SYS:2.162 + armr.r[13] = armr.user_r[5];2.163 + armr.r[14] = armr.user_r[6];2.164 + break;2.165 + case MODE_SVC:2.166 + armr.r[13] = armr.svc_r[0];2.167 + armr.r[14] = armr.svc_r[1];2.168 + armr.spsr = armr.svc_r[2];2.169 + break;2.170 + case MODE_ABT:2.171 + armr.r[13] = armr.abt_r[0];2.172 + armr.r[14] = armr.abt_r[1];2.173 + armr.spsr = armr.abt_r[2];2.174 + break;2.175 + case MODE_UND:2.176 + armr.r[13] = armr.und_r[0];2.177 + armr.r[14] = armr.und_r[1];2.178 + armr.spsr = armr.und_r[2];2.179 + break;2.180 + case MODE_IRQ:2.181 + armr.r[13] = armr.irq_r[0];2.182 + armr.r[14] = armr.irq_r[1];2.183 + armr.spsr = armr.irq_r[2];2.184 + break;2.185 + case MODE_FIQ:2.186 + armr.user_r[0] = armr.r[8];2.187 + armr.user_r[1] = armr.r[9];2.188 + armr.user_r[2] = armr.r[10];2.189 + armr.user_r[3] = armr.r[11];2.190 + armr.user_r[4] = armr.r[12];2.191 + armr.r[8] = armr.fiq_r[0];2.192 + armr.r[9] = armr.fiq_r[1];2.193 + armr.r[10] = armr.fiq_r[2];2.194 + armr.r[11] = armr.fiq_r[3];2.195 + armr.r[12] = armr.fiq_r[4];2.196 + armr.r[13] = armr.fiq_r[5];2.197 + armr.r[14] = armr.fiq_r[6];2.198 + armr.spsr = armr.fiq_r[7];2.199 + break;2.200 + }2.201 +}2.202 +2.203 /* Page references are as per ARM DDI 0100E (June 2000) */2.205 #define MEM_READ_BYTE( addr ) arm_read_byte(addr)2.206 @@ -68,11 +255,6 @@2.207 #define UNDEF(ir) do{ ERROR( "Raising exception on undefined instruction at %08x, opcode = %04x", PC, ir ); return TRUE; } while(0)2.208 #define UNIMP(ir) do{ ERROR( "Halted on unimplemented instruction at %08x, opcode = %04x", PC, ir ); return FALSE; }while(0)2.210 -void arm_restore_cpsr()2.211 -{2.212 -2.213 -}2.214 -2.215 static uint32_t arm_get_shift_operand( uint32_t ir )2.216 {2.217 uint32_t operand, tmp;
3.1 --- a/src/aica/armcore.h Mon Dec 26 03:11:14 2005 +00003.2 +++ b/src/aica/armcore.h Mon Dec 26 03:54:55 2005 +00003.3 @@ -1,5 +1,5 @@3.4 /**3.5 - * $Id: armcore.h,v 1.6 2005-12-25 05:57:00 nkeynes Exp $3.6 + * $Id: armcore.h,v 1.7 2005-12-26 03:54:55 nkeynes Exp $3.7 *3.8 * Interface definitions for the ARM CPU emulation core proper.3.9 *3.10 @@ -21,6 +21,11 @@3.12 #include "dream.h"3.13 #include <stdint.h>3.14 +#include <stdio.h>3.15 +3.16 +#define ARM_BASE_RATE 33 /* MHZ */3.17 +extern uint32_t arm_cpu_freq;3.18 +extern uint32_t arm_cpu_period;3.20 #define ROTATE_RIGHT_LONG(operand,shift) ((((uint32_t)operand) >> shift) | ((operand<<(32-shift))) )3.22 @@ -30,13 +35,16 @@3.23 uint32_t cpsr;3.24 uint32_t spsr;3.26 - /* Various banked versions of the registers. */3.27 - uint32_t fiq_r[7]; /* FIQ bank 8..14 */3.28 - uint32_t irq_r[2]; /* IRQ bank 13..14 */3.29 - uint32_t und_r[2]; /* UND bank 13..14 */3.30 - uint32_t abt_r[2]; /* ABT bank 13..14 */3.31 - uint32_t svc_r[2]; /* SVC bank 13..14 */3.32 + /* Various banked versions of the registers. Note that these are used3.33 + * to save the registers for the named bank when leaving the mode, they're3.34 + * not actually used actively.3.35 + **/3.36 uint32_t user_r[7]; /* User/System bank 8..14 */3.37 + uint32_t svc_r[3]; /* SVC bank 13..14, SPSR */3.38 + uint32_t abt_r[3]; /* ABT bank 13..14, SPSR */3.39 + uint32_t und_r[3]; /* UND bank 13..14, SPSR */3.40 + uint32_t irq_r[3]; /* IRQ bank 13..14, SPSR */3.41 + uint32_t fiq_r[8]; /* FIQ bank 8..14, SPSR */3.43 uint32_t c,n,z,v,t;3.45 @@ -54,18 +62,25 @@3.46 #define CPSR_T 0x00000020 /* Thumb mode */3.47 #define CPSR_MODE 0x0000001F /* Current execution mode */3.49 -#define MODE_USER 0x00 /* User mode */3.50 -#define MODE_FIQ 0x01 /* Fast IRQ mode */3.51 -#define MODE_IRQ 0x02 /* IRQ mode */3.52 -#define MODE_SV 0x03 /* Supervisor mode */3.53 -#define MODE_ABT 0x07 /* Abort mode */3.54 -#define MODE_UND 0x0B /* Undefined mode */3.55 -#define MODE_SYS 0x0F /* System mode */3.56 +#define MODE_USER 0x10 /* User mode */3.57 +#define MODE_FIQ 0x11 /* Fast IRQ mode */3.58 +#define MODE_IRQ 0x12 /* IRQ mode */3.59 +#define MODE_SVC 0x13 /* Supervisor mode */3.60 +#define MODE_ABT 0x17 /* Abort mode */3.61 +#define MODE_UND 0x1B /* Undefined mode */3.62 +#define MODE_SYS 0x1F /* System mode */3.64 extern struct arm_registers armr;3.66 #define CARRY_FLAG (armr.cpsr&CPSR_C)3.68 +/* ARM core functions */3.69 +void arm_reset( void );3.70 +uint32_t arm_run_slice( uint32_t nanosecs );3.71 +void arm_save_state( FILE *f );3.72 +int arm_load_state( FILE *f );3.73 +gboolean arm_execute_instruction( void );3.74 +3.75 /* ARM Memory */3.76 int32_t arm_read_long( uint32_t addr );3.77 int32_t arm_read_word( uint32_t addr );3.78 @@ -75,6 +90,5 @@3.79 void arm_write_byte( uint32_t addr, uint32_t val );3.80 int32_t arm_read_phys_word( uint32_t addr );3.81 int arm_has_page( uint32_t addr );3.82 -gboolean arm_execute_instruction( void );3.84 #endif /* !dream_armcore_H */
4.1 --- a/src/asic.c Mon Dec 26 03:11:14 2005 +00004.2 +++ b/src/asic.c Mon Dec 26 03:54:55 2005 +00004.3 @@ -1,5 +1,5 @@4.4 /**4.5 - * $Id: asic.c,v 1.7 2005-12-25 08:24:07 nkeynes Exp $4.6 + * $Id: asic.c,v 1.8 2005-12-26 03:54:52 nkeynes Exp $4.7 *4.8 * Support for the miscellaneous ASIC functions (Primarily event multiplexing,4.9 * and DMA).4.10 @@ -16,12 +16,14 @@4.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4.12 * GNU General Public License for more details.4.13 */4.14 +4.15 +#define MODULE asic_module4.16 +4.17 #include <assert.h>4.18 #include "dream.h"4.19 #include "mem.h"4.20 #include "sh4/intc.h"4.21 #include "dreamcast.h"4.22 -#include "modules.h"4.23 #include "maple/maple.h"4.24 #include "gdrom/ide.h"4.25 #include "asic.h"
5.1 --- a/src/bootstrap.c Mon Dec 26 03:11:14 2005 +00005.2 +++ b/src/bootstrap.c Mon Dec 26 03:54:55 2005 +00005.3 @@ -1,5 +1,5 @@5.4 /**5.5 - * $Id: bootstrap.c,v 1.4 2005-12-24 08:02:14 nkeynes Exp $5.6 + * $Id: bootstrap.c,v 1.5 2005-12-26 03:54:52 nkeynes Exp $5.7 *5.8 * CD Bootstrap header parsing. Mostly for informational purposes.5.9 *5.10 @@ -123,7 +123,7 @@5.11 sprintf( buf, "%4.4s", head->crc );5.12 crc = compute_crc16(head);5.13 hcrc = strtol( buf, NULL, 16 );5.14 - emit( NULL, crc == hcrc ? EMIT_INFO : EMIT_WARN, MODULE_ID,5.15 + emit( NULL, crc == hcrc ? EMIT_INFO : EMIT_WARN, "File",5.16 " Header CRC: %04X (Computed %04X)", hcrc, crc );5.17 INFO( " Boot File: %-16.16s", head->boot_file );5.18 INFO( " Product ID: %-10.10s Product Ver: %-6.6s Date: %-8.8s",
6.1 --- a/src/dream.h Mon Dec 26 03:11:14 2005 +00006.2 +++ b/src/dream.h Mon Dec 26 03:54:55 2005 +00006.3 @@ -1,5 +1,5 @@6.4 /**6.5 - * $Id: dream.h,v 1.6 2005-12-25 08:24:07 nkeynes Exp $6.6 + * $Id: dream.h,v 1.7 2005-12-26 03:54:52 nkeynes Exp $6.7 *6.8 * Miscellaneous application-wide declarations (mainly logging atm)6.9 *6.10 @@ -19,6 +19,7 @@6.11 #ifndef dream_H6.12 #define dream_H 16.14 +#include <stdio.h>6.15 #include <stdlib.h>6.16 #include <stdint.h>6.17 #include <string.h>6.18 @@ -26,10 +27,66 @@6.20 #ifdef __cplusplus6.21 extern "C" {6.22 -#if 06.23 -}6.24 #endif6.25 -#endif6.26 +6.27 +/************************ Modules ********************************/6.28 +/**6.29 + * Basic module structure defining the common operations across all6.30 + * modules, ie start, stop, reset, etc.6.31 + */6.32 +typedef struct dreamcast_module {6.33 + char *name;6.34 + /**6.35 + * Perform all initial module setup (ie register / allocate any6.36 + * memory required, etc). Only called once during DreamOn startup6.37 + */6.38 + void (*init)();6.39 + /**6.40 + * Reset the module into it's initial system boot state. Will be called6.41 + * once after init(), as well as whenever the user requests a reset.6.42 + */6.43 + void (*reset)();6.44 + /**6.45 + * Set the module into a running state (may be NULL)6.46 + */6.47 + void (*start)();6.48 + /**6.49 + * Execute one time-slice worth of operations, for the given number of6.50 + * nanoseconds.6.51 + * @return Number of nanoseconds actually executed6.52 + */6.53 + uint32_t (*run_time_slice)( uint32_t nanosecs );6.54 + /**6.55 + * Set the module into a stopped state (may be NULL)6.56 + */6.57 + void (*stop)();6.58 + /**6.59 + * Save the module state to the FILE stream. May be NULL, in which case6.60 + * the module is considered to have no state.6.61 + */6.62 + void (*save)(FILE *);6.63 + /**6.64 + * Load the saved module state from the FILE stream. May be NULL, in which6.65 + * case reset() will be called instead.6.66 + * @return 0 on success, nonzero on failure.6.67 + */6.68 + int (*load)(FILE *);6.69 +} *dreamcast_module_t;6.70 +6.71 +void dreamcast_register_module( dreamcast_module_t );6.72 +6.73 +extern struct dreamcast_module mem_module;6.74 +extern struct dreamcast_module sh4_module;6.75 +extern struct dreamcast_module asic_module;6.76 +extern struct dreamcast_module pvr2_module;6.77 +extern struct dreamcast_module aica_module;6.78 +extern struct dreamcast_module ide_module;6.79 +extern struct dreamcast_module maple_module;6.80 +extern struct dreamcast_module pvr2_module;6.81 +extern struct dreamcast_module gui_module;6.82 +extern struct dreamcast_module unknown_module;6.83 +6.84 +/*************************** Logging **************************/6.86 #define EMIT_FATAL 06.87 #define EMIT_ERR 16.88 @@ -38,21 +95,24 @@6.89 #define EMIT_DEBUG 46.90 #define EMIT_TRACE 56.92 -#ifndef MODULE_ID6.93 -#define MODULE_ID 06.94 +#ifndef MODULE6.95 +#define MODULE unknown_module6.96 #endif6.98 -void emit( void *, int level, int source, const char *msg, ... );6.99 +void emit( void *, int level, const char *source, const char *msg, ... );6.101 -#define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE_ID, __VA_ARGS__ )6.102 -#define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE_ID, __VA_ARGS__ )6.103 -#define WARN( ... ) emit( NULL, EMIT_WARN, MODULE_ID, __VA_ARGS__ )6.104 -#define INFO( ... ) emit( NULL, EMIT_INFO, MODULE_ID, __VA_ARGS__ )6.105 -#define DEBUG( ... ) emit( NULL, EMIT_DEBUG, MODULE_ID, __VA_ARGS__ )6.106 -#define TRACE( ... ) emit( NULL, EMIT_TRACE, MODULE_ID, __VA_ARGS__ )6.107 +#define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE.name, __VA_ARGS__ )6.108 +#define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE.name, __VA_ARGS__ )6.109 +#define WARN( ... ) emit( NULL, EMIT_WARN, MODULE.name, __VA_ARGS__ )6.110 +#define INFO( ... ) emit( NULL, EMIT_INFO, MODULE.name, __VA_ARGS__ )6.111 +#define DEBUG( ... ) emit( NULL, EMIT_DEBUG, MODULE.name, __VA_ARGS__ )6.112 +#define TRACE( ... ) emit( NULL, EMIT_TRACE, MODULE.name, __VA_ARGS__ )6.114 #define BIOS_PATH "../bios"6.116 +void fwrite_string( char *s, FILE *f );6.117 +int fread_string( char *s, int maxlen, FILE *f );6.118 +6.119 #ifdef __cplusplus6.120 }6.121 #endif
7.1 --- a/src/dreamcast.c Mon Dec 26 03:11:14 2005 +00007.2 +++ b/src/dreamcast.c Mon Dec 26 03:54:55 2005 +00007.3 @@ -1,5 +1,5 @@7.4 /**7.5 - * $Id: dreamcast.c,v 1.11 2005-12-25 05:56:55 nkeynes Exp $7.6 + * $Id: dreamcast.c,v 1.12 2005-12-26 03:54:52 nkeynes Exp $7.7 * Central switchboard for the system. This pulls all the individual modules7.8 * together into some kind of coherent structure. This is also where you'd7.9 * add Naomi support, if I ever get a board to play with...7.10 @@ -25,7 +25,6 @@7.11 #include "dreamcast.h"7.12 #include "gdrom/ide.h"7.13 #include "maple/maple.h"7.14 -#include "modules.h"7.16 /**7.17 * Current state of the DC virtual machine7.18 @@ -43,6 +42,13 @@7.19 dreamcast_module_t modules[MAX_MODULES];7.21 /**7.22 + * The unknown module is used for logging files without an actual module7.23 + * declaration7.24 + */7.25 +struct dreamcast_module unknown_module = { "****", NULL, NULL, NULL, NULL,7.26 + NULL, NULL, NULL };7.27 +7.28 +/**7.29 * This function is responsible for defining how all the pieces of the7.30 * dreamcast actually fit together.7.31 *
8.1 --- a/src/gdrom/ide.c Mon Dec 26 03:11:14 2005 +00008.2 +++ b/src/gdrom/ide.c Mon Dec 26 03:54:55 2005 +00008.3 @@ -1,5 +1,5 @@8.4 /**8.5 - * $Id: ide.c,v 1.4 2005-12-25 08:24:11 nkeynes Exp $8.6 + * $Id: ide.c,v 1.5 2005-12-26 03:54:55 nkeynes Exp $8.7 *8.8 * IDE interface implementation8.9 *8.10 @@ -15,8 +15,11 @@8.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8.12 * GNU General Public License for more details.8.13 */8.14 +8.15 +#define MODULE ide_module8.16 +8.17 #include <stdlib.h>8.18 -#include "modules.h"8.19 +#include "dream.h"8.20 #include "ide.h"8.22 #define MAX_WRITE_BUF 4096;
9.1 --- a/src/gui/debug_win.c Mon Dec 26 03:11:14 2005 +00009.2 +++ b/src/gui/debug_win.c Mon Dec 26 03:54:55 2005 +00009.3 @@ -1,5 +1,5 @@9.4 /**9.5 - * $Id: debug_win.c,v 1.11 2005-12-26 03:10:41 nkeynes Exp $9.6 + * $Id: debug_win.c,v 1.12 2005-12-26 03:54:55 nkeynes Exp $9.7 * This file is responsible for the main debugger gui frame.9.8 *9.9 * Copyright (c) 2005 Nathan Keynes.9.10 @@ -243,10 +243,10 @@9.11 }9.14 -void emit( void *ptr, int level, int source, const char *msg, ... )9.15 +void emit( void *ptr, int level, const gchar *source, const char *msg, ... )9.16 {9.17 char buf[20], addr[10] = "", *p;9.18 - char *arr[3] = {buf, addr};9.19 + const char *arr[4] = {buf, source, addr};9.20 int posn;9.21 time_t tm = time(NULL);9.22 va_list ap;9.23 @@ -258,9 +258,9 @@9.24 va_start(ap, msg);9.25 p = g_strdup_vprintf( msg, ap );9.26 strftime( buf, sizeof(buf), "%H:%M:%S", localtime(&tm) );9.27 - if( source != -1 )9.28 - sprintf( addr, "%08X", *data->cpu->pc );9.29 - arr[2] = p;9.30 + // if( source == NULL )9.31 + sprintf( addr, "%08X", *data->cpu->pc );9.32 + arr[3] = p;9.33 posn = gtk_clist_append(data->msgs_list, arr);9.34 free(p);9.35 va_end(ap);
10.1 --- a/src/gui/gui.h Mon Dec 26 03:11:14 2005 +000010.2 +++ b/src/gui/gui.h Mon Dec 26 03:54:55 2005 +000010.3 @@ -1,5 +1,5 @@10.4 /**10.5 - * $Id: gui.h,v 1.11 2005-12-25 05:57:00 nkeynes Exp $10.6 + * $Id: gui.h,v 1.12 2005-12-26 03:54:55 nkeynes Exp $10.7 *10.8 * General GUI definitions10.9 *10.10 @@ -22,7 +22,6 @@10.11 #include <gnome.h>10.12 #include "dream.h"10.13 #include "cpu.h"10.14 -#include "modules.h"10.15 #include "gui/interface.h"10.17 #ifdef __cplusplus
11.1 --- a/src/gui/interface.c Mon Dec 26 03:11:14 2005 +000011.2 +++ b/src/gui/interface.c Mon Dec 26 03:54:55 2005 +000011.3 @@ -352,12 +352,13 @@11.4 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow8), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);11.5 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow8), GTK_SHADOW_IN);11.7 - output_list = gtk_clist_new (3);11.8 + output_list = gtk_clist_new (4);11.9 gtk_widget_show (output_list);11.10 gtk_container_add (GTK_CONTAINER (scrolledwindow8), output_list);11.11 gtk_clist_set_column_width (GTK_CLIST (output_list), 0, 80);11.12 gtk_clist_set_column_width (GTK_CLIST (output_list), 1, 80);11.13 gtk_clist_set_column_width (GTK_CLIST (output_list), 2, 80);11.14 + gtk_clist_set_column_width (GTK_CLIST (output_list), 3, 80);11.15 gtk_clist_column_titles_hide (GTK_CLIST (output_list));11.17 label26 = gtk_label_new ("");
12.1 --- a/src/main.c Mon Dec 26 03:11:14 2005 +000012.2 +++ b/src/main.c Mon Dec 26 03:54:55 2005 +000012.3 @@ -1,5 +1,5 @@12.4 /**12.5 - * $Id: main.c,v 1.8 2005-12-26 03:11:14 nkeynes Exp $12.6 + * $Id: main.c,v 1.9 2005-12-26 03:54:52 nkeynes Exp $12.7 *12.8 * Main program, initializes dreamcast and gui, then passes control off to12.9 * the gtk main loop (currently).12.10 @@ -40,7 +40,7 @@12.11 video_open();12.12 dreamcast_register_module( >k_gui_module );12.14 - emit( main_debug, EMIT_INFO, -1, "DreamOn! ready..." );12.15 + INFO( "DreamOn! ready..." );12.17 gtk_main ();12.18 return 0;
13.1 --- a/src/maple/maple.c Mon Dec 26 03:11:14 2005 +000013.2 +++ b/src/maple/maple.c Mon Dec 26 03:54:55 2005 +000013.3 @@ -1,5 +1,5 @@13.4 /**13.5 - * $Id: maple.c,v 1.5 2005-12-25 08:24:11 nkeynes Exp $13.6 + * $Id: maple.c,v 1.6 2005-12-26 03:54:55 nkeynes Exp $13.7 *13.8 * Implements the core Maple bus, including DMA transfers to and from the bus.13.9 *13.10 @@ -15,10 +15,10 @@13.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13.12 * GNU General Public License for more details.13.13 */13.14 +#define MODULE maple_module13.16 #include <assert.h>13.17 #include "dream.h"13.18 -#include "modules.h"13.19 #include "mem.h"13.20 #include "asic.h"13.21 #include "maple.h"
14.1 --- a/src/mem.c Mon Dec 26 03:11:14 2005 +000014.2 +++ b/src/mem.c Mon Dec 26 03:54:55 2005 +000014.3 @@ -1,5 +1,5 @@14.4 /**14.5 - * $Id: mem.c,v 1.7 2005-12-23 11:44:51 nkeynes Exp $14.6 + * $Id: mem.c,v 1.8 2005-12-26 03:54:52 nkeynes Exp $14.7 * mem.c is responsible for creating and maintaining the overall system memory14.8 * map, as visible from the SH4 processor.14.9 *14.10 @@ -15,6 +15,7 @@14.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14.12 * GNU General Public License for more details.14.13 */14.14 +#define MODULE mem_module14.16 #include <sys/mman.h>14.17 #include <sys/stat.h>14.18 @@ -30,7 +31,6 @@14.19 #include "dream.h"14.20 #include "mem.h"14.21 #include "mmio.h"14.22 -#include "modules.h"14.23 #include "dreamcast.h"14.25 char **page_map = NULL;
15.1 --- a/src/modules.h Mon Dec 26 03:11:14 2005 +000015.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +000015.3 @@ -1,93 +0,0 @@15.4 -/**15.5 - * $Id: modules.h,v 1.5 2005-12-25 05:56:55 nkeynes Exp $15.6 - *15.7 - * Internal dreamcast module structure definition and associated variables.15.8 - * Included by all module implementations15.9 - *15.10 - * Copyright (c) 2005 Nathan Keynes.15.11 - *15.12 - * This program is free software; you can redistribute it and/or modify15.13 - * it under the terms of the GNU General Public License as published by15.14 - * the Free Software Foundation; either version 2 of the License, or15.15 - * (at your option) any later version.15.16 - *15.17 - * This program is distributed in the hope that it will be useful,15.18 - * but WITHOUT ANY WARRANTY; without even the implied warranty of15.19 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15.20 - * GNU General Public License for more details.15.21 - */15.22 -15.23 -#ifndef dreamcast_modules_H15.24 -#define dreamcast_modules_H 115.25 -15.26 -#include <stdint.h>15.27 -#include <stdlib.h>15.28 -#include <stdio.h>15.29 -15.30 -#ifdef __cplusplus15.31 -extern "C" {15.32 -#endif15.33 -15.34 -/**15.35 - * Basic module structure defining the common operations across all15.36 - * modules, ie start, stop, reset, etc. Nothing here is time-sensitive.15.37 - */15.38 -typedef struct dreamcast_module {15.39 - char *name;15.40 - /**15.41 - * Perform all initial module setup (ie register / allocate any15.42 - * memory required, etc). Only called once during DreamOn startup15.43 - */15.44 - void (*init)();15.45 - /**15.46 - * Reset the module into it's initial system boot state. Will be called15.47 - * once after init(), as well as whenever the user requests a reset.15.48 - */15.49 - void (*reset)();15.50 - /**15.51 - * Set the module into a running state (may be NULL)15.52 - */15.53 - void (*start)();15.54 - /**15.55 - * Execute one time-slice worth of operations, for the given number of15.56 - * nanoseconds.15.57 - * @return Number of nanoseconds actually executed15.58 - */15.59 - uint32_t (*run_time_slice)( uint32_t nanosecs );15.60 - /**15.61 - * Set the module into a stopped state (may be NULL)15.62 - */15.63 - void (*stop)();15.64 - /**15.65 - * Save the module state to the FILE stream. May be NULL, in which case15.66 - * the module is considered to have no state.15.67 - */15.68 - void (*save)(FILE *);15.69 - /**15.70 - * Load the saved module state from the FILE stream. May be NULL, in which15.71 - * case reset() will be called instead.15.72 - * @return 0 on success, nonzero on failure.15.73 - */15.74 - int (*load)(FILE *);15.75 -} *dreamcast_module_t;15.76 -15.77 -void dreamcast_register_module( dreamcast_module_t );15.78 -15.79 -extern struct dreamcast_module mem_module;15.80 -extern struct dreamcast_module sh4_module;15.81 -extern struct dreamcast_module asic_module;15.82 -extern struct dreamcast_module pvr2_module;15.83 -extern struct dreamcast_module aica_module;15.84 -extern struct dreamcast_module ide_module;15.85 -extern struct dreamcast_module maple_module;15.86 -extern struct dreamcast_module pvr2_module;15.87 -extern struct dreamcast_module gui_module;15.88 -15.89 -void fwrite_string( char *s, FILE *f );15.90 -int fread_string( char *s, int maxlen, FILE *f );15.91 -15.92 -#ifdef __cplusplus15.93 -}15.94 -#endif15.95 -15.96 -#endif /* !dreamcast_modules_H */
16.1 --- a/src/pvr2/pvr2.c Mon Dec 26 03:11:14 2005 +000016.2 +++ b/src/pvr2/pvr2.c Mon Dec 26 03:54:55 2005 +000016.3 @@ -1,5 +1,5 @@16.4 /**16.5 - * $Id: pvr2.c,v 1.9 2005-12-25 08:24:07 nkeynes Exp $16.6 + * $Id: pvr2.c,v 1.10 2005-12-26 03:54:52 nkeynes Exp $16.7 *16.8 * PVR2 (Video) MMIO and supporting functions.16.9 *16.10 @@ -15,12 +15,12 @@16.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16.12 * GNU General Public License for more details.16.13 */16.14 +#define MODULE pvr2_module16.16 #include "dream.h"16.17 #include "video.h"16.18 #include "mem.h"16.19 #include "asic.h"16.20 -#include "modules.h"16.21 #include "pvr2.h"16.22 #define MMIO_IMPL16.23 #include "pvr2.h"
17.1 --- a/src/sh4/scif.c Mon Dec 26 03:11:14 2005 +000017.2 +++ b/src/sh4/scif.c Mon Dec 26 03:54:55 2005 +000017.3 @@ -1,5 +1,5 @@17.4 /**17.5 - * $Id: scif.c,v 1.6 2005-12-26 03:10:23 nkeynes Exp $17.6 + * $Id: scif.c,v 1.7 2005-12-26 03:54:55 nkeynes Exp $17.7 * SCIF (Serial Communication Interface with FIFO) implementation - part of the17.8 * SH4 standard on-chip peripheral set. The SCIF is hooked up to the DCs17.9 * external serial port17.10 @@ -25,7 +25,6 @@17.11 #include "intc.h"17.12 #include "clock.h"17.13 #include "serial.h"17.14 -#include "modules.h"17.16 void SCIF_set_break(void);
18.1 --- a/src/sh4/sh4core.c Mon Dec 26 03:11:14 2005 +000018.2 +++ b/src/sh4/sh4core.c Mon Dec 26 03:54:55 2005 +000018.3 @@ -1,5 +1,5 @@18.4 /**18.5 - * $Id: sh4core.c,v 1.12 2005-12-26 03:10:23 nkeynes Exp $18.6 + * $Id: sh4core.c,v 1.13 2005-12-26 03:54:55 nkeynes Exp $18.7 *18.8 * SH4 emulation core, and parent module for all the SH4 peripheral18.9 * modules.18.10 @@ -17,9 +17,9 @@18.11 * GNU General Public License for more details.18.12 */18.14 +#define MODULE sh4_module18.15 #include <math.h>18.16 #include "dream.h"18.17 -#include "modules.h"18.18 #include "sh4core.h"18.19 #include "sh4mmio.h"18.20 #include "mem.h"
19.1 --- a/src/sh4/sh4mem.c Mon Dec 26 03:11:14 2005 +000019.2 +++ b/src/sh4/sh4mem.c Mon Dec 26 03:54:55 2005 +000019.3 @@ -1,5 +1,5 @@19.4 /**19.5 - * $Id: sh4mem.c,v 1.1 2005-12-11 05:15:36 nkeynes Exp $19.6 + * $Id: sh4mem.c,v 1.2 2005-12-26 03:54:55 nkeynes Exp $19.7 * sh4mem.c is responsible for the SH4's access to memory (including memory19.8 * mapped I/O), using the page maps created in mem.c19.9 *19.10 @@ -16,6 +16,8 @@19.11 * GNU General Public License for more details.19.12 */19.14 +#define MODULE sh4_module19.15 +19.16 #include <string.h>19.17 #include <zlib.h>19.18 #include "dream.h"
20.1 --- a/src/sh4/sh4mmio.c Mon Dec 26 03:11:14 2005 +000020.2 +++ b/src/sh4/sh4mmio.c Mon Dec 26 03:54:55 2005 +000020.3 @@ -1,5 +1,5 @@20.4 /**20.5 - * $Id: sh4mmio.c,v 1.5 2005-12-25 05:57:00 nkeynes Exp $20.6 + * $Id: sh4mmio.c,v 1.6 2005-12-26 03:54:55 nkeynes Exp $20.7 *20.8 * Miscellaneous and not-really-implemented SH4 peripheral modules. Also20.9 * responsible for including the IMPL side of the SH4 MMIO pages.20.10 @@ -17,6 +17,7 @@20.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20.12 * GNU General Public License for more details.20.13 */20.14 +#define MODULE sh4_module20.16 #include "dream.h"20.17 #include "mem.h"
21.1 --- a/src/util.c Mon Dec 26 03:11:14 2005 +000021.2 +++ b/src/util.c Mon Dec 26 03:54:55 2005 +000021.3 @@ -1,5 +1,5 @@21.4 /**21.5 - * $Id: util.c,v 1.2 2005-12-25 08:24:07 nkeynes Exp $21.6 + * $Id: util.c,v 1.3 2005-12-26 03:54:52 nkeynes Exp $21.7 *21.8 * Miscellaneous utility functions.21.9 *21.10 @@ -17,7 +17,6 @@21.11 */21.13 #include "dream.h"21.14 -#include "modules.h"21.16 void fwrite_string( char *s, FILE *f )21.17 {
.