Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
9e82bfb0
提交
9e82bfb0
8月 28, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename 8253pit.c to timer.c
上级
eae04163
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
15 行增加
和
28 行删除
+15
-28
defs.h
defs.h
+3
-3
main.c
main.c
+2
-2
runoff.list
runoff.list
+1
-1
timer.c
timer.c
+9
-22
没有找到文件。
defs.h
浏览文件 @
9e82bfb0
...
...
@@ -7,9 +7,6 @@ struct proc;
struct
spinlock
;
struct
stat
;
// 8253pit.c
void
pit8253_timerinit
(
void
);
// bio.c
void
binit
(
void
);
struct
buf
*
bread
(
uint
,
uint
);
...
...
@@ -140,6 +137,9 @@ int fetchint(struct proc*, uint, int*);
int
fetchstr
(
struct
proc
*
,
uint
,
char
**
);
void
syscall
(
void
);
// timer.c
void
timer_init
(
void
);
// trap.c
void
idtinit
(
void
);
extern
int
ticks
;
...
...
main.c
浏览文件 @
9e82bfb0
...
...
@@ -46,7 +46,7 @@ main(void)
ide_init
();
// disk
bootothers
();
// boot other CPUs
if
(
!
ismp
)
pit8253_timer
init
();
// uniprocessor timer
timer_
init
();
// uniprocessor timer
userinit
();
// first user process
// enable interrupts on this processor.
...
...
@@ -74,7 +74,7 @@ mpmain(void)
scheduler
();
}
void
static
void
bootothers
(
void
)
{
extern
uchar
_binary_bootother_start
[],
_binary_bootother_size
[];
...
...
runoff.list
浏览文件 @
9e82bfb0
...
...
@@ -64,7 +64,7 @@ picirq.c
kbd.h
kbd.c
console.c
8253pit
.c
timer
.c
# user-level
usys.S
...
...
8253pit
.c
→
timer
.c
浏览文件 @
9e82bfb0
// Intel 8253/8254/82C54 Programmable Interval Timer (PIT).
// Only used on uniprocessors;
// SMP machines use the local APIC timer.
#include "types.h"
#include "defs.h"
#include "traps.h"
#include "x86.h"
// Register definitions for the Intel
// 8253/8254/82C54 Programmable Interval Timer (PIT).
#define IO_TIMER1 0x040 // 8253 Timer #1
#define IO_TIMER2 0x048 // 8253 Timer #2 (EISA only)
// Frequency of all three count-down timers; (TIMER_FREQ/freq) is the
// appropriate count to generate a frequency of freq hz.
// Frequency of all three count-down timers;
// (TIMER_FREQ/freq) is the appropriate count
// to generate a frequency of freq Hz.
#define TIMER_FREQ 1193182
#define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
#define TIMER_CNTR0 (IO_TIMER1 + 0) // timer 0 counter port
#define TIMER_CNTR1 (IO_TIMER1 + 1) // timer 1 counter port
#define TIMER_CNTR2 (IO_TIMER1 + 2) // timer 2 counter port
#define TIMER_MODE (IO_TIMER1 + 3) // timer mode port
#define TIMER_SEL0 0x00 // select counter 0
#define TIMER_SEL1 0x40 // select counter 1
#define TIMER_SEL2 0x80 // select counter 2
#define TIMER_INTTC 0x00 // mode 0, intr on terminal cnt
#define TIMER_ONESHOT 0x02 // mode 1, one shot
#define TIMER_RATEGEN 0x04 // mode 2, rate generator
#define TIMER_SQWAVE 0x06 // mode 3, square wave
#define TIMER_SWSTROBE 0x08 // mode 4, s/w triggered strobe
#define TIMER_HWSTROBE 0x0a // mode 5, h/w triggered strobe
#define TIMER_LATCH 0x00 // latch counter for reading
#define TIMER_LSB 0x10 // r/w counter LSB
#define TIMER_MSB 0x20 // r/w counter MSB
#define TIMER_16BIT 0x30 // r/w counter 16 bits, LSB first
#define TIMER_BCD 0x01 // count in BCD
void
pit8253_timer
init
(
void
)
timer_
init
(
void
)
{
//
initialize 8253 clock to interrupt 100 times/sec
//
Interrupt 100 times/sec.
outb
(
TIMER_MODE
,
TIMER_SEL0
|
TIMER_RATEGEN
|
TIMER_16BIT
);
outb
(
IO_TIMER1
,
TIMER_DIV
(
100
)
%
256
);
outb
(
IO_TIMER1
,
TIMER_DIV
(
100
)
/
256
);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论