I'm just trying to boot the AP processors in bochs. This is how I'm doing:
I copy my SMP trampoline binary to 0x7000 with the following:
Code: Select all
memcpy( ( void* )0x7000, ( void* )&__smp_trampoline_start, trampoline_size );
Code: Select all
apic_write( LAPIC_ICR_LOW, 7 | /* vector */ ( 0x6 << 8 ) /* SIPI */ );
Code: Select all
#include <arch/gdt.h>
.extern ap_stack_top
.section .smp_trampoline
.code16
ap_entry:
cli
movw %cs, %ax
movw %ax, %ds
movw %ax, %es
lgdtl smp_gdtr - ap_entry
/* Enable protected mode */
movl %cr0, %eax
orl $1, %eax
movl %eax, %cr0
/* Jump into protected mode at the kernel's 32bit SMP entry point */
ljmpl $KERNEL_CS, $1f
smp_gdt:
.quad 0x0000000000000000
.word 0xFFFF /* limit */
.word 0x0000 /* base */
.byte 0x00 /* base */
.byte 0x9A /* access */
.byte 0xCF /* granularity */
.byte 0x00 /* base */
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0x92
.byte 0xCF
.byte 0x00
smp_gdtr:
.word smp_gdtr - smp_gdt - 1
.long smp_gdt
.size smp_gdtr,.-smp_gdtr
.section .text
.code32
.align 16
1:
hlt
jmp 1b
movw $KERNEL_DS, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %ss
/*movw %ax, %gs*/
/* Load the stack allocated by the BSP */
movl $ap_stack_top, %esp
/* Enter the C part of the kernel */
call ap_processor_entry
2:
hlt
jmp 2b
Code: Select all
00070627495i[APIC1] CPU 1 started up at 0700:00000000 by APIC
00070627500i[CPU1 ] WARNING: HLT instruction with IF=0!
CPU 1: HALTED
CPU 0: HALTED
CPU 0: HALTED
00070637500p[CPU1 ] >>PANIC<< load_seg_reg(): invalid segment register passed!
Code: Select all
00070637500i[CPU1 ] CPU is in protected mode (active)
00070637500i[CPU1 ] CS.d_b = 32 bit
00070637500i[CPU1 ] SS.d_b = 16 bit
00070637500i[CPU1 ] EFER = 0x00000000
00070637500i[CPU1 ] | RAX=0000000060000011 RBX=0000000000000000
00070637500i[CPU1 ] | RCX=0000000000000000 RDX=0000000000000f20
00070637500i[CPU1 ] | RSP=0000000000000000 RBP=0000000000000000
00070637500i[CPU1 ] | RSI=0000000000000000 RDI=0000000000000000
00070637500i[CPU1 ] | R8=0000000000000000 R9=0000000000000000
00070637500i[CPU1 ] | R10=0000000000000000 R11=0000000000000000
00070637500i[CPU1 ] | R12=0000000000000000 R13=0000000000000000
00070637500i[CPU1 ] | R14=0000000000000000 R15=0000000000000000
00070637500i[CPU1 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf zf af PF cf
00070637500i[CPU1 ] | SEG selector base limit G D
00070637500i[CPU1 ] | SEG sltr(index|ti|rpl) base limit G D
00070637500i[CPU1 ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00070637500i[CPU1 ] | DS:0700( 0000| 0| 0) 00007000 0000ffff 0 0
00070637500i[CPU1 ] | SS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00070637500i[CPU1 ] | ES:0700( 0000| 0| 0) 00007000 0000ffff 0 0
00070637500i[CPU1 ] | FS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00070637500i[CPU1 ] | GS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00070637500i[CPU1 ] | MSR_FS_BASE:0000000000000000
00070637500i[CPU1 ] | MSR_GS_BASE:0000000000000000
00070637500i[CPU1 ] | RIP=0000000000000000 (0000000000103361)
00070637500i[CPU1 ] | CR0=0x60000011 CR1=0x0 CR2=0x0000000000000000
00070637500i[CPU1 ] | CR3=0x00000000 CR4=0x00000000
(1).[70637500] [0x00103361] 0008:0000000000103361 (unk. ctxt): jmp .+0xfffffffd (0x00103360) ; ebfd
giszo