在我自己的操作系统内核中的周期性RTC中断
periodic RTC interrupt in My own OS kernel
我目前正在用c++编程一个内核。因此,作为内核的基本部分,我在我的内核中实现了一个中断处理模块,它工作得很好。但是它不能为RTC IRQ8中断工作
这是启用irq的代码:
void IDT::enable_irq(unsigned short x, void (*handler)(), unsigned char control){
current_mask &= ~(1<<x) ; //Zero off the IRQ mask to enable
if (x>=8)
{
current_mask &= ~(1<<2);
set_int((x + SLAVE_VEC - 7),(unsigned long) handler, control);
}
else //Sets the appropriate interrupt at the same time
{
set_int((x + MASTER_VEC),(unsigned long) handler, control);
}
outb(PICMI, current_mask & 0xff);
outb(PICSI, (current_mask >> 8) & 0xff);
}
set_int
是在IDT中添加中断项的函数。
如果我调用它,它可以很好地用于键盘中断:
enable_irq(1,kbInt,INT_GATE|BITS_32|PRESENT|RING_2);
但是如果我为irq8(即RTC)调用它,则它不起作用。
enable_irq(8,rtcInt,INT_GATE|BITS_32|PRESENT|RING_2);
给出如下错误:An unhandled interrupt has occurred...
然后我按照本教程的说明:http://wiki.osdev.org/RTC
但是我想做的是,我想在每个中断上生成周期性RTC中断和屏幕上的显示时间。或者我想在每个RTC中断上调用一个特定的函数
那么谁能帮我解决这个问题呢?
谢谢。
你的代码中的数学是错误的。
if (x>=8)
{
current_mask &= ~(1<<2);
set_int((x + SLAVE_VEC - 7),(unsigned long) handler, control);
}
将在IDT中的0x41位置安装处理程序,如果SLAVE_VEC是0x40(正如您的评论所暗示的),当您肯定想将其安装在0x40位置时,因为0x40是由PIC为IRQ8触发的中断(再次,假设PIC配置为具有0x40的基数)。
你的代码应该是:-
if (x>=8)
{
current_mask &= ~(1<<2);
set_int((x + SLAVE_VEC - 8),(unsigned long) handler, control);
}
将正确配置IRQ8的0x40 IDT项。
相关文章:
- 如何在 C++ 中获取随机函数的周期性
- CGAL 3D 周期性德劳内三角测量与信息的问题
- 我的 RSU 如何在静脉中以周期性的时间间隔调用函数
- 写入 Linux 上的共享内存时出现周期性延迟峰值
- 周期性共生
- C 的周期性线程创建
- 它是否需要为webrtc本机应用程序中的每个对等体提供单独的rtc::Runnable线程和PeerConnection
- 通过C 地图周期性迭代,程序崩溃
- 来自UDP插座的定期延迟峰值由周期性sendto()/recvFrom()延迟引起的Linux RT抢先系统的C
- 在 C++ 中以周期性的时间间隔调用函数的视觉需求
- C++在微秒范围内周期性调用函数
- 用于处理周期性事件的开源库
- 在c++ /C中后台运行周期性循环
- 如何在Qt中周期性地调用函数
- 播放产生的音频数据在声音中有噪音和周期性的咔嗒声
- 无法让 RTC 工作
- 在c++中生成与周期性晶格平移相对应的排列
- 在我自己的操作系统内核中的周期性RTC中断
- RTC with Eclipse:是否希望将代码存储在完全配置的Eclipse项目中
- 中断定时器的周期性网络摄像头帧捕获c++