intermezzOS / kernel

A hobby operating system, in Rust
http://intermezzos.github.io/
Apache License 2.0
1.39k stars 90 forks source link

Text mode enhancements! #39

Closed WilsonGiese closed 8 years ago

WilsonGiese commented 8 years ago

Work in progress: Fixed scrolling a bit by allowing the scroll to happen if we're about to write to a position outside the buffer. Before it only scrolled on newlines. Also added a bit of code to update the cursors location!

As stated above this is a WIP, I was just messing around a bit but it works well enough! I just copied the outb asm function from the interrupts lib, so that's something that might need to change.

Let me know what you guys think!

steveklabnik commented 8 years ago

Interesting! :smile: :+1:

So, we also have an outb already: https://github.com/intermezzOS/kernel/blob/master/src/interrupts/src/lib.rs#L196-L199 This probably means that this is a good thing to extract to another crate...

WilsonGiese commented 8 years ago

So, we also have an outb already: https://github.com/intermezzOS/kernel/blob/master/src/interrupts/src/lib.rs#L196-L199 This probably means that this is a good thing to extract to another crate...

Yeah! I was going to do so, but I wasn't really sure where to put it or what to call it. Was thinking maybe common/src/lib or common/src/asm

steveklabnik commented 8 years ago

So, I pulled this down and tried it, but I'm not actually seeing the cursor. Hm.

steveklabnik commented 8 years ago

Yeah! I was going to do so, but I wasn't really sure where to put it or what to call it. Was thinking maybe common/src/lib or common/src/asm

I'm thinking it might just be its own crate entirely. But.... http://gz.github.io/rust-x86/x86/io/fn.outb.html :wink:

WilsonGiese commented 8 years ago

http://gz.github.io/rust-x86/x86/io/fn.outb.html

Oh, awesome! Looks good to me

WilsonGiese commented 8 years ago

So, I pulled this down and tried it, but I'm not actually seeing the cursor. Hm.

Hm... weird. I did this last night on os x, but i don't think that should matter. Now I'm trying to remember if I ever saw the cursor on my linux box. It used to just sit around the 3rd or 4th row and idle.

WilsonGiese commented 8 years ago

Okay, so this is interesting... The only reason I added the cursor code was because on my mac there would be this static blinking cursor that annoyed me, but I just hopped on my linux box and I don't see a cursor at all; not on master, nor for my branch. First thought is a qemu difference and they are on my machines (Linux is 2.2.0, os x is 2.4.0.1). Maybe a BIOS difference could cause the cursor to be disabled by default? I'll do a little digging.

WilsonGiese commented 8 years ago

Okie dokie! So apparently QEMU sets up VGA registers differently for different machines, or versions (I don't know). Anyway, after looking at this very helpful document VGA Regs I was able to write an initialize function that setup the Cursor Start/End Register so that the cursor will work on both of my machines.

Looks like the version on my mac had the cursor visibility flag set to true by default with the scanlines going from 0xE-0xF, and my linux box had the visibility flag set to false by default with the scanlines going from 0x0-0x0. I don't know much of anything about the VGA hardware (a little more now 👍 ), so there is probably more that should be done.

steveklabnik commented 8 years ago

Awesome. Works great here. :+1:

steveklabnik commented 8 years ago

Eventually, we can deduplicate outb and such, but for now, I'm not worrying about it too much. Thanks a ton for this :+1: