The Keyboard Controller Essential steps for implementing an interrupt service routine for the Keyboard Controller.

Slides:



Advertisements
Similar presentations
Categories of I/O Devices
Advertisements

PROGRAMMABLE PERIPHERAL INTERFACE -8255
Input and Output CS 215 Lecture #20.
Programmable Interval Timer
Programmable Keyboard/ Display Interface: 8279
Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
Outline  Examine some of the H/W supplied with a typical PC and consider the software required to control it.  Introduce Commkit, a software tool that.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
Network Adapter Driver NCTU High Speed Network Lab.
8.7 Memory management Program E Program D System memory DOS INT 21, function 48H: Allocate Memory Specification: allocates a number of memory paragraphs.
Basic Input/Output Operations
Understanding POST and ROM-BIOS service functions Numerous low-level services are available to real-mode programs (include boot-loaders)
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Hardware Support for Operating Systems Sunny Gleason Vivek Uppal COM S 414
The Keyboard Controller Essential steps for implementing an interrupt service routine for the Keyboard Controller.
S. Barua – CPSC 240 CHAPTER 8 I/O How are I/O devices identified? Memory-mapped vs. special instructions.
Homework / Exam Return and Review Exam #1 Reading Machine Projects
8086 emulation Using Virtual-8086 mode to execute real-mode procedures in a protected-mode environment.
Interrupt Mechanisms in the 74xx PowerPC Architecture Porting Plan 9 to the PowerPC Architecture Ajay Surie Adam Wolbach.
Practical Session No. 10 Input &Output (I/O). I/O Devices Input/output (I/O) devices provide the means to interact with the “outside world”. An I/O device.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
CHARACTERS Data Representation. Using binary to represent characters Computers can only process binary numbers (1’s and 0’s) so a system was developed.
1 Advanced Features of Keyboard Processing Suthida Chaichomchuen
MIPS I/O and Interrupt. SPIM I/O and MIPS Interrupts The materials of this lecture can be found in A7-A8 (3 rd Edition) and B7-B8 (4 th Edition).
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
Three fundamental concepts in computer security: Reference Monitors: An access control concept that refers to an abstract machine that mediates all accesses.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Overview of Hardware.
Chapter 8 I/O. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8-2 I/O: Connecting to Outside World So far,
Chapter 2: Computer-System Structures 2.1 Computer System Operation 2.5 Hardware Protection 2.6 Network Structure.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Input/Output 2 What is I/O? How we get the CPU to communicate with devices From the computer’s point of view, it’s just 1’s and 0’s Gets interpreted.
MIPS I/O and Interrupt. .data val1:.float 0.6 val2:.float 0.8 msg_done:.asciiz "done\n".text.globl main main: li.s $f0, mfc1 $a0, $f0 jal calsqrt.
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
1 COMP541 Input Devices: Keyboards, Mice and Joysticks Montek Singh Apr 6, 2015.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Nevis FVTX Update Dave Winter FVTX Silicon Meeting 13 July 2006.
MIPS I/O and Interrupt.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
1/15 POST Operation MIS-B Spring 99. Agenda for 1/15 roll call discussion of POST handing out of group memberships discuss plans for Wednesday,
Lecture on Central Process Unit (CPU)
7. IRQ and PIC ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  Interrupts ◦ Section
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Integers/Characters Input/Output Integers and Characters Input/Output System Calls. syscall Trap Handler Services for Integers and Characters Read Integer,
BIOS and DOS Interrupts Basic Input /Outpu System Disk Operating System.
Chapter 8 Input/Output An Hong 2015 Fall School of Computer Science and Technology Lecture on Introduction to.
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
Computer System Structures
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Integers/Characters Input/Output
Discussions on hw5 Objectives:
Homework Reading Labs S&S Extracts ,
Homework Reading Machine Projects Labs
Chapter 8 I/O.
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
Interrupt Driven I/O References Text: Tanenbaum ch.1.4.3, ch Receiver Interrupt Program Example:
Discussions on hw5 Objectives:
Chapter 8 I/O.
COMPUTER PERIPHERALS AND INTERFACES
Computer Architecture and Assembly Language
Chapter 8 I/O.
Lecture 12 Input/Output (programmer view)
Interrupts & Syscalls.
Presentation transcript:

The Keyboard Controller Essential steps for implementing an interrupt service routine for the Keyboard Controller

Our 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 Most needed building-blocks already done

Keyboard and its controller Keyboard Controller CPU PIC bus KEYBOARDPS/2 MOUSE output port TIMER output bufferstatus regcontrol reg 0x64 0x60 input buffer input port RAM PIC

6 KB Controller Status PARETIMAUXBKEYLC / DSYSFINPBOUTB LEGEND 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)

Interrupt-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 Queue KBHEAD KBTAIL

BIOS 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:0x82

Format of KBFLAGS LSB Left-Shift key is pressed (1=yes, 0=no) Right-Shift key is pressed (1=yes, 0=no) 01 Ctrl-Key is pressed (1=yes, 0=no) Alt-Key is pressed (1=yes, 0=no) Caps-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 keystrokes IN-CLASS EXERCISE: modify this demo to run in Protected-Mode