Maystyle :
Admin : New post
Guestbook
Local
media
Catergories
Recent Articles
Recent Comments
Recent Trackbacks
Calendar
Tag
Archive
Link
Search
 
  인터럽트 개체 
작성일시 : 2007. 11. 12. 21:02 | 분류 : Windows Server/Kernel

(출처 : Windows internals)
Interrupt Objects
The kernel provides a portable mechanism—a kernel control object called an interrupt object—that allows device drivers to register ISRs for their devices. An interrupt object contains all the information the kernel needs to associate a device ISR with a particular level of interrupt, including the address of the ISR, the IRQL at which the device interrupts, and the entry in the kernel's IDT with which the ISR should be associated. When an interrupt object is initialized, a few instructions of assembly language code, called the dispatch code, are copied from an interrupt handling template, KiInterruptTemplate, and stored in the object. When an interrupt occurs, this code is executed.

This interrupt-object resident code calls the real interrupt dispatcher, which is typically either the kernel's KiInterruptDispatch or KiChainedDispatch routine, passing it a pointer to the interrupt object. KiInterruptDispatch is the routine used for interrupt vectors for which only one interrupt object is registered, and KiChainedDispatch is for vectors shared among multiple interrupt objects. The interrupt object contains information this second dispatcher routine needs to locate and properly call the ISR the device driver provides. The interrupt object also stores the IRQL associated with the interrupt so that KiInterruptDispatch or KiChainedDispatch can raise the IRQL to the correct level before calling the ISR and then lower the IRQL after the ISR has returned. This two-step process is required because there's no way to pass a pointer to the interrupt object (or any other argument for that matter) on the initial dispatch because the initial dispatch is done by hardware. On a multiprocessor system, the kernel allocates and initializes an interrupt object for each CPU, enabling the local APIC on that CPU to accept the particular interrupt.

커널은 장치 드라이버가 장치에 대한 ISR을 등록할 수 있도록 "인터럽트 개체"를 제공한다. 인터럽트 개체에는 ISR의 주소/ 장치IRQL / ISR이 연결되는 IDT 항목 및 필요한 모든 정보를 가지고 있다.

ISR과 특정 인터럽트 수준을 연결하는 것을 "인터럽트 개체 연결하기"라 하고 IDT 항목으로 부터 ISR의 연결을 끊는 것을 "인터럽트 개체 연결 끊기"라고 부른다. 드라이버를 시스템에 로드할 때 장치 드라이버가 ISR을 켜짐 상태로 만들고 드라이버가 언로드 될때 ISR을 꺼짐 상태로 만든다.

인터럽트 객체를 이용하면 커널이 하드웨어를 다룰 필요가 없음은 물론이고, 데이터 공유가 가능한 다른 장치 드라이버의 다른 부분과 ISR의 실행을 동기화 할 수 있다.
게다가 다중 장치 드라이버들을 하나의 IDT 항목에 연결해서 인터럽트 디스패처가 각 루틴을 차례로 실행하게 할 수 있다. (http://maystyle.tistory.com/entry/IDT-살펴-보기 의 0x83 번 루틴을 보면 알 수 있따.) 이를 Daisy-Chain 구성이라 한다. 이러한 구성은 모든 동일한 인터럽트를 사용하기 원하는 장치 드라이버가 그들의 인터럽트를 공유할 수 있도록 커널에 지시할때만 허가되고, 그렇지 않을때는 PNP가 인터럽트 할당을 재 구성한다.
(출처 : Windows internals)

위의 명령어 (dt nt!_kinterrupt) 는 ISR의 규정된 인터럽트 개체를 직접 보기위한 명령어 이다.

|