Page 1 of 1

GCC and simple VGA graphics?

Posted: Sat Sep 21, 2013 7:47 pm
by xlar54
Hey folks,

Im working on a kernal that needs some simple VGA routines (setpixel, etc). Are there some examples out there that I can look at? Right now, I have the following. It compiles, but in Qemu, it just reboots back to GRUB:

Code: Select all

	
        asm("mov %ax, 0x13");
	asm("int $0x10");
	
	unsigned char* p = (unsigned char*)0xa0000;
	for(zz=0; zz=100; zz++)
		p[zz]=1;
From what Ive read, I should be seeing a blue line. Do we have any very simple graphics routines out there, or can someone tell me what Im doing wrong? I dont think Im using protected mode. (Im using this tutorial: http://wiki.osdev.org/Bare_bones). Im wanting just a simple 320 x 200 8bit screen.

Re: GCC and simple VGA graphics?

Posted: Sat Sep 21, 2013 9:50 pm
by neon
Hello,

GrUB executes the image in protected mode thus BIOS services cannot be used without resulting in triple fault. To rectify, do one of the following:

General options
1. Real mode. Not recommended; provided for completeness only.
2. Use v8086 mode. Requires user mode task switching.
3. VGA video driver. Complicated but does not require a specific processor mode.

Specific to multi-boot compliant boot loaders
4. Set the requested video mode width, height, and bit depth in the multi-boot information header and set the bit 2 of the flags field set. This will tell the loader to set the video mode for you.

Note that most loaders use Vesa Bios Extensions (VBE) and thus may also support high resolution modes supported through VBE. VBE and VGA Bios services can also be used directly by methods (1) and (2) above.

We recommend options (2) and (3) over the others though for maximum compatibility. Option (4) would be a good idea for something quick though for you to test with.

Re: GCC and simple VGA graphics?

Posted: Sun Sep 22, 2013 4:57 am
by sortie
You are in 32-bit protected mode after being booted by GRUB using multiboot. You cannot call the BIOS directly.