Implementation of ACPIPCIHot-Plug in Linux2

Source: Internet
Author: User
Article Title: Implementation of ACPIPCIHot-Plug in Linux2. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   1. Introduction to ACPI hot plugging
The Advanced Configuration & Power Interface (ACPI), developed jointly by INTEL, MICROSOFT, and toshba, enables software, hardware, and operating systems (OS ), the motherboard and peripheral devices manage power usage in a certain way. The Hot-Plug event generated by the system hardware allows the operating system to directly control Plug-and-play devices from the user's perspective, different from the previous management through BIOS-based methods.
  
This technology has specific requirements on the system platform and the hardware of the plug-in Board: The system integrates the hot swapping Control Integrated Circuit (php asic) and the reverse current controller of the PCI slot, in this way, the system can automatically monitor whether there is a device in the PCI slot during the system startup process. When no device is detected in the PCI slot, the slot is automatically powered off, the system's acpi bios contains a series of hardware resources that store empty PCI slots, such as address segments and interrupt numbers, to provide the ACPI Table to the resource list used by Hot Plug-in cards, these resource lists are used to enumerate and configure PCI devices after power-on. Currently, the nanqiao chip is integrated with the ACPI protocol, such as Intel 82801DB I/O Controller Hub 4 (ICH4 ).
  
The basic architecture of ACPI 1 indicates:
The ACPI system consists of bus drivers that support the electrical characteristics of the main board bus system, the main board BIOS support, the ACPI layer, and the hot swapping function of the operating system.
    
With the maturity of Intel's 64-bit PCI technology, the operating systems developed by Microsoft, Novell, and SCO have begun to fully support the PCI device ACPI Hot swapping Technology (PCI Hot Plug ).
  
The Linux kernel supports ACPI technology from 2.4, and the kernel of version 2.6.0 and later fully supports the Hot-plug specification under ACPI, we will introduce in detail the driver structure under Linux kernel of acpi pci Hot swapping device based on the "traditional" x86 System and the working mode and process on ACPI layer (in the upper part, we will introduce the basic principle and command-form mode ), precautions for porting to non-x86 platforms and precautions for development of Linux ACPI hot plugging device drivers.
  
   II. Introduction to ACPI Drive System
The ACPI driver system is the basis for supporting ACPI Hot Plug. Before discussing Hot Plug, we should first introduce the ACPI system, and the ACPI Driver System (acpi ca) defined according to ACPI specifications ), at present, ACPI has provided a complete ACPI Driver System for the Unix version. The main purpose of this system is to isolate the operating system from the current ACPI hardware, allow Linux to access the ACPI layer through a series of interfaces. The following lists the acpi ca interfaces, such as power management and configuration, hot plugging, and so on:
  
In the ACPI specification, the ACPI system is divided into the ACPI Core layer (Core subsystem) to provide basic ACPI services (AML translation and namespace management), and the OS service layer (OS service) provides the ACPI Unit Interface services for different operating systems. The following describes them in detail.
  
A. ACPI core layer:
The ACPI core layer is divided into several interrelated logic modules. Each module contains related ACPI APIs. When you write related drivers containing ACPI services, call the interfaces of these modules.
    
1. AML Interpreter: we can see from the above that the AML (which will be detailed later) analyzer is the basis for analyzing and running the AML file stream provided by the BIOS from the local computer, generally, the AML translator provides object services for method node running and obtaining a method node in the namespace for other ACPI service modules.
  
2. ACPI Table Management is a special ACPI service Table used in the ACPI module for loading, Management, analysis, and validation from the system BIOS, such as RSDT, FSDT, FACS, DSDT and so on. These tables are loaded into the memory during initialization of the operating system.
  
3. Namespace Management provides the Namespace service on the AML translator. It is responsible for creating and managing internal namespaces.
  
4. Resource Management: Resource Management provides the configuration and acquisition of resources created in the namespace, including the IP address range and interruption of PCI devices. It provides the following services: Obtain and set the current resource, obtain the possible address range on the device, and obtain the IRQ Routing Tables of the PCI device ), gets the power support capability of the current device (for example, whether the S1-S5 status is supported ).
  
5. acpi h/W Management: This module is used to control access to the ACPI registers and clock on the bridge chip and other ACPI-related hardware, such as acpi gpe status registers and enable registers, and obtain the system status. Event handling: The Event management module is used to manage the occurrence of system control interruptions (SCI) and GPE Event responses. SCI includes ACPI clock interruptions and GPE Event management. This unit is responsible for "Distributing" events in the address space and OperationRegion to the current operating system layer, and is responsible for calling relevant handles for processing.
  
