Search
lxdream.org :: lxdream/src/mem.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/mem.h
changeset 502:c4ecae2b1b5e
prev477:9a373f2ff009
next510:41ce7a074f4e
author nkeynes
date Thu Nov 08 11:54:16 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Add sh4ptr_t type, start converting bare pointer refs to it
file annotate diff log raw
nkeynes@31
     1
/**
nkeynes@502
     2
 * $Id: mem.h,v 1.16 2007-11-08 11:54:16 nkeynes Exp $
nkeynes@31
     3
 *
nkeynes@31
     4
 * mem is responsible for creating and maintaining the overall system memory
nkeynes@31
     5
 * map, as visible from the SH4 processor. (Note the ARM has a different map)
nkeynes@31
     6
 *
nkeynes@31
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@31
     8
 *
nkeynes@31
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@31
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@31
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@31
    12
 * (at your option) any later version.
nkeynes@31
    13
 *
nkeynes@31
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@31
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@31
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@31
    17
 * GNU General Public License for more details.
nkeynes@31
    18
 */
nkeynes@31
    19
nkeynes@31
    20
#ifndef dream_mem_H
nkeynes@31
    21
#define dream_mem_H
nkeynes@10
    22
nkeynes@10
    23
#include <stdint.h>
nkeynes@477
    24
#include "lxdream.h"
nkeynes@10
    25
nkeynes@10
    26
#ifdef __cplusplus
nkeynes@10
    27
extern "C" {
nkeynes@10
    28
#endif
nkeynes@10
    29
nkeynes@10
    30
typedef struct mem_region {
nkeynes@10
    31
    uint32_t base;
nkeynes@10
    32
    uint32_t size;
nkeynes@422
    33
    const char *name;
nkeynes@502
    34
    sh4ptr_t mem;
nkeynes@10
    35
    int flags;
nkeynes@10
    36
} *mem_region_t;
nkeynes@10
    37
nkeynes@10
    38
#define MAX_IO_REGIONS 24
nkeynes@10
    39
#define MAX_MEM_REGIONS 8
nkeynes@10
    40
nkeynes@180
    41
#define MEM_REGION_BIOS "Bios ROM"
nkeynes@10
    42
#define MEM_REGION_MAIN "System RAM"
nkeynes@10
    43
#define MEM_REGION_VIDEO "Video RAM"
nkeynes@10
    44
#define MEM_REGION_AUDIO "Audio RAM"
nkeynes@10
    45
#define MEM_REGION_AUDIO_SCRATCH "Audio Scratch RAM"
nkeynes@146
    46
#define MEM_REGION_FLASH "System Flash"
nkeynes@10
    47
nkeynes@422
    48
void *mem_create_ram_region( uint32_t base, uint32_t size, const char *name );
nkeynes@422
    49
void *mem_create_repeating_ram_region( uint32_t base, uint32_t size, const char *name, 
nkeynes@146
    50
				       uint32_t repeat_offset, uint32_t last_repeat );
nkeynes@466
    51
void *mem_load_rom( const gchar *name, uint32_t base, uint32_t size, uint32_t crc,
nkeynes@466
    52
		    const gchar *region_name );
nkeynes@19
    53
void *mem_alloc_pages( int n );
nkeynes@502
    54
sh4ptr_t mem_get_region( uint32_t addr );
nkeynes@502
    55
sh4ptr_t mem_get_region_by_name( const char *name );
nkeynes@10
    56
int mem_has_page( uint32_t addr );
nkeynes@502
    57
sh4ptr_t mem_get_page( uint32_t addr );
nkeynes@146
    58
int mem_load_block( const gchar *filename, uint32_t base, uint32_t size );
nkeynes@146
    59
int mem_save_block( const gchar *filename, uint32_t base, uint32_t size );
nkeynes@156
    60
void mem_set_trace( uint32_t addr, int flag );
nkeynes@10
    61
void mem_init( void );
nkeynes@10
    62
void mem_reset( void );
nkeynes@502
    63
void mem_copy_from_sh4( sh4ptr_t dest, sh4addr_t src, size_t count );
nkeynes@502
    64
void mem_copy_to_sh4( sh4addr_t dest, sh4ptr_t src, size_t count );
nkeynes@10
    65
nkeynes@43
    66
#define ENABLE_DEBUG_MODE 1
nkeynes@43
    67
nkeynes@43
    68
struct breakpoint_struct {
nkeynes@43
    69
    uint32_t address;
nkeynes@43
    70
    int type;
nkeynes@43
    71
};
nkeynes@43
    72
nkeynes@43
    73
#define MAX_BREAKPOINTS 32
nkeynes@43
    74
#define BREAK_NONE 0
nkeynes@43
    75
#define BREAK_ONESHOT 1
nkeynes@43
    76
#define BREAK_KEEP 2
nkeynes@43
    77
nkeynes@234
    78
#undef ENABLE_WATCH
nkeynes@10
    79
nkeynes@10
    80
#define WATCH_WRITE 1
nkeynes@10
    81
#define WATCH_READ  2
nkeynes@10
    82
#define WATCH_EXEC  3  /* AKA Breakpoint :) */
nkeynes@10
    83
nkeynes@18
    84
#define MEM_FLAG_ROM 4 /* Mem region is ROM-based */
nkeynes@18
    85
#define MEM_FLAG_RAM 6 
nkeynes@18
    86
nkeynes@10
    87
typedef struct watch_point *watch_point_t;
nkeynes@10
    88
nkeynes@10
    89
watch_point_t mem_new_watch( uint32_t start, uint32_t end, int flags );
nkeynes@10
    90
void mem_delete_watch( watch_point_t watch );
nkeynes@10
    91
watch_point_t mem_is_watched( uint32_t addr, int size, int op );
nkeynes@10
    92
nkeynes@502
    93
extern sh4ptr_t *page_map;
nkeynes@10
    94
#ifdef __cplusplus
nkeynes@10
    95
}
nkeynes@10
    96
#endif
nkeynes@10
    97
#endif
.