Help Long Mode at 0x100000

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
orange
Posts: 16
Joined: Sun Dec 16, 2007 11:13 pm

Help Long Mode at 0x100000

Post by orange »

I create my own boot loader and setting up 64 bit long mode environment and load my 64 bit kernel into 0x7E00 and move up to 0x100000 and then jump to 0x100000 to execute it.

but something crazy happen. some of code doesn't works correctly

mov rax,'T E S T '
mov [0xB8000],rax

That code dosn't works. i just get blank screen!!!

can u tell me why this happens???

and how to resolve my problem??


Thanks


Orange.
blound
Member
Member
Posts: 70
Joined: Sat Dec 01, 2007 1:36 pm

Post by blound »

did you set the right mode before?
orange
Posts: 16
Joined: Sun Dec 16, 2007 11:13 pm

Post by orange »

blound wrote:did you set the right mode before?
Yes has set environment to long mode, and it works correctly but when i load to disk to boot, i get problem when jump to 0x100000

before i get an error when jump to 0x100000 becouse i map paging just 1Mb, then i increase to 8 mb and jump successfull to 0x100000.

but some of code doesn't works correctly. i try to access memory video

mov rax,'T E S T '
mov [0xB8000],rax

that code dosn't works
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

First are you using a emulator ?, does it work before moving address ?.
As i have seen people have problems with qemu and this code.

Also have you implemented A20 ?.
orange
Posts: 16
Joined: Sun Dec 16, 2007 11:13 pm

Post by orange »

Dex wrote:First are you using a emulator ?, does it work before moving address ?.
As i have seen people have problems with qemu and this code.

Also have implemented A20 ?.
Yes i m using emulator.. vmware. and boot with real machine i still get same problem.

Before activating long mode... In 32 Protected mode session i try jump to 0x100000 ... well that is good, i can see text on my screen.

Then when i activate long mode i still can see text on my screen

But when i move up my code to 0x100000, i can't see text any more.

no exception, no error mesage just blank!!!
orange
Posts: 16
Joined: Sun Dec 16, 2007 11:13 pm

Post by orange »

Dex wrote:Also have you implemented A20 ?.
yes i have implemented A20, without it i can't jump to 0x100000

i'm very sure successfuly jump to 0x100000 an execute any code on it. i just confuse when i can access video memory.


Thanks
Orange
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Have you tryed the same code for paging in pmode ?
Have you tryed jumping to 0x100000 and then back to see if you come back OK.
Or get some beep code (let me know if you need it ) convert it to 64bit and see if it beeps.
orange
Posts: 16
Joined: Sun Dec 16, 2007 11:13 pm

Post by orange »

Dex wrote:Have you tryed the same code for paging in pmode ?
Yes...
Dex wrote: Have you tryed jumping to 0x100000 and then back to see if you come back OK.
No... and i will try... thnk's
Dex wrote: Or get some beep code (let me know if you need it ) convert it to 64bit and see if it beeps.
Ok i will try to use beep code.. please can u give me your beep code...

But when i add Halt instruction "HLT", wmware give me a emessage "CPU halted" that is make me sure i m on 0x100000, and suscced execute my kernel

Code: Select all

   mov   rax,'T E S T '
   mov   [0xB8000],rax

   hlt
Text still not on screen, but hlt work

that is more make me confuse :? :?
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post by Craze Frog »

What happens if you try this?

Code: Select all

mov rax, ' T S E T'
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Here the beep code

Code: Select all

 ;----------------------------------------------------;
 ; Beep                                               ;
 ;----------------------------------------------------;
Beep:
        pushad
        mov   [Hz],0x200
        call  Sound
        call  Delay
        call  NoSound
        popad
        ret
 ;----------------------------------------------------;
 ; Sound                                              ;
 ;----------------------------------------------------;
Sound:
        mov   bx,[Hz]
        mov   ax,0x34dd
        mov   dx,0x0012
        cmp   dx,bx
        jnc   Done1
        div   bx
        mov   bx,ax
        in    al,0x61
        test  al,3
        jnz   A99
        or    al,3
        out   0x61,al
        mov   al,0xb6
        out   0x43,al
A99:
        mov   al,bl
        out   0x42,al
        mov   al,bh
        out   0x42,al
Done1:
        ret

 ;----------------------------------------------------;
 ; NoSound                                            ;
 ;----------------------------------------------------;
NoSound:
        in    al,0x61
        and   al,11111100b
        out   0x61,al
        ret

 ;----------------------------------------------------;
 ; DeLay                                              ;
 ;----------------------------------------------------;
DeLay:                   
        mov   cx,[ms]                
        jcxz  A2                
A1:
        call  DelayOneMS                
        loop  A1                
A2:
        ret   
 ;----------------------------------------------------;
 ; DeLaYoneMS                                         ;
 ;----------------------------------------------------;
DeLaYoneMS:            
        push  ecx                                    
        mov   cx,[OneMS]                
B1:
        loop  B1               
        pop   ecx                
        ret
                                   
OneMS                   dw      40000
Hz                      dw      0
MS                      dw      20
But if the HLT works, it all points to some problem with mapping the 1 for 1 address of paging.

Also if you have a floppy drive you can put the motor on/off (light on and off) .
With this code

Code: Select all

 ;----------------------------------------------------;
 ; Fdd motor off                                      ;
 ;----------------------------------------------------;
Fdd_motor_off:
        mov   dx,0x3F2                                 
        mov   al,0
        out   dx,al
        ret

 ;----------------------------------------------------;
 ; Fdd Motor On                                       ;
 ;----------------------------------------------------;

FddMotorOn:
        mov   dx,0x3F2                                
        mov   al,00011100b                             
        out   dx,al
        ret
orange
Posts: 16
Joined: Sun Dec 16, 2007 11:13 pm

Post by orange »

Thank's for your help guys:)))

i have resolve my problem... i found BUG in my assembler. The RAX register doesn't point to 0xB8000 so that i can't see text on screen.

after i change with other assembler, then i see text on screen.

and thank's four your beeb dex, i use your code for samething else...


i don't know why my first assembler generate mistake code.
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 »

orange wrote:i found BUG in my assembler.
I bet there isn't. Compiler bugs are rare, and assemblers which are an magnitude more simple, the chance one exists is very unlikely to the point where it neglegible.

If its indeed a bug, tell us how to reproduce it.
"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 ]
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

orange wrote:i have resolve my problem... i found BUG in my assembler. The RAX register doesn't point to 0xB8000 so that i can't see text on screen.

after i change with other assembler, then i see text on screen.
When you say bug in the assembler, which was fixed when you changed it, do you mean you changed assember to say fasm to nasm, or do you mean you change from one ver to another of the same assembler ? .

If you changed to a differant assembler, could you name it, as it would help others, as i have seen this problem posted before.
Thanks.

PS: If you do not want to name it in public, you can PM me the name.
orange
Posts: 16
Joined: Sun Dec 16, 2007 11:13 pm

Post by orange »

ok sorry long time i can't online coz i verry bussy...

first i use FASM to compile my OS.. then i use YASM and til now My OS run correctly.

now i get One problem... since 64bit doesn't support hardware multitasking.

Can u give me reference how to build software mutlitasking...


:)))

thank's
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 »

orange wrote:Can u give me reference how to build software mutlitasking...
Have a look around
"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 ]
Post Reply