flat assembler
Message board for the users of flat assembler.

Index > OS Construction > 32PM PAE and VESAtest error

Author
Thread Post new topic Reply to topic
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 27 Sep 2006, 15:26
Anybody knows why the VESAtest needs paging turned off to run properly?
This is the 'Bochs'-version...


Code:
; start.asm
; Niels

org 0x7c00
use16

dd_LFB                          equ     0x0500
d512_VBEcontrollerInfo          equ     0x0504

PDPTE32_start                   equ     0x1000
PDE32_start                     equ     0x2000

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                                       jmp 0:StartRM

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ENABLE A20 functions

SendCommandPort64:
        in al,0x64
        bt ax,1
        jc SendCommandPort64
        mov al,bl
        out 0x60,al
ret

RecieveCommandPort64:
        in al,0x64
        bt ax,0
        jc RecieveCommandPort64
        in al,0x60
ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MakePages32:
;blz.114 blz.118 blz.125 format
mov cx,2048 * 2 ; 2048byte * word = 4096 byte page * 2
mov di,PDPTE32_start
clearPages:
mov word [di],0
add di,2
dec cx
jnz clearPages

mov cx,4;1              ; Bochs needs all 4 instead of just 1
mov ax,PDE32_start + 3  ; 0011b blz.125 format with 'EM64T' supplement.
mov di,PDPTE32_start

fillPDPTE32:
mov word [di],ax
;mov ax,0               ; Comment this line with Bochs
add di,8
dec cx
jnz fillPDPTE32


mov cx,512
mov di,PDE32_start
mov ax,0
fillPDE32:
mov word [di],0000000010000011b
mov word [di+2],ax
add ax,100000b
add di,8
dec cx
jnz fillPDE32
        
ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                                             StartRM:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EnableA20:
        cli
        mov bl,0xd0
        call SendCommandPort64
        call RecieveCommandPort64
        mov cl,al
        mov bl,0xd1
        call SendCommandPort64
        mov bl,cl
        bts bx,1
        call SendCommandPort64
        sti

;BIOS A20
        mov ax,0x2401
        int 0x15

;Fast A20
        in al,0x92
        bts ax,1
        out 0x92,al

;Check A20
        mov ax,0xffff
        mov ds,ax
        mov ax,0x40
        mov es,ax
        wbinvd                  ; flushes the internal caches
        mov bx,[es:0x10]        ; bx = [0x40:0x10]      BDA Installed hardware word
        cmp bx,[ds:0x420]       ; bx == [0x100410] ?
        jne A20good             ; not equal is good, then there's no memory wrapping
        inc word [ds:0x420]     ; [0x100410] + 1
        wbinvd
        cmp bx,[es:0x10]        ; bx = [0x40:0x10] == [0x100410] ?
                                ; If A20 is not OK, inc [ds:0x420] would have inc [es:0x10] due wrapping
                                ; And thus bx compared to [0x400:0x10] would no longer be the same
        je A20good

jmp $

        A20good:
                dec word [ds:0x420]
                xor ax,ax
                mov ds,ax
                mov es,ax

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
checkPAE:       ; volgens pag. 112, zou de source-operand = eax 2 moeten zijn?
        mov eax,dword 1
        cpuid
        bt dx,6
        jc yesPAE
        jmp $
        yesPAE:
                        jmp SetupVESA   ; Standard Bochs hangs on EM64T test

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
checkEM64T:
        mov eax,dword 0x80000001
        cpuid
        bt edx,29
        jc yesEM64T
        jmp $
        yesEM64T:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SetupVESA:

        mov ax,0x4f02
        ;11b          100011011  1280x1024
        ;118          100011000  1024x 768 *
        ;115          100010101   800x 600
        mov bx,0100000100011000b
        int 0x10

; Recieve ModeInfo
        mov ax,0x4f01
        mov cx,bx
        mov di,d512_VBEcontrollerInfo
        int 0x10

