Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
b5dcebdb
提交
b5dcebdb
9月 27, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better lapic writes, suggested by cliff
上级
47212719
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
19 行删除
+26
-19
lapic.c
lapic.c
+26
-19
没有找到文件。
lapic.c
浏览文件 @
b5dcebdb
...
@@ -37,6 +37,13 @@
...
@@ -37,6 +37,13 @@
volatile
uint
*
lapic
;
// Initialized in mp.c
volatile
uint
*
lapic
;
// Initialized in mp.c
static
void
lapicw
(
int
index
,
int
value
)
{
lapic
[
index
]
=
value
;
lapic
[
ID
];
// wait for write to finish, by reading
}
//PAGEBREAK!
//PAGEBREAK!
void
void
lapic_init
(
int
c
)
lapic_init
(
int
c
)
...
@@ -45,43 +52,43 @@ lapic_init(int c)
...
@@ -45,43 +52,43 @@ lapic_init(int c)
return
;
return
;
// Enable local APIC; set spurious interrupt vector.
// Enable local APIC; set spurious interrupt vector.
lapic
[
SVR
]
=
ENABLE
|
(
IRQ_OFFSET
+
IRQ_SPURIOUS
);
lapic
w
(
SVR
,
ENABLE
|
(
IRQ_OFFSET
+
IRQ_SPURIOUS
)
);
// The timer repeatedly counts down at bus frequency
// The timer repeatedly counts down at bus frequency
// from lapic[TICR] and then issues an interrupt.
// from lapic[TICR] and then issues an interrupt.
// If xv6 cared more about precise timekeeping,
// If xv6 cared more about precise timekeeping,
// TICR would be calibrated using an external time source.
// TICR would be calibrated using an external time source.
lapic
[
TDCR
]
=
X1
;
lapic
w
(
TDCR
,
X1
)
;
lapic
[
TIMER
]
=
PERIODIC
|
(
IRQ_OFFSET
+
IRQ_TIMER
);
lapic
w
(
TIMER
,
PERIODIC
|
(
IRQ_OFFSET
+
IRQ_TIMER
)
);
lapic
[
TICR
]
=
10000000
;
lapic
w
(
TICR
,
10000000
)
;
// Disable logical interrupt lines.
// Disable logical interrupt lines.
lapic
[
LINT0
]
=
MASKED
;
lapic
w
(
LINT0
,
MASKED
)
;
lapic
[
LINT1
]
=
MASKED
;
lapic
w
(
LINT1
,
MASKED
)
;
// Disable performance counter overflow interrupts
// Disable performance counter overflow interrupts
// on machines that provide that interrupt entry.
// on machines that provide that interrupt entry.
if
(((
lapic
[
VER
]
>>
16
)
&
0xFF
)
>=
4
)
if
(((
lapic
[
VER
]
>>
16
)
&
0xFF
)
>=
4
)
lapic
[
PCINT
]
=
MASKED
;
lapic
w
(
PCINT
,
MASKED
)
;
// Map error interrupt to IRQ_ERROR.
// Map error interrupt to IRQ_ERROR.
lapic
[
ERROR
]
=
IRQ_OFFSET
+
IRQ_ERROR
;
lapic
w
(
ERROR
,
IRQ_OFFSET
+
IRQ_ERROR
)
;
// Clear error status register (requires back-to-back writes).
// Clear error status register (requires back-to-back writes).
lapic
[
ESR
]
=
0
;
lapic
w
(
ESR
,
0
)
;
lapic
[
ESR
]
=
0
;
lapic
w
(
ESR
,
0
)
;
// Ack any outstanding interrupts.
// Ack any outstanding interrupts.
lapic
[
EOI
]
=
0
;
lapic
w
(
EOI
,
0
)
;
// Send an Init Level De-Assert to synchronise arbitration ID's.
// Send an Init Level De-Assert to synchronise arbitration ID's.
lapic
[
ICRHI
]
=
0
;
lapic
w
(
ICRHI
,
0
)
;
lapic
[
ICRLO
]
=
BCAST
|
INIT
|
LEVEL
;
lapic
w
(
ICRLO
,
BCAST
|
INIT
|
LEVEL
)
;
while
(
lapic
[
ICRLO
]
&
DELIVS
)
while
(
lapic
[
ICRLO
]
&
DELIVS
)
;
;
// Enable interrupts on the APIC (but not on the processor).
// Enable interrupts on the APIC (but not on the processor).
lapic
[
TPR
]
=
0
;
lapic
w
(
TPR
,
0
)
;
}
}
int
int
...
@@ -116,7 +123,7 @@ void
...
@@ -116,7 +123,7 @@ void
lapic_eoi
(
void
)
lapic_eoi
(
void
)
{
{
if
(
lapic
)
if
(
lapic
)
lapic
[
EOI
]
=
0
;
lapic
w
(
EOI
,
0
)
;
}
}
// Spin for a given number of microseconds.
// Spin for a given number of microseconds.
...
@@ -139,16 +146,16 @@ lapic_startap(uchar apicid, uint addr)
...
@@ -139,16 +146,16 @@ lapic_startap(uchar apicid, uint addr)
volatile
int
j
=
0
;
volatile
int
j
=
0
;
// Send INIT interrupt to reset other CPU.
// Send INIT interrupt to reset other CPU.
lapic
[
ICRHI
]
=
apicid
<<
24
;
lapic
w
(
ICRHI
,
apicid
<<
24
)
;
lapic
[
ICRLO
]
=
INIT
|
LEVEL
;
lapic
w
(
ICRLO
,
INIT
|
LEVEL
)
;
microdelay
(
10
);
microdelay
(
10
);
// Send startup IPI (twice!) to enter bootstrap code.
// Send startup IPI (twice!) to enter bootstrap code.
// Regular hardware wants it twice, but Bochs complains.
// Regular hardware wants it twice, but Bochs complains.
// Too bad for Bochs.
// Too bad for Bochs.
for
(
i
=
0
;
i
<
2
;
i
++
){
for
(
i
=
0
;
i
<
2
;
i
++
){
lapic
[
ICRHI
]
=
apicid
<<
24
;
lapic
w
(
ICRHI
,
apicid
<<
24
)
;
lapic
[
ICRLO
]
=
STARTUP
|
(
addr
>>
12
);
lapic
w
(
ICRLO
,
STARTUP
|
(
addr
>>
12
)
);
for
(
j
=
0
;
j
<
10000
;
j
++
);
// 200us
for
(
j
=
0
;
j
<
10000
;
j
++
);
// 200us
}
}
}
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论