• Guest
HabraHabr
  • Main
  • Users

  • Development
    • Programming
    • Information Security
    • Website development
    • JavaScript
    • Game development
    • Open source
    • Developed for Android
    • Machine learning
    • Abnormal programming
    • Java
    • Python
    • Development of mobile applications
    • Analysis and design of systems
    • .NET
    • Mathematics
    • Algorithms
    • C#
    • System Programming
    • C++
    • C
    • Go
    • PHP
    • Reverse engineering
    • Assembler
    • Development under Linux
    • Big Data
    • Rust
    • Cryptography
    • Entertaining problems
    • Testing of IT systems
    • Testing Web Services
    • HTML
    • Programming microcontrollers
    • API
    • High performance
    • Developed for iOS
    • CSS
    • Industrial Programming
    • Development under Windows
    • Image processing
    • Compilers
    • FPGA
    • Professional literature
    • OpenStreetMap
    • Google Chrome
    • Data Mining
    • PostgreSQL
    • Development of robotics
    • Visualization of data
    • Angular
    • ReactJS
    • Search technologies
    • Debugging
    • Test mobile applications
    • Browsers
    • Designing and refactoring
    • IT Standards
    • Solidity
    • Node.JS
    • Git
    • LaTeX
    • SQL
    • Haskell
    • Unreal Engine
    • Unity3D
    • Development for the Internet of things
    • Functional Programming
    • Amazon Web Services
    • Google Cloud Platform
    • Development under AR and VR
    • Assembly systems
    • Version control systems
    • Kotlin
    • R
    • CAD/CAM
    • Customer Optimization
    • Development of communication systems
    • Microsoft Azure
    • Perfect code
    • Atlassian
    • Visual Studio
    • NoSQL
    • Yii
    • Mono и Moonlight
    • Parallel Programming
    • Asterisk
    • Yandex API
    • WordPress
    • Sports programming
    • Lua
    • Microsoft SQL Server
    • Payment systems
    • TypeScript
    • Scala
    • Google API
    • Development of data transmission systems
    • XML
    • Regular expressions
    • Development under Tizen
    • Swift
    • MySQL
    • Geoinformation services
    • Global Positioning Systems
    • Qt
    • Dart
    • Django
    • Development for Office 365
    • Erlang/OTP
    • GPGPU
    • Eclipse
    • Maps API
    • Testing games
    • Browser Extensions
    • 1C-Bitrix
    • Development under e-commerce
    • Xamarin
    • Xcode
    • Development under Windows Phone
    • Semantics
    • CMS
    • VueJS
    • GitHub
    • Open data
    • Sphinx
    • Ruby on Rails
    • Ruby
    • Symfony
    • Drupal
    • Messaging Systems
    • CTF
    • SaaS / S+S
    • SharePoint
    • jQuery
    • Puppet
    • Firefox
    • Elm
    • MODX
    • Billing systems
    • Graphical shells
    • Kodobred
    • MongoDB
    • SCADA
    • Hadoop
    • Gradle
    • Clojure
    • F#
    • CoffeeScript
    • Matlab
    • Phalcon
    • Development under Sailfish OS
    • Magento
    • Elixir/Phoenix
    • Microsoft Edge
    • Layout of letters
    • Development for OS X
    • Forth
    • Smalltalk
    • Julia
    • Laravel
    • WebGL
    • Meteor.JS
    • Firebird/Interbase
    • SQLite
    • D
    • Mesh-networks
    • I2P
    • Derby.js
    • Emacs
    • Development under Bada
    • Mercurial
    • UML Design
    • Objective C
    • Fortran
    • Cocoa
    • Cobol
    • Apache Flex
    • Action Script
    • Joomla
    • IIS
    • Twitter API
    • Vkontakte API
    • Facebook API
    • Microsoft Access
    • PDF
    • Prolog
    • GTK+
    • LabVIEW
    • Brainfuck
    • Cubrid
    • Canvas
    • Doctrine ORM
    • Google App Engine
    • Twisted
    • XSLT
    • TDD
    • Small Basic
    • Kohana
    • Development for Java ME
    • LiveStreet
    • MooTools
    • Adobe Flash
    • GreaseMonkey
    • INFOLUST
    • Groovy & Grails
    • Lisp
    • Delphi
    • Zend Framework
    • ExtJS / Sencha Library
    • Internet Explorer
    • CodeIgniter
    • Silverlight
    • Google Web Toolkit
    • CakePHP
    • Safari
    • Opera
    • Microformats
    • Ajax
    • VIM
  • Administration
    • System administration
    • IT Infrastructure
    • *nix
    • Network technologies
    • DevOps
    • Server Administration
    • Cloud computing
    • Configuring Linux
    • Wireless technologies
    • Virtualization
    • Hosting
    • Data storage
    • Decentralized networks
    • Database Administration
    • Data Warehousing
    • Communication standards
    • PowerShell
    • Backup
    • Cisco
    • Nginx
    • Antivirus protection
    • DNS
    • Server Optimization
    • Data recovery
    • Apache
    • Spam and antispam
    • Data Compression
    • SAN
    • IPv6
    • Fidonet
    • IPTV
    • Shells
    • Administering domain names
  • Design
    • Interfaces
    • Web design
    • Working with sound
    • Usability
    • Graphic design
    • Design Games
    • Mobile App Design
    • Working with 3D-graphics
    • Typography
    • Working with video
    • Work with vector graphics
    • Accessibility
    • Prototyping
    • CGI (graphics)
    • Computer Animation
    • Working with icons
  • Control
    • Careers in the IT industry
    • Project management
    • Development Management
    • Personnel Management
    • Product Management
    • Start-up development
    • Managing the community
    • Service Desk
    • GTD
    • IT Terminology
    • Agile
    • Business Models
    • Legislation and IT-business
    • Sales management
    • CRM-systems
    • Product localization
    • ECM / EDS
    • Freelance
    • Venture investments
    • ERP-systems
    • Help Desk Software
    • Media management
    • Patenting
    • E-commerce management
    • Creative Commons
  • Marketing
    • Conferences
    • Promotion of games
    • Internet Marketing
    • Search Engine Optimization
    • Web Analytics
    • Monetize Web services
    • Content marketing
    • Monetization of IT systems
    • Monetize mobile apps
    • Mobile App Analytics
    • Growth Hacking
    • Branding
    • Monetize Games
    • Display ads
    • Contextual advertising
    • Increase Conversion Rate
  • Sundry
    • Reading room
    • Educational process in IT
    • Research and forecasts in IT
    • Finance in IT
    • Hakatonas
    • IT emigration
    • Education abroad
    • Lumber room
    • I'm on my way

