intermezzOS / kernel

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

Major refactor. #64

Closed steveklabnik closed 7 years ago

steveklabnik commented 7 years ago

Because I wanted to Get :poop: Done, I wasn't too concerned about the quality of the code. And I always thought "I can just refactor it later." But, as it turns out, the more junk you throw on a pile, the harder it is to fix.

Specifically, the issue is global mutable state. By trying to port over the way that C did it, all of the crates were having their own, global singleton instance, and they all relied on each other's internals to make it work. I think we can do better.

As such, this commit removes a bunch of stuff. Namely:

  1. keyboards
  2. interrupts
  3. the pic crate

And changes what's there a bit. For starters, vga's kprintln is now in the kernel itself.

We also have a new KernelContext struct. This will hold all of the state for the kernel, and our first bit of state is the vga driver. Instead of a single, global kernel lock, we'll choose a lock for each bit of relevant state.

We can even keep it entirely on the stack of kmain, rather than having it available globally. The only thing that might not work for that is the panic handler; I'm not sure what to do there. I might just have to suck it up and make one single global reference and only use it for that.

slayerjain commented 7 years ago

This is very interesting! 💃

steveklabnik commented 7 years ago

Gonna :shipit:

This code will live in the git history, we'll get it back in at some point :)

WilsonGiese commented 7 years ago

Oo fun! New code to read