x86kernelinterruptosdevapic

How can I read and write to the IMCR register?


I'm currently programming an x86-64 kernel and need to set the APIC mode to symmetric I/O Mode. The Multiprocessor Specification from Intel at Page 31 says that to enable this mode you have to write 01H to the IMCR register. The problem is that this register (has to be accessed over outb/inb) doesn't seem to be documented. How can I read and write to the IMCR?


Solution

  • As @MichaelPetch pointed out in the comments the IMCR register is defined at pdf page 28, somehow I missed it. Quote:

    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

    however

    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

    The MP float tables are deprecated so checking the flag in these tables should be avoided. Instead parse the ACPI MADT table and check if the PIC flag bit is set in there