SRAT:ACPI 系统/静态资源关联表结构与字段说明

来源:OSDev Wiki· 阅读原文 ↗
ACPI
固定表
差异化表
工具/库

本页介绍 ACPI SRAT(System/Static Resource Affinity Table,系统/静态资源关联表) 它描述了 APIC 的工作方式。

简介

SRAT 表在 ACPI 规范 5.0a [1] 的第 5.2.16 节中被描述为一个提供信息的表,该信息使 OSPM(操作系统电源管理 [系统])“能够将处理器和内存范围(包括热添加内存设备提供的内存范围)与系统局部性邻近域和时钟域关联起来”。基本上,SRAT 提供系统中资源之间关系的信息——即处理器和内存。 SRAT 表将每个处理器和内存块关联到一个普通整数,在 ACPI 术语中称为 邻近域。

头部结构

SRAT 表遵循以下结构:

struct SRAT
{
    char signature[4];   // Contains "SRAT"
    uint32_t length;     // Length of entire SRAT including entries
    uint8_t  rev;        // 3
    uint8_t  checksum;   // Entire table must sum to zero
    uint8_t  OEMID[6];
    uint64_t OEMTableID; // For the SRAT it's the manufacturer model ID
    uint32_t OEMRev;     // OEM revision for OEM Table ID
    uint32_t creatorID;  // Vendor ID of the utility used to create the table
    uint32_t creatorRev;
    
    uint8_t reserved[12];
} __attribute__((packed));

该头部结构(48 字节)之后是一系列静态资源分配结构。共有 3 种 SRAS:

类型 名称
0x0 处理器本地 APIC/SAPIC 关联结构
0x1 内存关联结构
0x2 处理器本地 x2APIC 关联结构

处理器本地 APIC 关联结构

该结构描述了处理器的 APIC ID(或 SAPIC ID/EID)与其所属的邻近域(ACPI 术语)之间的关联。

struct SRAT_proc_lapic_struct
{
    uint8_t type;      // 0x0 for this type of structure
    uint8_t length;    // 16
    uint8_t lo_DM;     // Bits [0:7] of the proximity domain
    uint8_t APIC_ID;   // Processor's APIC ID
    uint32_t flags;    // Flags (see below)
    uint8_t SAPIC_EID; // The processor's local SAPIC EID.
    uint8_t hi_DM[3];  // Bits [8:31] of the proximity domain
    uint32_t _CDM;     // The clock domain which the processor belongs to (more jargon)
} __attribute__((packed));

目前,仅为 flags 字段定义了一个标志:

字段名 字段位宽 位偏移 描述
Enabled 1 0 如果清零,操作系统应忽略该结构的内容。这是为了让系统固件能够以固定数量的条目填充 SRAT,并根据需要启用。
Reserved 31 1 必须为零。

内存关联结构

内存关联结构包含:

  • 一段内存范围及其所属的普通整数(邻近域)
  • 关于该内存范围是否可热插拔的信息

请注意,由于存在各种内存空洞(例如 384 KiB 保留(“上位内存”) 空洞甚至可能出现在(QEMU) UEFI 机器上),单个邻近域可能对应多个内存关联结构。例如,1GiB 域可能有 (0x0, 0x80000) 和 (0x100000 - 0x40000000) 两个内存关联。

struct SRAT_mem_struct
{
    uint8_t type;         // 0x1 for this type of structure
    uint8_t length;       // 40
    uint32_t domain;      // The domain to which this memory region belongs to
    uint8_t reserved1[2]; // Reserved
    uint32_t lo_base;     // Low 32 bits of the base address of the memory range
    uint32_t hi_base;     // High 32 bits of the base address of the memory range
    uint32_t lo_length;   // Low 32 bits of the length of the range
    uint32_t hi_length;   // High 32 bits of the length
    uint8_t reserved2[4]; // Reserved
    uint32_t flags;       // Flags (see below)
    uint8_t reserved3[8]; // Reserved
} __attribute__ ((packed));

标志:

字段名 字段位宽 位偏移 描述
Enabled 1 0 如果清零,操作系统应忽略该结构的内容。这是为了让系统固件能够以固定数量的条目填充 SRAT,并根据需要启用。
Hot-pluggable* 1 1 如果 Enabled 和 Hot-pluggable 标志均已设置,则系统支持对该内存区域进行热添加和热移除。
Non-Volatile 1 2 如果设置,该内存区域为非易失性内存
Reserved 29 3 必须为零。

* 星号不表示任何含义

处理器本地 x2APIC 关联结构

x2APIC 结构基本上就是 API 结构,但用于 x2APIC。

struct SRAT_proc_lapic2_struct
{
    uint8_t type;         // 0x2 for this type of structure
    uint8_t length;       // 24
    uint8_t reserved1[2]; // Must be zero
    uint32_t domain;      // The proximity domain which the logical processor belongs to
    uint32_t x2APIC_ID;   // Processor's x2APIC ID
    uint32_t flags;
    uint32_t _CDM;        // The clock domain which the processor belongs to (more jargon)
    uint8_t reserved2[4]; // Reserved.
} __attribute__((packed));

时钟域

请参阅文档(第 6.2.1 节)。 时钟域表示连接到该域中处理器的时钟。当处理器尝试访问与自身不在同一时钟域的时钟源时,与其他处理器相比可能会出现不准确。这与邻近域的概念相同,即访问其域之外的内存或 I/O 资源的处理器需要请求域内的处理器来执行内存或 I/O 操作。

来源与翻译说明

本文根据原文快照翻译,保留原有代码、数值、技术限定及历史背景。原文中的命令与运行结果不代表本站已实际执行验证。

原文:SRAT;离线修订号:30858。

原作者:OSDev Wiki 社区贡献者。原文及引用资料的版权与许可声明继续适用:版权声明 许可说明

评论

暂无评论