3 * - By thePowersGang (John Hodge)
5 * PL050 (or comaptible) Driver
10 // TODO: Allow runtime/compile-time switching
11 // Maybe PCI will have it?
14 #define KEYBOARD_IRQ 3
15 #define KEYBOARD_BASE 0x18000000
17 #define MOUSE_BASE 0x19000000
21 #define KEYBOARD_IRQ 20
22 #define KEYBOARD_BASE 0x10006000
24 #define MOUSE_BASE 0x10007000
27 #define PL050_TXBUSY 0x20
30 void PL050_Init(void);
31 void PL050_KeyboardHandler(int IRQ);
32 void PL050_MouseHandler(int IRQ);
33 void PL050_EnableMouse(void);
34 static inline void PL050_WriteMouseData(Uint8 data);
35 static inline void PL050_WriteKeyboardData(Uint8 data);
36 static inline Uint8 PL050_ReadMouseData(void);
37 static inline Uint8 PL050_ReadKeyboardData(void);
42 IRQ_AddHandler(KEYBOARD_IRQ, PL050_KeyboardHandler);
43 IRQ_AddHandler(MOUSE_IRQ, PL050_MouseHandler); // Set IRQ
46 void PL050_KeyboardHandler(int IRQ)
50 scancode = PL050_ReadKeyboardData(0x60);
51 KB_HandleScancode( scancode );
54 void PL050_MouseHandler(int IRQ)
56 PS2Mouse_HandleInterrupt( PL050_ReadMouseData(0x60) );
59 void PL050_SetLEDs(Uint8 leds)
61 PL050_WriteKeyboardData(0xED);
62 PL050_WriteKeyboardData(leds);
65 void PL050_EnableMouse(void)
68 Log_Log("8042", "Enabling Mouse...");
71 //PL050_WriteMouseData(0xD4);
72 //PL050_WriteMouseData(0xF6); // Set Default Settings
73 PL050_WriteMouseData(0xD4);
74 PL050_WriteMouseData(0xF4); // Enable Packets
77 static inline void PL050_WriteMouseData(Uint8 Data)
80 while( --timeout && *(Uint32*)(MOUSE_BASE+1) & PL050_TXBUSY );
82 *(Uint32*)(MOUSE_BASE+2) = Data;
84 Log_Error("PL050", "Write to mouse timed out");
87 static inline Uint8 PL050_ReadMouseData(void)
89 return *(Uint32*)(MOUSE_BASE+2);
91 static inline void PL050_WriteKeyboardData(Uint8 data)
94 while( --timeout && *(Uint32*)(KEYBOARD_BASE+1) & PL050_TXBUSY );
96 *(Uint32*)(KEYBOARD_BASE+2) = Data;
98 Log_Error("PL050", "Write to keyboard timed out");
100 static inline Uint8 PL050_ReadKeyboardData(void)
102 return *(Uint32*)(MOUSE_BASE+2);