Search
lxdream.org :: lxdream :: r30:89b30313d757
lxdream 0.9.1
released Jun 29
Download Now
changeset30:89b30313d757
parent29:c29373ff63ee
child31:495e480360d7
authornkeynes
dateSun Dec 25 05:57:00 2005 +0000 (14 years ago)
Change timeslice to nanoseconds (was microseconds)
Generize single step (now steps through active CPU)
Add lots of header blocks
src/aica/aica.c
src/aica/armcore.c
src/aica/armcore.h
src/aica/armdasm.c
src/aica/armdasm.h
src/clock.h
src/cpu.h
src/dream.h
src/dreamcast.c
src/dreamcast.h
src/gui/callbacks.c
src/gui/debug_win.c
src/gui/gui.c
src/gui/gui.h
src/main.c
src/modules.h
src/pvr2/pvr2.c
src/sh4/scif.c
src/sh4/sh4core.c
src/sh4/sh4core.h
src/sh4/sh4dasm.c
src/sh4/sh4dasm.h
src/sh4/sh4mmio.c
src/sh4/sh4mmio.h
src/sh4/timer.c
1.1 --- a/src/aica/aica.c Sun Dec 25 04:54:40 2005 +0000
1.2 +++ b/src/aica/aica.c Sun Dec 25 05:57:00 2005 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: aica.c,v 1.4 2005-12-23 11:44:55 nkeynes Exp $
1.6 + * $Id: aica.c,v 1.5 2005-12-25 05:57:00 nkeynes Exp $
1.7 *
1.8 * This is the core sound system (ie the bit which does the actual work)
1.9 *
1.10 @@ -31,7 +31,7 @@
1.11 void aica_reset( void );
1.12 void aica_start( void );
1.13 void aica_stop( void );
1.14 -void aica_run_slice( int );
1.15 +uint32_t aica_run_slice( uint32_t );
1.16
1.17
1.18 struct dreamcast_module aica_module = { "AICA", aica_init, aica_reset,
1.19 @@ -59,7 +59,7 @@
1.20
1.21 }
1.22
1.23 -void aica_run_slice( int microsecs )
1.24 +uint32_t aica_run_slice( uint32_t nanosecs )
1.25 {
1.26 /* Run arm instructions */
1.27 /* Generate audio buffer */
2.1 --- a/src/aica/armcore.c Sun Dec 25 04:54:40 2005 +0000
2.2 +++ b/src/aica/armcore.c Sun Dec 25 05:57:00 2005 +0000
2.3 @@ -1,3 +1,20 @@
2.4 +/**
2.5 + * $Id: armcore.c,v 1.5 2005-12-25 05:57:00 nkeynes Exp $
2.6 + *
2.7 + * ARM7TDMI CPU emulation core.
2.8 + *
2.9 + * Copyright (c) 2005 Nathan Keynes.
2.10 + *
2.11 + * This program is free software; you can redistribute it and/or modify
2.12 + * it under the terms of the GNU General Public License as published by
2.13 + * the Free Software Foundation; either version 2 of the License, or
2.14 + * (at your option) any later version.
2.15 + *
2.16 + * This program is distributed in the hope that it will be useful,
2.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.19 + * GNU General Public License for more details.
2.20 + */
2.21
2.22 #include "aica/armcore.h"
2.23
2.24 @@ -48,8 +65,8 @@
2.25 #define IMMROT(ir) ((ir>>7)&0x1E)
2.26 #define SHIFT(ir) ((ir>>4)&0x07)
2.27 #define DISP24(ir) ((ir&0x00FFFFFF))
2.28 -#define UNDEF(ir) do{ ERROR( "Raising exception on undefined instruction at %08x, opcode = %04x", PC, ir ); return; } while(0)
2.29 -#define UNIMP(ir) do{ ERROR( "Halted on unimplemented instruction at %08x, opcode = %04x", PC, ir ); return; }while(0)
2.30 +#define UNDEF(ir) do{ ERROR( "Raising exception on undefined instruction at %08x, opcode = %04x", PC, ir ); return TRUE; } while(0)
2.31 +#define UNIMP(ir) do{ ERROR( "Halted on unimplemented instruction at %08x, opcode = %04x", PC, ir ); return FALSE; }while(0)
2.32
2.33 void arm_restore_cpsr()
2.34 {
2.35 @@ -322,7 +339,7 @@
2.36 return addr;
2.37 }
2.38
2.39 -void arm_execute_instruction( void )
2.40 +gboolean arm_execute_instruction( void )
2.41 {
2.42 uint32_t pc = PC;
2.43 uint32_t ir = MEM_READ_LONG(pc);
2.44 @@ -652,4 +669,5 @@
2.45 case 3: /* Copro */
2.46 break;
2.47 }
2.48 + return TRUE;
2.49 }
3.1 --- a/src/aica/armcore.h Sun Dec 25 04:54:40 2005 +0000
3.2 +++ b/src/aica/armcore.h Sun Dec 25 05:57:00 2005 +0000
3.3 @@ -1,3 +1,20 @@
3.4 +/**
3.5 + * $Id: armcore.h,v 1.6 2005-12-25 05:57:00 nkeynes Exp $
3.6 + *
3.7 + * Interface definitions for the ARM CPU emulation core proper.
3.8 + *
3.9 + * Copyright (c) 2005 Nathan Keynes.
3.10 + *
3.11 + * This program is free software; you can redistribute it and/or modify
3.12 + * it under the terms of the GNU General Public License as published by
3.13 + * the Free Software Foundation; either version 2 of the License, or
3.14 + * (at your option) any later version.
3.15 + *
3.16 + * This program is distributed in the hope that it will be useful,
3.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.19 + * GNU General Public License for more details.
3.20 + */
3.21
3.22 #ifndef dream_armcore_H
3.23 #define dream_armcore_H 1
3.24 @@ -58,5 +75,6 @@
3.25 void arm_write_byte( uint32_t addr, uint32_t val );
3.26 int32_t arm_read_phys_word( uint32_t addr );
3.27 int arm_has_page( uint32_t addr );
3.28 +gboolean arm_execute_instruction( void );
3.29
3.30 #endif /* !dream_armcore_H */
4.1 --- a/src/aica/armdasm.c Sun Dec 25 04:54:40 2005 +0000
4.2 +++ b/src/aica/armdasm.c Sun Dec 25 05:57:00 2005 +0000
4.3 @@ -1,8 +1,19 @@
4.4 -/*
4.5 +/**
4.6 + * $Id: armdasm.c,v 1.6 2005-12-25 05:57:00 nkeynes Exp $
4.7 + *
4.8 * armdasm.c 21 Aug 2004 - ARM7tdmi (ARMv4) disassembler
4.9 *
4.10 - * Copyright (c) 2004 Nathan Keynes. Distribution and modification permitted
4.11 - * under the terms of the GNU General Public License version 2 or later.
4.12 + * Copyright (c) 2005 Nathan Keynes.
4.13 + *
4.14 + * This program is free software; you can redistribute it and/or modify
4.15 + * it under the terms of the GNU General Public License as published by
4.16 + * the Free Software Foundation; either version 2 of the License, or
4.17 + * (at your option) any later version.
4.18 + *
4.19 + * This program is distributed in the hope that it will be useful,
4.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.22 + * GNU General Public License for more details.
4.23 */
4.24
4.25 #include "aica/armcore.h"
4.26 @@ -50,15 +61,13 @@
4.27
4.28
4.29 const struct cpu_desc_struct arm_cpu_desc =
4.30 - { "ARM7", arm_disasm_instruction, 4,
4.31 + { "ARM7", arm_disasm_instruction, arm_execute_instruction, arm_has_page, 4,
4.32 (char *)&armr, sizeof(armr), arm_reg_map,
4.33 - &armr.r[15], &armr.icount,
4.34 - arm_has_page };
4.35 + &armr.r[15], &armr.icount };
4.36 const struct cpu_desc_struct armt_cpu_desc =
4.37 - { "ARM7T", armt_disasm_instruction, 2,
4.38 + { "ARM7T", armt_disasm_instruction, arm_execute_instruction, arm_has_page, 2,
4.39 (char*)&armr, sizeof(armr), arm_reg_map,
4.40 - &armr.r[15], &armr.icount,
4.41 - arm_has_page };
4.42 + &armr.r[15], &armr.icount };
4.43
4.44
4.45
5.1 --- a/src/aica/armdasm.h Sun Dec 25 04:54:40 2005 +0000
5.2 +++ b/src/aica/armdasm.h Sun Dec 25 05:57:00 2005 +0000
5.3 @@ -1,7 +1,25 @@
5.4 +/**
5.5 + * $Id: armdasm.h,v 1.2 2005-12-25 05:57:00 nkeynes Exp $
5.6 + *
5.7 + * ARM CPU definition and disassembly function declarations
5.8 + *
5.9 + * Copyright (c) 2005 Nathan Keynes.
5.10 + *
5.11 + * This program is free software; you can redistribute it and/or modify
5.12 + * it under the terms of the GNU General Public License as published by
5.13 + * the Free Software Foundation; either version 2 of the License, or
5.14 + * (at your option) any later version.
5.15 + *
5.16 + * This program is distributed in the hope that it will be useful,
5.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.19 + * GNU General Public License for more details.
5.20 + */
5.21 +
5.22 #ifndef armdasm_H
5.23 #define armdasm_H 1
5.24
5.25 -#include "disasm.h"
5.26 +#include "cpu.h"
5.27
5.28 #ifdef __cplusplus
5.29 extern "C" {
6.1 --- a/src/clock.h Sun Dec 25 04:54:40 2005 +0000
6.2 +++ b/src/clock.h Sun Dec 25 05:57:00 2005 +0000
6.3 @@ -1,5 +1,5 @@
6.4 /**
6.5 - * $Id: clock.h,v 1.2 2005-12-23 11:44:50 nkeynes Exp $
6.6 + * $Id: clock.h,v 1.3 2005-12-25 05:56:55 nkeynes Exp $
6.7 * External interface to the dreamcast serial port, implemented by
6.8 * sh4/scif.c
6.9 *
6.10 @@ -31,6 +31,9 @@
6.11 extern uint32_t sh4_freq;
6.12 extern uint32_t sh4_peripheral_freq;
6.13 extern uint32_t sh4_bus_freq;
6.14 +extern uint32_t sh4_cpu_period;
6.15 +extern uint32_t sh4_peripheral_period;
6.16 +extern uint32_t sh4_bus_period;
6.17 extern uint32_t arm_freq;
6.18
6.19 #ifdef __cplusplus
7.1 --- a/src/cpu.h Sun Dec 25 04:54:40 2005 +0000
7.2 +++ b/src/cpu.h Sun Dec 25 05:57:00 2005 +0000
7.3 @@ -1,8 +1,27 @@
7.4 +/**
7.5 + * $Id: cpu.h,v 1.6 2005-12-25 05:56:55 nkeynes Exp $
7.6 + *
7.7 + * Generic CPU definitions, primarily for providing information to the GUI.
7.8 + *
7.9 + * Copyright (c) 2005 Nathan Keynes.
7.10 + *
7.11 + * This program is free software; you can redistribute it and/or modify
7.12 + * it under the terms of the GNU General Public License as published by
7.13 + * the Free Software Foundation; either version 2 of the License, or
7.14 + * (at your option) any later version.
7.15 + *
7.16 + * This program is distributed in the hope that it will be useful,
7.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.19 + * GNU General Public License for more details.
7.20 + */
7.21
7.22 -#ifndef dream_disasm_H
7.23 -#define dream_disasm_H 1
7.24 +#ifndef dream_cpu_H
7.25 +#define dream_cpu_H 1
7.26
7.27 +#include <stdint.h>
7.28 #include <stdlib.h>
7.29 +#include <glib/gtypes.h>
7.30
7.31 #ifdef __cplusplus
7.32 extern "C" {
7.33 @@ -19,6 +38,7 @@
7.34 typedef uint32_t (*disasm_func_t)(uint32_t pc, char *buffer, int buflen, char *opcode );
7.35
7.36 typedef int (*is_valid_page_t)(uint32_t pc);
7.37 +typedef gboolean (*step_func_t)();
7.38
7.39 #define REG_INT 0
7.40 #define REG_FLT 1
7.41 @@ -33,21 +53,24 @@
7.42 void *value;
7.43 } reg_desc_t;
7.44
7.45 +/**
7.46 + * CPU definition structure - basic information and support functions.
7.47 + */
7.48 typedef struct cpu_desc_struct {
7.49 char *name; /* CPU Name */
7.50 disasm_func_t disasm_func; /* Disassembly function */
7.51 + step_func_t step_func; /* Single step function */
7.52 + is_valid_page_t is_valid_page_func; /* Test for valid memory page */
7.53 size_t instr_size; /* Size of instruction */
7.54 char *regs; /* Pointer to start of registers */
7.55 size_t regs_size; /* Size of register structure in bytes */
7.56 const struct reg_desc_struct *regs_info; /* Description of all registers */
7.57 uint32_t *pc; /* Pointer to PC register */
7.58 uint32_t *icount; /* Pointer to instruction counter */
7.59 - /* Memory map? */
7.60 - is_valid_page_t is_valid_page_func; /* Test for valid memory page */
7.61 } *cpu_desc_t;
7.62
7.63 #ifdef __cplusplus
7.64 }
7.65 #endif
7.66
7.67 -#endif /* !dream_disasm_H */
7.68 +#endif /* !dream_cpu_H */
8.1 --- a/src/dream.h Sun Dec 25 04:54:40 2005 +0000
8.2 +++ b/src/dream.h Sun Dec 25 05:57:00 2005 +0000
8.3 @@ -7,6 +7,7 @@
8.4 #include <stdlib.h>
8.5 #include <stdint.h>
8.6 #include <string.h>
8.7 +#include <glib/gtypes.h>
8.8
8.9 #ifdef __cplusplus
8.10 extern "C" {
9.1 --- a/src/dreamcast.c Sun Dec 25 04:54:40 2005 +0000
9.2 +++ b/src/dreamcast.c Sun Dec 25 05:57:00 2005 +0000
9.3 @@ -1,5 +1,5 @@
9.4 /**
9.5 - * $Id: dreamcast.c,v 1.10 2005-12-25 01:28:36 nkeynes Exp $
9.6 + * $Id: dreamcast.c,v 1.11 2005-12-25 05:56:55 nkeynes Exp $
9.7 * Central switchboard for the system. This pulls all the individual modules
9.8 * together into some kind of coherent structure. This is also where you'd
9.9 * add Naomi support, if I ever get a board to play with...
9.10 @@ -137,6 +137,19 @@
9.11 return dreamcast_state == STATE_RUNNING;
9.12 }
9.13
9.14 +/***************************** User Configuration **************************/
9.15 +
9.16 +void dreamcast_load_config( const gchar *filename )
9.17 +{
9.18 +
9.19 +
9.20 +}
9.21 +
9.22 +void dreamcast_save_config( const gchar *filename )
9.23 +{
9.24 +
9.25 +
9.26 +}
9.27
9.28 /********************************* Save States *****************************/
9.29
10.1 --- a/src/dreamcast.h Sun Dec 25 04:54:40 2005 +0000
10.2 +++ b/src/dreamcast.h Sun Dec 25 05:57:00 2005 +0000
10.3 @@ -1,5 +1,5 @@
10.4 /**
10.5 - * $Id: dreamcast.h,v 1.7 2005-12-24 08:02:14 nkeynes Exp $
10.6 + * $Id: dreamcast.h,v 1.8 2005-12-25 05:56:55 nkeynes Exp $
10.7 *
10.8 * Public interface for dreamcast.c -
10.9 * Central switchboard for the system. This pulls all the individual modules
10.10 @@ -29,13 +29,16 @@
10.11 extern "C" {
10.12 #endif
10.13
10.14 -#define DEFAULT_TIMESLICE_LENGTH 1000 /* microseconds */
10.15 +#define DEFAULT_TIMESLICE_LENGTH 1000000 /* nanoseconds */
10.16
10.17 void dreamcast_init(void);
10.18 void dreamcast_reset(void);
10.19 void dreamcast_run(void);
10.20 void dreamcast_stop(void);
10.21
10.22 +void dreamcast_load_config( const gchar *filename );
10.23 +void dreamcast_save_config( const gchar *filename );
10.24 +
10.25 int dreamcast_save_state( const gchar *filename );
10.26 int dreamcast_load_state( const gchar *filename );
10.27
11.1 --- a/src/gui/callbacks.c Sun Dec 25 04:54:40 2005 +0000
11.2 +++ b/src/gui/callbacks.c Sun Dec 25 05:57:00 2005 +0000
11.3 @@ -1,5 +1,5 @@
11.4 /**
11.5 - * $Id: callbacks.c,v 1.9 2005-12-25 01:28:39 nkeynes Exp $
11.6 + * $Id: callbacks.c,v 1.10 2005-12-25 05:57:00 nkeynes Exp $
11.7 *
11.8 * All GTK callbacks go here (stubs are autogenerated by Glade)
11.9 *
11.10 @@ -117,8 +117,8 @@
11.11 on_step_btn_clicked (GtkButton *button,
11.12 gpointer user_data)
11.13 {
11.14 - sh4_execute_instruction();
11.15 - gtk_gui_update();
11.16 + debug_info_t data = get_debug_info(GTK_WIDGET(button));
11.17 + debug_win_single_step(data);
11.18 }
11.19
11.20
12.1 --- a/src/gui/debug_win.c Sun Dec 25 04:54:40 2005 +0000
12.2 +++ b/src/gui/debug_win.c Sun Dec 25 05:57:00 2005 +0000
12.3 @@ -1,5 +1,5 @@
12.4 /**
12.5 - * $Id: debug_win.c,v 1.9 2005-12-25 04:54:40 nkeynes Exp $
12.6 + * $Id: debug_win.c,v 1.10 2005-12-25 05:57:00 nkeynes Exp $
12.7 * This file is responsible for the main debugger gui frame.
12.8 *
12.9 * Copyright (c) 2005 Nathan Keynes.
12.10 @@ -20,7 +20,7 @@
12.11 #include <math.h>
12.12 #include "gui.h"
12.13 #include "mem.h"
12.14 -#include "disasm.h"
12.15 +#include "cpu.h"
12.16
12.17 GdkColor *msg_colors[] = { &clrError, &clrError, &clrWarn, &clrNormal,
12.18 &clrDebug, &clrTrace };
12.19 @@ -41,7 +41,7 @@
12.20 char saved_regs[0];
12.21 };
12.22
12.23 -debug_info_t init_debug_win(GtkWidget *win, struct cpu_desc_struct **cpu_list )
12.24 +debug_info_t init_debug_win(GtkWidget *win, const cpu_desc_t *cpu_list )
12.25 {
12.26 GnomeAppBar *appbar;
12.27
12.28 @@ -214,7 +214,7 @@
12.29 if( strcmp( data->cpu_list[i]->name, cpu ) == 0 ) {
12.30 if( data->cpu != data->cpu_list[i] ) {
12.31 data->cpu = data->cpu_list[i];
12.32 - set_disassembly_region( data, data->disasm_from );
12.33 + set_disassembly_pc( data, *data->cpu->pc, FALSE );
12.34 init_register_list( data );
12.35 }
12.36 return;
12.37 @@ -222,6 +222,15 @@
12.38 }
12.39 }
12.40
12.41 +/**
12.42 + * Execute a single instruction using the current CPU mode.
12.43 + */
12.44 +void debug_win_single_step( debug_info_t data )
12.45 +{
12.46 + data->cpu->step_func();
12.47 + gtk_gui_update();
12.48 +}
12.49 +
12.50 uint32_t row_to_address( debug_info_t data, int row ) {
12.51 return data->cpu->instr_size * row + data->disasm_from;
12.52 }
13.1 --- a/src/gui/gui.c Sun Dec 25 04:54:40 2005 +0000
13.2 +++ b/src/gui/gui.c Sun Dec 25 05:57:00 2005 +0000
13.3 @@ -1,3 +1,21 @@
13.4 +/**
13.5 + * $Id: gui.c,v 1.8 2005-12-25 05:57:00 nkeynes Exp $
13.6 + *
13.7 + * Top-level GUI (GTK2) module.
13.8 + *
13.9 + * Copyright (c) 2005 Nathan Keynes.
13.10 + *
13.11 + * This program is free software; you can redistribute it and/or modify
13.12 + * it under the terms of the GNU General Public License as published by
13.13 + * the Free Software Foundation; either version 2 of the License, or
13.14 + * (at your option) any later version.
13.15 + *
13.16 + * This program is distributed in the hope that it will be useful,
13.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13.19 + * GNU General Public License for more details.
13.20 + */
13.21 +
13.22 #include <stdlib.h>
13.23 #include <stdarg.h>
13.24 #include <gnome.h>
13.25 @@ -5,8 +23,8 @@
13.26 #include "dream.h"
13.27 #include "dreamcast.h"
13.28 #include "mem.h"
13.29 -#include "sh4dasm.h"
13.30 -#include "sh4core.h"
13.31 +#include "sh4/sh4dasm.h"
13.32 +#include "aica/armdasm.h"
13.33 #include "gui/gui.h"
13.34
13.35 #define REGISTER_FONT "-*-fixed-medium-r-normal--12-*-*-*-*-*-iso8859-1"
13.36 @@ -23,7 +41,7 @@
13.37 void gtk_gui_update( void );
13.38 void gtk_gui_start( void );
13.39 void gtk_gui_stop( void );
13.40 -int gtk_gui_run_slice( int microsecs );
13.41 +uint32_t gtk_gui_run_slice( uint32_t nanosecs );
13.42
13.43 struct dreamcast_module gtk_gui_module = { "Debugger", gtk_gui_init,
13.44 gtk_gui_update, gtk_gui_start,
13.45 @@ -88,12 +106,12 @@
13.46 gtk_gui_update();
13.47 }
13.48
13.49 -int gtk_gui_run_slice( int microsecs )
13.50 +uint32_t gtk_gui_run_slice( uint32_t nanosecs )
13.51 {
13.52 while( gtk_events_pending() )
13.53 gtk_main_iteration();
13.54 update_icount(main_debug);
13.55 - return microsecs;
13.56 + return nanosecs;
13.57 }
13.58
13.59 void gtk_gui_update(void) {
14.1 --- a/src/gui/gui.h Sun Dec 25 04:54:40 2005 +0000
14.2 +++ b/src/gui/gui.h Sun Dec 25 05:57:00 2005 +0000
14.3 @@ -1,16 +1,29 @@
14.4 -/*
14.5 - * Gui related code
14.6 +/**
14.7 + * $Id: gui.h,v 1.11 2005-12-25 05:57:00 nkeynes Exp $
14.8 + *
14.9 + * General GUI definitions
14.10 + *
14.11 + * Copyright (c) 2005 Nathan Keynes.
14.12 + *
14.13 + * This program is free software; you can redistribute it and/or modify
14.14 + * it under the terms of the GNU General Public License as published by
14.15 + * the Free Software Foundation; either version 2 of the License, or
14.16 + * (at your option) any later version.
14.17 + *
14.18 + * This program is distributed in the hope that it will be useful,
14.19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14.20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14.21 + * GNU General Public License for more details.
14.22 */
14.23 +
14.24 #ifndef dream_gui_H
14.25 #define dream_gui_H 1
14.26
14.27 #include <gnome.h>
14.28 #include "dream.h"
14.29 -#include "disasm.h"
14.30 +#include "cpu.h"
14.31 #include "modules.h"
14.32 #include "gui/interface.h"
14.33 -#include "sh4/sh4dasm.h"
14.34 -#include "aica/armdasm.h"
14.35
14.36 #ifdef __cplusplus
14.37 extern "C" {
14.38 @@ -30,10 +43,11 @@
14.39 void open_file_dialog( char *title, file_callback_t file_handler, char *pattern, char *patname );
14.40 void save_file_dialog( char *title, file_callback_t file_handler, char *pattern, char *patname );
14.41
14.42 -debug_info_t init_debug_win(GtkWidget *, cpu_desc_t *cpu );
14.43 -debug_info_t get_debug_info(GtkWidget *widget);
14.44 void update_mmr_win( void );
14.45 void init_mmr_win( void );
14.46 +
14.47 +debug_info_t init_debug_win(GtkWidget *, const cpu_desc_t *cpu );
14.48 +debug_info_t get_debug_info(GtkWidget *widget);
14.49 void update_registers( debug_info_t debug );
14.50 void update_icount( debug_info_t debug );
14.51 void dump_win_update_all();
14.52 @@ -43,6 +57,7 @@
14.53 void jump_to_disassembly( debug_info_t debug, unsigned int addr, gboolean select );
14.54 void jump_to_pc( debug_info_t debug, gboolean select );
14.55 void debug_win_set_running( debug_info_t debug, gboolean isRunning );
14.56 +void debug_win_single_step( debug_info_t debug );
14.57 uint32_t row_to_address( debug_info_t debug, int row );
14.58 int address_to_row( debug_info_t debug, uint32_t address );
14.59
15.1 --- a/src/main.c Sun Dec 25 04:54:40 2005 +0000
15.2 +++ b/src/main.c Sun Dec 25 05:57:00 2005 +0000
15.3 @@ -1,6 +1,22 @@
15.4 -/*
15.5 - * Initial main.c file generated by Glade. Edit as required.
15.6 - * Glade will not overwrite this file.
15.7 +/**
15.8 + * $Id: main.c,v 1.7 2005-12-25 05:56:55 nkeynes Exp $
15.9 + *
15.10 + * Main program, initializes dreamcast and gui, then passes control off to
15.11 + * the gtk main loop (currently).
15.12 + *
15.13 + * FIXME: Remove explicit GTK/Gnome references from this file
15.14 + *
15.15 + * Copyright (c) 2005 Nathan Keynes.
15.16 + *
15.17 + * This program is free software; you can redistribute it and/or modify
15.18 + * it under the terms of the GNU General Public License as published by
15.19 + * the Free Software Foundation; either version 2 of the License, or
15.20 + * (at your option) any later version.
15.21 + *
15.22 + * This program is distributed in the hope that it will be useful,
15.23 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15.24 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15.25 + * GNU General Public License for more details.
15.26 */
15.27
15.28 #ifdef HAVE_CONFIG_H
15.29 @@ -8,23 +24,21 @@
15.30 #endif
15.31
15.32 #include <gnome.h>
15.33 -
15.34 #include "gui/gui.h"
15.35 #include "dream.h"
15.36 #include "dreamcast.h"
15.37
15.38 -int
15.39 -main (int argc, char *argv[])
15.40 +int main (int argc, char *argv[])
15.41 {
15.42 #ifdef ENABLE_NLS
15.43 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
15.44 textdomain (PACKAGE);
15.45 #endif
15.46 dreamcast_init();
15.47 +
15.48 gnome_init ("dreamon", VERSION, argc, argv);
15.49 dreamcast_register_module( &gtk_gui_module );
15.50 video_open();
15.51 - // mem_new_watch( 0x0C204818, 0x0C204830, WATCH_WRITE );
15.52
15.53 emit( main_debug, EMIT_INFO, -1, "DreamOn! ready..." );
15.54
16.1 --- a/src/modules.h Sun Dec 25 04:54:40 2005 +0000
16.2 +++ b/src/modules.h Sun Dec 25 05:57:00 2005 +0000
16.3 @@ -1,7 +1,26 @@
16.4 +/**
16.5 + * $Id: modules.h,v 1.5 2005-12-25 05:56:55 nkeynes Exp $
16.6 + *
16.7 + * Internal dreamcast module structure definition and associated variables.
16.8 + * Included by all module implementations
16.9 + *
16.10 + * Copyright (c) 2005 Nathan Keynes.
16.11 + *
16.12 + * This program is free software; you can redistribute it and/or modify
16.13 + * it under the terms of the GNU General Public License as published by
16.14 + * the Free Software Foundation; either version 2 of the License, or
16.15 + * (at your option) any later version.
16.16 + *
16.17 + * This program is distributed in the hope that it will be useful,
16.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.20 + * GNU General Public License for more details.
16.21 + */
16.22
16.23 #ifndef dreamcast_modules_H
16.24 #define dreamcast_modules_H 1
16.25
16.26 +#include <stdint.h>
16.27 #include <stdlib.h>
16.28 #include <stdio.h>
16.29
16.30 @@ -31,9 +50,10 @@
16.31 void (*start)();
16.32 /**
16.33 * Execute one time-slice worth of operations, for the given number of
16.34 - * micro-seconds.
16.35 + * nanoseconds.
16.36 + * @return Number of nanoseconds actually executed
16.37 */
16.38 - int (*run_time_slice)( int microsecs );
16.39 + uint32_t (*run_time_slice)( uint32_t nanosecs );
16.40 /**
16.41 * Set the module into a stopped state (may be NULL)
16.42 */
17.1 --- a/src/pvr2/pvr2.c Sun Dec 25 04:54:40 2005 +0000
17.2 +++ b/src/pvr2/pvr2.c Sun Dec 25 05:57:00 2005 +0000
17.3 @@ -10,7 +10,7 @@
17.4 char *video_base;
17.5
17.6 void pvr2_init( void );
17.7 -int pvr2_run_slice( int );
17.8 +uint32_t pvr2_run_slice( uint32_t );
17.9 void pvr2_next_frame( void );
17.10
17.11 struct dreamcast_module pvr2_module = { "PVR2", pvr2_init, NULL, NULL,
17.12 @@ -24,16 +24,16 @@
17.13 }
17.14
17.15 uint32_t pvr2_time_counter = 0;
17.16 -uint32_t pvr2_time_per_frame = 20000;
17.17 +uint32_t pvr2_time_per_frame = 20000000;
17.18
17.19 -int pvr2_run_slice( int microsecs )
17.20 +uint32_t pvr2_run_slice( uint32_t nanosecs )
17.21 {
17.22 - pvr2_time_counter += microsecs;
17.23 - if( pvr2_time_counter >= pvr2_time_per_frame ) {
17.24 + pvr2_time_counter += nanosecs;
17.25 + while( pvr2_time_counter >= pvr2_time_per_frame ) {
17.26 pvr2_next_frame();
17.27 pvr2_time_counter -= pvr2_time_per_frame;
17.28 }
17.29 - return microsecs;
17.30 + return nanosecs;
17.31 }
17.32
17.33 uint32_t vid_stride, vid_lpf, vid_ppl, vid_hres, vid_vres, vid_col;
18.1 --- a/src/sh4/scif.c Sun Dec 25 04:54:40 2005 +0000
18.2 +++ b/src/sh4/scif.c Sun Dec 25 05:57:00 2005 +0000
18.3 @@ -1,5 +1,5 @@
18.4 /**
18.5 - * $Id: scif.c,v 1.4 2005-12-23 11:44:55 nkeynes Exp $
18.6 + * $Id: scif.c,v 1.5 2005-12-25 05:57:00 nkeynes Exp $
18.7 * SCIF (Serial Communication Interface with FIFO) implementation - part of the
18.8 * SH4 standard on-chip peripheral set. The SCIF is hooked up to the DCs
18.9 * external serial port
18.10 @@ -172,6 +172,9 @@
18.11 */
18.12 gboolean SCIF_rcvd_last_tick = FALSE;
18.13
18.14 +uint32_t SCIF_tick_period = 0;
18.15 +uint32_t SCIF_tick_remainder = 0;
18.16 +
18.17 void SCIF_save_state( FILE *f )
18.18 {
18.19 fwrite( &SCIF_recvq, sizeof(SCIF_recvq), 1, f );
18.20 @@ -441,6 +444,9 @@
18.21 if( serial_device != NULL && serial_device->set_line_speed != NULL )
18.22 serial_device->set_line_speed( baudrate );
18.23 INFO( "SCIF baud rate set to %d", baudrate );
18.24 +
18.25 + SCIF_tick_period = sh4_peripheral_period * (32 * mult * (bbr+1));
18.26 +
18.27 /*
18.28 clock_set_tick_rate( CLOCK_SCIF, baudrate / 10 );
18.29 */
18.30 @@ -610,8 +616,16 @@
18.31 SCIF_rcvd_last_tick = rcvd;
18.32 }
18.33
18.34 -void SCIF_run_slice( int microsecs )
18.35 +void SCIF_reset( void )
18.36 {
18.37 - /* TODO */
18.38 - SCIF_clock_tick();
18.39 + SCIF_tick_remainder = 0;
18.40 }
18.41 +
18.42 +void SCIF_run_slice( uint32_t nanosecs )
18.43 +{
18.44 + SCIF_tick_remainder += nanosecs;
18.45 + while( SCIF_tick_remainder >= SCIF_tick_period ) {
18.46 + SCIF_tick_remainder -= SCIF_tick_period;
18.47 + SCIF_clock_tick();
18.48 + }
18.49 +}
19.1 --- a/src/sh4/sh4core.c Sun Dec 25 04:54:40 2005 +0000
19.2 +++ b/src/sh4/sh4core.c Sun Dec 25 05:57:00 2005 +0000
19.3 @@ -1,5 +1,5 @@
19.4 /**
19.5 - * $Id: sh4core.c,v 1.10 2005-12-25 01:28:39 nkeynes Exp $
19.6 + * $Id: sh4core.c,v 1.11 2005-12-25 05:57:00 nkeynes Exp $
19.7 *
19.8 * SH4 emulation core, and parent module for all the SH4 peripheral
19.9 * modules.
19.10 @@ -41,11 +41,15 @@
19.11 uint32_t sh4_bus_freq = SH4_BASE_RATE;
19.12 uint32_t sh4_peripheral_freq = SH4_BASE_RATE / 2;
19.13
19.14 +uint32_t sh4_cpu_period = 1000 / SH4_BASE_RATE; /* in nanoseconds */
19.15 +uint32_t sh4_bus_period = 1000 / SH4_BASE_RATE;
19.16 +uint32_t sh4_peripheral_period = 2000 / SH4_BASE_RATE;
19.17 +
19.18 /********************** SH4 Module Definition ****************************/
19.19
19.20 void sh4_init( void );
19.21 void sh4_reset( void );
19.22 -int sh4_run_slice( int );
19.23 +uint32_t sh4_run_slice( uint32_t );
19.24 void sh4_start( void );
19.25 void sh4_stop( void );
19.26 void sh4_save_state( FILE *f );
19.27 @@ -85,9 +89,9 @@
19.28 intc_reset();
19.29 }
19.30
19.31 -int sh4_run_slice( int microsecs )
19.32 +uint32_t sh4_run_slice( uint32_t nanosecs )
19.33 {
19.34 - int target = sh4r.icount + sh4_freq * microsecs;
19.35 + int target = sh4r.icount + nanosecs / sh4_cpu_period;
19.36 int start = sh4r.icount;
19.37 int i;
19.38
19.39 @@ -101,15 +105,20 @@
19.40 if( !sh4_execute_instruction() )
19.41 break;
19.42 }
19.43 - if( target != sh4r.icount ) {
19.44 +
19.45 + /* If we aborted early, but the cpu is still technically running,
19.46 + * we're doing a hard abort - cut the timeslice back to what we
19.47 + * actually executed
19.48 + */
19.49 + if( target != sh4r.icount && sh4r.sh4_state == SH4_STATE_RUNNING ) {
19.50 /* Halted - compute time actually executed */
19.51 - microsecs = (sh4r.icount - start) / sh4_freq;
19.52 + nanosecs = (sh4r.icount - start) * sh4_cpu_period;
19.53 }
19.54 if( sh4r.sh4_state != SH4_STATE_STANDBY ) {
19.55 - TMU_run_slice( microsecs );
19.56 - SCIF_run_slice( microsecs );
19.57 + TMU_run_slice( nanosecs );
19.58 + SCIF_run_slice( nanosecs );
19.59 }
19.60 - return microsecs;
19.61 + return nanosecs;
19.62 }
19.63
19.64 void sh4_stop(void)
20.1 --- a/src/sh4/sh4core.h Sun Dec 25 04:54:40 2005 +0000
20.2 +++ b/src/sh4/sh4core.h Sun Dec 25 05:57:00 2005 +0000
20.3 @@ -1,5 +1,5 @@
20.4 /**
20.5 - * $Id: sh4core.h,v 1.5 2005-12-25 01:28:39 nkeynes Exp $
20.6 + * $Id: sh4core.h,v 1.6 2005-12-25 05:57:00 nkeynes Exp $
20.7 *
20.8 * This file defines the public functions exported by the SH4 core, except
20.9 * for disassembly functions defined in sh4dasm.h
20.10 @@ -16,6 +16,7 @@
20.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20.12 * GNU General Public License for more details.
20.13 */
20.14 +
20.15 #ifndef sh4core_H
20.16 #define sh4core_H 1
20.17
20.18 @@ -101,9 +102,9 @@
20.19 int32_t sh4_read_phys_word( uint32_t addr );
20.20
20.21 /* Peripheral functions */
20.22 -void DMAC_run_slice( int );
20.23 -void TMU_run_slice( int );
20.24 -void SCIF_run_slice( int );
20.25 +void DMAC_run_slice( uint32_t );
20.26 +void TMU_run_slice( uint32_t );
20.27 +void SCIF_run_slice( uint32_t );
20.28 void SCIF_save_state( FILE *f );
20.29 int SCIF_load_state( FILE *f );
20.30
21.1 --- a/src/sh4/sh4dasm.c Sun Dec 25 04:54:40 2005 +0000
21.2 +++ b/src/sh4/sh4dasm.c Sun Dec 25 05:57:00 2005 +0000
21.3 @@ -1,3 +1,21 @@
21.4 +/**
21.5 + * $Id: sh4dasm.c,v 1.7 2005-12-25 05:57:00 nkeynes Exp $
21.6 + *
21.7 + * SH4 CPU definition and disassembly functions
21.8 + *
21.9 + * Copyright (c) 2005 Nathan Keynes.
21.10 + *
21.11 + * This program is free software; you can redistribute it and/or modify
21.12 + * it under the terms of the GNU General Public License as published by
21.13 + * the Free Software Foundation; either version 2 of the License, or
21.14 + * (at your option) any later version.
21.15 + *
21.16 + * This program is distributed in the hope that it will be useful,
21.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
21.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21.19 + * GNU General Public License for more details.
21.20 + */
21.21 +
21.22 #include "sh4core.h"
21.23 #include "sh4dasm.h"
21.24 #include "mem.h"
21.25 @@ -25,9 +43,9 @@
21.26
21.27
21.28 const struct cpu_desc_struct sh4_cpu_desc =
21.29 - { "SH4", sh4_disasm_instruction, 2,
21.30 + { "SH4", sh4_disasm_instruction, sh4_execute_instruction, mem_has_page, 2,
21.31 (char *)&sh4r, sizeof(sh4r), sh4_reg_map,
21.32 - &sh4r.pc, &sh4r.icount, mem_has_page };
21.33 + &sh4r.pc, &sh4r.icount };
21.34
21.35 uint32_t sh4_disasm_instruction( uint32_t pc, char *buf, int len, char *opcode )
21.36 {
22.1 --- a/src/sh4/sh4dasm.h Sun Dec 25 04:54:40 2005 +0000
22.2 +++ b/src/sh4/sh4dasm.h Sun Dec 25 05:57:00 2005 +0000
22.3 @@ -1,7 +1,25 @@
22.4 +/**
22.5 + * $Id: sh4dasm.h,v 1.5 2005-12-25 05:57:00 nkeynes Exp $
22.6 + *
22.7 + * SH4 CPU definition and disassembly function declarations
22.8 + *
22.9 + * Copyright (c) 2005 Nathan Keynes.
22.10 + *
22.11 + * This program is free software; you can redistribute it and/or modify
22.12 + * it under the terms of the GNU General Public License as published by
22.13 + * the Free Software Foundation; either version 2 of the License, or
22.14 + * (at your option) any later version.
22.15 + *
22.16 + * This program is distributed in the hope that it will be useful,
22.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
22.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22.19 + * GNU General Public License for more details.
22.20 + */
22.21 +
22.22 #ifndef sh4dasm_H
22.23 #define sh4dasm_H 1
22.24
22.25 -#include "disasm.h"
22.26 +#include "cpu.h"
22.27
22.28 #ifdef __cplusplus
22.29 extern "C" {
23.1 --- a/src/sh4/sh4mmio.c Sun Dec 25 04:54:40 2005 +0000
23.2 +++ b/src/sh4/sh4mmio.c Sun Dec 25 05:57:00 2005 +0000
23.3 @@ -1,3 +1,23 @@
23.4 +/**
23.5 + * $Id: sh4mmio.c,v 1.5 2005-12-25 05:57:00 nkeynes Exp $
23.6 + *
23.7 + * Miscellaneous and not-really-implemented SH4 peripheral modules. Also
23.8 + * responsible for including the IMPL side of the SH4 MMIO pages.
23.9 + * Most of these will eventually be split off into their own files.
23.10 + *
23.11 + * Copyright (c) 2005 Nathan Keynes.
23.12 + *
23.13 + * This program is free software; you can redistribute it and/or modify
23.14 + * it under the terms of the GNU General Public License as published by
23.15 + * the Free Software Foundation; either version 2 of the License, or
23.16 + * (at your option) any later version.
23.17 + *
23.18 + * This program is distributed in the hope that it will be useful,
23.19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
23.20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23.21 + * GNU General Public License for more details.
23.22 + */
23.23 +
23.24 #include "dream.h"
23.25 #include "mem.h"
23.26 #include "clock.h"
24.1 --- a/src/sh4/sh4mmio.h Sun Dec 25 04:54:40 2005 +0000
24.2 +++ b/src/sh4/sh4mmio.h Sun Dec 25 05:57:00 2005 +0000
24.3 @@ -1,3 +1,22 @@
24.4 +/**
24.5 + * $Id: sh4mmio.h,v 1.4 2005-12-25 05:57:00 nkeynes Exp $
24.6 + *
24.7 + * MMIO region and supporting function declarations. Private to the sh4
24.8 + * module.
24.9 + *
24.10 + * Copyright (c) 2005 Nathan Keynes.
24.11 + *
24.12 + * This program is free software; you can redistribute it and/or modify
24.13 + * it under the terms of the GNU General Public License as published by
24.14 + * the Free Software Foundation; either version 2 of the License, or
24.15 + * (at your option) any later version.
24.16 + *
24.17 + * This program is distributed in the hope that it will be useful,
24.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
24.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24.20 + * GNU General Public License for more details.
24.21 + */
24.22 +
24.23 #include "mmio.h"
24.24
24.25 #if (defined(MMIO_IMPL) && !defined(SH4MMIO_IMPL)) || \
25.1 --- a/src/sh4/timer.c Sun Dec 25 04:54:40 2005 +0000
25.2 +++ b/src/sh4/timer.c Sun Dec 25 05:57:00 2005 +0000
25.3 @@ -1,5 +1,5 @@
25.4 /**
25.5 - * $Id: timer.c,v 1.1 2005-12-23 11:44:55 nkeynes Exp $
25.6 + * $Id: timer.c,v 1.2 2005-12-25 05:57:00 nkeynes Exp $
25.7 *
25.8 * SH4 Timer/Clock peripheral modules (CPG, TMU, RTC), combined together to
25.9 * keep things simple (they intertwine a bit).
25.10 @@ -85,10 +85,10 @@
25.11 MMIO_WRITE( TMU, reg, val );
25.12 }
25.13
25.14 -void TMU_run_slice( int microsecs )
25.15 +void TMU_run_slice( uint32_t nanosecs )
25.16 {
25.17 int tcr = MMIO_READ( TMU, TSTR );
25.18 - int cycles = microsecs * 16 * 200;
25.19 + int cycles = nanosecs / sh4_peripheral_period;
25.20 if( tcr & 0x01 ) {
25.21 int count = cycles / timer_divider[0];
25.22 int *val = MMIO_REG( TMU, TCNT0 );
.