2. What to Do?

Write in C language several functions that use the PC's keyboard low level interface. The key functionality to implement is:

  1. Read and display the scancodes, both the make codes and the break codes, generated by the PC's keyboard via interrupts;
  2. Read and display the scancodes, both the make codes and the break codes, generated by the PC's keyboard via polling;

Furthermore, we want you to learn:

  1. How to mix C-code with assembly code
  2. How to handle interrupts from more than one I/O device

Unlike in previous labs you are not given the prototypes of the functions to implement: the specification of these functions is part of your job. However, to make the task of grading your assignment feasible, you are required to implement the following test functions:

  1. int kbd_test_scan(unsigned short asm)
  2. int kbd_test_poll()
  3. int kbd_test_timed_scan(unsigned short n)

These functions are declared in header file test3.h, and source file test3.c contains their implementation stubs. You may find it convenient to add your test code to that file; this way you will avoid mistakes in their definition. Section 5 describes what these functions should do.

2.1 Class Preparation

This lab is planned for two lab classes.

First class

The goal for the first class is to implement:

  1. int kbd_test_scan(), with the IH written in C
  2. int kbd_test_poll()

Therefore, for the first class you should read the material presented in the lectures about the PC's keyboard and this handout, except Sections 4.3, 4.4 and 5.3, which are for the second class.

Furthermore, you should:

  1. Create a folder named lab3 at the top level of your SVN repository
  2. Create a file named lab3.c with the main() function that allows to test your code in a flexible way without having to compile it. You should also add this file, and the test files provided to your SVN repository. (IMP: Doing this before the beginning of your first class is worth 5% of the grade of this lab.)

You may wish to read the information provided in Section 8 about some SVN commands that may be useful to perform these actions.

Second class

The goal for the second class is to implement:

  1. int kbd_test_scan(), with the IH written in assembly
  2. int kbd_test_timed_scan(unsigned short n)

Therefore, for the second class you should read also Sections 4.3, 4.4 and 5.3 of this handout, and the material presented in the lecture about assembly programming. Furthermore you should also refresh your knowledge of IA32 assembly programming.