Running code on different processor (x86 assembly)
In real mode on x86, what instructions would need to be used to run the code on a different processor, in a multiprocessor system?
(I'm writing some pre-boot code in assembler that needs to set certain CPU registers, and do this on every CPU in the system, before the actual operating system boots.)
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.
链接地址: http://www.djcxy.com/p/82360.html上一篇: 为什么像Windows,Linux这样的汇编语言有区别?
下一篇: 在不同的处理器上运行代码(x86程序集)