Modules/armv7 - Fixing PL050 support
authorJohn Hodge <[email protected]>
Fri, 7 Oct 2011 08:42:45 +0000 (16:42 +0800)
committerJohn Hodge <[email protected]>
Fri, 7 Oct 2011 08:42:45 +0000 (16:42 +0800)
Modules/Input/PS2KbMouse/Makefile
Modules/Input/PS2KbMouse/main.c
Modules/Input/PS2KbMouse/pl050.c
Modules/Input/PS2KbMouse/ps2mouse.c

index 2500c02..306e2b4 100644 (file)
@@ -2,7 +2,7 @@
 #
 
 OBJ = main.o kb.o ps2mouse.o
-OBJ += 8042.o
+OBJ += 8042.o pl050.o
 NAME = PS2KbMouse
 
 -include ../Makefile.tpl
index 0015b93..08dfb00 100644 (file)
@@ -30,8 +30,8 @@
 
 // === GLOBALS ===
 MODULE_DEFINE(0, 0x0100, Input_PS2KbMouse, PS2_Install, NULL, NULL);   // Shuts the makefile up
-MODULE_DEFINE(0, 0x0100, PS2Keyboard, KB_Install, NULL, NULL);
-MODULE_DEFINE(0, 0x0100, PS2Mouse, PS2Mouse_Install, NULL, NULL);
+MODULE_DEFINE(0, 0x0100, PS2Keyboard, KB_Install, NULL, "Input_PS2KbMouse", NULL);
+MODULE_DEFINE(0, 0x0100, PS2Mouse, PS2Mouse_Install, NULL, "Input_PS2KbMouse", NULL);
 
 // === CODE ===
 int PS2_Install(char **Arguments)
index bd4f196..8d65e3a 100644 (file)
@@ -7,13 +7,13 @@
 #include <acess.h>
 #include "common.h"
 
-
+// === CONSTANTS ===
 #define PL050_TXBUSY   0x20
 
 // === PROTOTYPES ===
 void   PL050_Init(Uint32 KeyboardBase, Uint8 KeyboardIRQ, Uint32 MouseBase, Uint8 MouseIRQ);
-void   PL050_KeyboardHandler(int IRQ);
-void   PL050_MouseHandler(int IRQ);
+void   PL050_KeyboardHandler(int IRQ, void *Ptr);
+void   PL050_MouseHandler(int IRQ, void *Ptr);
 void   PL050_EnableMouse(void);
 static inline void     PL050_WriteMouseData(Uint8 data);
 static inline void     PL050_WriteKeyboardData(Uint8 data);
@@ -28,26 +28,26 @@ Uint32      *gpPL050_MouseBase;
 void PL050_Init(Uint32 KeyboardBase, Uint8 KeyboardIRQ, Uint32 MouseBase, Uint8 MouseIRQ)
 {
        if( KeyboardBase ) {
-               gpPL050_KeyboardBase = MM_MapHW(KeyboardBase, 0x1000);
-               IRQ_AddHandler(KeyboardIRQ, PL050_KeyboardHandler);
+               gpPL050_KeyboardBase = (void*)MM_MapHWPages(KeyboardBase, 1);
+               IRQ_AddHandler(KeyboardIRQ, PL050_KeyboardHandler, NULL);
        }
        if( MouseBase ) {
-               gpPL050_MouseBase = MM_MapHW(MouseBase, 0x1000);
-               IRQ_AddHandler(MouseIRQ, PL050_MouseHandler);
+               gpPL050_MouseBase = (void*)MM_MapHWPages(MouseBase, 1);
+               IRQ_AddHandler(MouseIRQ, PL050_MouseHandler, NULL);
        }
 }
 
-void PL050_KeyboardHandler(int IRQ)
+void PL050_KeyboardHandler(int IRQ, void *Ptr)
 {
        Uint8   scancode;
 
-       scancode = PL050_ReadKeyboardData(0x60);
+       scancode = PL050_ReadKeyboardData();
        KB_HandleScancode( scancode );
 }
 
-void PL050_MouseHandler(int IRQ)
+void PL050_MouseHandler(int IRQ, void *Ptr)
 {
-       PS2Mouse_HandleInterrupt( PL050_ReadMouseData(0x60) );
+       PS2Mouse_HandleInterrupt( PL050_ReadMouseData() );
 }
 
 void PL050_SetLEDs(Uint8 leds)
@@ -58,9 +58,7 @@ void PL050_SetLEDs(Uint8 leds)
 
 void PL050_EnableMouse(void)
 {
-       Uint8   status;
-       Log_Log("8042", "Enabling Mouse...");
-       
+       Log_Log("PL050", "Enabling Mouse...");
        
        //PL050_WriteMouseData(0xD4);
        //PL050_WriteMouseData(0xF6);   // Set Default Settings
@@ -71,28 +69,49 @@ void PL050_EnableMouse(void)
 static inline void PL050_WriteMouseData(Uint8 Data)
 {
         int    timeout = 10000;
-       while( --timeout && *(Uint32*)(MOUSE_BASE+1) & PL050_TXBUSY );
+
+       if( !gpPL050_MouseBase ) {
+               Log_Error("PL050", "Mouse disabled (gpPL050_MouseBase = NULL)");
+               return ;
+       }
+
+       while( --timeout && gpPL050_MouseBase[1] & PL050_TXBUSY );
        if(timeout)
-               *(Uint32*)(MOUSE_BASE+2) = Data;
+               gpPL050_MouseBase[2] = Data;
        else
                Log_Error("PL050", "Write to mouse timed out");
 }
 
 static inline Uint8 PL050_ReadMouseData(void)
 {
-       return *(Uint32*)(MOUSE_BASE+2);
+       if( !gpPL050_MouseBase ) {
+               Log_Error("PL050", "Mouse disabled (gpPL050_MouseBase = NULL)");
+               return 0;
+       }
+       return gpPL050_MouseBase[2];
 }
-static inline void PL050_WriteKeyboardData(Uint8 data)
+static inline void PL050_WriteKeyboardData(Uint8 Data)
 {
         int    timeout = 10000;
-       while( --timeout && *(Uint32*)(KEYBOARD_BASE+1) & PL050_TXBUSY );
+
+       if( !gpPL050_KeyboardBase ) {
+               Log_Error("PL050", "Keyboard disabled (gpPL050_KeyboardBase = NULL)");
+               return ;
+       }
+
+       while( --timeout && gpPL050_KeyboardBase[1] & PL050_TXBUSY );
        if(timeout)
-               *(Uint32*)(KEYBOARD_BASE+2) = Data;
+               gpPL050_KeyboardBase[2] = Data;
        else
                Log_Error("PL050", "Write to keyboard timed out");
 }
 static inline Uint8 PL050_ReadKeyboardData(void)
 {
-       return *(Uint32*)(MOUSE_BASE+2);
+       if( !gpPL050_KeyboardBase ) {
+               Log_Error("PL050", "Keyboard disabled (gpPL050_KeyboardBase = NULL)");
+               return 0;
+       }
+
+       return gpPL050_KeyboardBase[2];
 }
 
index 15b02e4..abf2a60 100644 (file)
@@ -59,7 +59,7 @@ int PS2Mouse_Install(char **Arguments)
        \r
        // Initialise Mouse Controller\r
        giMouse_Cycle = 0;      // Set Current Cycle position\r
-       KBC8042_EnableMouse();\r
+       gpMouse_EnableFcn();\r
        \r
        DevFS_AddDevice(&gMouse_DriverStruct);\r
        \r

UCC git Repository :: git.ucc.asn.au