diff --git a/Modules/Input/PS2KbMouse/common.h b/Modules/Input/PS2KbMouse/common.h index f7fa36b61f6d1ba9957e39a857ad96a012359653..7cbffe9c0b6e2e686471598dc895f310355264f0 100644 --- a/Modules/Input/PS2KbMouse/common.h +++ b/Modules/Input/PS2KbMouse/common.h @@ -15,7 +15,12 @@ extern int PS2Mouse_Install(char **Arguments); extern void KBC8042_Init(void); extern void KBC8042_EnableMouse(void); +extern void PL050_Init(Uint32 KeyboardBase, Uint8 KeyboardIRQ, Uint32 MouseBase, Uint8 MouseIRQ); +extern void PL050_EnableMouse(void); + extern void KB_HandleScancode(Uint8 scancode); extern void PS2Mouse_HandleInterrupt(Uint8 InputByte); +extern void (*gpMouse_EnableFcn)(void); + #endif diff --git a/Modules/Input/PS2KbMouse/main.c b/Modules/Input/PS2KbMouse/main.c index e3ea35cfeec9518ac975591d86c32c33b8578bc4..7a2b83d4a7d930bf4a05a12a22af5beb386bf425 100644 --- a/Modules/Input/PS2KbMouse/main.c +++ b/Modules/Input/PS2KbMouse/main.c @@ -8,6 +8,22 @@ #include "common.h" // === IMPORTS === +// TODO: Allow runtime/compile-time switching +// Maybe PCI will have it? +// Integrator-CP +#if 0 +#define KEYBOARD_IRQ 3 +#define KEYBOARD_BASE 0x18000000 +#define MOUSE_IRQ 4 +#define MOUSE_BASE 0x19000000 +#endif +// Realview +#if 1 +#define KEYBOARD_IRQ 20 +#define KEYBOARD_BASE 0x10006000 +#define MOUSE_IRQ 21 +#define MOUSE_BASE 0x10007000 +#endif // === PROTOTYPES === int PS2_Install(char **Arguments); @@ -20,6 +36,13 @@ MODULE_DEFINE(0, 0x0100, PS2Mouse, PS2Mouse_Install, NULL, NULL); // === CODE === int PS2_Install(char **Arguments) { + #if ARCH_is_x86 || ARCH_is_x86_64 KBC8042_Init(); + gpMouse_EnableFcn = KBC8042_EnableMouse; + #elif ARCH_is_armv7 + PL050_Init(KEYBOARD_IRQ, KEYBOARD_IRQ, MOUSE_BASE, MOUSE_IRQ); + gpMouse_EnableFcn = PL050_EnableMouse; + #endif + return MODULE_ERR_OK; } diff --git a/Modules/Input/PS2KbMouse/pl050.c b/Modules/Input/PS2KbMouse/pl050.c index f4b319864021650fc8ae11ee179409491768906e..bd4f19687aea324939e37c97257eefd13e6d7600 100644 --- a/Modules/Input/PS2KbMouse/pl050.c +++ b/Modules/Input/PS2KbMouse/pl050.c @@ -7,27 +7,11 @@ #include <acess.h> #include "common.h" -// TODO: Allow runtime/compile-time switching -// Maybe PCI will have it? -// Integrator-CP -#if 0 -#define KEYBOARD_IRQ 3 -#define KEYBOARD_BASE 0x18000000 -#define MOUSE_IRQ 4 -#define MOUSE_BASE 0x19000000 -#endif -// Realview -#if 1 -#define KEYBOARD_IRQ 20 -#define KEYBOARD_BASE 0x10006000 -#define MOUSE_IRQ 21 -#define MOUSE_BASE 0x10007000 -#endif #define PL050_TXBUSY 0x20 // === PROTOTYPES === -void PL050_Init(void); +void PL050_Init(Uint32 KeyboardBase, Uint8 KeyboardIRQ, Uint32 MouseBase, Uint8 MouseIRQ); void PL050_KeyboardHandler(int IRQ); void PL050_MouseHandler(int IRQ); void PL050_EnableMouse(void); @@ -36,11 +20,21 @@ static inline void PL050_WriteKeyboardData(Uint8 data); static inline Uint8 PL050_ReadMouseData(void); static inline Uint8 PL050_ReadKeyboardData(void); +// === GLOBALS === +Uint32 *gpPL050_KeyboardBase; +Uint32 *gpPL050_MouseBase; + // === CODE === -void PL050_Init(void) +void PL050_Init(Uint32 KeyboardBase, Uint8 KeyboardIRQ, Uint32 MouseBase, Uint8 MouseIRQ) { - IRQ_AddHandler(KEYBOARD_IRQ, PL050_KeyboardHandler); - IRQ_AddHandler(MOUSE_IRQ, PL050_MouseHandler); // Set IRQ + if( KeyboardBase ) { + gpPL050_KeyboardBase = MM_MapHW(KeyboardBase, 0x1000); + IRQ_AddHandler(KeyboardIRQ, PL050_KeyboardHandler); + } + if( MouseBase ) { + gpPL050_MouseBase = MM_MapHW(MouseBase, 0x1000); + IRQ_AddHandler(MouseIRQ, PL050_MouseHandler); + } } void PL050_KeyboardHandler(int IRQ) diff --git a/Modules/Input/PS2KbMouse/ps2mouse.c b/Modules/Input/PS2KbMouse/ps2mouse.c index 7c831f76910df1ce8e5d84c678796d330c59f0e0..15b02e45e31a3bf0dd5cd866d41d2b34c47b7468 100644 --- a/Modules/Input/PS2KbMouse/ps2mouse.c +++ b/Modules/Input/PS2KbMouse/ps2mouse.c @@ -26,6 +26,7 @@ Uint64 PS2Mouse_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer int PS2Mouse_IOCtl(tVFS_Node *Node, int ID, void *Data); // == GLOBALS == +void (*gpMouse_EnableFcn)(void); // - Settings int giMouse_Sensitivity = 1; int giMouse_MaxX = 640, giMouse_MaxY = 480;