Page 1 of 1
Gotta rewrite my kernel: Some questions
Posted: Sat Jan 15, 2011 7:00 pm
by casnix
So, today, my 14 year old laptop did that "suspended mode crashes," leaving me with a blank disk. Pfft. Kernel-gone. Boot Script-gone. VFS-gone. Thus the wisdom in backups.
So instead of moping around about losing all that work, I'm going to consider it
an "easy purge" of badly written code. I'm talking about the Unix kernel for Casnix OS 3.
I'm approaching the kernel differently, so I'm gonna have some questions, such as:
I need to set the VGA text mode to 80x50, with the 8x8 font. I can do this in the boot loader,
Code: Select all
mov ax, 0x1112
xor bl, bl
int 0x10
but I'm depending on GRUB to boot, so I can't do this.
Can someone post (or point me to) some code at kernel level that will allow me to switch modes? I know of modes.c, but I was hoping that there is an easier way (like with assembly instead of C).
Thank you.
Re: Gotta rewrite my kernel: Some questions
Posted: Sat Jan 15, 2011 7:08 pm
by NickJohnson
I believe you can ask GRUB to switch video modes in the config file (although this may require a patch). However, I don't think there is a text mode beyond the standard 80x24, because it would require super-VGA resolution. You may have to render the fonts yourself even if you get GRUB to set the proper mode. As far as switching modes in the kernel, you'd need to write a VGA driver (see the wiki), but you can't get more than 320x240 (or 640x480 with 4 bit color).
Re: Gotta rewrite my kernel: Some questions
Posted: Sat Jan 15, 2011 7:21 pm
by casnix
There are two text modes beyond 80x24, one is bios supported (kind of a hack, if you will), and the other 90x60 is something you have to code a driver for. When a PC boots regularly in the midsized text its in eighty by twenty four. I booted Casnix OS/II with 80x50, butthat was in real mode. It took some searching (but both text modes are slightly documented on the wiki). But otherwise, 24 is not enough space to scroll to my tastes...
How do you set the video mode in grub? What is the configjration file? Unless you mean menu.lst (grub.cfg in GRUB 2)
Re: Gotta rewrite my kernel: Some questions
Posted: Sat Jan 15, 2011 7:48 pm
by casnix
okay....how about this...
I can easily write a multi stage bootloader so i can do this stuff as i need it (i actually a lot of tutorials and wrote one in my notebook today). But because my kernel consists of mostly C, i need to add elf compatibility, so that it can actually boot it. Any tutorials?
Re: Gotta rewrite my kernel: Some questions
Posted: Sun Jan 16, 2011 11:56 am
by Tosi
Using available VGA documentation and a standard text mode font, I was able to write code to switch between multiple text modes without using the BIOS.
It was all written entirely in C, and runs entirely in protected mode.
This was the most useful reference. The wiki also has a list of sample register settings for different video modes. It's actually really easy to do, it's just tedious and it took me some hours of reading the documentation to figure out what was going on.
Re: Gotta rewrite my kernel: Some questions
Posted: Sun Jan 16, 2011 1:40 pm
by Combuster
casnix wrote:But because my kernel consists of mostly C, i need to add elf compatibility, so that it can actually boot it. Any tutorials?
Just to get it over with:
http://wiki.osdev.org/Beginner_Mistakes ... orial_on_X - There is no such thing as a free lunch - OS development is hard work and you need to spend quite some time on it to get somewhere.
Back to the original question: VGA text mode is 80x2
5, not 24. There's a FAQ entry on how to change video modes - there's the way discussed, but if you are just after getting things to work with the least effort (which does yield the technically most ugly solution) you might just as well temporarily drop back to real mode and call the bios for whatever you want. If you do that directly after GRUB, you haven't messed up the system beyond that to work, nor do you need to depend on specific versions of GRUB and the corresponding configurations.
But I'm paraphrasing a
FAQ entry, and so did Tosi and NickJohnson, so I'm just going to end with what Berkus, yours truly and probably quite a few more are probably thinking:
learn to STFW.
Re: Gotta rewrite my kernel: Some questions
Posted: Sun Jan 16, 2011 5:56 pm
by bewing
You can beta test my bootloader if you like. It's small and trivial to customize. It's much much nicer than either version of GRUB. Let me know if you'd like to give it a shot.