Interrupts from external devices in the x86 system. The evolution of interrupt controllers

 
3r3-31. In this article I would like to consider the mechanisms for delivering interrupts from external devices on the x86 system and try to answer the questions: 3r33428  
3r33434.  
- what is PIC and what is it for? 3r33434.  
- What is APIC and what is it for? What are LAPIC and I /O APIC for? 3r33434.  
- What is the difference between APIC, xAPIC and x2APIC? 3r33434.  
- what is MSI? What are the differences between MSI and MSI-X? 3r33434.  
- How are the $ PIR, MPtable, ACPI tables associated with this? 3r33434.  
3r33434.  
If you are interested in an answer to any of these questions, or you just want to familiarize yourself with the evolution of the x86 interrupt controllers, welcome under cat. 3r33434.  
3r33434.  
Wiki / Osdev )
 
3r33434.  
The first was a chip. Intel 8259 PIC . 8 input lines (IRQ0-7), and one output, connecting the controller with the INTR line of the processor. When an interrupt from a device arises, the 8259 draws the INTR line, the processor realizes that some device signals an interrupt and polls the PIC in order to understand which IRQx is causing the interrupt. An additional delay for this poll appears, but the number of interrupt lines increases to 8. 3r33428.  
3r33434.  
3r3-300. 3r33434.  
3r33434.  
However, 8 lines quickly turned out to be small, and to increase their number they began to use ??? controllers (master and slave) connected in cascade (Dual PIC). 3r33434.  
IRQs from 0 to 7 are processed by the first Intel 8259 PIC (master), and IRQs from 8 to 15 by the second 8259 PIC (slave). The occurrence of a CPU interrupt is signaled only by master. If an interrupt occurs on lines 8-1? the second PIC (slave) signals an interrupt to the master via IRQ ? and that one in turn signals the CPU. This cascade interrupt takes away one of the 16 lines, but ultimately results in 15 available interrupts for devices. 3r33434.  
3r33434.  
3r3111. 3r33434.  
3r33434.  
The scheme is established, and that is what they mean when they talk about PIC (Programm Interrupt Controller). Subsequently, the 8259 controllers received some improvements, and became known as the 8259A, and this scheme became part of the chipset. At a time when the main bus for connecting external devices was the ISA bus, such a system as a whole was enough. It was necessary only to ensure that different devices did not connect to the same IRQ line in order to avoid conflicts, since ISA interrupts are not shared. 3r33434.  
3r33434.  
Typically, the layout of interrupts for devices was less standard
 
