LAB3: Timer and KBD drivers
                         DUE: 9/14/2023

INTerrupts Programming requirements:

1. device must be allowed to generate interrupts:
   (Control reg enable interrupts)
2. for timer: VIC must route device IRQ 4
   for KBD  : SIC must route IRQ3, and VIC must route IRQ31
3. CPU must accept IRQ (I bit in cpsr=0 to mask-in IRQ)

------------ when IRQ occurs: -------------------------------
4. Vector table at address 0 must have entry for IRQ interrupts
5. Must have interrupt handler function to process/ACK the interrupt
-------------------------------------------------------------

		   
		   PART1: Timer Driver		   
Download files from samples/LAB3.1/lab3.1.tgz:
                    ts.s t.c vid.c timer.c type.h  mk t.ld
which will be explained in class. Listen to lecture

=============================================================================
As is, the code does NOT work yet. You MUST write code for
A1    : in timer.c
A2, A3: in t.c
A4    : in ts.s
---------------------------------
With YOUR correct code at A1, A2, A3, A4
	    
The timer driver in timer.c generates 60 interrupts per second.
		    
It displays a   timer interrupt  line on the LCD every second.
---------------------------------

		    REQUIREMENTS
		    
1. Per the timer driver in the book, display a wall-clock for timer0

2. Make the cursor flashing once every second.

=============================================================================

		    PART2: KBD Driver
1. Download file from samples/LAB3.2/lab3.2.tgz
		     
   The timer driver is the SAME as in LAB3.1. It is included to
   show how to support multiple interrupt sources: timer and kbd.

The topics here is KBD driver. The KBD driver in the book works for Keyset#1.

Newer ARM VMs in Ubuntu 20, 22 use Keyset#2: read website scancode.pdf
The mapping table of Keyset#2 is in the file keymap2 
		     
                For ARM VM using keyset #2:

   Key press  : ONE interrupt : data = scan code of key
   key release: TWO interrupts: data = 0xF0; followed by data = scan code of key

2. The KBD driver in kbd.c can only handle lowercase keys.

		     REQUIREMENTS

(0). Write code at A1       in timer.c
                   A2       in kbd.c
                   A3,A4,A5 in t.c
		   A5       in ts.s
     to make the code work first.
		    
(1). Modify the KBD driver to handle both lowercase and uppercase keys.
    
(2). Catch Control-C key: print "Control-C key" on LCD display
     Catch Control-D key: set input char to 0x4 (for EOF)

(3). Handle the CapsLock key:
     press-release once:  Convert lowercase to uppercase
                                  uppercase to lowercase
     press-release again: NO conversion
		    

HINT : Use state variables to keep track of key status