Page 7 of 7

Re: Setting VESA/VBE Mode

Posted: Fri Jul 15, 2016 8:14 pm
by FallenAvatar
For anyone finding this thread in the future: This whole thread (with exception of a few posts, from "not" the 2 main posters) is the blind leading the blind. Would not recommend giving this thread a 2nd thought if your are seriously trying to learn of find a solution for an issue you have.

- Monk

Re: Setting VESA/VBE Mode

Posted: Sat Jul 16, 2016 5:55 am
by sortie
thehardcoreOS wrote:Hey sortie, I am not using gcc cross-compiler because it refused to build, I was getting some strange errors while building it...
It is a real pain to make it work since you need to manually move and install all those binutils.
There's also prebuilt toolchains available for some platforms at the bottom of the cross-compiler page. If you want help building a cross toolchain, you can post a topic and ask for help (I wouldn't know if you already did this), or show up in #osdev on freenode IRC and see if people can't help you out.

Re: Setting VESA/VBE Mode

Posted: Tue Oct 04, 2016 8:52 pm
by ch3ll0v3k
Can you please share the implementation of this:

Code: Select all

init(mboot->framebuffer_addr, mboot->framebuffer_pitch, mboot->framebuffer_width, mboot->framebuffer_height, mboot->framebuffer_bpp, 1024, 768);
I cant, switch video mode. :?

Re: Setting VESA/VBE Mode

Posted: Tue Oct 04, 2016 10:04 pm
by Brendan
Hi,
ch3ll0v3k wrote:Can you please share the implementation of this:

Code: Select all

