Linux ACPI(一) -- 解析ACPI表

  • 简析 ACPI 表

1.ACPI表

  For ACPI on arm64, tables also fall into the following categories:

  • Required: DSDT, FADT, GTDT, MADT, MCFG, RSDP, SPCR, XSDT

  • Recommended: BERT, EINJ, ERST, HEST, PCCT, SSDT

  • Optional: BGRT, CPEP, CSRT, DBG2, DRTM, ECDT, FACS, FPDT, IBFT, IORT, MCHI, MPST, MSCT, NFIT, PMTT, RASF, SBST, SLIT, SPMI, SRAT, STAO, TCPA, TPM2, UEFI, XENV

  • Not supported: BOOT, DBGP, DMAR, ETDT, HPET, IVRS, LPIT, MSDM, OEMx, PSDT, RSDT, SLIC, WAET, WDAT, WDRT, WPBT

1.1.解析ACPI表

root@uos-PC:/sys/firmware/acpi/tables# tree
.
├── APIC
├── data
├── DSDT
├── dynamic
├── FACP
├── FACS
├── MCFG
├── SLIT
└── SRAT
2 directories, 7 files

2.解析工具

2.1.iasl
  iasl是一个编译和解析ACPI的工具,在编译UEFI的时候也是必不可少的。默认系统不会安装,需要额外安装:apt install iasl

  然后就可以通过iasl命令来解析ACPI文件了,但不能直接在/sys/firmare/acpi/tables上来解析,会报错:

root@uos-PC:/sys/firmware/acpi/tables# iasl -d APIC
Intel ACPI Component Architecture
ASL+ Optimizing Compiler/Disassembler version 20181213
Copyright (c) 2000 - 2018 Intel Corporation

Input file APIC, Length 0x5E (94) bytes
ACPI: APIC 0x0000000000000000 00005E (v01 LOONGS LOONGSON 00000002 LIUX 01000013)
Could not open output file APIC.dsl

  先将需要解析的文件拿出来再解析:

root@uos-PC:/home/uos# iasl -d APIC 
Intel ACPI Component Architecture
ASL+ Optimizing Compiler/Disassembler version 20181213
Copyright (c) 2000 - 2018 Intel Corporation

Input file APIC, Length 0x5E (94) bytes
ACPI: APIC 0x0000000000000000 00005E (v01 LOONGS LOONGSON 00000002 LIUX 01000013)
Acpi Data Table [APIC] decoded
Formatted output:  APIC.dsl - 3519 bytes

root@uos-PC:/home/uos# cat APIC.dsl 
[000h 0000   4]                    Signature : "APIC"    [Multiple APIC Description Table (MADT)]
[004h 0004   4]                 Table Length : 0000005E
[008h 0008   1]                     Revision : 01
[009h 0009   1]                     Checksum : 39
[00Ah 0010   6]                       Oem ID : "LOONGS"
[010h 0016   8]                 Oem Table ID : "LOONGSON"
[018h 0024   4]                 Oem Revision : 00000002
[01Ch 0028   4]              Asl Compiler ID : "LIUX"
[020h 0032   4]        Asl Compiler Revision : 01000013

[024h 0036   4]           Local Apic Address : 1FE01400
[028h 0040   4]        Flags (decoded below) : 00000001
                         PC-AT Compatibility : 1

[02Ch 0044   1]                Subtable Type : 00 [Processor Local APIC]
[02Dh 0045   1]                       Length : 08
[02Eh 0046   1]                 Processor ID : 01
[02Fh 0047   1]                Local Apic ID : 00
[030h 0048   4]        Flags (decoded below) : 00000001
                           Processor Enabled : 1

[034h 0052   1]                Subtable Type : 00 [Processor Local APIC]
[035h 0053   1]                       Length : 08
[036h 0054   1]                 Processor ID : 02
[037h 0055   1]                Local Apic ID : 01
[038h 0056   4]        Flags (decoded below) : 00000001
                           Processor Enabled : 1

[03Ch 0060   1]                Subtable Type : 00 [Processor Local APIC]
[03Dh 0061   1]                       Length : 08
[03Eh 0062   1]                 Processor ID : 03
[03Fh 0063   1]                Local Apic ID : 02
[040h 0064   4]        Flags (decoded below) : 00000001
                           Processor Enabled : 1

[044h 0068   1]                Subtable Type : 00 [Processor Local APIC]
[045h 0069   1]                       Length : 08
[046h 0070   1]                 Processor ID : 04
[047h 0071   1]                Local Apic ID : 03
[048h 0072   4]        Flags (decoded below) : 00000001
                           Processor Enabled : 1

[04Ch 0076   1]                Subtable Type : 01 [I/O APIC]
[04Dh 0077   1]                       Length : 0C
[04Eh 0078   1]                  I/O Apic ID : 00
[04Fh 0079   1]                     Reserved : 00
[050h 0080   4]                      Address : 10000000
[054h 0084   4]                    Interrupt : 00000040

[058h 0088   1]                Subtable Type : 04 [Local APIC NMI]
[059h 0089   1]                       Length : 06
[05Ah 0090   1]                 Processor ID : 02
[05Bh 0091   2]        Flags (decoded below) : 0000
                                    Polarity : 0
                                Trigger Mode : 0
[05Dh 0093   1]         Interrupt Input LINT : 01

Raw Table Data: Length 94 (0x5E)

    0000: 41 50 49 43 5E 00 00 00 01 39 4C 4F 4F 4E 47 53  // APIC^....9LOONGS
    0010: 4C 4F 4F 4E 47 53 4F 4E 02 00 00 00 4C 49 55 58  // LOONGSON....LIUX
    0020: 13 00 00 01 00 14 E0 1F 01 00 00 00 00 08 01 00  // ................
    0030: 01 00 00 00 00 08 02 01 01 00 00 00 00 08 03 02  // ................
    0040: 01 00 00 00 00 08 04 03 01 00 00 00 01 0C 00 00  // ................
    0050: 00 00 00 10 40 00 00 00 04 06 02 00 00 01        // ....@.........

2.2.acpidump

  iasl工具获取ACPI表需要从特定目录去拿,比较复杂,这里还可以用一个简单的工具acpidump来获取。它是一系列工具中的一个,可以通过如下的命令来安装:

apt install acpica-tools

  acpidump工具需要在root用户下使用:

root@uos-PC:~# acpidump -s   (-s来查看现有的表)
ACPI: MCFG 0x0000000000000000 00003C (v01 LOONGS LOONGSON 00000001 LIUX 01000013)
ACPI: APIC 0x0000000000000000 00005E (v01 LOONGS LOONGSON 00000002 LIUX 01000013)
ACPI: SLIT 0x0000000000000000 00002D (v01 LOONGS LOONGSON 00000002 LIUX 01000013)
ACPI: DSDT 0x0000000000000000 00202C (v02 LOONGS LOONGSON 00000002 INTL 20190509)
ACPI: SRAT 0x0000000000000000 0000C0 (v02 LOONGS LOONGSON 00000002 LIUX 01000013)
ACPI: FACP 0x0000000000000000 0000F4 (v03 LOONGS LOONGSON 00000002 LIUX 01000013)
ACPI: FACS 0x0000000000000000 000040

root@uos-PC:~# acpidump -n APIC -b
root@uos-PC:~# ls
APIC  apic.dat
root@uos-PC:~# iasl -d apic.dat 

你可能感兴趣的:(linux,linux,ACPI)