Problems booting the 2nd processor

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
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Problems booting the 2nd processor

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Post 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 :?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Post 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 :)
Post Reply