3r33434.  
Example (taken From here ):
 
IRQ 0 - system timer
 
IRQ 1 - keyboard controller
 
IRQ 2 - cascade (interrupt from slave controller)
 
IRQ 3 - serial port COM2
 
IRQ 4 - serial port COM1
 
IRQ 5 - parallel port 2 and 3 or sound card
 
IRQ 6 - floppy controller
 
IRQ 7 - parallel port 1
 
IRQ 8 - RTC timer
 
IRQ 9 - ACPI
 
IRQ 10 - open /SCSI /NIC
 
IRQ 11 - open /SCSI /NIC
 
IRQ 12 - mouse controller
 
IRQ 13 - math co-processor
 
IRQ 14 - ATA channel 1
 
IRQ 15 - ATA channel 2
 
3r33434.  
Configuration and operation with 8259 microcircuits is carried out via I /O ports:
 
3r33434.  
3r3r1616.  
 
3r3176. Chip
 
3r3176. Register 3r3-37777.  
3r3176. I /O port
 
 
 
Master PIC
 
Command
 
0x0020
 
 
 
Master PIC
 
Data
 
0x0021
 
 
 
Slave pic
 
Command
 
0x00A0
 
 
 
Slave pic
 
Data
 
0x00A1
 
 
3r33434.  
3r33434.  
The documentation for the 8259A can be found here 3r3431. 3r33434.  
3r33434.  
The PCI bus has replaced the ISA bus. And the number of devices clearly became more than 1? plus, in contrast to the static ISA bus, in this case, devices can be added to the system dynamically. But fortunately, in this bus interrupts can be shared (that is, several devices can be connected to the same IRQ line). As a result, in order to solve the problem of lack of IRQ lines, it was decided to group interrupts from all PCI devices into PIRQ lines (Programmable Interrupt Request). 3r33434.  
3r33434.  
Suppose we have 4 interrupt lines freely on the PIC controller, and PCI devices 20 pieces. We connect interrupts of 5 devices to the PIRQx line and connect the PIRQx lines to the controller. When an interrupt occurs on the PIRQx line, the processor will have to interrogate all devices connected to this line in order to understand from whom exactly the interruption came, but in general it solves the problem. The device interconnecting PCI interrupt lines on a PIRQ line is often called a PIR router. 3r33434.  
3r33434.  
In this method, you must ensure that the PIRQx lines are not connected to the IRQx lines on which the ISA interrupts are already set up (as this will cause conflicts), and that the PIRQx lines are balanced (because the more devices we have connected to one PIRQ line, the more devices we need will interrogate the processor to understand which of these devices caused the interruption). 3r33434.  
3r33434.  
Interrupts from external devices in the x86 system. The evolution of interrupt controllers 3r33434.  
3r33434.  
[b] Remark 3r33262. : in the picture, the mapping of the PCI device -> PIR is depicted in the abstract, because in reality it is somewhat more complicated. In reality, each PCI device has 4 interrupt lines (INTA, INTB, INTC, INTD). Each PCI device (device) can have up to 8 functions (functions), and for each function there is already one INTx interrupt. Which INTx will be pulled by each device function is determined by the chipset configuration. 3r33434.  
In essence, functions are separate logical blocks. For example, in one PCI device there may be an Smbus controller function, a SATA controller function, an LPC bridge function. On the OS side, each function is as a separate device with its own PCI Config configuration space. 3r33434.  
3r33434.  
Information about routing interrupts on the PIC controller BIOS was transmitted by the OS using the $ PIR table and using the 3Ch (INT_LN Interrupt Line (R /W)) and 3Dh (INT_PN Interrupt Pin (RO)) registers of the PCI configuration space for each function. The specification for the $ PIR table used to be
on the Intel
website. , but now it is no longer there. The contents of the rows of the $ PIR table can be understood from 3r-3271. PCI BIOS Specification
[4.2.2. Get PCI Interrupt Routing Options]or read here here 3r3431. 3r33434.  
3r33434.  

