Bona Fide OS Developer
View unanswered posts | View active topics It is currently Sat Feb 24, 2018 6:53 pm

Post new topic Reply to topic  [ 2 posts ] 
Author Message

Joined: Fri Aug 20, 2010 10:04 pm
Posts: 41
Post keyboard 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

U64 p1,p2;

if (p2&SCF_CTRL && p2.u8[0]==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.

Sat Jan 08, 2011 12:06 am

Joined: Fri Aug 20, 2010 10:04 pm
Posts: 41
Post 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.

Last edited by losethos on Sun Jan 09, 2011 12:14 am, edited 1 time in total.

Sat Jan 08, 2011 9:49 pm
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin and tweaked by the BF Team.