Use 'lock incw' to ensure proper synchronization between cpus.
Jump to the 0xf0000 segment for the halt (to ensure halt code isn't overwritten).
Improve code comments.
.code16gcc
+// Shutdown a CPU. We want this in the 0xf000 section to ensure that
+// the code wont be overwritten with something else. (Should
+// something spurious wake up the CPU, we want to be sure that the hlt
+// insn will still be present and will shutdown the CPU.)
+ .global permanent_halt
+permanent_halt:
+ cli
+1: hlt
+ jmp 1b
+
/****************************************************************
* GDT and IDT tables
" .code16\n"
"smp_ap_boot_code_start:\n"
- " xor %ax, %ax\n"
- " mov %ax, %ds\n"
- " incw " __stringify(BUILD_CPU_COUNT_ADDR) "\n"
- "1:\n"
- " hlt\n"
- " jmp 1b\n"
+ // Increament the counter at BUILD_CPU_COUNT_ADDR
+ " xorw %ax, %ax\n"
+ " movw %ax, %ds\n"
+ " lock incw " __stringify(BUILD_CPU_COUNT_ADDR) "\n"
+ // Halt the processor.
+ " ljmpl $" __stringify(SEG_BIOS) ", $(permanent_halt - " __stringify(BUILD_BIOS_ADDR) ")\n"
"smp_ap_boot_code_end:\n"
" .code32\n"