init(mboot->framebuffer_addr, mboot->framebuffer_pitch, mboot->framebuffer_width, mboot->framebuffer_height, mboot->framebuffer_bpp, 1024, 768);
I cant, switch video mode. :?
That doesn't switch video mode (and I'd assume it only configures the kernel to suit whatever video mode GRUB happened to set); and the values being passed look a little redundant to me (it has width and height from multi-boot that should be correct even if GRUB couldn't find 1024*768 and chose something else, and then the "1024, 768" at the end that looks both unnecessary and potentially wrong).


Cheers,

Brendan

Re: Setting VESA/VBE Mode

Posted: Wed Oct 05, 2016 12:25 am
by ch3ll0v3k
ahh, oke!

I see sometimes people talk about this function:

Code: Select all

intV86(0x10, "ax,cx,es:di", 0x4F01, modes[i], 0, modeInfo);
so thay can make call to BIOS in real mode to switch or get info.
Do i need implement this function or is it part of something that i can just use?

I use GRUB and my system runs direct in protected mode. My skils in assembly is very basic.

If i execute assembly instruction before i clear all interruprs, my system kips rebooting.
I use this,

Code: Select all

; // MODE    RESOLUTION  BITS PER PIXEL  MAXIMUM COLORS
; // 0x0100  640x480     4               16
; // 0x0101  640x480     8               256
; // 0x0102  800x600     4               16
; // 0x0103  800x600     8               256
; // 0x010D  320x200     15              32k
; // 0x010E  320x200     16              64k
; // 0x010F  320x200     24/32*          16m
; // 0x0110  640x480     15              32k
; // 0x0111  640x480     16              64k
; // 0x0112  640x480     24/32*          16m
; // 0x0113  800x600     15              32k
; // 0x0114  800x600     16              64k
; // 0x0115  800x600     24/32*          16m
; // 0x0116  1024x768    15              32k
; // 0x0117  1024x768    16              64k
; // 0x0118  1024x768    24/32*          16m

loader:

	mov ax, 0x4F02
    mov bx, 0x4100
	int 0x10
	cmp ax, 0x004F
    jne error:

	cli						; Clear interrupt flag [IF = 0]; 0xFA
	mov esp, kernel_stack	; set stack pointer

	push ebx				; info (ram-size, ... ) [multiboot structure]
	push eax				; MAGIC
	call kernel_main 		; controll to kernel_main(); in kernelc.c 
	hlt						; HLT 	Enter halt state 0xF4


I do something wrong, bud what ? Any help would be awesome.

Re: Setting VESA/VBE Mode

Posted: Wed Oct 05, 2016 1:10 am
by Brendan
Hi,
ch3ll0v3k wrote:I see sometimes people talk about this function:

Code: Select all

intV86(0x10, "ax,cx,es:di", 0x4F01, modes[i], 0, modeInfo);
so thay can make call to BIOS in real mode to switch or get info.
I have no idea what that is (the name "intV86" implies that it might be a function that uses virtual80x86 mode to execute an interrupt but I've seen misleading/wrong names too often to make assumptions like that and it could be switching back to real mode instead).
ch3ll0v3k wrote:Do i need implement this function or is it part of something that i can just use?
It's part of something that you'd need to write or copy or steal.
ch3ll0v3k wrote:I use GRUB and my system runs direct in protected mode. My skils in assembly is very basic.
Then you should probably let GRUB choose a video mode for you (by telling GRUB what you want in you're kernel's "multiboot header"), so you don't need to deal with any assembly.
ch3ll0v3k wrote:If i execute assembly instruction before i clear all interruprs, my system kips rebooting.
I use this,
That's because the BIOS functions (and the BIOS "IVT/Interrupt Vector Table") are designed for real mode and you aren't in real mode.
ch3ll0v3k wrote:

Code: Select all

; // MODE    RESOLUTION  BITS PER PIXEL  MAXIMUM COLORS
; // 0x0100  640x480     4               16
; // 0x0101  640x480     8               256
; // 0x0102  800x600     4               16
; // 0x0103  800x600     8               256
; // 0x010D  320x200     15              32k
; // 0x010E  320x200     16              64k
; // 0x010F  320x200     24/32*          16m
; // 0x0110  640x480     15              32k
; // 0x0111  640x480     16              64k
; // 0x0112  640x480     24/32*          16m
; // 0x0113  800x600     15              32k
; // 0x0114  800x600     16              64k
; // 0x0115  800x600     24/32*          16m
; // 0x0116  1024x768    15              32k
; // 0x0117  1024x768    16              64k
; // 0x0118  1024x768    24/32*          16m[/quote]

Note that "fixed mode numbers" (what you've listed here) were deprecated by VBE2.0 in 1994 and should not be relied on (unless you know the video card's ROM doesn't support VBE2.0 but does support VBE1.x).


Cheers,

Brendan

Re: Setting VESA/VBE Mode

Posted: Wed Oct 05, 2016 1:15 am
by ch3ll0v3k
Thank you for awesome answer! Now i get it! :)

Re: Setting VESA/VBE Mode

Posted: Wed Oct 05, 2016 3:48 am
by ch3ll0v3k
I found how to switch, maybe will be use-full for other:

Code: Select all

[BITS 32]
align 4

; // ======================================================================
; // http://www.osdever.net/bkerndev/Docs/basickernel.htm
; // https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format
MBALIGN  equ  1<<0              ; // align loaded modules on page boundaries
MEMINFO  equ  1<<1              ; // provide memory map
VIDMOD   equ  1<<2              ; // information about the video mode table must be available to the kernel.
;ELF_OR   equ  1<<16            ; // must be providet if kernel is not ELF
FLAGS    equ  MBALIGN | MEMINFO | VIDMOD
MAGIC    equ  0x1BADB002        ; // 'magic number' lets bootloader find the header
CHECKSUM equ -(MAGIC + FLAGS)   ; // checksum of above, to prove we are multiboot
 
section .multiboot
	dd MAGIC
	dd FLAGS
	dd CHECKSUM
   	dd 0						; 12 	u32 	header_addr 	if flags[16] is set
    dd 0						; 16 	u32 	load_addr 	if flags[16] is set
    dd 0						; 20 	u32 	load_end_addr 	if flags[16] is set
    dd 0						; 24 	u32 	bss_end_addr 	if flags[16] is set
    dd 0						; 28 	u32 	entry_addr 	if flags[16] is set
    dd 0						; 32 	u32 	mode_type 	if flags[2] is set
    dd 800						; 36 	u32 	width 	if flags[2] is set
    dd 600						; 40 	u32 	height 	if flags[2] is set
    dd 32						; 44 	u32 	depth 	if flags[2] is set 

;//======================================================================
global loader
extern kernel_main

The last 4 params can be for text mode

Code: Select all

    dd 1 // 1== is text mode
    dd 80 // == width in chars
    dd 24 // == height in chars
    dd 0 // if mode "1" then this is "0"
Or for graphic mode

Code: Select all

    dd 0 // 0== is graphic mode
    dd 1024 // == width in PX
    dd 768 // == height in PX
    dd 32 // depth
If there will be something wrong, setting provided by user may be ignored