APIC

3r33434.  
(
Wiki
, Osdev )
 
3r33434.  
The previous method worked until a multiprocessor system appeared. The fact is that in its device PIC can transmit interrupts only to one main processor. And I would like the load on processors from interrupt handling to be balanced. The solution to this problem was the new APIC interface (Advanced PIC). 3r33434.  
3r33434.  
For each processor, a special LAPIC controller (Local APIC) is added, and a controller 3r-3295 is added to route interrupts from devices. I /O APIC
. All these controllers are combined into a common bus with the name APIC (new systems are now connected via a standard system bus). 3r33434.  
3r33434.  
When an interrupt from a device arrives at the I /O APIC pin, the controller sends the interrupt to the LAPIC of one of the processors. The presence of I /O APIC allows for balanced distribution of interrupts from external devices between processors. 3r33434.  
3r33434.  
The first APIC chip was 3r3305. 82489DX
, it was a separate chip, combining LAPIC and I /O APIC. To create a system of 2 processors, 3 such chips were needed. 2 would function as LAPIC and one as I /O APIC. Later, the LAPIC functionality was directly incorporated into the processors, and the I /O APIC functionality was framed in an 82093AA chip. 3r33434.  
3r33434.  
I /O APIC 82093AA contained 24 input outputs, and the APIC architecture could support up to 16 CPUs. To maintain compatibility with older systems, interrupts 0 ~ 15 were taken under old ISA interrupts. And interrupts from PCI devices began to output on the line IRQ 16-23. Now you could not think about conflicts of interruptions from ISA and PCI devices. Also, due to the increased number of free interrupt lines, it has also become possible to increase the number of PIRQx lines. 3r33434.  
3r33434.  
3r33333. 3r33434.  
3r33434.  
The programming of the I /O APIC and LAPIC is carried out via the MMIO. LAPIC registers are usually located at 0xFEE0000? I /O APIC registers at 0xFEС00000. Although, in principle, all these addresses can be reconfigured. 3r33434.  
As in the case of the PIC, originally separate chips were later incorporated into the chipset. 3r33434.  
3r33434.  
In the future, the APIC architecture was upgraded and the new version was called xAPIC (x - extended). Preserved backward compatibility with the previous version. The number of possible CPUs in the system has increased to 256. 3r3-33428.  
3r33434.  
The next round of architectural development was called x2APIC . The number of possible CPUs in the system has increased to 2 ^ 32. The controllers can work in compatibility mode with xAPIC, and they can work in the new x2APIC mode, where LAPIC is programmed not through MMIO, but through MSR registers (which is much faster). Judging link for this mode to work, IOMMU support is required. 3r33434.  
3r33434.  
It should be noted that there may be several I /O APIC controllers in the system. For example, one for 24 interrupts in the south bridge, the other for 32 in the north bridge. In the context of I /O APIC, interrupts are often referred to as GSI (Global System Interrupt). So in this system will be GSI 0-55. 3r33434.  
3r33434.  
Is there a built-in LAPIC in the CPU and which architecture can be understood by the bit flags in CPUID. 3r33434.  
In order for the system to detect LAPIC and I /O APIC, the BIOS must provide information about them to the system either through the MPtable table (old method) or through the ACPI table (MADT table in this case). In addition to general information, both MPtable and ACPI (this time in the DSDT table) should contain information on interrupt routing, that is, information on which device sits on which interrupt line (similar to $ PIR). 3r33434.  
3r33434.  
You can read about the MPTable table in the official 3r33350. specifications 3r3431. . Previously, the specification was on the Intel site, and now it can only be found in the archive. WITHThe ACPI specification is now located on the UEFI website (current version 3-3-33352. ???-33431.). It should be noted that using ACPI, you can specify routing interrupts for systems without APIC (instead of using the $ PIR table). 3r33434.  
3r33434.  

MSI 3r39797. 3r33434.  
( Wiki )
 
