File tree Expand file tree Collapse file tree 5 files changed +27
-12
lines changed Expand file tree Collapse file tree 5 files changed +27
-12
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "files.associations" : {
3+ "assert.h" : " c"
4+ }
5+ }
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ include mk/toolchain.mk
44OUT ?= build
55BIN := $(OUT ) /rv32emu
66
7- CFLAGS = -std=gnu99 -O2 -Wall -Wextra
7+ # CFLAGS = -std=gnu99 -O2 -Wall -Wextra
8+ CFLAGS = -std=gnu99 -Ofast -DNDEBUG -Wall -Wextra
89CFLAGS += -Wno-unused-label
910CFLAGS += -include src/common.h
1011
Original file line number Diff line number Diff line change 77#include <stdint.h>
88#include <stdlib.h>
99#include <string.h>
10+ #include <sys/mman.h>
11+ #include <unistd.h>
12+ #include <stdio.h>
1013
1114#include "io.h"
1215#include "mpool.h"
13-
16+ #define MEM_SIZE (512 * 1024 * 1024)
1417static const uint32_t mask_lo = 0xffff ;
1518static const uint32_t mask_hi = ~(0xffff );
1619
1720static struct mpool * mp ;
21+ static uint32_t mem_base ;
1822
19- memory_t * memory_new ()
23+ void memory_new ()
2024{
21- memory_t * m = calloc (1 , sizeof (memory_t ));
22- /* Initialize the mpool size to sizeof(chunk_t) << 2, and it will extend
23- * automatically if needed */
24- mp = mpool_create (sizeof (chunk_t ) << 2 , sizeof (chunk_t ));
25- return m ;
25+ mem_base = mmap (NULL , MEM_SIZE , PROT_READ | PROT_WRITE ,
26+ MAP_PRIVATE | MAP_ANONYMOUS , -1 , 0 );
27+ if (mem_base == MAP_FAILED ) {
28+ fprintf (stderr , "Could not map RAM\n" );
29+ }
30+ // memory_t *m = calloc(1, sizeof(memory_t));
31+ // /* Initialize the mpool size to sizeof(chunk_t) << 2, and it will extend
32+ // * automatically if needed */
33+ // mp = mpool_create(sizeof(chunk_t) << 2, sizeof(chunk_t));
34+ // return m;
2635}
2736
2837void memory_delete (memory_t * m )
2938{
3039 if (!m )
3140 return ;
32- mpool_destory (mp );
41+ // mpool_destory(mp);
3342 free (m );
3443}
3544
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ typedef struct {
1515 chunk_t * chunks [0x10000 ];
1616} memory_t ;
1717
18- memory_t * memory_new ();
18+ void memory_new ();
1919void memory_delete (memory_t * m );
2020
2121/* read a C-style string from memory */
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ typedef struct {
2525static inline state_t * state_new ()
2626{
2727 state_t * s = malloc (sizeof (state_t ));
28- s -> mem = memory_new ();
28+ // s->mem = memory_new();
2929 s -> break_addr = 0 ;
3030
3131 s -> fd_map = map_init (int , FILE * , map_cmp_int );
@@ -42,6 +42,6 @@ static inline void state_delete(state_t *s)
4242 return ;
4343
4444 map_delete (s -> fd_map );
45- memory_delete (s -> mem );
45+ // memory_delete(s->mem);
4646 free (s );
4747}
You can’t perform that action at this time.
0 commit comments