I'm trying tu put my kernel in higher memory (0xC0000000) with this tutorial: http://wiki.osdev.org/Higher_Half_With_GDT but I get some problems.
As explained in the document, I defined a GDT and a pointer to this GDT. This section is linked to 0x100000.
Code: Select all
.org 0xe000
gdt_desc:
.word bootstrap_gdt_end - bootstrap_gdt - 1
.long
.word 0x0 /* Padding */
bootstrap_gdt:
.long 0x0 /* Null gate */
.long 0x0
.long 0x40CF9A00
.long 0x0000FFFF /* Code selector */
.long 0x40CF9200
.long 0x0000FFFF /* Data selector */
.long 0x0
.long 0x0
bootstrap_gdt_end:
Code: Select all
/* The entry point must be before the multiboot header. */
.global entry
entry:
movl %eax, multiboot_magic - 0xC0000000 /* It can be verified later. */
movl %ebx, multiboot_info - 0xC0000000
/*** Load the tricky GDT ***/
cli
lgdtl gdt_desc
movw $0x10, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
jmp $0x08, $virtual_kernel
/* The multiboot header. */
.p2align 2
0: .long 0x1BADB002 /* magic number. */
.long 0x00010002 /* flags. */
.long -0x1BADB002-0x00010002 /* checksum. */
.long 0b
.long _start
.long _edata
.long __bss_end
.long entry
virtual_kernel:
...
Code: Select all
jmp $0x08, $virtual_kernel
Code: Select all
00066806313e[CPU0 ] check_cs(0x0008): attempt to jump to long mode without enabling EFER.LMA !
00066806313e[CPU0 ] check_cs(0x0008): conforming code seg descriptor dpl > cpl, dpl=3, cpl=0
00066806313e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00066806313e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
00066806313i[CPU0 ] CPU is in protected mode (active)
00066806313i[CPU0 ] CS.d_b = 32 bit
00066806313i[CPU0 ] SS.d_b = 32 bit
00066806313i[CPU0 ] EFER = 0x00000000
00066806313i[CPU0 ] | RAX=0000000000000010 RBX=000000000000e004
00066806313i[CPU0 ] | RCX=000000000000e104 RDX=0000000000000000
00066806313i[CPU0 ] | RSP=0000000000067e3c RBP=0000000000067e5c
00066806313i[CPU0 ] | RSI=000000000002f600 RDI=000000000002f5f8
00066806313i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
00066806313i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
00066806313i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
00066806313i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
00066806313i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af pf cf
00066806313i[CPU0 ] | SEG selector base limit G D
00066806313i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00066806313i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
00066806313i[CPU0 ] | DS:0010( 0002| 0| 0) ffffffff ffffffff 1 1
00066806313i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00066806313i[CPU0 ] | ES:0010( 0002| 0| 0) ffffffff ffffffff 1 1
00066806313i[CPU0 ] | FS:0010( 0002| 0| 0) ffffffff ffffffff 1 1
00066806313i[CPU0 ] | GS:0010( 0002| 0| 0) ffffffff ffffffff 1 1
00066806313i[CPU0 ] | MSR_FS_BASE:00000000ffffffff
00066806313i[CPU0 ] | MSR_GS_BASE:00000000ffffffff
00066806313i[CPU0 ] | RIP=0000000000100038 (0000000000100038)
00066806313i[CPU0 ] | CR0=0x60000011 CR2=0x0000000000000000
00066806313i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
(0).[66806313] [0x0000000000100038] 0008:0000000000100038 (unk. ctxt): [b]jmp far 0008:c0100060[/b] ; ea600010c00800
00066806313e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00066806313i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00066806313i[CPU0 ] cpu hardware reset
00066806313i[APIC0] allocate APIC id=0 (MMIO enabled) to 0x00000000fee00000
00066806313i[CPU0 ] CPU[0] is the bootstrap processor
00066806313i[ ] reset of 'unmapped' plugin device by virtual method
00066806313i[ ] reset of 'biosdev' plugin device by virtual method
00066806313i[ ] reset of 'speaker' plugin device by virtual method
00066806313i[ ] reset of 'extfpuirq' plugin device by virtual method
00066806313i[ ] reset of 'gameport' plugin device by virtual method
00066806313i[ ] reset of 'pci_ide' plugin device by virtual method
00066806313i[ ] reset of 'acpi' plugin device by virtual method
00066806313i[ ] reset of 'ioapic' plugin device by virtual method
00066806313i[ ] reset of 'keyboard' plugin device by virtual method
00066806313i[ ] reset of 'harddrv' plugin device by virtual method
00066806313i[ ] reset of 'serial' plugin device by virtual method
00066806313i[ ] reset of 'parallel' plugin device by virtual method
Next at t=66806314
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0
<bochs:4>