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.
- How to install Linux NICs
- Install and configure the Linux Ethernet Card
- Fully understand the operating principles of Linux NICs
- Do you know about Linux boot?
- Teach you how to send emails and fax in Linux