DOC PREVIEW
USF CS 630 - The Keyboard Controller

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

The Keyboard ControllerOur near-term goalKeyboard and its controllerKB Controller StatusA few Controller CommandsCommand to set LEDsInterrupt-Handler actionsKeyboard ‘scancode’ formatKeyboard QueueBIOS DATA AREAFormat of KBFLAGS LSBDemo ‘minikybd.s’The Keyboard ControllerEssential steps for implementing an interrupt service routine for the Keyboard ControllerOur near-term goal•To build a ‘mini’ x86 operating system •It should be able run a Linux application •It needs to support:–basic console input/output (keyboard, screen)–handling of device-interrupts (timer, keyboard)–‘exit’ gracefully when application is finished–utilize x86 privilege restrictions and 32bit code•Certain building-blocks are already doneKeyboard and its controllerKeyboard ControllerCPUPICbusKEYBOARDPS/2 MOUSEoutput portTIMERoutput bufferstatus regcontrol reg0x64 0x64 0x60 0x60input bufferinput portRAMPICIRQ0 IRQ1IRQ26KB Controller StatusPARE TIM AUXB KEYL C / D SYSF INPB OUTB7 5 4 3 2 1 0LEGEND OUTB: Output-Buffer Full (1=yes, 0=no) INPB: Input-Buffer Full (1=yes, 0=no) SYSF: System-Flag (1=self-test successful, 0=power-on reset) C/D: Command/Data was written to (1=port 0x64, 0=port 0x60) KEYL: Keyboard-Lock status (1=keyboard available, 0=locked) AUXB: Output-Buffer’s data is (1=for mouse, 0=for keyboard) TIM: General Timeout-Error has occurred (1=yes, 0=no) PARE: Parity-Error on last byte from keyboard/mouse (1=yes, 0=no)A few Controller Commands•0xAD: Disable Keyboard•0xAE: Enable Keyboard•0xA7: Disable PS/2 Mouse•0xA8: Enable PS/2 Mouse•0xC0: Read input-port (to output buffer)•0XD0: Read output-port (to output buffer)Command to set LEDs•0xED: Turns on/off the keyboard’s LEDs## Algorithm to change the keyboard’s Light Emitting Diodes#•Wait until keyboard controller’s output buffer is not full•Output command-byte 0xED to port 0x60 •Wait until keyboard controller’s output buffer is not full•Output octal value 0..7 to port 0x60CAPSLOCKNUMLOCKSCROLLLOCKOctal-value =2 1 01=on0=off1=on0=off1=on0=offInterrupt-Handler actions•When the keyboard-controller issues an interrupt, these actions should be taken:–Save values in the working CPU registers–Read keyboard-controller’s status-register–If the output-buffer has new data, read it–If a “special” key (shift/toggle), adjust kb_flags–For a normal key, translate scancode to ascii–Insert the code-pair at tail-end of kb-queue–Send EOI-command to Interrupt Controller–Restore the saved values from CPU registers–Resume the interrupted procedure (with ‘iret’)Keyboard ‘scancode’ formatBRK 7 6 5 4 3 2 1 0Key identifier (bits 6..0)BRK (bit 7) 1 = ’Break’ (the key was released) 0 = ‘Make’ (the key was pressed)Keyboard QueueKBHEADKBTAILBIOS DATA AREA•KBFLAGS is word at address 0x40:0x17•KBHEAD is word at address 0x40:0x1A•KBTAIL is word at address 0x40:0x1C•KBQUEUE is array of 16 words array base-address at 0x40:0x1E•KBBASE is word at 0x40:0x80•KBTAIL is word at 0x40:0x82Format of KBFLAGS LSB Left-Shift key is pressed (1=yes, 0=no)Right-Shift key is pressed (1=yes, 0=no)01Ctrl-Key is pressed (1=yes, 0=no)Alt-Key is pressed (1=yes, 0=no)234567Caps-Lock is active (1=yes, 0=no)Num-Lock is active (1=yes, 0=no)Scroll-Lock is active (1=yes, 0=no)Insert-mode is active (1=yes, 0=no)Demo ‘minikybd.s’•It shows a minimal implementation for the keyboard-controller’s interrupt-handler•It runs in Real-Mode•It ‘echos’ a user’s keystrokesIN-CLASS EXERCISE: modify this demo to run in


View Full Document

USF CS 630 - The Keyboard Controller

Documents in this Course
Load more
Download The Keyboard Controller
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The Keyboard Controller and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The Keyboard Controller 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?