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.
nicola
Member
Posts: 32 Joined: Mon May 16, 2011 2:05 pm
Location: hanoi
Post
by nicola » Tue May 17, 2011 6:04 am
hi guys,
i followed the sample in osdev wiki at
http://wiki.osdev.org/Entering_Long_Mode_Directly
but got stuck in this line (cant compile)
Code: Select all
;Enter long mode
mov eax,10100000b ;Set PAE and PGE
mov cr4,eax
mov edx, 0x0000a000 ;Point CR3 at PML4
mov cr3,edx
mov ecx,0xC0000080 ;Specify EFER MSR
rdmsr ;Enable Long Mode
or eax,0x00000100
wrmsr
mov ebx,cr0 ;Activate long mode
or ebx,0x80000001 ;by enabling paging and protection simultaneously
mov cr0,ebx ;skipping protected mode entirely
lgdt [gdt.pointer] ;load 80-bit gdt.pointer below
jmp gdt.code:startLongMode ;Load CS with 64 bit segment and flush the instruction cache
;Global Descriptor Table
gdt:
dq 0x0000000000000000 ;Null Descriptor
.code equ $ - gdt
dq 0x0020980000000000
.data equ $ - gdt
dq 0x0000900000000000
.pointer:
dw $-gdt-1 ;16-bit Size (Limit)
dq gdt
i'm using flat assembler and it say the line
has unknown symbol "gdt.code"
but it is clearly declared in Global Descriptor Table above.
and i wonder why
gdt.pointer is known
and
gdt.code is unknown
please help
I'm using AMD Sempron 140 Single core 2.7GHz
Combuster
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 » Tue May 17, 2011 7:52 am
The wiki wrote: NASM code
You wrote: i'm using flat assembler
Use the right tool for the job
"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 ]
nicola
Member
Posts: 32 Joined: Mon May 16, 2011 2:05 pm
Location: hanoi
Post
by nicola » Wed May 18, 2011 6:14 am
ok combuster,
now i'm using NASM
i copied exactly the source from
http://wiki.osdev.org/Entering_Long_Mode_Directly
after assembling, i got
624 bytes
i then booted it as a floppy using Bochs, but the line "
Put long mode kernel here.__ " didn't appear
as quoted in the wiki article
nothing but the blinking cursor
is that wiki article reliable?
I'm using AMD Sempron 140 Single core 2.7GHz
nicola
Member
Posts: 32 Joined: Mon May 16, 2011 2:05 pm
Location: hanoi
Post
by nicola » Wed May 18, 2011 6:44 am
my apology
the code runs fine, but it did not clear screen before writing
out "Put long mode kernel here.__" so i thought it hanged
I'm using AMD Sempron 140 Single core 2.7GHz