VBE:in real mode or in protected mode

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.
shindow
Member
Member
Posts: 26
Joined: Thu Feb 25, 2010 7:35 am

VBE:in real mode or in protected mode

Post by shindow »

I want to do something with graphics.and I read the papersheet of VBE,there 2ways to call the function of it.One is in real mode,easy but in prtected mode,you cann't do anything about it.the other is in protected,there are 10 steps if you wish do in this way,so complicated,what would you do.

thanks in advance
User avatar
XanClic
Member
Member
Posts: 138
Joined: Wed Feb 13, 2008 9:38 am

Re: VBE:in real mode or in protected mode

Post by XanClic »

As far as I know, there are just a few video cards supporting the protected mode interface.

I'd write a VM86 monitor and use the real mode interface.
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: VBE:in real mode or in protected mode

Post by Combuster »

I'd personally start with a VGA driver, being that if you can work with it, everything else is a bonus. But you could have asked the wiki on the pros and cons of all the alternatives.
"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 ]
shindow
Member
Member
Posts: 26
Joined: Thu Feb 25, 2010 7:35 am

Re: VBE:in real mode or in protected mode

Post by shindow »

Combuster wrote:I'd personally start with a VGA driver, being that if you can work with it, everything else is a bonus. But you could have asked the wiki on the pros and cons of all the alternatives.
I'd personally start with a VGA driver, being that if you can work with it, everything else is a bonus. But you could have asked the wiki on the pros and cons of all the alternatives.
but if you want to display more clear,VGA maybe seems not enough?
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: VBE:in real mode or in protected mode

Post by neon »

Thats up to you - I personally find 640x480 fine. Im seconding Combuster, separate the graphics from the video driver and you can go with SVGA+ modes later if you wish.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: VBE:in real mode or in protected mode

Post by Dex »

You can use high res vesa modes in pmode, just as easy as realmode, but you can only change modes in realmode, as most will be vesa2 with LFB.
They say theres a a pmode interface in vesa3, but its really 16bit pmode interface, so why not just switch back to realmode to change modes or stick to one mode.

Heres a simple vesa pmode demo

Code: Select all

;************************************
; By Dex
; Assemble with fasm 
; c:\fasm Vesa.asm Vesa.bin
;
;************************************
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   Letsloop 
;*****************************
; 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
Letsloop:
        hlt
        jmp   Letsloop
;*************************************
; 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.
;*************************************
;=========================================================;
; Vesa Information Block                         11/12/03 ;
;---------------------------------------------------------;
; DOS EXTREME OS V0.01                                    ;
; by Craig Bamford(Dex).                                  ;
;                                                         ;
;=========================================================;

;============================== VESA MODE INFORMATION ===========================================
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
;======================================= START OF PROGRAM  ======================================





User avatar
osdnlo
Member
Member
Posts: 136
Joined: Thu Feb 25, 2010 5:39 pm

Re: VBE:in real mode or in protected mode

Post by osdnlo »

You configure VESA in your loader, then pass the struct to your kernel, map the LFB, and you're ready to start GUI programming in pmode. If you're using GRUB, then disregard me. I don't know how to do the same using GRUB. A patch is needed I think.
Yes, I see that you have proven it, but my question was, 'How did you know that would work?'.
User avatar
KotuxGuy
Member
Member
Posts: 96
Joined: Wed Nov 25, 2009 1:28 pm
Location: Somewhere within 10ft of my favorite chubby penguin!

Re: VBE:in real mode or in protected mode

Post by KotuxGuy »

Yes, this can be done in GRUB, but you're right: To enable/configure VESA in GRUB Legacy, you need the VBE patch( I saw a thread on the forums about this; search for it ). GRUB 2, however, can configure VESA without a patch.
Give a man Linux, you feed the nearest optician ( Been staring at the PC too long again? ).
Give a man OS X, you feed the nearest NVidia outlet ( I need more GPU power!! )
Give a man Windows, you feed the entire Tylenol company ( Self explanatory :D )
aeritharcanum
Posts: 13
Joined: Sun Mar 07, 2010 3:17 pm

Re: VBE:in real mode or in protected mode

Post by aeritharcanum »

<Deleted>
Last edited by aeritharcanum on Sun Feb 28, 2021 11:04 pm, edited 1 time in total.
User avatar
KotuxGuy
Member
Member
Posts: 96
Joined: Wed Nov 25, 2009 1:28 pm
Location: Somewhere within 10ft of my favorite chubby penguin!

Re: VBE:in real mode or in protected mode

Post by KotuxGuy »

This may be off-topic!

Unfortunately, you can't set a new resolution from GRUB without restarting the computer.
Give a man Linux, you feed the nearest optician ( Been staring at the PC too long again? ).
Give a man OS X, you feed the nearest NVidia outlet ( I need more GPU power!! )
Give a man Windows, you feed the entire Tylenol company ( Self explanatory :D )
torshie
Member
Member
Posts: 89
Joined: Sun Jan 11, 2009 7:41 pm

Re: VBE:in real mode or in protected mode

Post by torshie »

KotuxGuy wrote:Yes, this can be done in GRUB, but you're right: To enable/configure VESA in GRUB Legacy, you need the VBE patch( I saw a thread on the forums about this; search for it ). GRUB 2, however, can configure VESA without a patch.
Could you please give me more information on configure VESA in GRUB2?

Thanks
torshie
User avatar
KotuxGuy
Member
Member
Posts: 96
Joined: Wed Nov 25, 2009 1:28 pm
Location: Somewhere within 10ft of my favorite chubby penguin!

Re: VBE:in real mode or in protected mode

Post by KotuxGuy »

Again, this may be off-topic!

Certainly.

First the gfxterm GRUB 2 module must be loaded. Then in your grub.cfg file:

Code: Select all

insmod gfxterm
set gfxmode="1024x768x32,800x600x32,640x480x32,1024x768,800x600,640x480"
That will give the highest resolution available.

Or:

Code: Select all

insmod gfxterm
set gfxmode=[resolution you want]
# Like: 1024x768x32 ( which has 32bpp ), 1024x768 ( which will give the highest bpp )
Give a man Linux, you feed the nearest optician ( Been staring at the PC too long again? ).
Give a man OS X, you feed the nearest NVidia outlet ( I need more GPU power!! )
Give a man Windows, you feed the entire Tylenol company ( Self explanatory :D )
shindow
Member
Member
Posts: 26
Joined: Thu Feb 25, 2010 7:35 am

Re: VBE:in real mode or in protected mode

Post by shindow »

I think using a vm86 is a good way,but must it running on level 3 ?i tend to simplify my kernel which is always running on level 0.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: VBE:in real mode or in protected mode

Post by qw »

In V86 mode, the privilege level is always 3.
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: VBE:in real mode or in protected mode

Post by quanganht »

You can try this emulator out in protected mode http://forum.osdev.org/viewtopic.php?f=2&t=21678
"Programmers are tools for converting caffeine into code."
Post Reply