how to set PhysBasePtr of mode info block to my own space??

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
weezo
Posts: 9
Joined: Wed Jul 23, 2008 4:33 am
Location: Egypt

how to set PhysBasePtr of mode info block to my own space??

Post by weezo »

hi
1-when i get vesa info from qemu it only set the first 4 chars with "vesa" but the mode i selected set succefully "800x600x8",any comments about that?

2-how to set PhysBasePtr of mode info block to known address?

simply this is my code:

Code: Select all

mov ax,0x4f02
mov bx,0x4103 ;800x600x8 linear frame buffer
int 0x10


thnx
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:

Re: how to set PhysBasePtr of mode info block to my own space??

Post by Combuster »

weezo wrote:1-when i get vesa info from qemu it only set the first 4 chars with "vesa" but the mode i selected set succefully "800x600x8",any comments about that?
I have no idea what you mean - VBE doesn't normally pass resolutions as a string.
2-how to set PhysBasePtr of mode info block to known address?
You don't. The physical address where the video card resides is fixed by the BIOS to make sure there is no overlap between the video card's addresses and other devices.

Instead your code will have to use the value in PhysBasePtr as provided and write whatever you want to put on the screen to that physical location. That said, you can use paging (or segmentation) to make a fixed virtual address point to the physical address dictated by the hardware.

--------------------------------------------------------------------------------
And then you edited your post

two issues in the code:
- don't assume a mode number will give you a fixed resolution on all hardware
- you should call the VBE information and mode information functions to actually get the physbaseptr and actual mode info.
"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:

Re: how to set PhysBasePtr of mode info block to my own space??

Post by Dex »

Heres a quick demo

Code: Select all

;************************************
; By Dex
;
; Assemble with fasm 
; c:\fasm Vesa.asm Vesa.bin
;
; Use rawrite to put on floppy
;
;************************************
org 0x7C00 

use16
;****************************
; Realmode startup code.
;****************************

start:
        xor   ax,ax
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   sp,0x7C00 

;****************************
; Vesa start code.
;****************************

        mov  bx,4112h
        mov  ax,4f01h
        mov  di,Mode_Info	
        mov  cx,bx
        int  10h 
        
        mov  ax,4f02h
        int  10h

;*****************************
; Setting up, to enter pmode.
;*****************************

        cli 
        lgdt  [gdtr]
        
        mov   eax, cr0
        or    al,0x1 
        mov   cr0,eax
 
        jmp   0x10: protected

;*****************************
; Pmode. ;-)
;*****************************

use32
protected:
        mov   ax,0x8 
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   esp,0x7C00
;*****************************
; Turn floppy off 
;*****************************

        mov   dx,3F2h
        mov   al,0
        out   dx,al

;*****************************
; Do we have 32 BitsPerPixel.
;*****************************

        cmp   byte[ModeInfo_BitsPerPixel],32
        jne   JustLoop

;*****************************
; fade background screen.
;*****************************

fade_screen:
        mov   edx,[ModeInfo_PhysBasePtr]
        mov   edi,edx
        xor   eax,eax
        mov   al,0xc5          
        xor   ebx,ebx
        mov   bl,195 
DoLoop:    
        mov   cx,640*2 
        dec   eax    

        rep   stosd
       
        dec   ebx
        jnz   DoLoop

;***********************************
; Draws the iPOD.
;***********************************

        mov   edi,236*4+640*4*125 
        add   edi,edx
Pod:
        xor   ecx,ecx
        mov   ebx,245
button2:
        mov   cl,14
        mov   al,0x2d
letsloop1:
        stosd
        add   eax,15
        loop  letsloop1
        mov   cl,130
        rep   stosd
        mov   cl,14
letsloop2:
        stosd
        sub   eax,15
        loop  letsloop2
        add   edi,640*4-158*4
        dec   ebx
        jnz   button2
       
;***********************************
; Draws the Pod window.  :-(
;***********************************

        mov   edi,263*4+640*4*143
        add   edi,edx 
PodWindow:
        mov   eax,0xffa6ffff
        xor   edx,edx
        mov   dl,65
DrawSomePixals:
        mov   cl,104
        rep   stosd
        add   edi,640*4-104*4 
        dec   edx
        jnz   DrawSomePixals

        xor   eax,eax
        mov   dl,65
DrawaLine:
        sub   edi,641*4
        stosd
        dec   edx
        jnz   DrawaLine

        mov   cl,104
        rep   stosd
JustLoop:
        jmp   $


;*************************************
; GDT. 
;*************************************

gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000
sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CF
sys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CF
gdt_end:

gdtr:	    dw gdt_end - gdt - 1	                                  
	    dd gdt 


;*************************************
; Make program 510 byte's + 0xaa55
;*************************************
            
times 510- ($-start)  db 0  
dw 0xaa55

;*************************************
; Put uninitialized data here. eg: vesa info
;*************************************

Mode_Info:		
ModeInfo_ModeAttributes		rw	1
ModeInfo_WinAAttributes		rb	1
ModeInfo_WinBAttributes		rb	1
ModeInfo_WinGranularity		rw	1
ModeInfo_WinSize		rw	1
ModeInfo_WinASegment		rw	1
ModeInfo_WinBSegment		rw	1
ModeInfo_WinFuncPtr		rd	1
ModeInfo_BytesPerScanLine	rw	1
ModeInfo_XResolution		rw	1
ModeInfo_YResolution		rw	1
ModeInfo_XCharSize		rb	1
ModeInfo_YCharSize		rb	1
ModeInfo_NumberOfPlanes		rb	1
ModeInfo_BitsPerPixel		rb	1
ModeInfo_NumberOfBanks		rb	1
ModeInfo_MemoryModel		rb	1
ModeInfo_BankSize		rb	1
ModeInfo_NumberOfImagePages	rb	1
ModeInfo_Reserved_page		rb	1
ModeInfo_RedMaskSize		rb	1
ModeInfo_RedMaskPos		rb	1
ModeInfo_GreenMaskSize		rb	1
ModeInfo_GreenMaskPos		rb	1
ModeInfo_BlueMaskSize		rb	1
ModeInfo_BlueMaskPos		rb	1
ModeInfo_ReservedMaskSize	rb	1
ModeInfo_ReservedMaskPos	rb	1
ModeInfo_DirectColorModeInfo	rb	1
; VBE 2.0 extensions
ModeInfo_PhysBasePtr		rd	1
ModeInfo_OffScreenMemOffset	rd	1
ModeInfo_OffScreenMemSize	rw	1



This is the bit you want

Code: Select all

       mov  bx,4112h
        mov  ax,4f01h
        mov  di,Mode_Info	
        mov  cx,bx
        int  10h 
Note: you will need to put your mode
Post Reply