Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
68ae4cc1
提交
68ae4cc1
8月 24, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
comment what +m means; omit needless __
上级
2aae7205
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
27 行增加
和
25 行删除
+27
-25
x86.h
x86.h
+27
-25
没有找到文件。
x86.h
浏览文件 @
68ae4cc1
// Special assembly routines to access x86-specific
// Special assembly routines to access x86-specific
// hardware instructions.
// hardware instructions.
static
__
inline
uchar
static
inline
uchar
inb
(
ushort
port
)
inb
(
ushort
port
)
{
{
uchar
data
;
uchar
data
;
__asm
__
volatile
(
"in %1,%0"
:
"=a"
(
data
)
:
"d"
(
port
));
asm
volatile
(
"in %1,%0"
:
"=a"
(
data
)
:
"d"
(
port
));
return
data
;
return
data
;
}
}
static
__
inline
void
static
inline
void
insl
(
int
port
,
void
*
addr
,
int
cnt
)
insl
(
int
port
,
void
*
addr
,
int
cnt
)
{
{
__asm
__
volatile
(
"cld
\n\t
repne
\n\t
insl"
:
asm
volatile
(
"cld
\n\t
repne
\n\t
insl"
:
"=D"
(
addr
),
"=c"
(
cnt
)
:
"=D"
(
addr
),
"=c"
(
cnt
)
:
"d"
(
port
),
"0"
(
addr
),
"1"
(
cnt
)
:
"d"
(
port
),
"0"
(
addr
),
"1"
(
cnt
)
:
"memory"
,
"cc"
);
"memory"
,
"cc"
);
}
}
static
__
inline
void
static
inline
void
outb
(
ushort
port
,
uchar
data
)
outb
(
ushort
port
,
uchar
data
)
{
{
__asm
__
volatile
(
"out %0,%1"
:
:
"a"
(
data
),
"d"
(
port
));
asm
volatile
(
"out %0,%1"
:
:
"a"
(
data
),
"d"
(
port
));
}
}
static
__
inline
void
static
inline
void
outw
(
ushort
port
,
ushort
data
)
outw
(
ushort
port
,
ushort
data
)
{
{
__asm
__
volatile
(
"out %0,%1"
:
:
"a"
(
data
),
"d"
(
port
));
asm
volatile
(
"out %0,%1"
:
:
"a"
(
data
),
"d"
(
port
));
}
}
static
__
inline
void
static
inline
void
outsl
(
int
port
,
const
void
*
addr
,
int
cnt
)
outsl
(
int
port
,
const
void
*
addr
,
int
cnt
)
{
{
__asm
__
volatile
(
"cld
\n\t
repne
\n\t
outsl"
:
asm
volatile
(
"cld
\n\t
repne
\n\t
outsl"
:
"=S"
(
addr
),
"=c"
(
cnt
)
:
"=S"
(
addr
),
"=c"
(
cnt
)
:
"d"
(
port
),
"0"
(
addr
),
"1"
(
cnt
)
:
"d"
(
port
),
"0"
(
addr
),
"1"
(
cnt
)
:
"cc"
);
"cc"
);
...
@@ -41,7 +41,7 @@ outsl(int port, const void *addr, int cnt)
...
@@ -41,7 +41,7 @@ outsl(int port, const void *addr, int cnt)
struct
segdesc
;
struct
segdesc
;
static
__
inline
void
static
inline
void
lgdt
(
struct
segdesc
*
p
,
int
size
)
lgdt
(
struct
segdesc
*
p
,
int
size
)
{
{
volatile
ushort
pd
[
3
];
volatile
ushort
pd
[
3
];
...
@@ -55,7 +55,7 @@ lgdt(struct segdesc *p, int size)
...
@@ -55,7 +55,7 @@ lgdt(struct segdesc *p, int size)
struct
gatedesc
;
struct
gatedesc
;
static
__
inline
void
static
inline
void
lidt
(
struct
gatedesc
*
p
,
int
size
)
lidt
(
struct
gatedesc
*
p
,
int
size
)
{
{
volatile
ushort
pd
[
3
];
volatile
ushort
pd
[
3
];
...
@@ -67,27 +67,27 @@ lidt(struct gatedesc *p, int size)
...
@@ -67,27 +67,27 @@ lidt(struct gatedesc *p, int size)
asm
volatile
(
"lidt (%0)"
:
:
"r"
(
pd
));
asm
volatile
(
"lidt (%0)"
:
:
"r"
(
pd
));
}
}
static
__
inline
void
static
inline
void
ltr
(
ushort
sel
)
ltr
(
ushort
sel
)
{
{
__asm
__
volatile
(
"ltr %0"
:
:
"r"
(
sel
));
asm
volatile
(
"ltr %0"
:
:
"r"
(
sel
));
}
}
static
__
inline
uint
static
inline
uint
read_eflags
(
void
)
read_eflags
(
void
)
{
{
uint
eflags
;
uint
eflags
;
__asm
__
volatile
(
"pushfl; popl %0"
:
"=r"
(
eflags
));
asm
volatile
(
"pushfl; popl %0"
:
"=r"
(
eflags
));
return
eflags
;
return
eflags
;
}
}
static
__
inline
void
static
inline
void
write_eflags
(
uint
eflags
)
write_eflags
(
uint
eflags
)
{
{
__asm
__
volatile
(
"pushl %0; popfl"
:
:
"r"
(
eflags
));
asm
volatile
(
"pushl %0; popfl"
:
:
"r"
(
eflags
));
}
}
static
__
inline
void
static
inline
void
cpuid
(
uint
info
,
uint
*
eaxp
,
uint
*
ebxp
,
uint
*
ecxp
,
uint
*
edxp
)
cpuid
(
uint
info
,
uint
*
eaxp
,
uint
*
ebxp
,
uint
*
ecxp
,
uint
*
edxp
)
{
{
uint
eax
,
ebx
,
ecx
,
edx
;
uint
eax
,
ebx
,
ecx
,
edx
;
...
@@ -104,27 +104,29 @@ cpuid(uint info, uint *eaxp, uint *ebxp, uint *ecxp, uint *edxp)
...
@@ -104,27 +104,29 @@ cpuid(uint info, uint *eaxp, uint *ebxp, uint *ecxp, uint *edxp)
*
edxp
=
edx
;
*
edxp
=
edx
;
}
}
static
__
inline
uint
static
inline
uint
cmpxchg
(
uint
oldval
,
uint
newval
,
volatile
uint
*
lock_addr
)
cmpxchg
(
uint
oldval
,
uint
newval
,
volatile
uint
*
lock_addr
)
{
{
uint
result
;
uint
result
;
__asm__
__volatile__
(
"lock; cmpxchgl %2, %0"
:
// The + in "+m" denotes a read-modify-write operand.
asm
volatile
(
"lock; cmpxchgl %2, %0"
:
"+m"
(
*
lock_addr
),
"=a"
(
result
)
:
"+m"
(
*
lock_addr
),
"=a"
(
result
)
:
"r"
(
newval
),
"1"
(
oldval
)
:
"r"
(
newval
),
"1"
(
oldval
)
:
"cc"
);
"cc"
);
return
result
;
return
result
;
}
}
static
__
inline
void
static
inline
void
cli
(
void
)
cli
(
void
)
{
{
__asm__
volatile
(
"cli"
);
asm
volatile
(
"cli"
);
}
}
static
__
inline
void
static
inline
void
sti
(
void
)
sti
(
void
)
{
{
__asm__
volatile
(
"sti"
);
asm
volatile
(
"sti"
);
}
}
// Layout of the trap frame on the stack upon entry to trap.
// Layout of the trap frame on the stack upon entry to trap.
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论