Page 1 of 1

Testing if a Startup IPI worked

Posted: Wed Jul 08, 2020 6:26 am
by nexos
Hello,
I am currently making SMP code for my OS. It currently sends an SIPI. I was wondering how I can check if the CPU has started in QEMU.
Thanks,
nexos

Re: Testing if a Startup IPI worked

Posted: Wed Jul 08, 2020 6:48 am
by Velko
When you wake an AP, it will start to execute your code. The obvious solution is to make CPU to report the status. For example: set a flag somewhere, retrieve and print Local APIC Id.

If you have not yet written trampoline code that switches it from Real mode to something more convenient, you can point it at 16-bit code containing an infinite loop or HLT instruction. Then examine in QEMU monitor, if CPU has reached that.

Re: Testing if a Startup IPI worked

Posted: Wed Jul 08, 2020 8:30 am
by iansjack
Cores that are not running code will all be halted at the same instruction (in the BIOS ROM). In qemu this appears to be 0xfd0ca.

In the qemu monitor use the commands

cpu 2 (for example)
info registers

to inspect the registers for any core. If %eip is other than the above value then it's running.

Re: Testing if a Startup IPI worked

Posted: Wed Jul 08, 2020 11:18 am
by nexos
Ok Thank you!