Issue with my Interrupt Handler.
Posted: Mon May 14, 2007 8:02 am
I must prefix by saying, that I do not have code on hand to paste, but the under-pinnings of OS is based on the Bran Kernel Tutorial.
Basically, I have a keyboard isr, and it works... it fires fine and outputs to the screen whatever letter I typed, so I know its not an issue with the ISR or PIC or anything of the like. I wanted to extended the basic functionality that Bran kernel gave, so I added support for Uppercase letters, and Shift/Caps Lock support. Again that works fine. I wanted to make the keyboard a requestable device, now when a key is pressed it calles a function pointer to a user-definable keyboard handler. So I further tested it by assigning a "test" function that recieves the key code as a parameter and then prints it out on the screen... that works.
Now heres, the problem, I am trying to implement a "getch" function, and instead of doing a hard loop poling the keyboard port, I do something along the line of this (granted this is pseudo code, but the pricipal is the same)
Now, I know it mainly working because, when I press a key I get the Message "Event Handler Called.", but It never breaks the loop. I don't know for certain, but I am assuming that its because something funny is happening to my stack in the middle of the ISR, and I am not sure why. I only have 1 kernel stack, and I do not have task switching or even paging enabled yet. Here is the link to the code for Brans Kernel, the ISR code is unmodified: http://osdever.net/bkerndev/Docs/whatsleft.htm
Thanks,
Rich
Basically, I have a keyboard isr, and it works... it fires fine and outputs to the screen whatever letter I typed, so I know its not an issue with the ISR or PIC or anything of the like. I wanted to extended the basic functionality that Bran kernel gave, so I added support for Uppercase letters, and Shift/Caps Lock support. Again that works fine. I wanted to make the keyboard a requestable device, now when a key is pressed it calles a function pointer to a user-definable keyboard handler. So I further tested it by assigning a "test" function that recieves the key code as a parameter and then prints it out on the screen... that works.
Now heres, the problem, I am trying to implement a "getch" function, and instead of doing a hard loop poling the keyboard port, I do something along the line of this (granted this is pseudo code, but the pricipal is the same)
Code: Select all
int keyEvent;
void keyhandler(int pKey)
{
kprintf("Event Handler Called.\n");
AddKeyToBuffer(pKey);
keyEvent = 1;
}
int getch()
{
int key;
SetKeyHandler(&keyhandler);
keyEvent = 0;
do {
//nothing
} while (keyEvent == 0);
key = GetKeyFromBuffer();
ClearKeyHandler();
}
Thanks,
Rich