4 * mem is responsible for creating and maintaining the overall system memory
5 * map, as visible from the SH4 processor. (Note the ARM has a different map)
7 * Copyright (c) 2005 Nathan Keynes.
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.
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.
21 #define lxdream_mem_H 1
30 typedef struct mem_region_fn {
31 FASTCALL int32_t (*read_long)(sh4addr_t addr);
32 FASTCALL void (*write_long)(sh4addr_t addr, uint32_t val);
33 FASTCALL int32_t (*read_word)(sh4addr_t addr);
34 FASTCALL void (*write_word)(sh4addr_t addr, uint32_t val);
35 FASTCALL int32_t (*read_byte)(sh4addr_t addr);
36 FASTCALL void (*write_byte)(sh4addr_t addr, uint32_t val);
37 FASTCALL void (*read_burst)(unsigned char *dest, sh4addr_t addr);
38 FASTCALL void (*write_burst)(sh4addr_t addr, unsigned char *src);
41 typedef struct mem_region {
50 #define MAX_IO_REGIONS 24
51 #define MAX_MEM_REGIONS 8
53 #define MEM_REGION_BIOS "Bios ROM"
54 #define MEM_REGION_MAIN "System RAM"
55 #define MEM_REGION_VIDEO "Video RAM"
56 #define MEM_REGION_AUDIO "Audio RAM"
57 #define MEM_REGION_AUDIO_SCRATCH "Audio Scratch RAM"
58 #define MEM_REGION_FLASH "System Flash"
60 void *mem_create_ram_region( uint32_t base, uint32_t size, const char *name, mem_region_fn_t fn );
61 void *mem_create_repeating_ram_region( uint32_t base, uint32_t size, const char *name, mem_region_fn_t fn,
62 uint32_t repeat_offset, uint32_t last_repeat );
64 * Load a ROM image from the specified filename. If the memory region has not
65 * been allocated, it is created now, otherwise the existing region is reused.
66 * If the CRC check fails, a warning will be printed.
67 * @return TRUE if the image was loaded successfully (irrespective of CRC failure).
69 gboolean mem_load_rom( const gchar *filename, uint32_t base, uint32_t size,
70 uint32_t crc, const gchar *region_name, mem_region_fn_t fn );
71 void *mem_alloc_pages( int n );
72 sh4ptr_t mem_get_region( uint32_t addr );
73 sh4ptr_t mem_get_region_by_name( const char *name );
74 int mem_has_page( uint32_t addr );
75 sh4ptr_t mem_get_page( uint32_t addr );
76 int mem_load_block( const gchar *filename, uint32_t base, uint32_t size );
77 int mem_save_block( const gchar *filename, uint32_t base, uint32_t size );
78 void mem_set_trace( const gchar *tracelist, int flag );
79 void mem_init( void );
80 void mem_reset( void );
81 void mem_copy_from_sh4( sh4ptr_t dest, sh4addr_t src, size_t count );
82 void mem_copy_to_sh4( sh4addr_t dest, sh4ptr_t src, size_t count );
85 * Write a long value directly to SH4-addressable memory.
86 * @param dest a valid, writable physical memory address, relative to the SH4
87 * @param value the value to write.
89 void mem_write_long( sh4addr_t dest, uint32_t value );
91 #define ENABLE_DEBUG_MODE 1
93 typedef enum { BREAK_NONE=0, BREAK_ONESHOT=1, BREAK_KEEP=2 } breakpoint_type_t;
95 struct breakpoint_struct {
97 breakpoint_type_t type;
100 #define MAX_BREAKPOINTS 32
103 #define MEM_FLAG_ROM 4 /* Mem region is ROM-based */
104 #define MEM_FLAG_RAM 6
106 #define WATCH_WRITE 1
108 #define WATCH_EXEC 3 /* AKA Breakpoint :) */
110 typedef struct watch_point *watch_point_t;
112 watch_point_t mem_new_watch( uint32_t start, uint32_t end, int flags );
113 void mem_delete_watch( watch_point_t watch );
114 watch_point_t mem_is_watched( uint32_t addr, int size, int op );
116 extern sh4ptr_t *page_map;
122 #endif /* !lxdream_mem_H */
.