Testing if a Startup IPI worked

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Testing if a Startup IPI worked

Post 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
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: Testing if a Startup IPI worked

Post 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.
If something looks overcomplicated, most likely it is.
User avatar
iansjack
Member
Member
Posts: 4834
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Testing if a Startup IPI worked

Post 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.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Testing if a Startup IPI worked

Post by nexos »

Ok Thank you!
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply