Systems Programming Project: Interrupt Questions (etc..)
Posted: Sat Feb 17, 2007 12:25 am
First of all, this looks like it has the potential to be a great resource!
Anyway, I am a third year computer science student and Rochester Institute of Technology. Currently I am taking a systems programming class along with a general operating systems class.
For the systems programming class my last project is quite challenging. We are required to write a simply program that prints a sentence to the screen, and tests the user for accuracy and speed based on 3 attempts at typing the sentence. Well, the hard part is the fact that we have to implement this on an x86 system WITHOUT AND O.S.! We are compiling the program onto bootable files (based on my professors standalone framework). For more details, the project page is here if you're interested:
http://www.cs.rit.edu/~wrc/courses/sp1/projects/3/
Now, on to my questions.
We are required to communicate with a serial device (connected to a simple terminal with screen and keyboard) using interrupt driven IO. We must implement this ourselves as there is no operating system running. For the most part I understand how this works, and basically have most of it already coded.
(assuming intel x86 based system)
1) What are the PROPER, required procedures when handling:
a. serial interrupts
b. keyboard interrupts
c. timer interrupts
2) With the timer interrupt, how does this work if I want to increment an integer once every second? I believe the timer interrupt ticks a defined number of times per second, in one of my professors included files is the definition:
As an example of what I am doing, here is my in progress keyboard interrupt service routine. Even though I have done assembly (some assembly is in my project), this is my first time working with low level hardware in this manner.
Thanks for reading the long post and contributing (anything) if possible,
Tom
P.S. Upon request I will supply some source code I am working with.[/url]
Anyway, I am a third year computer science student and Rochester Institute of Technology. Currently I am taking a systems programming class along with a general operating systems class.
For the systems programming class my last project is quite challenging. We are required to write a simply program that prints a sentence to the screen, and tests the user for accuracy and speed based on 3 attempts at typing the sentence. Well, the hard part is the fact that we have to implement this on an x86 system WITHOUT AND O.S.! We are compiling the program onto bootable files (based on my professors standalone framework). For more details, the project page is here if you're interested:
http://www.cs.rit.edu/~wrc/courses/sp1/projects/3/
Now, on to my questions.
We are required to communicate with a serial device (connected to a simple terminal with screen and keyboard) using interrupt driven IO. We must implement this ourselves as there is no operating system running. For the most part I understand how this works, and basically have most of it already coded.
(assuming intel x86 based system)
1) What are the PROPER, required procedures when handling:
a. serial interrupts
b. keyboard interrupts
c. timer interrupts
2) With the timer interrupt, how does this work if I want to increment an integer once every second? I believe the timer interrupt ticks a defined number of times per second, in one of my professors included files is the definition:
Code: Select all
#define TIMER_TICKS_PER_SECOND 18
Code: Select all
void keyboard_isr(int vector, int code) {
char newch;
int ctrl_m = 0xff;
int k_code = inportb( KEYBOARD_DATA ); /* get code */
k_code &= 0xff;
switch( k_code ) {
case 0x2a: /* make shift */
case 0x36:
shift = 1;
break;
case 0xaa: /* break shift */
case 0xb6:
shift = 0;
break;
case 0x1c: /* enter key */
if(!READY) READY = 1;
break;
case 0x1d: /* handle ctrl mask */
ctrl_m = 0x1f;
break
case 0x9d:
ctrl_m = 0xff;
break;
default:
if (k_code & 0x80) {
/* ignore break code */
} else {
/* get char */
newch = scan_code[ shift ][ (int)k_code ];
if(newch != '\377') {
/* TODO: process characters */
}
}
break;
} /* switch */
outportb(0x20,0x20); /* acknowledge irq */
}
Thanks for reading the long post and contributing (anything) if possible,
Tom
P.S. Upon request I will supply some source code I am working with.[/url]