Page 1 of 1
IA-32e mode
Posted: Tue Sep 04, 2007 4:30 am
by HJED
Hi
I am trying to write an OS that runs in IA-32e mode i have read the intel documantation on this
at curent my code is in protected mode
it has
gdt , idt , irqs, a keboard layout , and i can print mesages to the screan
it then tries to enable pagging and long mode(it makes seans to put them together becouse u change pagging setting to enable long mode)
paging is not enabled
i am using the NASM assembler
could some one pleas tell me how to
2. Enable physical-address extensions (PAE) by setting CR4.PAE = 1.
and
4. Enable IA-32e mode by setting IA32_EFER.LME = 1.
PS i have figured out how to do the other steps
Posted: Tue Sep 04, 2007 4:45 am
by exkor
use this example, you'll save yourself lots of time
http://flatassembler.net/examples/longmode.zip
there was corresponding thread about these examples here
http://board.flatassembler.net/forum.php?f=11
fasm is similar to nasm i think.
Re: IA-32e mode
Posted: Tue Sep 04, 2007 4:51 am
by bluecode
AT&T assembler:
HJED wrote:2. Enable physical-address extensions (PAE) by setting CR4.PAE = 1.
Code: Select all
/* Set cr4.PAE */
mov %cr4, %eax
or $0x20, %eax
mov %eax, %cr4
4. Enable IA-32e mode by setting IA32_EFER.LME = 1.
Code: Select all
/* Set EFER.LME */
mov $0xC0000080, %ecx
rdmsr
or $0x100, %eax
wrmsr
Posted: Tue Sep 04, 2007 6:01 pm
by HJED
Thank you
i foud i site that explanes chaging AT&T asm in to intel asm and now it works thanks
for your code it was realy help full
here is my code for swiching to long mode for others who have a smilar problem
c++
Code: Select all
long_mode1(); // start long mode int
write_cr3((unsigned long *)0x9C000); // put that page directory address into CR3
long_mode2(); // pagging int 2
write_cr0( (unsigned long *)((unsigned long) read_cr0() | (unsigned long) 0x80000000)); // set the paging bit in CR0 to 1
NASM
Code: Select all
[global _read_cr0]
_read_cr0:
mov eax, cr0
retn
[global _write_cr0]
_write_cr0:
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov cr0, eax
pop ebp
retn
[global _read_cr3]
_read_cr3:
mov eax, cr3
retn
[global _write_cr3]
_write_cr3:
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov cr3, eax
pop ebp
retn
[global _long_mode1]
_long_mode1:
; cr0.PG is alread at 0
; Set cr4.PAE
mov eax , cr4
or eax , 0x2000000
mov cr4 , eax
; L4PT loaded in pagging.cpp
retn
[global _long_mode2]
_long_mode2:
;Set EFER.LME
mov ecx , 0xC0000080
rdmsr
or eax , 0x100
wrmsr
rent
;rest in paging
once again thanks for your help
Posted: Wed Sep 05, 2007 8:05 am
by Combuster
Posted: Wed Sep 05, 2007 3:43 pm
by HJED
no it was in a pagging tutorial which had lot of erros
Posted: Thu Sep 06, 2007 12:01 am
by Combuster
HJED wrote:Combuster wrote:Typo?
no it was in a pagging tutorial which had lot of erros
Well, it makes me wonder why you post code of which you know is incorrect.
Posted: Thu Sep 06, 2007 1:55 am
by HJED
u assume i already new that orginaly i only found out it had lots of errors after i posted this
Posted: Thu Sep 06, 2007 7:07 am
by Zacariaz
still you should make an effort to check for errors before posting, both gramma and programing.
I usually write a post and then hit the "submit" button forgetting to read it through first.
and then i use alot of time editing the post. well maybe not alot of time, but anyways.
Code: Select all
10 GOTO 30
20 CORRECT ERROR
30 LOOK FOR ERROR!
40 IF ERROR FOUND GOTO 20
50 HIT SUBMIT
I never did learn basic but you get the message...
THIS POST BEEN EDITED "1" TIME!
Posted: Thu Sep 06, 2007 4:44 pm
by HJED
what you just said dose`nt make sense the paging post wasn`t working i was going thought issue 1 @ a time the paging code dose now work and i din`t know that rent thing was an error until someone in this post told me because asm did`nt complain abut it
Posted: Sun Sep 09, 2007 10:40 pm
by SpooK
Paying rent will keep you from getting booted.
Posted: Mon Sep 10, 2007 2:18 am
by HJED
whattttttt?
Posted: Mon Sep 10, 2007 10:37 am
by Zacariaz
paying rent will keep you from getting booted, but you could allso not pay rent and uffer the consequeses (damn i cant spell)
e.g. paying the rent is a smart thing to do.