🔒 Locked
Mode-changing without BIOS
Advertisement
Original Post
Does anyone know how to change the screen resolution and plot pixels in protected mode without using the BIOS? I''ve seen several sites say "you can program the VGA registers directly", but nothing that tells *how*.
You can do this by programming the VGA I/O ports.
I haven''t got my old VGA book at hand right now, but if I remember the ports are in the range 0x3C0..0x3DF.
The ports can be programmed by using the inportb/outportb family of functions (inpb/outpb depending on the compiler), or IN/OUT assembler instructions.
I''m afraid I won''t be able to dig up some source at this point, the book is probably somewhere in a dusty corner
I haven''t got my old VGA book at hand right now, but if I remember the ports are in the range 0x3C0..0x3DF.
The ports can be programmed by using the inportb/outportb family of functions (inpb/outpb depending on the compiler), or IN/OUT assembler instructions.
I''m afraid I won''t be able to dig up some source at this point, the book is probably somewhere in a dusty corner
If you know Spanish, I can send you a document explaining how to do it. Years ago I did a project for the University called something like "Programming VGA driver for a protected mode operating system".
Basically, all you need to do is to program 60/70 registers of de VGA card.
This document also explain other things like change default VGA card font, different write and read modes of the VGA cards...
Basically, all you need to do is to program 60/70 registers of de VGA card.
This document also explain other things like change default VGA card font, different write and read modes of the VGA cards...
Fortunatly, I *do* know a bit of spanish. Not much, but hopefully enough to stumble through the code. Anything helps!
[edited by - Quantum2005 on December 6, 2002 4:35:58 PM]
[edited by - Quantum2005 on December 6, 2002 4:35:58 PM]
quote:
Original post by MattS423
He doesn''t necessarly need to change it, but maybe there is a better way of doing it. thats all i''m saying.
Let''s not reinvent the wheel...
Unfortunatly, I don''t have that luxury. The project I''m working on (probably should''ve said this in the first place) is a mini OS. I had simple graphics working in real mode using the following:
_setmode13h: ; VGA 320x200, 8bpp
mov ah,00
mov al,0x13
int 10h
ret
But now that I''m using protected mode, I can''t use the BIOS anymore.
Does anyone know the exact ports Prototype was talking about, and what to put into them? Also, it''d be nice to do SVGA modes as well, but I have a sneaking suspicion that that''s asking a bit much...
Had the same problem. My quick''n dirty solution was to set the screen resolution at boot time via the VESA BIOS.
Backing up a little, you can forget doing SVGA stuff by yourself (you''d at the very least need a mode set routine for the different chipsets; while GFx use almost the same code, that''s not the way to go.). Assuming you want more than 640x480:4, that leaves the VESA BIOS (spec available at www.vesa.org), and 3 ways to call it:
1) v86 mode (ugly)
2) with the protected mode entry point (I could not for the life of me get this working, and I’ve read that this is sometimes broken (that would be a nice explanation
)
3) at system boot, in real mode (assuming you’re writing your own loader). This way’s the smallest, easiest, and least flexible.
Code from my boot sector:
Note: a config program autodetects / asks for the following:
(values from my current config)
If you’ve got paging enabled, you will of course have to map the LFB.
Again a little explanation: the VBE sets the desired video mode, and returns a pointer to the linear frame buffer (=: LFB; I get the address at install/assemble time, because hey, we''re talking boot sector here
). There’s no bank switching like in VBE 1.2 or hand rolled SVGA – just a simple array a la mode 0x13.
HTH
Jan
Backing up a little, you can forget doing SVGA stuff by yourself (you''d at the very least need a mode set routine for the different chipsets; while GFx use almost the same code, that''s not the way to go.). Assuming you want more than 640x480:4, that leaves the VESA BIOS (spec available at www.vesa.org), and 3 ways to call it:
1) v86 mode (ugly)
2) with the protected mode entry point (I could not for the life of me get this working, and I’ve read that this is sometimes broken (that would be a nice explanation
3) at system boot, in real mode (assuming you’re writing your own loader). This way’s the smallest, easiest, and least flexible.
Code from my boot sector:
bits 16
; set vbe mode
mov ax, 0x4f02
mov bx, VMODE|0xc800 ; lfb, no mem clear, use crtc pll timing data
mov di, crtc_timing [see vbe dox]
int 0x10
...
bits 32
; set lfb cache type to wc via mtrr
; > ecx = 0x0000????
; > edx = 0
mov cx, 0x20e
mov eax, lfb|1 ; base address; type = wc
lea edi, [eax-1]
wrmsr ; MTRRPhysBase7
inc ecx
mov eax, (-lfb_size)|0x800 ; length of range; valid bit = 1
wrmsr
; clear screen
; > edi -> lfb
mov eax, 0x00396da5 ; light blue
mov ecx, XRES*YRES
rep stosd
Note: a config program autodetects / asks for the following:
VMODE equ 0x118
XRES equ 1024
YRES equ 768
lfb equ 0xe0000000
mmio equ 0xec000000
lfb_size equ (16*1024*1024)
(values from my current config)
If you’ve got paging enabled, you will of course have to map the LFB.
Again a little explanation: the VBE sets the desired video mode, and returns a pointer to the linear frame buffer (=: LFB; I get the address at install/assemble time, because hey, we''re talking boot sector here
HTH
Jan
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement