Page 1 of 1

Problems booting the 2nd processor

Posted: Mon Nov 26, 2007 12:40 am
by Laksen
Hey

I'm trying to get the second processor in my system to boot but I can't really make it do anything besides hanging.

So far I've managed to parse the SMP table seemingly correctly. The only thing I didn't get was the Apic ID specified for each processor entry. When I try to signal the Apic specified by that ID nothing happens, but if I instead signal by the logical processor number then at least it hangs :P

Next I've asserted and deasserted init ipi's. Then if I try to send the startup ipi with the bootpage loaded(0x1000) it just hangs.

The contents of the bootpage:

Code: Select all

[bits 16]

[org 0x1000]			;Will be loaded at address 0x1000
BOOTAPENTRY:
      lgdt [GDTDESC]

      mov eax, cr0
      or al, 1
      mov cr0, eax

      jmp GDT_DATA:GO_PMODE

[BITS 32]

GO_PMODE:
      mov ax, GDT_DATA
      mov ds, ax
      mov es, ax
      mov ss, ax

      JMP GDT_END
	

GDTDESC:
      dw GDT_END - GDT - 1
      dd GDT
GDT:
		times 8 db 0
GDT_CODE  equ  $-GDT
      dw 0xFFFF
      dw 0
      db 0
      db 0x9A
      db 0xCF
      db 0
GDT_DATA  equ  $-GDT
      dw 0xFFFF
      dw 0
      db 0
      db 0x92
      db 0xCF
      db 0
GDT_END:
Can anyone give a clue where I might be going wrong here? Another thing: Is it possible to get some debug info from QEmu while it's running?

Posted: Mon Nov 26, 2007 3:38 am
by Combuster
You should use Bochs - there is a prebuilt binary which supports multiple CPUs. You can compile your own that also includes a debugger which is very useful to have.

The code snippet you provided doesn't show us how the processors actually get started - which can be the actual cause of the bug.

Posted: Mon Nov 26, 2007 5:20 pm
by Laksen
I've finally got the second processor started and am just having a few(probably solvable) problems with the gdt, but so far so good.

Seems Bochs(I haven't tested on a real machine) needs to have the physical bootpage number multiplied by 10 for it to work. If I load the code at address 0x8000, i must supply 80 in the startup ipi vector for it to hit the right address :?

Posted: Mon Nov 26, 2007 9:51 pm
by Brendan
Hi,
Laksen wrote:Seems Bochs(I haven't tested on a real machine) needs to have the physical bootpage number multiplied by 10 for it to work. If I load the code at address 0x8000, i must supply 80 in the startup ipi vector for it to hit the right address :?
On both Bochs and real (Pentium or later) machines, the vector in the startup IPI is shifted left 8 times and loaded into CS, and IP is cleared.

For e.g. with 0x80 in the startup IPI vector, the (real mode) starting address (CS:IP) will be 0x8000:0x0000 (which is actually 0x00080000 as a flat 32-bit physical address).

I'm guessing you're getting real mode addressing mixed up with protected mode addressing... ;)


Cheers,

Brendan

Posted: Mon Nov 26, 2007 11:13 pm
by Laksen
Ah thanks :P

Yes indeed. I just skipped easily over the bootloader part by using grub so I haven't really tried that much of this real mode trickery :)