B. OS service layer:
The acpi OS service layer (OSL) allows the ACPI logic module to run on the local operating system. The OS service layer converts the access and call of the operating system from the ACP core services to the interfaces and device drivers that can be used in the host operating system; the operating system layer sends a call to the ACPI core layer through OSL. the OSL layer implements a series of standard interfaces (such as storage allocation and hardware access) for the ACPI core layer to complete the independent functions of the operating system ). Introduction to the component modules of OSL:
  
1. OS boot service:
During OS loading, the bootstrap service is initialized before most other operating systems are initialized. These services include the initialization of the ACPI subsystem.
  
2. Device Driver loading service:
For device nodes that appear in the ACPI namespace, the operating system must have a module to detect them and load them into the driver, read the configuration space, and the device driver loading Service provides this device.
  
3. operating system running services:
The running service includes a majority of peripheral interfaces for interaction between ACPI and OS, used for process/thread operations in the current kernel, and provides mutex, signal, process queue, and sleep with the interfaces of the current operating system, pause, and Event Logs and power management functions.
  
4. asynchronous Service
Asynchronous functions include interrupt service (System Control interrupt), event processing and allocation (established events, GPE events, notification events and access events in the operation area), and error handling.
  
Requests from OS to ACPI subsystem:
The relationship between ACPI core layer and acpi OS layer and the operating system is as follows:
    
We can see from the above that a complete ACPI core layer and OS interface function compliant with ACPI specifications are provided in Linux2.6.6, however, the acpi pci device Hot Plug-In described below only uses a small part.
  
   Iii. Important Terms in ACPI System
DSDT: The DSDT is called Differentiated Definition Block. It exists in the BIOS and is compatible with the current hardware platform. It provides the hardware features of the system (such as internal registers and memory of some devices) application policy and configuration. during system initialization, DSDT is initialized to the namespace when the current system is started.
  
FADT: The FADT contains the application and configuration (including their hardware addresses) of the ACPI hardware register group (GPE), and also the hardware address of the DSDT table.
  
ACPI Namespace: For the ACPI layer, the memory maintains a directory that points to each device and GPE Namespace. This name tree is created by DSDT during initialization, the name tree can load DSDT changes from the BIOS using the loadtable method, and each device is described as an object in the ACPI layer, including a list of the features and operation policies of this device, all types of devices in the system are stored under the same name tree. Call _ ADR on the acpi OS layer to obtain the device name of Namesapce. For the Namespace example, see Example 1-1:
  
OSPM (OS-directed Power Management): The OSPM operating system supports a part of ACPI. The operating system (OS) can control the ACPI sub-module from the perspective of the driver in the operating system, ACPI supports SCI interrupt, device event, and System Event modes. These event modes fully support the Hot-plug mode.
  
SCI Interrupt: (System Control Interrupt) System Control Interrupt. SCI Interrupt is a source from the ACPI compatible chip System Interrupt. The System maps different ACPI event Interrupt vectors to share the Interrupt, when the underlying hardware suffers an SCI interruption (for example, a device insertion event causes an interruption), The OSPM layer will call the pre-installed interrupt handle to handle the ACPI event based on the notification to the OSPM layer.
  
GPE Block Device and GPE event: GPE Block Device is the register group that the platform designer can follow in the description Table of FADT (Fixed ACPI Descriptor Table) to respond to GPE. The address in the description Block of The GPE Device exists in FADT. Each GPE Block Device can accommodate 128 GPE events. The ACPI layer provides two general target Register Groups: GPE0_BLK and gpew.blk, (that is to say, you can respond to 256 GPE events) each register group contains two equal-length registers GPEx_STS and GPEx_EN. Their system addresses (hardware addresses) are stored in FADT, the action (or action) description part of GPE Blocks exists in the ACPI namespace. It is used to indicate the current device event, such as when a device insertion/removal event occurs, related status bits (the bits in GPEx_STS, which are connected to the event signals of related devices during hardware design) will be set by external events to generate SCI, inform the ACPI layer of the control process method related to running the OSPM layer; GPEx_EN indicates the Enable bit of each event. Generally, these registers are available in the South Bridge (ICH4 ). The hardware address is saved in FADT.
  
GPE events are events related to devices at the OSPM layer after SCI interruption is triggered by the GPE register group. For example, bus enumeration is introduced in detail or briefly in Hot-Plug, device check, device wake up, and several events are displayed on the device.
    
ACPI Source Language (ASL): The ACPI Language used by the ACPI layer to describe specific ACPI objects. It also includes the Control method of ACPI objects ), OEMs and BIOS designers define all devices as ACPI objects in the BIOS using ASL and can generate specialized control methods in the ASL format. Example 1-1 is an example of ASL:
For ASL language regulations, see ACPI Specification Revision 2.0.
AML and AML Analyzer: AML is a virtual ACPI control method.
Related Article

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.