Running code on different processor (x86 assembly)

女生的网名这么多〃 提交于 2019-12-03 12:03:12

So you have a stand-alone (you said "pre-boot") program, like a bootloader, running in real mode? And this is on a PeeCee with the usual BIOS?

In that case you have only one CPU running. In order to spin-up the other CPU units an operating system will typically execute what is called the universal startup algorithm which goes like this:

BSP sends AP an INIT IPI
BSP DELAYs (10mSec)
If (APIC_VERSION is not an 82489DX) {
  BSP sends AP a STARTUP IPI
  BSP DELAYs (200μSEC)
  BSP sends AP a STARTUP IPI
  BSP DELAYs (200μSEC)
}
BSP verifies synchronization with executing AP

The BSP is the Boot Processor. An AP is an Application Processor. An IPI is an inter-processor interrupt. In order to do an IPI, you need to enable the APIC, an interrupt controller extension to the PC architecture which is not enabled at bootup. That's why the code is worried about what kind of ICU version it is running. All of this is fairly deep kernel magic. You might try looking at Linux, NetBSD, or other *BSD source code for an example, but it won't be easy to read. If you really win, you might find a small kernel or standalone SMP test program out there somewhere.

For more information, see the Intel Multiprocessor Specification.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!