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.
For starters, your code is not taking care of various bit depths.
Also, what is the exact mode you are setting?
"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 ]
The VBE mode number for that mode is 280 (0x118), not 792. I'd guess you got that number from Linux - IIRC its mode numbers are <VESA mode number> + 0x200, which would give what you're using.
SamyPesse wrote:i want to use the mode : 792 (1024x728 and 24 bits per pixel)
Some video cards don't support 24 bits per pixel at all, some video cards don't support 1024*768 at all, and some do support "1024*768 * 24-bpp" but don't support VBE. AFAIK in all of these cases, GRUB will fail to set "1024*768 * 24-bpp" and will leave you in text mode.
If the video card does support "1024*768 * 24-bpp", there's no guarantee that the monitor will support it. In this case GRUB will set the video mode but the user won't be able to see anything on the screen after that (and some ancient "VGA only" video cards will blow up).
IMHO there's only 3 sane choices:
Use a video mode that every video card and monitor supports (e.g. 640 * 480 * 4 bits per pixel, or text mode)
Force the end-user to tell GRUB which video mode to use, so that they can use a video mode that their hardware actually does support. IMHO this idea isn't very user-friendly. For example, if you're using the "mode_type", "width", "height" and "depth" fields in the multi-boot header, then the end user needs to create a customized version of your kernel before using it (which is a pain in the neck for end-users). It also doesn't work in some situations (e.g. a live CD where the person who makes the CD doesn't know which computers it'll be booted on). It also means that the OS has to support every possible video mode (including strange/rare video modes), because it has no control over which video mode the user might select.
Switch back to real mode, then create a list of video modes that the video card and OS (and monitor?) do support, then choose a video mode from this list during boot. In this case GRUB's video support isn't used at all (and your OS doesn't require a special patched GRUB, which means people who are already using an unpatched GRUB to boot an existing OS can continue using the version of GRUB they've already installed to dual boot their existing OS and your OS). In this case, the OS could automatically choose any video mode, and could let the user set preferences (e.g. with a pretty menu system or with kernel parameters) where the OS searches the list of usable video modes and finds the video mode that most closely matches the requested resolution and colour depth (and refresh rate?). Unfortunately this is complex and GRUB just makes things worse. For example, you'd need to copy some code below 0x00100000 (as you can't run real mode code above 0x00100000), and you'd need to make sure you don't trash anything that could be the area below 0x00100000 (e.g. the multiboot information data structure).
Mostly, the video support in GRUB (or more correctly, the multi-boot specification) isn't adequate...
It does make me wonder how GRUB 2 will handle video though. Ideally, the multi-boot header should contain a complete description of which video modes the OS does/doesn't support (possibly including ranges - e.g. "this OS supports all video modes from 640 * 480 to 1600 * 1200, but not resolutions that are outside this range, and not any 4-bit per pixel video modes"); so that GRUB 2 can create a list of video modes that the video card and OS (and monitor?) do support and choose a video mode for the OS intelligently (including taking user preferences into account). In addition, the boot loader should display an error message if no suitable video mode is found, rather than using text mode as a fallback (so that an OS that requires graphics mode doesn't have to support text mode). Unfortunately, as far as I can tell GRUB 2 is intending to use the original multi-boot specification, so it won't be any better at mis-handling video...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.