如何读写 IMCR 寄存器?

How can I read and write to the IMCR register?

我目前正在编写 x86-64 内核,需要将 APIC 模式设置为对称 I/O 模式。 Intel 的多处理器规范第 31 页指出,要启用此模式,您必须将 01H 写入 IMCR 寄存器。问题是这个寄存器(必须通过 outb/inb 访问)似乎没有记录。我如何读取和写入 IMCR?

正如@MichaelPetch 在评论中指出的那样,IMCR 寄存器在 pdf 第 28 页定义,但不知何故我错过了它。引用:

The IMCR is supported by two read/writable or write-only I/O ports, 22h and 23h, which receiveaddress and data respectively. To access the IMCR, write a value of 70h to I/O port 22h, whichselects the IMCR. Then write the data to I/O port 23h. The power-on default value is zero, whichconnects the NMI and 8259 INTR lines directly to the BSP. Writing a value of 01h forces theNMI and 8259 INTR signals to pass through the APIC

然而

The IMCR is optional if PIC Mode is not implemented. The IMCRP bit of the MP featureinformation bytes (refer to Chapter 4) enables the operating system to detect whether the IMCR isimplemented

MP 浮动 table 已弃用,因此应避免检查这些 table 中的标志。而是解析 ACPI MADT table 并检查 PIC 标志位是否设置在那里