|Bona Fide OS Development
|Page 1 of 1|
|Author:||losethos [ Sat Jan 08, 2011 12:06 am ]|
http://www.osdev.org is confused by my keyboard code.
Let's worry about the end-user API.
when a KEY_DOWN message is sent, it's two parameters are ASCII code and scan code. In LoseThos, parameters are 64-bits (8-bytes).
The ASCII is just one byte and is pretty normal, except SHIFT-SPACE is 31.
Bits 0-6 are scan code like eveyone else has.
Bit 7 is set if it had an E0 Scan code prefix.
Therefore the lowest byte makes a scan code value that works for NONASCII keys like cursor key. They would normally be preceded by an E0 byte, but the driver absorbs that and sets bit 7.
Bits 8-19 are flags for CTRL ALT NUM SHIFT, ect.
You can check for CTRL-CURSOR_LEFT for example
if (p2&SCF_CTRL && p2.u8==SCF_CURSOR_DOWN)
In losethos, every 64-bit integer value can be accessessed as an array of 8 bytes or a single 64-bit value.
Since we're not using bits 32-63, I decided to get fancy. Sometimes, you want to distinguish between left and right shift keys or left and right CTRL. most times you don't. What I did was to offer a choice of using distinct values in 32-63 or merged values in 0-31.
Merging left and right SHIFT keys means that LEFT is returned whether it's left or right.
As an added bonus, there is a bit array with the current state of scan code key values, not ascii. You can test a bit for each key at any time without affecting messages.
Silly people -- you need to support both polling and nonpolling. In your debugger (you have written a debugger, right) you don't want interrupts happening because your system might not be stable and you don't want to change values all over the place. You certainly wouldn't want to work with messaging in a debugger.
The reason LoseThos has lots of users and your operating systems don't is because LoseThos is compatible. If my mouse interrupt is not working, it falls-back on polling.
You have been brainwashed on the negatives of polling -- checking the keyboard or mouse every milisecond... there are 2 million clock cycles per millisecond. Actually, port IO takes a microsecond, so it's a thousanth of your processing power.
If you are not doing some things different from everybody else your design has no purpose. My message does have two values like Windows but I have only 63 possible messages so you can combine bits together into masks to indicate which messages you are interested in.
|Author:||losethos [ Sat Jan 08, 2011 9:49 pm ]|
|Post subject:||Re: keyboard|
When I began my kernel, I wanted the ultimate in performance--just kernel mode and no paging or virtual memory. Don't argue--you know damn well that's the ultimate in perfomrnace.
I wanted a supercomputer and was not interrested in laptops. I did not use the HLT instruction because I assumed it had a large penalty, so I just looped to idled. I did this for all cores.
Low latency is critical for small-scale parallelism and avoiding the HLT did win me lower latency on parallel jobs. I caved-into pressure, though, and started using HLT. If you want low latency, you can spawn a task on other cores and loop-not-asleep, yourself.
Web archive from 2004 telling why I made LoseThos.
|Page 1 of 1||All times are UTC - 6 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group