3r33434.  
The previous version with APIC is good, but not without flaws. All these interrupt lines from devices complicate the circuit and increase the likelihood of errors. PCI express came to replace the PCI bus, in which the interrupt lines were simply decided to be removed. To maintain compatibility, interrupt signals (INTx #) are emulated by separate types of messages. In this scheme, the logical addition of interrupt lines, which was previously made by the physical connection of wires, fell on the shoulders of PCI bridges. However, legacy INTx support for interrupts is only support for backward compatibility with the PCI bus. In fact, PCI express offered a new method for delivering interrupt messages - MSI (Message Signaled Interrupts). In this method, to interrupt a device, the device simply writes to the MMIO area allocated for the LAPIC processor. 3r33434.  
3r33434.  
If earlier only one interrupt was allocated to one PCI device (that is, all its functions), now it is now possible to address up to 32 interrupts. 3r33434.  
3r33434.  
In the case of MSI, there is no sharing for the lines, each interrupt corresponds to its device. 3r33434.  
3r33434.  
MSI interrupts also solve another problem. Suppose a device conducts a memory-write transaction, and wants to report its completion through an interrupt. But the write transaction can be delayed on the bus during transmission (which the device does not know about), and the interrupt signal will come to the processor earlier. Thus, the CPU will read more invalid data. If MSI is used, information about MSI is transmitted as well as data, and it will not be able to arrive earlier. 3r33434.  
3r33434.  
It should be noted that MSI interrupts cannot work without LAPIC, but using MSI can replace us with I /O APIC (design simplification). 3r33434.  
3r33434.  
Subsequently, this method received an extension MSI-X. Now each device can have up to 2048 interrupts. And it became possible to specify individually each interrupt on which processor it should be executed. This can be very useful for heavily loaded devices, such as network cards. 3r33434.  
3r33434.  
MSI support does not require any additional BIOS tables. But the device must report support for MSI in one of the Capability in its PCI Config, and the device driver must support operation with MSI. 3r33434.  
3r33434.  
Conclusion

3r33434.  
In this article, we looked at the evolution of interrupt controllers, and obtained general theoretical information on the delivery of interrupts from external devices in the x86 system. 3r33434.  
3r33434.  
In the next part, we will look at how to use each of the described controllers in Linux in practice. 3r33434.  
3r33434.  
3r3408. References: 3r3403. 3r33434.  
3r33412. Interrupt Controllers (Stuff in the Middle)
3r33434.  
3r33434.  
3r33418. What do the different interrupts in PCIe do?
3r33434.  
3r33434.  
3r33424. Interrupts
3r33434.  
3r33434.  
3r33430. Interrupt architecture in Intel compatible systems 3r3431.

It may be interesting

  • Comments
  • About article
  • Similar news
This publication has no comments.

weber

Author

20-11-2018, 18:15

Publication Date

Development / Programming

Category
  • Comments: 0
  • Views: 365
Create a Vuex Undo /Redo plugin for
You can buy electronic components in
Digital events in Moscow from December
Introduction to custom CSS properties
Interrupts from external devices in the
FadeObjects - Hide the objects between
Write a comment
Name:*
E-Mail:


Comments
this is really nice to read..informative post is very good to read..thanks a lot! How is the cost of house cleaning calculated?
Yesterday, 17:14

Legend SEO

It’s very informative and you are obviously very knowledgeable in this area. You have opened my eyes to varying views on this topic with interesting and solid content.

entegrasyon programları
Yesterday, 17:09

taxiseo2

I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.

entegrasyon programları
Yesterday, 17:02

taxiseo2

I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work...먹튀

Yesterday, 16:50

raymond weber

Lose Weight Market provides the best fitness tips, workout guides, keto recipes and diet plans, yoga workout routine and plans, healthy recipes, and more! Check Out: Lose Weight Market


Corvus Health provides medical training services as well as recruiting high quality health workers for you or placing our own best team in your facility. Check Out: Health Workforce Recruitment




I.T HATCH offers a wide range of IT services including remote access setup, small business servers, data storage solutions, IT strategy services, and more. Check Out: IT strategy services
Yesterday, 22:33

noorseo

Adv
Website for web developers. New scripts, best ideas, programming tips. How to write a script for you here, we have a lot of information about various programming languages. You are a webmaster or a beginner programmer, it does not matter, useful articles will help to make your favorite business faster.

Login

Registration Forgot password