如何禁用传统的8253/4 PIT?

时间:2017-06-09 21:00:21

标签: operating-system kernel hardware

我正在为AMD64架构编写一个操作系统内核,并希望禁用IRQ 0(旧版PIT),原因很复杂,我宁愿不介入。 (此外,如果我需要一个计时器,我宁愿使用HPET或本地APIC。)但是,osdever.netWikipediaOSDev Wiki都没有谈论如何关闭它,只是如何使用它。任何人都可以解释如何执行此操作,理想情况是在一些in / out ASM说明中?

1 个答案:

答案 0 :(得分:0)

我也正在开发一个内核--Silcos内核,你可以在GitHub上找到它。在为我的内核开发计时器子系统框架时,我也遇到了这个问题。实际上,没有办法通过配置来禁用PIT,可能有一种主板特定的方法,但我们不想去那里。

因此,您需要做的是您必须通过PIT以最大允许周期生成周期性中断,以在不需要时减少其开销。在每个IRQ上,您应该构建一个IRQ子系统,如

//!
//! This class will manage a 'device' interrupt. As multiple devices may share
//! the same IRQ in the IOAPIC and even the CPU's LAPIC vectors, we must create
//! a queue for each IRQ entry. When an interrupt occurs, each IRQHandler is
//! checked using @code doesDeviceRequireService() and the first device to return
//! @code true is executed by @code action(). On this further checking is stopped
//!
//! @see IRQ
//! @see IRQ::trigger()
//!
class IRQHandler
{
public:
    void doesDeviceRequireService();//!< checks whether the device is triggering
                                    //< an interrupt.
    void action();//!< Executes the handler for the device-interrupt
protected:
    IRQHandler();//!< You could create classes like PIT, HPET which are IRQHandler           
                 //! which will have interrupt-handlers.
    ~IRQHandler();
};

//!
//! The IRQ class is a IOAPIC irq or a local IRQ. This will have a queue of IRQHandlers
//! and can be executed. You should have __irqCallback .asm function which will
//! invoke a 'C' function which calculates the IRQ class based on the given vector
//! and then calls execute() and then also does a EOI.
//!
//! @see IRQHandler
//!
class IRQ
{
public:
    void execute();//!< Tests all the IRQHandlers in the queue, and does the
                   //! action() if true is returned.

private:
    IRQ();
    ~IRQ();
};

将在一个IRQ上处理多个设备。