dthain / basekernel

A simple OS kernel for research, teaching, and fun.
GNU General Public License v2.0
781 stars 109 forks source link

Switch video modes from inside kernel? #54

Open xlar54 opened 6 years ago

xlar54 commented 6 years ago

I see work being done on querying the video mode before the kernel boots up. Could it be done such that switching video modes is possible from within the kernel? The only example of such code Ive seen using VESA is using a virtual x86 mode thread and making the switch, but I dont know enough about VESA to be certain.

btw, thanks for your efforts. Im seriously considering switching my project to use your core, but I really need a VESA method to switch from 320x640x256, 640x480, and text 25x80. (Mine just uses a VGA driver)

https://github.com/xlar54/emudore64

(Edit: I also have the beginnings of a FAT32 filesystem that may be useful to this project, unless filesystems are outside the scope and intent)

dthain commented 6 years ago

Looks like you are having fun with Emudore! I have good memories of assembly hacking on the C64...

Unfortunately, I am not an expert on VESA mode switching. What I do know is that it is relatively easy to probe and switch VESA modes before entering protected mode by making BIOS calls. For Baserkernel, my intent was to just pick a mode at boot time and then treat it as a static framebuffer from then on.

It is possible to switch modes at runtime, but what you have to do is ask the BIOS for the protected mode entry point at boot time. Then, from the kernel, there is a clunky mode of invoking the entry point at runtime. We don't have any code for that, but it is described in the VESA document:

https://github.com/dthain/basekernel/blob/master/doc/vesa-bios.pdf

Another complication is that modern PCs don't necessarily implement fixed standard VESA modes. (Our code would be better if it enumerated the available modes before selecting one.)

A FAT filesystem would be interesting. We currently have an ISO9660 filesystem and are still sorting out some of the higher level abstractions. Send us a pull request and I can try to point you in the right direction..

xlar54 commented 6 years ago

Yeah, im starting to think trying to switch bears no real benefit when i can just use a set VESA mode and scale up the 64's screen. Thank you though for the info.

Once I get your code plugged in, Ill try adding my FAT32 code and send you a pull request. Its not complete, but right now at least you can read files and directories. Writing is next. Expect ugly code though - you guys have been doing this longer than I have for certain. I take no offense to criticism if it helps your end project goal. :)

kevinwern commented 6 years ago

@xlar54, how is the FAT32 filesystem going with basekernel? Do you need any help from us? It'd be really cool to support!

xlar54 commented 6 years ago

ive been away a few days but will be jumping back in soon. will keep you posted!