Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e28d4b35
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e28d4b35
编写于
3月 11, 2013
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: Add context switching for ARM and MIPS
ARM definitely compiles
上级
48cb9a8a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
31 deletion
+63
-31
src/libcore/rt/context.rs
src/libcore/rt/context.rs
+63
-26
src/libcore/rt/mod.rs
src/libcore/rt/mod.rs
+0
-5
未找到文件。
src/libcore/rt/context.rs
浏览文件 @
e28d4b35
...
...
@@ -65,7 +65,42 @@ pub impl Context {
fn
swap_registers
(
out_regs
:
*
mut
Registers
,
in_regs
:
*
Registers
);
}
// Definitions of these registers are in rt/arch/x86_64/regs.h
#[cfg(target_arch
=
"x86"
)]
struct
Registers
{
eax
:
u32
,
ebx
:
u32
,
ecx
:
u32
,
edx
:
u32
,
ebp
:
u32
,
esi
:
u32
,
edi
:
u32
,
esp
:
u32
,
cs
:
u16
,
ds
:
u16
,
ss
:
u16
,
es
:
u16
,
fs
:
u16
,
gs
:
u16
,
eflags
:
u32
,
eip
:
u32
}
#[cfg(target_arch
=
"x86"
)]
fn
new_regs
()
->
~
Registers
{
~
Registers
{
eax
:
0
,
ebx
:
0
,
ecx
:
0
,
edx
:
0
,
ebp
:
0
,
esi
:
0
,
edi
:
0
,
esp
:
0
,
cs
:
0
,
ds
:
0
,
ss
:
0
,
es
:
0
,
fs
:
0
,
gs
:
0
,
eflags
:
0
,
eip
:
0
}
}
#[cfg(target_arch
=
"x86"
)]
fn
initialize_call_frame
(
regs
:
&
mut
Registers
,
fptr
:
*
c_void
,
arg
:
*
c_void
,
sp
:
*
mut
uint
)
{
let
sp
=
align_down
(
sp
);
let
sp
=
mut_offset
(
sp
,
-
4
);
// XXX: -4 words? Needs this be done at all?
unsafe
{
*
sp
=
arg
as
uint
;
}
let
sp
=
mut_offset
(
sp
,
-
1
);
unsafe
{
*
sp
=
0
;
}
// The final return address
regs
.esp
=
sp
as
u32
;
regs
.eip
=
fptr
as
u32
;
// Last base pointer on the stack is 0
regs
.ebp
=
0
;
}
#[cfg(target_arch
=
"x86_64"
)]
type
Registers
=
[
uint
*
22
];
...
...
@@ -101,40 +136,42 @@ fn initialize_call_frame(regs: &mut Registers,
regs
[
RUSTRT_RBP
]
=
0
;
}
#[cfg(target_arch
=
"x86"
)]
struct
Registers
{
eax
:
u32
,
ebx
:
u32
,
ecx
:
u32
,
edx
:
u32
,
ebp
:
u32
,
esi
:
u32
,
edi
:
u32
,
esp
:
u32
,
cs
:
u16
,
ds
:
u16
,
ss
:
u16
,
es
:
u16
,
fs
:
u16
,
gs
:
u16
,
eflags
:
u32
,
eip
:
u32
}
#[cfg(target_arch
=
"arm"
)]
type
Registers
=
[
uint
*
32
];
#[cfg(target_arch
=
"x86"
)]
fn
new_regs
()
->
~
Registers
{
~
Registers
{
eax
:
0
,
ebx
:
0
,
ecx
:
0
,
edx
:
0
,
ebp
:
0
,
esi
:
0
,
edi
:
0
,
esp
:
0
,
cs
:
0
,
ds
:
0
,
ss
:
0
,
es
:
0
,
fs
:
0
,
gs
:
0
,
eflags
:
0
,
eip
:
0
}
}
#[cfg(target_arch
=
"arm"
)]
fn
new_regs
()
->
~
Registers
{
~
[
0
,
..
32
]
}
#[cfg(target_arch
=
"
x86
"
)]
#[cfg(target_arch
=
"
arm
"
)]
fn
initialize_call_frame
(
regs
:
&
mut
Registers
,
fptr
:
*
c_void
,
arg
:
*
c_void
,
sp
:
*
mut
uint
)
{
let
sp
=
mut_offset
(
sp
,
-
1
);
let
sp
=
align_down
(
sp
);
let
sp
=
mut_offset
(
sp
,
-
4
);
// XXX: -4 words? Needs this be done at all?
// The final return address. 0 indicates the bottom of the stack
unsafe
{
*
sp
=
0
;
}
unsafe
{
*
sp
=
arg
as
uint
;
}
regs
[
0
]
=
arg
as
uint
;
// r0
regs
[
13
]
=
sp
as
uint
;
// #53 sp, r13
regs
[
14
]
=
fptr
as
uint
;
// #60 pc, r15 --> lr
}
#[cfg(target_arch
=
"mips"
)]
type
Registers
=
[
uint
*
32
];
#[cfg(target_arch
=
"mips"
)]
fn
new_regs
()
->
~
Registers
{
~
[
0
,
..
32
]
}
#[cfg(target_arch
=
"mips"
)]
fn
initialize_call_frame
(
regs
:
&
mut
Registers
,
fptr
:
*
c_void
,
arg
:
*
c_void
,
sp
:
*
mut
uint
)
{
let
sp
=
mut_offset
(
sp
,
-
1
);
unsafe
{
*
sp
=
0
;
}
// The final return address
regs
.esp
=
sp
as
u32
;
regs
.eip
=
fptr
as
u32
;
// The final return address. 0 indicates the bottom of the stack
unsafe
{
*
sp
=
0
;
}
// Last base pointer on the stack is 0
regs
.ebp
=
0
;
regs
[
4
]
=
arg
as
uint
;
regs
[
29
]
=
sp
as
uint
;
regs
[
31
]
=
fptr
as
uint
;
}
fn
align_down
(
sp
:
*
mut
uint
)
->
*
mut
uint
{
...
...
src/libcore/rt/mod.rs
浏览文件 @
e28d4b35
...
...
@@ -8,11 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// XXX: Missing some implementation for other architectures
#[cfg(target_os
=
"linux"
)]
;
#[cfg(target_os
=
"mac"
)]
;
#[cfg(target_os
=
"win32"
)]
;
// Some basic logging
macro_rules!
rtdebug
(
(
$
(
$arg:expr
),
+
)
=>
(
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录