Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
1d6ed6cc
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
11 个月 前同步成功
通知
1183
Star
3914
Fork
526
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
XiangShan
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1d6ed6cc
编写于
11月 27, 2020
作者:
Y
Yinan Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ram: support simulating larger RAM by using mmap
上级
6be8443d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
9 deletion
+28
-9
src/test/csrc/emu.cpp
src/test/csrc/emu.cpp
+2
-3
src/test/csrc/ram.cpp
src/test/csrc/ram.cpp
+25
-5
src/test/csrc/ram.h
src/test/csrc/ram.h
+1
-1
未找到文件。
src/test/csrc/emu.cpp
浏览文件 @
1d6ed6cc
...
...
@@ -125,9 +125,8 @@ Emulator::Emulator(int argc, const char *argv[]):
}
Emulator
::~
Emulator
()
{
#ifdef WITH_DRAMSIM3
dramsim3_finish
();
#endif
ram_finish
();
#ifdef VM_SAVABLE
snapshot_slot
[
0
].
save
();
snapshot_slot
[
1
].
save
();
...
...
src/test/csrc/ram.cpp
浏览文件 @
1d6ed6cc
#include <sys/mman.h>
#include <zlib.h>
#include "common.h"
#include "ram.h"
#include <zlib.h>
#define RAMSIZE (256 * 1024 * 1024)
#define RAMSIZE (256 * 1024 * 1024UL)
#ifdef WITH_DRAMSIM3
#include "cosimulation.h"
CoDRAMsim3
*
dram
=
NULL
;
#endif
static
uint64_t
ram
[
RAMSIZE
/
sizeof
(
uint64_t
)]
;
static
uint64_t
*
ram
;
static
long
img_size
=
0
;
void
*
get_img_start
()
{
return
&
ram
[
0
];
}
long
get_img_size
()
{
return
img_size
;
}
void
*
get_ram_start
()
{
return
&
ram
[
0
];
}
long
get_ram_size
()
{
return
RAMSIZE
;
}
#ifdef TLB_UNITTEST
void
addpageSv39
()
{
//three layers
//addr range: 0x0000000080000000 - 0x0000000088000000 for 128MB from 2GB - 2GB128MB
...
...
@@ -99,6 +101,7 @@ void addpageSv39() {
memcpy
((
char
*
)
ram
+
(
RAMSIZE
-
PAGESIZE
*
(
PTENUM
+
PDENUM
)),
pde
,
PAGESIZE
*
PDENUM
);
memcpy
((
char
*
)
ram
+
(
RAMSIZE
-
PAGESIZE
*
PTENUM
),
pte
,
PAGESIZE
*
PTENUM
);
}
#endif
// Return whether the file is a gz file
int
isGzFile
(
const
char
*
img
)
{
...
...
@@ -153,9 +156,17 @@ void init_ram(const char *img) {
printf
(
"The image is %s
\n
"
,
img
);
// initialize memory using Linux mmap
printf
(
"Using simulated %luMB RAM
\n
"
,
RAMSIZE
/
(
1024
*
1024
));
ram
=
(
uint64_t
*
)
mmap
(
NULL
,
RAMSIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_ANON
|
MAP_PRIVATE
,
-
1
,
0
);
if
(
ram
==
(
uint64_t
*
)
MAP_FAILED
)
{
printf
(
"Cound not mmap 0x%lx bytes
\n
"
,
RAMSIZE
);
assert
(
0
);
}
int
ret
;
if
(
isGzFile
(
img
))
{
printf
(
"Gzip file detected
. Loading image from extracted gz file.
\n
"
);
printf
(
"Gzip file detected
and loading image from extracted gz file
\n
"
);
img_size
=
readFromGz
(
ram
,
img
);
assert
(
img_size
>=
0
);
}
...
...
@@ -179,9 +190,11 @@ void init_ram(const char *img) {
fclose
(
fp
);
}
#ifdef TLB_UNITTEST
//new add
addpageSv39
();
//new end
#endif
#ifdef WITH_DRAMSIM3
#if !defined(DRAMSIM3_CONFIG) || !defined(DRAMSIM3_OUTDIR)
...
...
@@ -193,6 +206,13 @@ void init_ram(const char *img) {
}
void
ram_finish
()
{
munmap
(
ram
,
RAMSIZE
);
#ifdef WITH_DRAMSIM3
dramsim3_finish
();
#endif
}
extern
"C"
uint64_t
ram_read_helper
(
uint8_t
en
,
uint64_t
rIdx
)
{
if
(
en
&&
rIdx
>=
RAMSIZE
/
sizeof
(
uint64_t
))
{
printf
(
"ERROR: ram idx = 0x%lx out of bound!
\n
"
,
rIdx
);
...
...
src/test/csrc/ram.h
浏览文件 @
1d6ed6cc
...
...
@@ -3,8 +3,8 @@
#include "common.h"
// #define WITH_DRAMSIM3
void
init_ram
(
const
char
*
img
);
void
ram_finish
();
#ifdef WITH_DRAMSIM3
// 4*64 bits
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录