- /*
- By Marcus Xing
- kernel/init_8253.c
- 设置8253,控制2次时钟中断发生的间隙
- */
- #include "type.h"
- #include "const.h"
- #include "ipc.h"
- #include "console.h"
- #include "tty.h"
- #include "protect.h"
- #include "proc.h"
- #include "proto.h"
- /*
- 8253端口
- 端口 描述
- 40h 8253Counter0
- 41h 8253Counter1
- 42h 8253Counter2
- 43h 8253模式控制寄存器
- 其中Counter0关系到时钟中断发生的间隙,PC的频率为1193180HZ
- 每发生一个时钟周期Counter0值减1,减到0发生一次时钟中断,并
- 且回到最大值,Counter0为16位,所以最大值为65535。
- 想设置Counter0,必须先写模式控制寄存器,此处选择模式2,并
- 先读低位,再读高位,选择Counter0,即为0x34
- */
- /*---------------------------------------------------------------------Init_8253
- 初始化8253
- */
- void Init_8253()
- {
- Out_Byte(MODE_CTL,0x34);
- Out_Byte(COUNTER0,(u8)(PC_FREQ / MY_HZ));
- Out_Byte(COUNTER0,(u8)((PC_FREQ / MY_HZ) >> 8));
- }