; Store Linear Frame Buffer
        mov word ax,[d512_VBEcontrollerInfo+0x28]
        mov word bx,[d512_VBEcontrollerInfo+0x2a]
        mov word [dd_LFB],ax
        mov word [dd_LFB+2],bx

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Prepare32PM:    ; blz.381

        call MakePages32

        cli
        lgdt [GDT32PM]

        ; enable physical-address extension paging PAE
        mov eax,cr4
        bts eax,5               ; PAE
        mov cr4,eax

        mov eax,PDPTE32_start
        mov cr3,eax

        mov eax,cr0
        bts eax,0               ; enable PM
        bts eax,31              ; enable PG
        mov cr0,eax

        mov ax,0x10             ; segment 32bitPM laden
        mov ds,ax
        mov es,ax
        mov ss,ax

        mov esp,0x09FFFF        

        jmp 0x08:Start32PM      ; Far jump blz.381, stap 4 en 7

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
use32

align 8
GDT32PM_start:                                  ; segment descriptor blz.94 97 blz.253tss
nullsegment32PM                 dq 0
code32PM:
        csegment_limit32PM      dw 0xffff       ; 16Mb 1024*1024*16/4096=4096
        cbase_address32PM       dw 0            ; locatie van byte 0
        cbase2316_32PM          db 0            ; vervolg baseadres
        ctypesdplp_32PM         db 10011010b    ; l>rN P1,DPL2,S1,Type4
        cgdblavlseglimit_32PM   db 11001111b    ; l>rN G1,D/B1,L1,AVL1,SegLimit19:16_4
        cbase3124_32PM          db 0            ; vervolg baseadres
data32PM:
        dsegment_limit32PM      dw 0xffff       ; 16Mb 1024*1024*16/4096=4096
        dbase_address32PM       dw 0            ; locatie van byte 0
        dbase2316_32PM          db 0            ; vervolg baseadres
        dtypesdplp_32PM         db 10010010b    ; l>rN P1,DPL2,S1,Type4
        dgdblavlseglimit_32PM   db 11001111b    ; l>rN G1,D/B1,L1,AVL1,SegLimit19:16_4
        dbase3124_32PM          db 0            ; vervolg baseadres
GDT32PM_end:

GDT32PM:
        dw GDT32PM_end - GDT32PM_start
        dd GDT32PM_start

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                                           Start32PM:
;align 4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; VESA test
; VESA test is working when CR0.PG bit31 is disabled
; Weird, since page-mapping is done 1:1

mov ecx,800*600
mov eax,[dd_LFB]
mov ebx,0xffffffff

here:
        mov dword [eax],ebx
        add eax,4
        dec ecx
jnz here

jmp $

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
times (510-($-$$)) db 0
dw 0xaa55
    
Post 27 Sep 2006, 15:26
View user's profile Send private message Reply with quote
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 27 Sep 2006, 15:32
If you see a language you don't know... it's dutch.
Post 27 Sep 2006, 15:32
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 27 Sep 2006, 20:57
Maybe because of the address of LFB, if you use paging you will need to map it one to one.
Post 27 Sep 2006, 20:57
View user's profile Send private message Reply with quote
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 28 Sep 2006, 10:18
Hello Dex4u,

I placed 'marks' around the 'realmode' get/host-address(above this is 0x0500) for LFB. When arrived in 32PM with paging on, I looked up the marks and concluded there is a 1 on 1 mapping done... The 32-bit address of the LFB should linear be equal to the physical-address behind paging. Since the retrieval of the LFB-address is correct, there could be a problem above the first (0-)2Mb, this due an incorrect function MakePages32 but at this point I can't see what should be wrong in the particular function.

You got more options? Smile

Niels.
Post 28 Sep 2006, 10:18
View user's profile Send private message Reply with quote
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 28 Sep 2006, 10:36
For the record: To me linear 1:1 page-mapping is; Make a segment p.a. 4Gb, start with the first page-physical-address on 0 and continuously map the following pages.
Post 28 Sep 2006, 10:36
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 28 Sep 2006, 18:54
HI Niels, I do not use paging myself but have seen others who do get this problem
See here:
http://www.mega-tokyo.com/forum/index.php?board=1;action=display;threadid=9940;start=msg85934

Also not make sure your A20 is working right as this can also cause problems.
Post 28 Sep 2006, 18:54
View user's profile Send private message Reply with quote
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 28 Sep 2006, 20:35
Hello Dex4u,

The above code, is not rebooting or shuttingdown the computer.

Niels.

ps.
This is my first experience with paging...PAE-paging.
Post 28 Sep 2006, 20:35
View user's profile Send private message Reply with quote
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 18 Oct 2006, 06:40
Solved BTW.
Post 18 Oct 2006, 06:40
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.