The K Project LSE Team I/O Ports PIC Keyboard The K Project Timer Conclusion LSE Team EPITA March 21, 2016 LSE Team (EPITA) The K Project March 21, 2016 1 / 28
I/O Ports The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 2 / 28
I/O Ports The K Project LSE Team I/O Ports PIC asm volatile("outb %0, %1 \ n \ t" Keyboard : /* No output */ Timer : "a" (val), "d" (port)); Conclusion asm volatile("inb %1, %0 \ n \ t" : "=&a" (res) : "d" (port)); LSE Team (EPITA) The K Project March 21, 2016 3 / 28
8259 Overview The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 4 / 28
PIC Wiring The K Project LSE Team I/O Ports Master PIC 0 IRQ 0 Keyboard 1 IRQ 1 Timer S lave 2 0 IRQ 8 Conclusion 3 IRQ 3 1 IRQ 9 CPU INT 4 IRQ 4 2 IRQ 10 5 IRQ 5 3 IRQ 11 6 IRQ 6 INT 4 IRQ 12 7 IRQ 7 5 IRQ 13 6 IRQ 14 7 IRQ 15 Figure: LSE Team (EPITA) The K Project March 21, 2016 5 / 28
Typical wiring of the PIC (Master) The K Project LSE Team I/O Ports IRQ0 - PIT PIC IRQ1 - Keyboard Keyboard Timer IRQ2 - Not assigned in PC/XT; cascaded to slave 8256 Conclusion IRQ3 - UART (COM2 and COM4) IRQ4 - UART (COM1 and COM3) IRQ5 - Hard disk in PC/XT; Parallel port LPT2 in PC/AT IRQ6 - Floppy disk controller IRQ7 - Parallel port LPT1 LSE Team (EPITA) The K Project March 21, 2016 6 / 28
Typical wiring of the PIC (Slave) The K Project LSE Team I/O Ports IRQ8 - RTC PIC IRQ9 - Keyboard Timer IRQ10 - Conclusion IRQ11 - IRQ12 - PS/2 mouse controller IRQ13 - Math coprocessor IRQ14 - Hard disk controller 1 IRQ15 - Hard disk controller 2 LSE Team (EPITA) The K Project March 21, 2016 7 / 28
Interrupt acknowledge (8086/8088) The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 8 / 28
PIC ports The K Project LSE Team I/O Ports PIC Keyboard 0x20 , the master PIC’s port A Timer 0x21 , the master PIC’s port B Conclusion 0xA0 , the slave PIC’s port A 0xA1 , the slave PIC’s port B LSE Team (EPITA) The K Project March 21, 2016 9 / 28
PIC Initialization The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 10 / 28
ICW1 The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 11 / 28
ICW2 The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 12 / 28
ICW3 The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 13 / 28
ICW4 The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 14 / 28
OCW1 The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 15 / 28
OCW2 The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 16 / 28
8042 Controller The K Project LSE Team I/O Ports PIC Keyboard Timer 0x60 : I/0 buffer Conclusion 0x64 : Status register LSE Team (EPITA) The K Project March 21, 2016 17 / 28
8042 Status Register The K Project LSE Team BIT BIT DESCRIPTION FUNCTION I/O Ports 0 Output Buffer Full 0: Output Buffer Empty PIC 1: Output Buffer Full 1 Input Buffer Full 0: Input Buffer Empty Keyboard 1: Input Buffer Full 2 System Flag This bit may be set to 0 or 1 by writing to the system flag bit in Timer the command byte of the keyboard controller. It is set to 0 after a Conclusion power-on reset 3 Command/data 0: Data Byte 1: Com m and Byte 4 Inhibit Switch 0: Keyboard is Inhibited 1: Keyboard is Not Inhibited 5 Transmit Time Out 0: No Transmit Time Out Error 1: Transmit Time Out Error 6 Receive Time Out 0: No Receive Time Out Error 1: Receive Time Out Error 7 Parity Error 0: Odd Parity (No Error) 1: Even Parity (Error) Figure: LSE Team (EPITA) The K Project March 21, 2016 18 / 28
Keyboard scancode The K Project LSE Team I/O Ports PIC Keyboard x x x x x x x x Timer | ------------- Conclusion | | | +--------- Key number +----------------- Key press (clear) or release (set) LSE Team (EPITA) The K Project March 21, 2016 19 / 28
8254 Overview The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 20 / 28
Programmable Interval Timer The K Project LSE Team I/O Ports PIC Keyboard Counter 0: fire an interrupt at a user-defined frequency. Timer Counter 1: historically used in order to periodically refresh Conclusion the RAM, but it not used anymore. Counter 2: linked with the PC speaker, so you can use it in order to generate sound LSE Team (EPITA) The K Project March 21, 2016 21 / 28
PIT Registers The K Project LSE Team I/O Ports PIC Keyboard 0x40 : Counter 0 Timer 0x41 : Counter 1 Conclusion 0x42 : Counter 2 0x43 : Control Register LSE Team (EPITA) The K Project March 21, 2016 22 / 28
PIT Configuration The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 23 / 28
PIT Operation Modes The K Project LSE Team I/O Ports PIC Mode 0: Interrupt on terminal count Keyboard Mode 1: hardware retriggerable one-shot Timer Conclusion Mode 2: rate generator Mode 3: square generator Mode 4: Software Triggered Strobe Mode 5: Hardware Triggered Strobe LSE Team (EPITA) The K Project March 21, 2016 24 / 28
PIT - Mode 2 The K Project LSE Team I/O Ports PIC Keyboard Timer Conclusion Figure: LSE Team (EPITA) The K Project March 21, 2016 25 / 28
PIT Programming The K Project LSE Team I/O Ports PIC Keyboard unsigned long gettick(void); Timer Counter 0 Conclusion Mode 2 Interrupt rate : 100 Hz (Input clock frequency = 1193182 Hz) LSE Team (EPITA) The K Project March 21, 2016 26 / 28
Summary The K Project LSE Team Build IDT I/O Ports Write context saving/restoring in assembly code PIC Implement exceptions and interrupt wrappers Keyboard Timer Load IDT Conclusion Initialize PIC send ICWs to both master and slave mask all interrupts Set keyboard interrupt handler Initialize PIT Send CW Set PIT interrupt handler LSE Team (EPITA) The K Project March 21, 2016 27 / 28
Contact The K Project LSE Team I/O Ports PIC Keyboard #k (irc.rezosup.org) Timer epita.cours.k Conclusion k[at]lse.epita.fr naam[at]lse.epita.fr nurelin[at]lse.epita.fr LSE Team (EPITA) The K Project March 21, 2016 28 / 28
Recommend
More recommend