APIC programming in Linux Kernel

Source: Internet
Author: User

Microsoft's operating system is booming. Are you applying a Linux operating system? If you are an old Linux user. The issues described here will be helpful for APIC programming in the Linux kernel. The Linux kernel name is also "Linux ". APIC is an advanced PIC controller and an advanced programmable interrupt controller. In the current multi-core system, each cpu corresponds to a localapic, which is used to manage interruptions, including external interruptions and internal cpu interruptions.

1. For details about the principles and specifications of apic, see "Intel? 64andia-32ubunturessoftwaredeveloper 'smanualvolume3a: SystemProgrammingGuide chapter 10 TheAdvancedProgrammableInterruptController (APIC)'

2. About APIC initialization in BIOS, the BIOS will probably initialize APIC, and then provide an APIC table cpu table for the system to be started. In ntel? 64andia-32ubunturessoftwaredeveloper 'smanualvolume3a: Chapter 1 MULTIPLE-PROCESSORMANAGEMENT Chapter 2 PROCESSORMANAGEMENTANDINITIALIZATION detailed introduction 'in SystemProgrammingGuide. You can also continue to read the description of the table in the standard document "ACPIspec40" "IntelMultiprocessorSpecification.

3. Chinese people on the Internet wrote this article very well. He sorted out the above documents and Linux-related code. I only found this document for APIC. There are still few documents related to APIC.
"InterruptinLinux (hardware)-detail, implementation, and question Author: ZX_WING (xing5820@163.com )"

4. kernel code
Http://lxr.linux.no/#linux+v2.6.30.5/arch/x86/kernel/apic/apic.c
Http://lxr.linux.no/#linux+v2.6.30.5/arch/x86/kernel/mpparse.c
And so on. You can view the ACPI and apicid output at startup according to the document mentioned above and the output at system startup, processor prints the output when the system initializes the apic.
You may see more detailed output by adding apic = debug to the kernel parameters.

5. When your own driver needs to set and control apic, you can also use the functions defined in the system. There are a lot of function declarations here. You can also take a look at how it works.
Http://lxr.linux.no/#linux+v2.6.30.5/arch/x86/include/asm/apic.h
Many macro definitions are related to the configuration of apic. For more information, see the intel documentation.
Http://lxr.linux.no/#linux+v2.6.30.5/arch/x86/include/asm/apicdef.h

For example, KDB uses the ipicpu internal interrupt function to disable other cpu

Void (* send_IPI_allbutself) (intvector );
Void (* send_IPI_all) (intvector );
Void (* send_IPI_self) (intvector );

In general, apic is implemented through the following two functions:

Apic_wait_icr_idle ();
Apic_write_around (APIC_ICR2, SET_APIC_DEST_FIELD (x86_cpu_to_apicid [I]);
Apic_write

X86_cpu_to_apicid is a variable exported by the system to obtain the physical apicid. However, the implementation in different kernel versions is somewhat different. You can refer to the specific code. Apicid is the identifier of each apic. It is also used to differentiate different processors.

We hope that you can learn APIC programming in the Linux Kernel through the introduction in this article.

  1. How to install Linux NICs
  2. Install and configure the Linux Ethernet Card
  3. Fully understand the operating principles of Linux NICs
  4. Do you know about Linux boot?
  5. Teach you how to send emails and fax in Linux

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.