Currently once the system boots, all we do is to sit in the chair and watch it. It's time to add some interaction.
How does the OS know it when a key is pressed?
It's easy: the keyboard generates an interrupt to let the OS know.
We will enable the keyboard interrupt, write a handler and read the code of the key(s) from the keyboard.
See a/
and b/
.
Now we have the codes of keys pressed.
We use a process to manipulate them (see c/
) so that
we can recognize letters and numbers (see d/
), Shift, Alt and Ctrl (see e/
) and even
Pause and PrintScreen (see f/
).
Then we can decide how to deal with these key presses, probably display something in the screen (see g/
):
The screen is small. It won't be long before you type too many letters in it, so we should support screen scroll.
We want to see where we are when typing, so we should be able to move the cursor (the cursor hasn't moved for long).
All of these can be easily done by writing some I/O ports.
We'll try to write some ports in h/
.
When using Linux, we know we can swtich TTYs by pressing Alt+Fx, where x is 1, 2, ...
We will simulate this in our OS (see i/
and j/
):
Everything is good.
It's time to polish our code to support screen scroll (see k/
), Enter and Backspace (see l/
), CapsLock, NumLock and ScrLock (see m/
).
So far we have two types of processes: a system process TTY and three user processes A, B and C.
As was mentioned in Step 06, we want them to run in different privilege levels.
See n/
for details.
We use printf()
a lot.
Now that we have our own OS, we should implement one.
See o/
for details.