Search
lxdream.org :: lxdream/src/mem.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/mem.h
changeset 669:ab344e42bca9
prev586:2a3ba82cf243
next736:a02d1475ccfd
author nkeynes
date Sun Jun 22 06:49:00 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Big cleanup of the command-line options
Add an actual manpage (*gasp*)
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     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)
     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 dream_mem_H
    21 #define dream_mem_H
    23 #include <stdint.h>
    24 #include "lxdream.h"
    26 #ifdef __cplusplus
    27 extern "C" {
    28 #endif
    30 typedef struct mem_region {
    31     uint32_t base;
    32     uint32_t size;
    33     const char *name;
    34     sh4ptr_t mem;
    35     uint32_t flags;
    36 } *mem_region_t;
    38 #define MAX_IO_REGIONS 24
    39 #define MAX_MEM_REGIONS 8
    41 #define MEM_REGION_BIOS "Bios ROM"
    42 #define MEM_REGION_MAIN "System RAM"
    43 #define MEM_REGION_VIDEO "Video RAM"
    44 #define MEM_REGION_AUDIO "Audio RAM"
    45 #define MEM_REGION_AUDIO_SCRATCH "Audio Scratch RAM"
    46 #define MEM_REGION_FLASH "System Flash"
    48 void *mem_create_ram_region( uint32_t base, uint32_t size, const char *name );
    49 void *mem_create_repeating_ram_region( uint32_t base, uint32_t size, const char *name, 
    50 				       uint32_t repeat_offset, uint32_t last_repeat );
    51 /**
    52  * Load a ROM image from the specified filename. If the memory region has not
    53  * been allocated, it is created now, otherwise the existing region is reused.
    54  * If the CRC check fails, a warning will be printed.
    55  * @return TRUE if the image was loaded successfully (irrespective of CRC failure).
    56  */
    57 gboolean mem_load_rom( const gchar *filename, uint32_t base, uint32_t size, 
    58 		       uint32_t crc, const gchar *region_name );
    59 void *mem_alloc_pages( int n );
    60 sh4ptr_t mem_get_region( uint32_t addr );
    61 sh4ptr_t mem_get_region_by_name( const char *name );
    62 int mem_has_page( uint32_t addr );
    63 sh4ptr_t mem_get_page( uint32_t addr );
    64 int mem_load_block( const gchar *filename, uint32_t base, uint32_t size );
    65 int mem_save_block( const gchar *filename, uint32_t base, uint32_t size );
    66 void mem_set_trace( const gchar *tracelist, int flag );
    67 void mem_init( void );
    68 void mem_reset( void );
    69 void mem_copy_from_sh4( sh4ptr_t dest, sh4addr_t src, size_t count );
    70 void mem_copy_to_sh4( sh4addr_t dest, sh4ptr_t src, size_t count );
    72 /**
    73  * Write a long value directly to SH4-addressable memory.
    74  * @param dest a valid, writable physical memory address, relative to the SH4
    75  * @param value the value to write.
    76  */
    77 void mem_write_long( sh4addr_t dest, uint32_t value );
    79 #define ENABLE_DEBUG_MODE 1
    81 typedef enum { BREAK_NONE=0, BREAK_ONESHOT=1, BREAK_KEEP=2 } breakpoint_type_t;
    83 struct breakpoint_struct {
    84     uint32_t address;
    85     breakpoint_type_t type;
    86 };
    88 #define MAX_BREAKPOINTS 32
    91 #define MEM_FLAG_ROM 4 /* Mem region is ROM-based */
    92 #define MEM_FLAG_RAM 6 
    94 #define WATCH_WRITE 1
    95 #define WATCH_READ  2
    96 #define WATCH_EXEC  3  /* AKA Breakpoint :) */
    98 typedef struct watch_point *watch_point_t;
   100 watch_point_t mem_new_watch( uint32_t start, uint32_t end, int flags );
   101 void mem_delete_watch( watch_point_t watch );
   102 watch_point_t mem_is_watched( uint32_t addr, int size, int op );
   104 extern sh4ptr_t *page_map;
   105 #ifdef __cplusplus
   106 }
   107 #endif
   108 #endif
.