Linux Kernel series-7. OS development interruptions and exceptions, Linux Kernel

Source: Internet
Author: User

Linux Kernel series-7. OS development interruptions and exceptions, Linux Kernel

A. Overview

The mechanism of the interrupt and trap doors is almost the same, except that the call command is used to call the door. Here we use the int command. The structure of the interrupt door and trap door is as follows:

The four-digit TYPE is changed to 0xE (Interrupt gate) or 0xF (trap gate ).

As shown in the case when the int n command is interrupted, n is the vector number, which is similar to the use of the call door.

 

 

B. Create an IDT

; IDT [SECTION. idt] ALIGN32 [BITS32] LABEL_IDT:; Target Selection Sub-, offset, DCount, attribute % rep 255GateSelectorCode32, SpuriousHandler, 0, DA_386IGate % rows $-rows-1; Segment limit dd0; base address; END of [SECTION. idt]

Each descriptor is set to the interrupt gate pointing to SelectorCode32: SpuriousHandler.

Prepare xoreax, eaxmovax, dsshleax, 4 addeax, LABEL_IDT; eax <-idt base address movdword [IdtPtr + 2], eax; [IdtPtr + 2] <-idt base address; disconnect cli; load IDTRlidt [IdtPtr]

C. Implement an interruption

callInit8259Aint080h

The running result is as follows:

Next, modify the IDT and list the 80h interrupt separately.

; IDT [SECTION. idt] ALIGN32 [BITS32] LABEL_IDT:; Target Selection Sub-, offset, DCount, attribute % rep handler, SpuriousHandler, 0, DA_386IGate % handler: GateSelectorCode32, UserIntHandler, 0, DA_386IGateIdtLenequ $-LABEL_IDTIdtPtrdwIdtLen-1; Segment boundaries dd0; base address; END of [SECTION. idt]

The running result is as follows:

 

 

 

Source code]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.