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);
16 void PL050_MouseHandler(int IRQ);
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 = MM_MapHW(KeyboardBase, 0x1000);
32 IRQ_AddHandler(KeyboardIRQ, PL050_KeyboardHandler);
35 gpPL050_MouseBase = MM_MapHW(MouseBase, 0x1000);
36 IRQ_AddHandler(MouseIRQ, PL050_MouseHandler);
40 void PL050_KeyboardHandler(int IRQ)
44 scancode = PL050_ReadKeyboardData(0x60);
45 KB_HandleScancode( scancode );
48 void PL050_MouseHandler(int IRQ)
50 PS2Mouse_HandleInterrupt( PL050_ReadMouseData(0x60) );
53 void PL050_SetLEDs(Uint8 leds)
55 PL050_WriteKeyboardData(0xED);
56 PL050_WriteKeyboardData(leds);
59 void PL050_EnableMouse(void)
62 Log_Log("8042", "Enabling Mouse...");
65 //PL050_WriteMouseData(0xD4);
66 //PL050_WriteMouseData(0xF6); // Set Default Settings
67 PL050_WriteMouseData(0xD4);
68 PL050_WriteMouseData(0xF4); // Enable Packets
71 static inline void PL050_WriteMouseData(Uint8 Data)
74 while( --timeout && *(Uint32*)(MOUSE_BASE+1) & PL050_TXBUSY );
76 *(Uint32*)(MOUSE_BASE+2) = Data;
78 Log_Error("PL050", "Write to mouse timed out");
81 static inline Uint8 PL050_ReadMouseData(void)
83 return *(Uint32*)(MOUSE_BASE+2);
85 static inline void PL050_WriteKeyboardData(Uint8 data)
88 while( --timeout && *(Uint32*)(KEYBOARD_BASE+1) & PL050_TXBUSY );
90 *(Uint32*)(KEYBOARD_BASE+2) = Data;
92 Log_Error("PL050", "Write to keyboard timed out");
94 static inline Uint8 PL050_ReadKeyboardData(void)
96 return *(Uint32*)(MOUSE_BASE+2);