Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
nexus-am
提交
cec4e12d
N
nexus-am
项目概览
OpenXiangShan
/
nexus-am
10 个月 前同步成功
通知
0
Star
21
Fork
25
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nexus-am
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cec4e12d
编写于
4月 11, 2018
作者:
Y
Yanyan Jiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pte api finalize
上级
fd8024aa
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
23 deletion
+24
-23
am/am.h
am/am.h
+7
-7
am/arch/x86-qemu/include/am-x86.h
am/arch/x86-qemu/include/am-x86.h
+1
-2
am/arch/x86-qemu/src/asye.c
am/arch/x86-qemu/src/asye.c
+9
-5
am/arch/x86-qemu/src/pte.c
am/arch/x86-qemu/src/pte.c
+6
-8
am/arch/x86-qemu/src/trm.c
am/arch/x86-qemu/src/trm.c
+1
-1
未找到文件。
am/am.h
浏览文件 @
cec4e12d
...
...
@@ -59,7 +59,8 @@ typedef struct _RegSet _RegSet;
// A protected address space with user memory @area
// and arch-dependent @ptr
typedef
struct
_Protect
{
_Area
area
;
size_t
pgsize
;
_Area
area
;
void
*
ptr
;
}
_Protect
;
...
...
@@ -72,7 +73,7 @@ void _halt(int code);
// ======================= I/O Extension (IOE) =======================
int
_ioe_init
();
_Device
*
_device
(
int
n
);
_Device
*
_device
(
int
n
);
// get the device #n
// ================== Asynchronous Extension (ASYE) ==================
...
...
@@ -84,12 +85,11 @@ void _intr_write(int enable);
// =================== Protection Extension (PTE) ====================
int
_pte_init
(
void
*
(
*
pgalloc
)(
size_t
npages
),
void
(
*
pgfree
)(
void
*
));
int
_prot
_create
(
_Protect
*
p
);
void
_
prot_destroy
(
_Protect
*
p
);
void
_
prot_
switch
(
_Protect
*
p
);
int
_pte_init
(
void
*
(
*
pgalloc
)(
size_t
size
),
void
(
*
pgfree
)(
void
*
));
int
_prot
ect
(
_Protect
*
p
);
void
_
unprotect
(
_Protect
*
p
);
void
_switch
(
_Protect
*
p
);
int
_map
(
_Protect
*
p
,
void
*
va
,
void
*
pa
,
int
prot
);
int
_unmap
(
_Protect
*
p
,
void
*
va
);
_RegSet
*
_umake
(
_Protect
*
p
,
_Area
ustack
,
_Area
kstack
,
void
(
*
entry
)(
void
*
),
void
*
args
);
...
...
am/arch/x86-qemu/include/am-x86.h
浏览文件 @
cec4e12d
...
...
@@ -8,5 +8,4 @@ void lapic_bootap(int cpu, uint32_t address);
void
ioapic_enable
(
int
irq
,
int
cpu
);
void
smp_init
();
#endif
#endif
\ No newline at end of file
am/arch/x86-qemu/src/asye.c
浏览文件 @
cec4e12d
...
...
@@ -212,16 +212,20 @@ int _asye_init(_RegSet*(*handler)(_Event, _RegSet*)) {
}
_RegSet
*
_make
(
_Area
stack
,
void
(
*
entry
)(
void
*
),
void
*
arg
)
{
_RegSet
*
regs
=
(
_RegSet
*
)
stack
.
start
;
_RegSet
*
regs
=
(
_RegSet
*
)
stack
.
start
;
regs
->
eax
=
regs
->
ebx
=
regs
->
ecx
=
regs
->
edx
=
0
;
regs
->
esi
=
regs
->
edi
=
regs
->
ebp
=
regs
->
esp3
=
0
;
regs
->
ss0
=
0
;
// only used for ring3 procs
regs
->
esp0
=
(
uint32_t
)
stack
.
end
;
regs
->
cs
=
KSEL
(
SEG_KCODE
);
regs
->
ds
=
regs
->
es
=
regs
->
ss
=
KSEL
(
SEG_KDATA
);
regs
->
eip
=
(
uint32_t
)
entry
;
regs
->
eflags
=
0
;
regs
->
esp0
-=
4
;
*
((
void
**
)(
regs
->
esp0
))
=
arg
;
// argument
regs
->
esp0
-=
4
;
*
(
(
void
**
)(
regs
->
esp0
))
=
NULL
;
// return address
uint32_t
**
esp
=
(
uint32_t
**
)
&
regs
->
esp0
;
*
(
*
esp
-=
4
)
=
(
uint32_t
)
arg
;
// argument
*
(
*
esp
-=
4
)
=
0
;
// return address
return
regs
;
}
...
...
am/arch/x86-qemu/src/pte.c
浏览文件 @
cec4e12d
...
...
@@ -47,8 +47,9 @@ int _pte_init(void* (*palloc)(size_t), void (*pfree)(void*)) {
return
0
;
}
int
_prot_create
(
_Protect
*
p
)
{
PDE
*
updir
=
(
PDE
*
)(
palloc_f
(
1
));
int
_protect
(
_Protect
*
p
)
{
PDE
*
updir
=
(
PDE
*
)(
palloc_f
(
PGSIZE
));
p
->
pgsize
=
PGSIZE
;
p
->
ptr
=
updir
;
// map kernel space
for
(
int
i
=
0
;
i
<
1024
;
i
++
)
...
...
@@ -62,8 +63,8 @@ int _prot_create(_Protect *p) {
return
0
;
}
void
_
release
(
_Protect
*
p
)
{
//
free all spaces
void
_
unprotect
(
_Protect
*
p
)
{
//
DFS pages and call release
}
void
_switch
(
_Protect
*
p
)
{
...
...
@@ -76,7 +77,7 @@ int _map(_Protect *p, void *va, void *pa, int prot) {
uint32_t
wflag
=
0
;
// TODO: this should be not accessible
if
(
prot
&
_PROT_WRITE
)
wflag
=
PTE_W
;
if
(
!
(
*
pde
&
PTE_P
))
{
*
pde
=
PTE_P
|
wflag
|
PTE_U
|
(
uint32_t
)(
palloc_f
(
1
));
*
pde
=
PTE_P
|
wflag
|
PTE_U
|
(
uint32_t
)(
palloc_f
(
PGSIZE
));
}
PTE
*
pte
=
&
((
PTE
*
)
PTE_ADDR
(
*
pde
))[
PTX
(
va
)];
if
(
!
(
*
pte
&
PTE_P
))
{
...
...
@@ -85,9 +86,6 @@ int _map(_Protect *p, void *va, void *pa, int prot) {
return
0
;
}
void
_unmap
(
_Protect
*
p
,
void
*
va
)
{
}
_RegSet
*
_umake
(
_Protect
*
p
,
_Area
ustack
,
_Area
kstack
,
void
(
*
entry
)(
void
*
),
void
*
args
)
{
_RegSet
*
regs
=
(
_RegSet
*
)
kstack
.
start
;
regs
->
cs
=
USEL
(
SEG_UCODE
);
...
...
am/arch/x86-qemu/src/trm.c
浏览文件 @
cec4e12d
#include <x86.h>
#include <am-x86.h>
#include <am.h>
#include <am-x86.h>
int
main
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录