Search
lxdream.org :: lxdream/src/mem.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/mem.h
changeset 31:495e480360d7
prev19:9da7a8e38f9d
next43:0cf3e339cc59
author nkeynes
date Sun Dec 25 08:24:11 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change Finish adding header blocks to all files
file annotate diff log raw
nkeynes@31
     1
/**
nkeynes@31
     2
 * $Id: mem.h,v 1.5 2005-12-25 08:24:07 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@10
    24
nkeynes@10
    25
#ifdef __cplusplus
nkeynes@10
    26
extern "C" {
nkeynes@10
    27
#endif
nkeynes@10
    28
nkeynes@10
    29
typedef struct mem_region {
nkeynes@10
    30
    uint32_t base;
nkeynes@10
    31
    uint32_t size;
nkeynes@10
    32
    char *name;
nkeynes@10
    33
    char *mem;
nkeynes@10
    34
    int flags;
nkeynes@10
    35
} *mem_region_t;
nkeynes@10
    36
nkeynes@10
    37
#define MAX_IO_REGIONS 24
nkeynes@10
    38
#define MAX_MEM_REGIONS 8
nkeynes@10
    39
nkeynes@10
    40
#define MEM_REGION_MAIN "System RAM"
nkeynes@10
    41
#define MEM_REGION_VIDEO "Video RAM"
nkeynes@10
    42
#define MEM_REGION_AUDIO "Audio RAM"
nkeynes@10
    43
#define MEM_REGION_AUDIO_SCRATCH "Audio Scratch RAM"
nkeynes@10
    44
nkeynes@10
    45
#define MB * (1024 * 1024)
nkeynes@10
    46
#define KB * 1024
nkeynes@10
    47
nkeynes@10
    48
void *mem_create_ram_region( uint32_t base, uint32_t size, char *name );
nkeynes@10
    49
void *mem_load_rom( char *name, uint32_t base, uint32_t size, uint32_t crc );
nkeynes@19
    50
void *mem_alloc_pages( int n );
nkeynes@10
    51
char *mem_get_region( uint32_t addr );
nkeynes@10
    52
char *mem_get_region_by_name( char *name );
nkeynes@10
    53
int mem_has_page( uint32_t addr );
nkeynes@10
    54
char *mem_get_page( uint32_t addr );
nkeynes@10
    55
nkeynes@10
    56
void mem_init( void );
nkeynes@10
    57
void mem_reset( void );
nkeynes@10
    58
nkeynes@10
    59
#define ENABLE_WATCH 1
nkeynes@10
    60
nkeynes@10
    61
#define WATCH_WRITE 1
nkeynes@10
    62
#define WATCH_READ  2
nkeynes@10
    63
#define WATCH_EXEC  3  /* AKA Breakpoint :) */
nkeynes@10
    64
nkeynes@18
    65
#define MEM_FLAG_ROM 4 /* Mem region is ROM-based */
nkeynes@18
    66
#define MEM_FLAG_RAM 6 
nkeynes@18
    67
nkeynes@10
    68
typedef struct watch_point *watch_point_t;
nkeynes@10
    69
nkeynes@10
    70
watch_point_t mem_new_watch( uint32_t start, uint32_t end, int flags );
nkeynes@10
    71
void mem_delete_watch( watch_point_t watch );
nkeynes@10
    72
watch_point_t mem_is_watched( uint32_t addr, int size, int op );
nkeynes@10
    73
nkeynes@10
    74
extern char **page_map;
nkeynes@10
    75
#ifdef __cplusplus
nkeynes@10
    76
}
nkeynes@10
    77
#endif
nkeynes@10
    78
#endif
.