Keyboard: Problem with the (re)programmed Interrupt handler
Posted: Sun Feb 19, 2006 7:58 am
Hi all
I recently started on this project of devving a nice personal tool kit that would boot off from a CD, and instead went to OS Development.
I have worked hard for 2 weeks or so, and got the bootsector working. Successful linking of assembler code to start my kernel.
Loading sectors properly.
Reaching the PMode.
Loaded the GDT, IDT ... no LDT so far.
Now, I left assembly and started coding in C.
Now, the problematic part.
I got my keyboard interrupt written. It *works*. The function runs whenever I hit a key. Thats fine.
But, how do I *wait* for a key to be pressed? i.e. to program the getch() function?
I did:
(Pseudo code)
Buffer [0 ... 0xFF] //Software buffer
While the buffer position of the software buffer isnt zero, run an infinite loop:
while(buffer_pos == 0);
buffer_pos is zero initially.
But, now, if i hit a key, it doenst even respond. I have found that it gets stuck at this while loop.
And, the buffer_pos is *volatile* data type. So, no optimizations are done.
So, how do i solve this problem?
My question is: If the CPU is interrupted (IRQ1, Keyboard), does it stop executing *whatever* it is executing? i.e.: even an infinite looP?
Thanks!
PS:
I am using VMWare for testing.
Floppy image / an El-Torito bootable CD is used.
I recently started on this project of devving a nice personal tool kit that would boot off from a CD, and instead went to OS Development.
I have worked hard for 2 weeks or so, and got the bootsector working. Successful linking of assembler code to start my kernel.
Loading sectors properly.
Reaching the PMode.
Loaded the GDT, IDT ... no LDT so far.
Now, I left assembly and started coding in C.
Now, the problematic part.
I got my keyboard interrupt written. It *works*. The function runs whenever I hit a key. Thats fine.
But, how do I *wait* for a key to be pressed? i.e. to program the getch() function?
I did:
(Pseudo code)
Buffer [0 ... 0xFF] //Software buffer
While the buffer position of the software buffer isnt zero, run an infinite loop:
while(buffer_pos == 0);
buffer_pos is zero initially.
But, now, if i hit a key, it doenst even respond. I have found that it gets stuck at this while loop.
And, the buffer_pos is *volatile* data type. So, no optimizations are done.
So, how do i solve this problem?
My question is: If the CPU is interrupted (IRQ1, Keyboard), does it stop executing *whatever* it is executing? i.e.: even an infinite looP?
Thanks!
PS:
I am using VMWare for testing.
Floppy image / an El-Torito bootable CD is used.