8
8
#include <stdint.h>
9
9
#include <string.h>
10
10
11
- /* Directly map a memory with a size of 2^32 bytes. All memory read/write
12
- * operations can access this memory through the memory subsystem.
13
- */
14
-
15
11
typedef struct {
16
12
uint8_t * mem_base ;
17
13
uint64_t mem_size ;
18
14
} memory_t ;
19
15
16
+ /* create a memory instance */
20
17
memory_t * memory_new (uint32_t size );
18
+
19
+ /* delete a memory instance */
21
20
void memory_delete (memory_t * m );
22
21
23
22
/* read an instruction from memory */
@@ -35,6 +34,7 @@ uint8_t memory_read_b(uint32_t addr);
35
34
/* read a length of data from memory */
36
35
void memory_read (const memory_t * m , uint8_t * dst , uint32_t addr , uint32_t size );
37
36
37
+ /* write a length of data to memory */
38
38
static inline void memory_write (memory_t * m ,
39
39
uint32_t addr ,
40
40
const uint8_t * src ,
@@ -43,12 +43,16 @@ static inline void memory_write(memory_t *m,
43
43
memcpy (m -> mem_base + addr , src , size );
44
44
}
45
45
46
+ /* write a word to memory */
46
47
void memory_write_w (uint32_t addr , const uint8_t * src );
47
48
49
+ /* write a short to memory */
48
50
void memory_write_s (uint32_t addr , const uint8_t * src );
49
51
52
+ /* write a byte to memory */
50
53
void memory_write_b (uint32_t addr , const uint8_t * src );
51
54
55
+ /* write a length of certain value to memory */
52
56
static inline void memory_fill (memory_t * m ,
53
57
uint32_t addr ,
54
58
uint32_t size ,
0 commit comments