Carnegie Mellon
SCS logo
Computer Science Department
home
syllabus
staff
schedule
lecture
projects
homeworks
QA
 
 

QA: Project 1


Q: What's this I hear about remap_intr needing to be called after, not before, we install our interrupt handlers?

A: Yes, you need to install your interrupt handlers before you remap interrupts to the new locations in the IDT. This is because the timer interrupt (and keyboard interrupt) are already enabled when you get into the kernel's main function (our support code supports the timer and keyboard until you take them over). If you remap the interrupts to go to new locations in the IDT before you install interrupt handlers in those new IDT locations, you'll get OSKit's default "unexpected interrupt" handler.

Q: What color should the background, foreground, etc. be?

A: As long as things are legible, you may pick any color combination you see fit.

Q: I'm confused as to how to send commands to the CRTC register.

A: The CRTC register takes the position of the cursor as a two-byte offset value from the start of the console. So, this two-byte value is NOT a memory location - it is simply an integer offset from the first possible cursor position on the screen. Because this value is two bytes, you must send it to the CRTC in two steps. First, send the command for the least significant byte of the cursor position to the CRTC index register, and then send the LSB to the data register. Then, repeat the process for the MSB.

Q: The process_scancode() function takes an integer and returns an integer. Shouldn't these be characters?

A: It's arguable whether or not scancodes are characters. The return value should be a character, however it does not break anything because it is an int. Simply casting the return value to a char is acceptable.

Q: Why do we have access to functions such as shift and caps lock? And why do some keys not produce the right characters on screen?

A: You do not need to use the shift or caps_lock function. The process_scancode function keeps track of the shift state internally. These functions were accidentally left in the header file. If you would like to observe the shift state simply because you are curious, then you may do so with these functions.

As far as the wierd characters coming out of process_scancodes, you do not need to worry about this. Process_scancodes is a very incomplete (and somewhat incorrect) scancode converter that only really deals with letters and numbers (and shift, backspace, enter, etc) properly. Many other characters do not produce the right output, and this is ok, you are not responsible for this.

Q: When I hold a key down, it needs to repeat after a while. How does that work?

A: When you press a key on the keyboard, it generates an interrupt and sends a scan code indicating the key was pressed. If you continue to hold the key down, the keyboard starts sending a stream of interrupts with scancodes indicating that key was pressed again (without any key release scancode). The process_scancode function will deal with this situation correctly - for every interrupt, just pass the corresponding scan code to the process_scancode function and check it's return value.

Q: What happens if the console memory gets cached?

A: The support code that initializes the machine takes care of disabling caching in that region of memory.

Q: When I hold down a key, my clock goes really slow. Is this ok?

A: The important thing is that your clock stays live. The simulator runs fairly slowly and will not keep up with wall clock time, especially if you hold a key down. However, the clock should still advance, eventually.

Q: The sscanf function does not appear to give me the correct return value!

A: The sscanf function provided by OSKit is broken. Rather than returning the number of arguments successfully parsed, it returns the number of arguments you attempted to parse. You will have to write your own code to check the format of the line submitted. Sscanf still parses things correctly, it just always returns the number of arguments you attempted to parse.

Q: What should happen if I enter 99 99 99?

A: This is up to you. Our solution code ignores lines where the seconds or minutes are 60 or greater, or the hours are 24 or greater (and also when any value is negative). If someone enters 1 1 61, you could parse that into 1 2 1, for example. Our solution ignores such lines.

Q: Does the CRTC cursor command take a memory address or an offset?

A: When submitting the position of the cursor to the CRTC, you submit the offset of the cursor from the first possible cursor position (the upper left hand corner), NOT a memory address. This value is a two byte value. You send the least significant byte (LSB) and the most significant byte (MSB) with two separate commands to the CRTC.

Q: How do I include the Assembly files into my project?

A: You will need to create an object file for each assembly file, this can be done as follows (in your Makefile):

%.o: %.S
$(CC) -c -o $(*F).o $(OSKIT_FLAGS) -I. -I./inc -I$(OSKIT_INC) \
$(CFLAGS) $(*F).S

You must also list these .o files when linking together the final kernel. For more information on Makefiles and gmake go here.


Last modified: Thu Jan 23 16:32:18 EST 2003