Page 1 of 2
VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 7:01 am
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
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 7:46 am
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.
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 8:48 am
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.
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 9:22 am
by shindow
but if you want to display more clear,VGA maybe seems not enough?
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 10:45 am
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.
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 11:13 am
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 ======================================
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 4:21 pm
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.
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 4:36 pm
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.
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 5:34 pm
by aeritharcanum
<Deleted>
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 6:51 pm
by KotuxGuy
This may be off-topic!
Unfortunately, you can't set a new resolution from GRUB without restarting the computer.
Re: VBE:in real mode or in protected mode
Posted: Sat Mar 13, 2010 11:58 pm
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
Re: VBE:in real mode or in protected mode
Posted: Sun Mar 14, 2010 9:29 pm
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 )
Re: VBE:in real mode or in protected mode
Posted: Mon Mar 15, 2010 1:23 am
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.
Re: VBE:in real mode or in protected mode
Posted: Mon Mar 15, 2010 4:15 am
by qw
In V86 mode, the privilege level is always 3.
Re: VBE:in real mode or in protected mode
Posted: Mon Mar 15, 2010 5:01 am
by quanganht
You can try this emulator out in protected mode
http://forum.osdev.org/viewtopic.php?f=2&t=21678