3 * - By thePowersGang (John Hodge)
5 * PL050 (or comaptible) Driver
13 #define PL050_TXBUSY 0x20
16 void PL050_Init(Uint32 KeyboardBase, Uint8 KeyboardIRQ, Uint32 MouseBase, Uint8 MouseIRQ);
17 void PL050_KeyboardHandler(int IRQ, void *Ptr);
18 void PL050_MouseHandler(int IRQ, void *Ptr);
19 void PL050_EnableMouse(void);
20 static inline void PL050_WriteMouseData(Uint8 data);
21 static inline void PL050_WriteKeyboardData(Uint8 data);
22 static inline Uint8 PL050_ReadMouseData(void);
23 static inline Uint8 PL050_ReadKeyboardData(void);
26 Uint32 *gpPL050_KeyboardBase;
27 Uint32 *gpPL050_MouseBase;
30 void PL050_Init(Uint32 KeyboardBase, Uint8 KeyboardIRQ, Uint32 MouseBase, Uint8 MouseIRQ)
33 LOG("KeyboardBase = 0x%x", KeyboardBase);
34 gpPL050_KeyboardBase = (void*)MM_MapHWPages(KeyboardBase, 1);
35 LOG("gpPL050_KeyboardBase = %p", gpPL050_KeyboardBase);
36 IRQ_AddHandler(KeyboardIRQ, PL050_KeyboardHandler, NULL);
38 gpPL050_KeyboardBase[0] = 0x10;
41 gpPL050_MouseBase = (void*)MM_MapHWPages(MouseBase, 1);
42 IRQ_AddHandler(MouseIRQ, PL050_MouseHandler, NULL);
44 gpPL050_MouseBase[0] = 0x10;
48 void PL050_KeyboardHandler(int IRQ, void *Ptr)
52 scancode = PL050_ReadKeyboardData();
53 KB_HandleScancode( scancode );
56 void PL050_MouseHandler(int IRQ, void *Ptr)
58 PS2Mouse_HandleInterrupt( PL050_ReadMouseData() );
61 void PL050_SetLEDs(Uint8 leds)
63 PL050_WriteKeyboardData(0xED);
64 PL050_WriteKeyboardData(leds);
67 void PL050_EnableMouse(void)
69 Log_Log("PL050", "Enabling Mouse...");
71 //PL050_WriteMouseData(0xD4);
72 //PL050_WriteMouseData(0xF6); // Set Default Settings
73 // PL050_WriteMouseData(0xD4);
74 // PL050_WriteMouseData(0xF4); // Enable Packets
78 static inline void PL050_WriteMouseData(Uint8 Data)
82 if( !gpPL050_MouseBase ) {
83 Log_Error("PL050", "Mouse disabled (gpPL050_MouseBase = NULL)");
89 while( --timeout && (gpPL050_MouseBase[1] & PL050_TXBUSY) );
91 gpPL050_MouseBase[2] = Data;
93 Log_Error("PL050", "Write to mouse timed out");
97 static inline Uint8 PL050_ReadMouseData(void)
99 if( !gpPL050_MouseBase ) {
100 Log_Error("PL050", "Mouse disabled (gpPL050_MouseBase = NULL)");
103 return gpPL050_MouseBase[2];
105 static inline void PL050_WriteKeyboardData(Uint8 Data)
109 if( !gpPL050_KeyboardBase ) {
110 Log_Error("PL050", "Keyboard disabled (gpPL050_KeyboardBase = NULL)");
114 while( --timeout && (gpPL050_KeyboardBase[1] & PL050_TXBUSY) );
116 gpPL050_KeyboardBase[2] = Data;
118 Log_Error("PL050", "Write to keyboard timed out");
120 static inline Uint8 PL050_ReadKeyboardData(void)
122 if( !gpPL050_KeyboardBase ) {
123 Log_Error("PL050", "Keyboard disabled (gpPL050_KeyboardBase = NULL)");
127 return gpPL050_KeyboardBase[2];