Hello and welcome.
And in this election year, we're going to further implement the keyboard, we're going to receive keyboard
interests from the two keyboard driver, and we are then going to use the keyboard push function to
push the keys that will press to the keyboard buffa of the running process.
Once this is implemented correctly, it should be pretty simple for us to type keys on the keyboard
and they will be pushed into the process as keyboard buffa ready for that process, his task to pop
them.
OK, so yes, let's begin go to classic stage and we're just going to go define classic keyboard key
released zero eight.
Now this is a bit massive, OK?
The scan code also has a bit mask applied to it.
So let us know certain things, such as if the key was released or not and we need to take that into
account.
So now we go define Finisar keyboard interrupt and that is zero twenty one.
OK, back to Classic Tazi and we'll begin implementing our keyboard interop Tandler.
OK, so this classic keyboard handle function will be called from our internal handler.
We haven't created that yet, but let's just stop filling in this function and we'll do that a bit later.
So the very first thing we need to do is switch to the kernel page.
So just include kernel that at the top here, guys.
OK, we're also going to want to include it, the Hajj as well, guys.
OK, scroll back down.
We see Colonel Page now works fine.
We're going to go unit eighty.
Scan code equals zero.
Scan code equals Ehnes be keyboard input port and we haven't defined that yet.
Will define that shortly.
And we can also end up with a rogue IQ also sent to us.
So we should just ignore that one.
OK, so we ignore that one by just reading from the keyboard part once again.
Sometimes it sends other information that we don't really care about so much.
So this one reads the scan code.
This one ignores the rogue byte sent to us after that.
OK, go back, go back to classic Hajj and we're just going to go hashtag define keyboard input part
060.
OK, now these are parts we can read from on the bus, OK.
And 060 is responsible for letting us know which keys were pressed.
OK, now if I just go to Firefox, I can show you this a little better.
So I'm just going to go across 60 parts, OK?
OK, so it's this article here.
We were already on it signing a search for Zywiec 16 here, so you can see the power to control itself,
uses iReports CEREC 16 06, six for.
OK, so that's why we're reading from zero to 60, because that's the data part.
OK, that's why we're doing that.
So this part is where those keys to oppressed are sent to us.
And so we need to read from that part on the bus.
OK, so brilliant.
At this point, online 57, we have the scan code that was pressed on the keyboard.
Perfect.
We now to convert that to a character.
Well, we made that function here a few lectures ago.
Classic keyboard scan code to.
OK, so the first thing we need to do is check if the key was released.
So how do we do that is we say if scanned code ampersand, classic keyboard key released.
OK, so if this bit is set in the scanned code, then the key was released.
OK, and if the key was released, we're just going to return because we don't want to handle any key
releases at this point in time.
We don't care if they release the key or not.
We only care if they press the key.
OK, we can worry about key releases another time.
But anyway, so yeah, we return if that bit is set.
OK, brilliant.
So now here we're going to go unit 80 C equals classic keyboard scan code to CHA and we're going to
pass in the scan code here.
OK, and if the C does not equal zero, then we have a character in the Bufford and if the character
is not equal to zero, then we have a valid scan code that that that is being converted to an ASCII
character.
OK, and we can push that to the keyboard.
So we go keyboard push, see, OK, like that.
And that will push the character to the keyboard buffer of the current process.
OK, we now need to switch back to the task page and that is it for the classic keyboard handle interrupt.
So if we scroll down now, it's a classic keyboard in it.
Uh, scroll up.
I mean by here we now need to register the callback, so we're just going to go ADT register in callback
and we're going to use the ISO keyboard and SREP, which is Xerox twenty one and we're going to have
the function, the classic keyboard handle interrupts.
OK, and if we scroll down to that classic keyboard handle and just copy and paste this prototype,
OK, just copy and paste it above there so it can resolve it.
And you can see a little spelling mistake here, but a second s here.
OK, and scroll down.
Because we also made the mistake with this function here, so just correct that it should say classic
guys like classic.
Like that, OK, classic keyboard handle interrupt.
OK, perfect.
So now that we have registered that intro, Tangela, we should now be able to handle keyboard key presses,
OK, when we press a key on the keyboard, that should cause the interruption to be to be invoked 621,
which will lead to our classic keyboard handle interop function being run, we should then be able to
extract the schang code.
And if the key was was not released, i.e. they pressed it, it wasn't just a release.
We don't care for release events basically.
OK, so if it was only press then it will convert the Chanko to a char and then push that to the buffer.
Let's see if this works then.
OK, so we're going to go make clean build that S.H..
And we can see implicit declaration of TASC Page, that's no big deal, scroll up, we're going to need
to include tests Hajj.
OK, just like that.
We try that now.
We can see that compiles absolutely fine, and if we just run that for a second.
Yeah, we can see that that is working all OK, so we're about to debug this now and check if the key
press is handled correctly.
But before we do that, go to Canada.
Let's see, because we're going to remove that time in time.
Call back we made so you can see here, we said it registered your callback 620 time, but just get
rid of that, OK?
And scroll up.
And you will also notice I passed an interim frame here.
This was an unfortunate mistake.
If we go to I see that you can see that the prototype takes no arguments for callbacks, OK?
Nevertheless, we passed a function with an interim frame and obviously it's not passing as an interim
frame.
So this is an initialized point one one.
The interim calls pick a time a callback.
OK, so what it should have been is that OK?
Just to let you know that it's no big deal because it was just for testing purposes.
But yeah, minor mistake that that's all.
Just delete this function because we don't need that anymore because we've removed the the actual callback,
the registration of the callback, we've removed that.
So just go to that function.
OK, now we have a nice blank slate to work with.
Let's just build again and then we will go to GDB.
So now we're just going to go CDB and GDB, add Simbo file build kind of 4.0 06 one one, two, three,
four, five.
And we're just going to scroll up to Classic Tazi and we're going to put a breakpoint on classic keyboard
handle interrupts to just go break.
Classic keyboard handle interrupt and we're going to now stop the emulator.
And I would just kind see to continue and we can see here there was a little bug launch in the emulator
since the program started running.
So just close the emulator if that happened to you, and just run that command again.
And that we are we can see that works.
OK, now.
So now just pressie to continue.
OK, press any key whilst you're on kumu and there we go.
I pressed a and you can see the classic keyboard handles interrupt routine was called if I just go next
next next next.
If I print the scan code here.
And we can see we lost our way here, that's because in speeches, an assembly instruction and because
it doesn't have line information, it's caused our emulator here debugger, I should say, to make a
little mistake here.
So we're going to have to go layaways and just just go step by step by step by step by step by until
we're back and now we're back.
We can go layo prev like that, which will take us back to the CAVU.
OK, so we're going to go next and we scan code now we can see that's 30.
OK, because I pressed a it might be something different for you.
OK, now I'm going to go break source keyboard classic dot c line sixty nine.
I see.
And I go next, I have to go princi and what do we see, we see a.
So the colonel completely knows that I pressed the character a so well done.
You've now actually created your very first keyboard driver and we can see if we go next.
That pushes the character was press to our processes keyboard.
So we step into that next, next, next we can see the processes there.
OK, perfect.
And if we now go next, next we can see that the keyboard buffer now contains a do print process.
We can see two ways because we printed one in kernel that C which I forgot to remove a good candidate
c c the key will push the example.
We did get rid of it.
OK, we don't want that because that's pushing characters that were never pressed to the keyboard before.
Emulating a key press.
I suppose so.
Yeah.
We can see the buffer contains two ways.
Well because the kernel that c we push there and also because they pressed A on the keyboard.
So that's really, really good guys.
Well done.
And if we now go C to continue again, go back to commute press, any other key will go for Z.
I'm going to go for Z and I'll press C to continue.
I'm going to go next princi and what we see there Z was press.
OK, so congratulations.
You've just implemented the keyboard.
Now how do we get the user process to interact with the keyboard.
OK, well this is fairly simple.
All right.
We create a kernel command for popping from the keyboard, OK?
And then in a user program we'll have a while loop where it's constantly popping from the keyboard.
And if it's not zero, then a key was pressed.
If a key was pressed, it can output it to the terminal for us.
So in the next few lectures, we'll be creating the ability to push to push characters to the terminal
and also popping from the keyboard, OK, which will allow people to enter text.
So thanks so much for watching this lecture.
You now have the keyboard drive implemented.
Granted, it doesn't support caps lock or anything like that.
Everything you type will be in uppercase.
We can worry about implementing case sensitivity later on and listening to the caps lock and so on.
These things can come later.
Let's just get it so you can actually type something on the terminal first.
So thanks so much for watching.