2. What to Do

Write in the C programming language several functions that use the PS/2's mouse low level interface. The key functionality to implement is:

  1. Read and display the packets sent by the PS/2's mouse
  2. To display the configuration of the mouse
  3. To use the PS/2 mouse in remote mode
  4. Recognize a simple "mouse gesture" using a state machine

With respect to the first task, the communication between the keyboard controller (KBC) interrupt handler and the part of your program that displays the packets should use a simple array whose elements are of type unsigned char and a counter variable of type unsigned short that keeps track of the bytes received.

Like in Lab 3 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 testing functions:

  1. int mouse_test_packet()
  2. int mouse_test_async()
  3. int mouse_test_remote()
  4. int mouse_test_gesture()

These functions are declared in header file test4.h, and file test4.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.

IMP. In addition to these files, you should submit the file lab4.c, which should be similar to lab2.c, and will be used to grade the flexibility of your test code. Nevertheless, we will use our own main() function to test your code, therefore you must ensure that your implementation is consistent with the function declarations in test4.h.

2.1 Class Preparation

So that you can accomplish this lab's objectives, you should do some homework, i.e. some work before the lab class. In addition to read, and understand, this handout and the class notes, you should:

  1. Create directory/folder lab4 at the top level of your SVN repository, and add all files for this lab, under this folder
  2. Create a file named lab4.c with the main() function that allows to invoke the test functions mentioned above in a flexible way, i.e. without having to recompile 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.)
  3. Write mouse_test_packet()
  4. Write mouse_test_remote()

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