|
|
1.1 root 1: /*
1.1.1.2 root 2: Hatari - stMemory.h
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
1.1 root 6: */
7:
1.1.1.2 root 8: #ifndef HATARI_STMEMORY_H
9: #define HATARI_STMEMORY_H
10:
1.1.1.9 root 11: #include "main.h"
1.1.1.3 root 12: #include "sysdeps.h"
13: #include "maccess.h"
14:
1.1.1.7 root 15: #if ENABLE_SMALL_MEM
16: extern Uint8 *STRam;
17: extern uae_u8 *ROMmemory;
18: # define RomMem (ROMmemory-0xe00000)
19: #else
1.1.1.3 root 20: extern Uint8 STRam[16*1024*1024];
1.1.1.7 root 21: #define RomMem STRam
22: #endif /* ENABLE_SMALL_MEM */
1.1.1.3 root 23:
1.1.1.7 root 24: extern Uint32 STRamEnd;
1.1.1.3 root 25:
1.1.1.10 root 26: /* TODO: when Hatari will support TT/fast-RAM, take it into account
27: * in STRAM_ADDR() and STMemory_ValidArea().
28: */
29:
1.1.1.3 root 30: /* Offset ST address to PC pointer: */
1.1.1.8 root 31: #if ENABLE_SMALL_MEM
32: # define STRAM_ADDR(Var) \
33: (((Var)>= 0xe00000) \
34: ? ((unsigned long)RomMem+((Uint32)(Var) & 0x00ffffff)) \
35: : ((unsigned long)STRam+((Uint32)(Var) & 0x00ffffff)))
36: #else
37: # define STRAM_ADDR(Var) ((unsigned long)STRam+((Uint32)(Var) & 0x00ffffff))
38: #endif
1.1.1.3 root 39:
1.1.1.10 root 40:
41: /**
42: * Check whether given memory address and size are within
43: * valid ST memory area (i.e. read/write from/to there doesn't
44: * overwrite Hatari's own memory & cause potential segfaults)
45: * and that the size is positive.
46: *
47: * If they are; return true, otherwise false.
48: */
49: static inline bool STMemory_ValidArea(Uint32 addr, int size)
50: {
51: if (size >= 0 && addr+size < 0xff0000 &&
52: (addr+size < STRamEnd || addr >= 0xe00000))
53: {
54: return true;
55: }
56: return false;
57: }
58:
59:
60: /**
61: * Write 32-bit word into ST memory space.
62: * NOTE - value will be convert to 68000 endian
63: */
1.1.1.3 root 64: static inline void STMemory_WriteLong(Uint32 Address, Uint32 Var)
65: {
1.1.1.4 root 66: Address &= 0xffffff;
1.1.1.7 root 67: #if ENABLE_SMALL_MEM
68: if (Address >= 0xe00000)
69: do_put_mem_long(&ROMmemory[Address-0xe00000], Var);
70: else
71: do_put_mem_long(&STRam[Address], Var);
72: #else
1.1.1.4 root 73: do_put_mem_long(&STRam[Address], Var);
1.1.1.7 root 74: #endif
1.1.1.3 root 75: }
76:
1.1.1.10 root 77:
78: /**
79: * Write 16-bit word into ST memory space.
80: * NOTE - value will be convert to 68000 endian.
81: */
1.1.1.3 root 82: static inline void STMemory_WriteWord(Uint32 Address, Uint16 Var)
83: {
1.1.1.4 root 84: Address &= 0xffffff;
1.1.1.7 root 85: #if ENABLE_SMALL_MEM
86: if (Address >= 0xe00000)
87: do_put_mem_word(&ROMmemory[Address-0xe00000], Var);
88: else
89: do_put_mem_word(&STRam[Address], Var);
90: #else
1.1.1.4 root 91: do_put_mem_word(&STRam[Address], Var);
1.1.1.7 root 92: #endif
1.1.1.3 root 93: }
94:
1.1.1.10 root 95:
96: /**
97: * Write 8-bit byte into ST memory space.
98: */
1.1.1.3 root 99: static inline void STMemory_WriteByte(Uint32 Address, Uint8 Var)
100: {
1.1.1.4 root 101: Address &= 0xffffff;
1.1.1.7 root 102: #if ENABLE_SMALL_MEM
103: if (Address >= 0xe00000)
104: ROMmemory[Address-0xe00000] = Var;
105: else
106: STRam[Address] = Var;
107: #else
1.1.1.4 root 108: STRam[Address] = Var;
1.1.1.7 root 109: #endif
1.1.1.3 root 110: }
111:
112:
1.1.1.10 root 113: /**
114: * Read 32-bit word from ST memory space.
115: * NOTE - value will be converted to PC endian.
116: */
1.1.1.3 root 117: static inline Uint32 STMemory_ReadLong(Uint32 Address)
118: {
1.1.1.4 root 119: Address &= 0xffffff;
1.1.1.7 root 120: #if ENABLE_SMALL_MEM
121: if (Address >= 0xe00000)
122: return do_get_mem_long(&ROMmemory[Address-0xe00000]);
123: else
124: return do_get_mem_long(&STRam[Address]);
125: #else
1.1.1.4 root 126: return do_get_mem_long(&STRam[Address]);
1.1.1.7 root 127: #endif
1.1.1.3 root 128: }
129:
1.1.1.10 root 130:
131: /**
132: * Read 16-bit word from ST memory space.
133: * NOTE - value will be converted to PC endian.
134: */
1.1.1.3 root 135: static inline Uint16 STMemory_ReadWord(Uint32 Address)
136: {
1.1.1.4 root 137: Address &= 0xffffff;
1.1.1.7 root 138: #if ENABLE_SMALL_MEM
139: if (Address >= 0xe00000)
140: return do_get_mem_word(&ROMmemory[Address-0xe00000]);
141: else
142: return do_get_mem_word(&STRam[Address]);
143: #else
1.1.1.4 root 144: return do_get_mem_word(&STRam[Address]);
1.1.1.7 root 145: #endif
1.1.1.3 root 146: }
147:
1.1.1.10 root 148:
149: /**
150: * Read 8-bit byte from ST memory space
151: */
1.1.1.3 root 152: static inline Uint8 STMemory_ReadByte(Uint32 Address)
153: {
1.1.1.4 root 154: Address &= 0xffffff;
1.1.1.7 root 155: #if ENABLE_SMALL_MEM
156: if (Address >= 0xe00000)
157: return ROMmemory[Address-0xe00000];
158: else
159: return STRam[Address];
160: #else
1.1.1.4 root 161: return STRam[Address];
1.1.1.7 root 162: #endif
1.1.1.3 root 163: }
164:
165:
1.1.1.5 root 166: extern void STMemory_Clear(Uint32 StartAddress, Uint32 EndAddress);
1.1.1.11! root 167: extern bool STMemory_SafeCopy(Uint32 addr, Uint8 *src, unsigned int len, const char *name);
1.1.1.10 root 168: extern void STMemory_MemorySnapShot_Capture(bool bSave);
1.1.1.6 root 169: extern void STMemory_SetDefaultConfig(void);
1.1.1.2 root 170:
171: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.