3 * - By thePowersGang (John Hodge)
5 * PL050 (or comaptible) Driver
11 #define PL050_TXBUSY 0x20
14 void PL050_Init(Uint32 KeyboardBase, Uint8 KeyboardIRQ, Uint32 MouseBase, Uint8 MouseIRQ);
15 void PL050_KeyboardHandler(int IRQ, void *Ptr);
16 void PL050_MouseHandler(int IRQ, void *Ptr);
17 void PL050_EnableMouse(void);
18 static inline void PL050_WriteMouseData(Uint8 data);
19 static inline void PL050_WriteKeyboardData(Uint8 data);
20 static inline Uint8 PL050_ReadMouseData(void);
21 static inline Uint8 PL050_ReadKeyboardData(void);
24 Uint32 *gpPL050_KeyboardBase;
25 Uint32 *gpPL050_MouseBase;
28 void PL050_Init(Uint32 KeyboardBase, Uint8 KeyboardIRQ, Uint32 MouseBase, Uint8 MouseIRQ)
31 gpPL050_KeyboardBase = (void*)MM_MapHWPages(KeyboardBase, 1);
32 IRQ_AddHandler(KeyboardIRQ, PL050_KeyboardHandler, NULL);
35 gpPL050_MouseBase = (void*)MM_MapHWPages(MouseBase, 1);
36 IRQ_AddHandler(MouseIRQ, PL050_MouseHandler, NULL);
40 void PL050_KeyboardHandler(int IRQ, void *Ptr)
44 scancode = PL050_ReadKeyboardData();
45 KB_HandleScancode( scancode );
48 void PL050_MouseHandler(int IRQ, void *Ptr)
50 PS2Mouse_HandleInterrupt( PL050_ReadMouseData() );
53 void PL050_SetLEDs(Uint8 leds)
55 PL050_WriteKeyboardData(0xED);
56 PL050_WriteKeyboardData(leds);
59 void PL050_EnableMouse(void)
61 Log_Log("PL050", "Enabling Mouse...");
63 //PL050_WriteMouseData(0xD4);
64 //PL050_WriteMouseData(0xF6); // Set Default Settings
65 PL050_WriteMouseData(0xD4);
66 PL050_WriteMouseData(0xF4); // Enable Packets
69 static inline void PL050_WriteMouseData(Uint8 Data)
73 if( !gpPL050_MouseBase ) {
74 Log_Error("PL050", "Mouse disabled (gpPL050_MouseBase = NULL)");
78 while( --timeout && gpPL050_MouseBase[1] & PL050_TXBUSY );
80 gpPL050_MouseBase[2] = Data;
82 Log_Error("PL050", "Write to mouse timed out");
85 static inline Uint8 PL050_ReadMouseData(void)
87 if( !gpPL050_MouseBase ) {
88 Log_Error("PL050", "Mouse disabled (gpPL050_MouseBase = NULL)");
91 return gpPL050_MouseBase[2];
93 static inline void PL050_WriteKeyboardData(Uint8 Data)
97 if( !gpPL050_KeyboardBase ) {
98 Log_Error("PL050", "Keyboard disabled (gpPL050_KeyboardBase = NULL)");
102 while( --timeout && gpPL050_KeyboardBase[1] & PL050_TXBUSY );
104 gpPL050_KeyboardBase[2] = Data;
106 Log_Error("PL050", "Write to keyboard timed out");
108 static inline Uint8 PL050_ReadKeyboardData(void)
110 if( !gpPL050_KeyboardBase ) {
111 Log_Error("PL050", "Keyboard disabled (gpPL050_KeyboardBase = NULL)");
115 return gpPL050_KeyboardBase[2];