From de881e611aac6603399d746b6a4b764c007f98e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 24 Aug 2005 20:34:50 +0000 Subject: [PATCH] Cleanup i8042prt.h Remove $Id$ tags Replace Win32 types by their kernel counterparts (DWORD -> ULONG, ...) svn path=/trunk/; revision=17519 --- reactos/drivers/input/i8042prt/i8042prt.c | 34 ++++---- reactos/drivers/input/i8042prt/i8042prt.h | 98 ++++++++--------------- reactos/drivers/input/i8042prt/keyboard.c | 30 ++++--- reactos/drivers/input/i8042prt/mouse.c | 22 +++-- reactos/drivers/input/i8042prt/ps2pp.c | 8 +- reactos/drivers/input/i8042prt/registry.c | 48 ++++++----- 6 files changed, 102 insertions(+), 138 deletions(-) diff --git a/reactos/drivers/input/i8042prt/i8042prt.c b/reactos/drivers/input/i8042prt/i8042prt.c index fe35636f7ff..e6ce9fa7721 100644 --- a/reactos/drivers/input/i8042prt/i8042prt.c +++ b/reactos/drivers/input/i8042prt/i8042prt.c @@ -10,11 +10,9 @@ /* INCLUDES ****************************************************************/ -#include -#include -#include - +#ifndef NDEBUG #define NDEBUG +#endif #include #include "i8042prt.h" @@ -34,18 +32,18 @@ /* * FUNCTION: Write data to a port, waiting first for it to become ready */ -BOOLEAN I8042Write(PDEVICE_EXTENSION DevExt, int addr, BYTE data) +BOOLEAN I8042Write(PDEVICE_EXTENSION DevExt, PUCHAR addr, UCHAR data) { ULONG ResendIterations = DevExt->Settings.PollingIterations; - while ((KBD_IBF & READ_PORT_UCHAR((PUCHAR)I8042_CTRL_PORT)) && + while ((KBD_IBF & READ_PORT_UCHAR(I8042_CTRL_PORT)) && (ResendIterations--)) { KeStallExecutionProcessor(50); } if (ResendIterations) { - WRITE_PORT_UCHAR((PUCHAR)addr,data); + WRITE_PORT_UCHAR(addr,data); DPRINT("Sent %x to %x\n", data, addr); return TRUE; } @@ -56,7 +54,7 @@ BOOLEAN I8042Write(PDEVICE_EXTENSION DevExt, int addr, BYTE data) /* * FUNCTION: Write data to a port, without waiting first */ -static BOOLEAN I8042WriteNoWait(PDEVICE_EXTENSION DevExt, int addr, BYTE data) +static BOOLEAN I8042WriteNoWait(PDEVICE_EXTENSION DevExt, int addr, UCHAR data) { WRITE_PORT_UCHAR((PUCHAR)addr,data); DPRINT("Sent %x to %x\n", data, addr); @@ -67,10 +65,10 @@ static BOOLEAN I8042WriteNoWait(PDEVICE_EXTENSION DevExt, int addr, BYTE data) /* * FUNCTION: Read data from port 0x60 */ -NTSTATUS I8042ReadData(BYTE *Data) +NTSTATUS I8042ReadData(UCHAR *Data) { - BYTE Status; - Status=READ_PORT_UCHAR((PUCHAR)I8042_CTRL_PORT); + UCHAR Status; + Status=READ_PORT_UCHAR(I8042_CTRL_PORT); // If data is available if ((Status & KBD_OBF)) { @@ -84,16 +82,16 @@ NTSTATUS I8042ReadData(BYTE *Data) return STATUS_UNSUCCESSFUL; } -NTSTATUS I8042ReadStatus(BYTE *Status) +NTSTATUS I8042ReadStatus(UCHAR *Status) { - Status[0]=READ_PORT_UCHAR((PUCHAR)I8042_CTRL_PORT); + Status[0]=READ_PORT_UCHAR(I8042_CTRL_PORT); return STATUS_SUCCESS; } /* * FUNCTION: Read data from port 0x60 */ -NTSTATUS I8042ReadDataWait(PDEVICE_EXTENSION DevExt, BYTE *Data) +NTSTATUS I8042ReadDataWait(PDEVICE_EXTENSION DevExt, UCHAR *Data) { ULONG Counter = DevExt->Settings.PollingIterations; NTSTATUS Status; @@ -112,7 +110,7 @@ NTSTATUS I8042ReadDataWait(PDEVICE_EXTENSION DevExt, BYTE *Data) VOID I8042Flush() { - BYTE Ignore; + UCHAR Ignore; while (STATUS_SUCCESS == I8042ReadData(&Ignore)) { ; /* drop */ @@ -141,7 +139,7 @@ NTSTATUS STDCALL I8042SynchWritePort(PDEVICE_EXTENSION DevExt, { NTSTATUS Status; UCHAR Ack; - UINT ResendIterations = DevExt->Settings.ResendIterations + 1; + ULONG ResendIterations = DevExt->Settings.ResendIterations + 1; do { if (Port) @@ -311,7 +309,7 @@ BOOLEAN STDCALL I8042PacketIsr(PDEVICE_EXTENSION DevExt, VOID I8042PacketDpc(PDEVICE_EXTENSION DevExt) { - BOOL FinishIrp = FALSE; + BOOLEAN FinishIrp = FALSE; NTSTATUS Result = STATUS_INTERNAL_ERROR; /* Shouldn't happen */ KIRQL Irql; @@ -512,7 +510,7 @@ static NTSTATUS STDCALL I8042BasicDetect(PDEVICE_EXTENSION DevExt) { NTSTATUS Status; UCHAR Value = 0; - UINT Counter; + ULONG Counter; DevExt->MouseExists = FALSE; DevExt->KeyboardExists = FALSE; diff --git a/reactos/drivers/input/i8042prt/i8042prt.h b/reactos/drivers/input/i8042prt/i8042prt.h index 03290663030..6d7e56c5a7a 100644 --- a/reactos/drivers/input/i8042prt/i8042prt.h +++ b/reactos/drivers/input/i8042prt/i8042prt.h @@ -1,51 +1,19 @@ #ifndef _I8042DRV_H #define _I8042DRV_H -#include -#include -#include + +#include +#include +#include + +#ifdef _MSC_VER + #define STDCALL + #define DDKAPI +#endif #define KEYBOARD_IRQ 1 #define MOUSE_IRQ 12 #define KBD_BUFFER_SIZE 32 -// should be in ntdd8042.h - -typedef VOID DDKAPI -(*KEYBOARD_CLASS_SERVICE_CALLBACK) ( - IN PDEVICE_OBJECT DeviceObject, - IN PKEYBOARD_INPUT_DATA InputDataStart, - IN PKEYBOARD_INPUT_DATA InputDataEnd, - IN OUT PULONG InputDataConsumed -); - -/* I'm not actually sure if this is in the ddk, would seem logical */ -typedef VOID DDKAPI -(*MOUSE_CLASS_SERVICE_CALLBACK) ( - IN PDEVICE_OBJECT DeviceObject, - IN PMOUSE_INPUT_DATA InputDataStart, - IN PMOUSE_INPUT_DATA InputDataEnd, - IN OUT PULONG InputDataConsumed -); - -typedef struct _CONNECT_DATA { - PDEVICE_OBJECT ClassDeviceObject; - PVOID ClassService; -} CONNECT_DATA, *PCONNECT_DATA; - -#define IOCTL_INTERNAL_KEYBOARD_CONNECT \ - CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0080, METHOD_NEITHER, FILE_ANY_ACCESS) - -#define IOCTL_INTERNAL_MOUSE_CONNECT \ - CTL_CODE(FILE_DEVICE_MOUSE, 0x0080, METHOD_NEITHER, FILE_ANY_ACCESS) - -/* For some bizarre reason, these are different from the defines in - * w32api. I'm quite sure these are correct though, needs to be checked - * against the ddk - */ -#define KEYBOARD_SCROLL_LOCK_ON 0x01 -#define KEYBOARD_NUM_LOCK_ON 0x02 -#define KEYBOARD_CAPS_LOCK_ON 0x04 - #define WHEEL_DELTA 120 /*----------------------------------------------------- @@ -77,21 +45,21 @@ typedef enum _MOUSE_TIMEOUT_STATE /* TODO: part of this should be in the _ATTRIBUTES structs instead */ typedef struct _I8042_SETTINGS { - DWORD Headless; /* done */ - DWORD CrashScroll; - DWORD CrashSysRq; /* done */ - DWORD ReportResetErrors; - DWORD PollStatusIterations; /* done */ - DWORD ResendIterations; /* done */ - DWORD PollingIterations; - DWORD PollingIterationsMaximum; - DWORD OverrideKeyboardType; - DWORD OverrideKeyboardSubtype; - DWORD MouseResendStallTime; - DWORD MouseSynchIn100ns; /* done */ - DWORD MouseResolution; /* done */ - DWORD NumberOfButtons; - DWORD EnableWheelDetection; + ULONG Headless; /* done */ + ULONG CrashScroll; + ULONG CrashSysRq; /* done */ + ULONG ReportResetErrors; + ULONG PollStatusIterations; /* done */ + ULONG ResendIterations; /* done */ + ULONG PollingIterations; + ULONG PollingIterationsMaximum; + ULONG OverrideKeyboardType; + ULONG OverrideKeyboardSubtype; + ULONG MouseResendStallTime; + ULONG MouseSynchIn100ns; /* done */ + ULONG MouseResolution; /* done */ + ULONG NumberOfButtons; + ULONG EnableWheelDetection; } I8042_SETTINGS, *PI8042_SETTINGS; typedef enum _I8042_MOUSE_TYPE @@ -178,7 +146,7 @@ typedef struct _DEVICE_EXTENSION I8042_MOUSE_TYPE MouseType; OUTPUT_PACKET Packet; - UINT PacketResends; + ULONG PacketResends; BOOLEAN PacketComplete; NTSTATUS PacketResult; UCHAR PacketBuffer[16]; @@ -228,8 +196,8 @@ typedef struct _I8042_HOOK_WORKITEM * Keyboard controller ports */ -#define I8042_DATA_PORT 0x60 -#define I8042_CTRL_PORT 0x64 +#define I8042_DATA_PORT ((PUCHAR)0x60) +#define I8042_CTRL_PORT ((PUCHAR)0x64) /* @@ -295,11 +263,11 @@ typedef struct _I8042_HOOK_WORKITEM #define MOUSE_NACK 0xFE /* i8042prt.c */ -NTSTATUS I8042ReadData(BYTE *Data); +NTSTATUS I8042ReadData(UCHAR *Data); -NTSTATUS I8042ReadStatus(BYTE *Status); +NTSTATUS I8042ReadStatus(UCHAR *Status); -NTSTATUS I8042ReadDataWait(PDEVICE_EXTENSION DevExt, BYTE *Data); +NTSTATUS I8042ReadDataWait(PDEVICE_EXTENSION DevExt, UCHAR *Data); VOID I8042Flush(); @@ -326,7 +294,7 @@ VOID I8042PacketDpc(PDEVICE_EXTENSION DevExt); VOID STDCALL I8042SendHookWorkItem(PDEVICE_OBJECT DeviceObject, PVOID Context); -BOOLEAN I8042Write(PDEVICE_EXTENSION DevExt, int addr, BYTE data); +BOOLEAN I8042Write(PDEVICE_EXTENSION DevExt, PUCHAR addr, UCHAR data); /* keyboard.c */ VOID STDCALL I8042IsrWritePortKbd(PVOID Context, @@ -382,12 +350,12 @@ VOID STDCALL I8042MouseHandleButtons(PDEVICE_EXTENSION DevExt, USHORT Mask); VOID STDCALL I8042MouseHandle(PDEVICE_EXTENSION DevExt, - BYTE Output); + UCHAR Output); BOOLEAN STDCALL I8042MouseEnable(PDEVICE_EXTENSION DevExt); BOOLEAN STDCALL I8042MouseDisable(PDEVICE_EXTENSION DevExt); /* ps2pp.c */ -VOID I8042MouseHandlePs2pp(PDEVICE_EXTENSION DevExt, BYTE Input); +VOID I8042MouseHandlePs2pp(PDEVICE_EXTENSION DevExt, UCHAR Input); #endif // _KEYBOARD_H_ diff --git a/reactos/drivers/input/i8042prt/keyboard.c b/reactos/drivers/input/i8042prt/keyboard.c index f4c32724524..02bb4aa0279 100644 --- a/reactos/drivers/input/i8042prt/keyboard.c +++ b/reactos/drivers/input/i8042prt/keyboard.c @@ -11,18 +11,16 @@ /* INCLUDES ****************************************************************/ -#include -#include -#include - +#ifndef NDEBUG #define NDEBUG +#endif #include #include "i8042prt.h" /* GLOBALS *******************************************************************/ -static BYTE TypematicTable[] = { +static UCHAR TypematicTable[] = { 0x00, 0x00, 0x00, 0x05, 0x08, 0x0B, 0x0D, 0x0F, 0x10, 0x12, /* 0-9 */ 0x13, 0x14, 0x15, 0x16, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1A, /* 10-19 */ 0x1B, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1E }; @@ -87,12 +85,12 @@ NTSTATUS STDCALL I8042SynchWritePortKbd(PVOID Context, BOOLEAN STDCALL I8042InterruptServiceKbd(struct _KINTERRUPT *Interrupt, VOID * Context) { - BYTE Output; - BYTE PortStatus; + UCHAR Output; + UCHAR PortStatus; NTSTATUS Status; PDEVICE_EXTENSION DevExt = (PDEVICE_EXTENSION) Context; BOOLEAN HookContinue = FALSE, HookReturn; - UINT Iterations = 0; + ULONG Iterations = 0; KEYBOARD_INPUT_DATA *InputData = DevExt->KeyboardBuffer + DevExt->KeysInBuffer; @@ -228,7 +226,7 @@ VOID STDCALL I8042DpcRoutineKbd(PKDPC Dpc, if (!DevExt->KeyboardData.ClassService) return; - ((KEYBOARD_CLASS_SERVICE_CALLBACK) DevExt->KeyboardData.ClassService)( + ((PSERVICE_CALLBACK_ROUTINE) DevExt->KeyboardData.ClassService)( DevExt->KeyboardData.ClassDeviceObject, DevExt->KeyboardBuffer, DevExt->KeyboardBuffer + KeysInBufferCopy, @@ -240,9 +238,9 @@ VOID STDCALL I8042DpcRoutineKbd(PKDPC Dpc, } /* You have to send the rate/delay in a somewhat awkward format */ -static USHORT I8042GetTypematicByte(USHORT Rate, USHORT Delay) +static UCHAR I8042GetTypematicByte(USHORT Rate, USHORT Delay) { - USHORT ret; + UCHAR ret; if (Rate < 3) { ret = 0x0; @@ -630,7 +628,7 @@ BOOLEAN STDCALL I8042DetectKeyboard(PDEVICE_EXTENSION DevExt) { NTSTATUS Status; UCHAR Value; - UINT RetryCount = 10; + ULONG RetryCount = 10; DPRINT("Detecting keyboard\n"); @@ -713,6 +711,7 @@ detectsetleds: /* debug stuff */ VOID STDCALL KdpServiceDispatcher(ULONG Code, PVOID Context1, PVOID Context2); +#define EnterDebugger ((PVOID)0x25) static VOID STDCALL I8042DebugWorkItem(PDEVICE_OBJECT DeviceObject, PVOID Context) @@ -727,5 +726,10 @@ static VOID STDCALL I8042DebugWorkItem(PDEVICE_OBJECT DeviceObject, if (!Key) return; - KdpServiceDispatcher(TAG('R', 'o', 's', ' '), (PVOID)Key, NULL); +#ifdef __REACTOS__ + /* We hope kernel would understand this. If + * that's not the case, nothing would happen. + */ + KdpServiceDispatcher(TAG('R', 'o', 's', ' '), EnterDebugger, NULL); +#endif /* __REACTOS__ */ } diff --git a/reactos/drivers/input/i8042prt/mouse.c b/reactos/drivers/input/i8042prt/mouse.c index e30bc6e8d15..649ba8d3ef5 100644 --- a/reactos/drivers/input/i8042prt/mouse.c +++ b/reactos/drivers/input/i8042prt/mouse.c @@ -11,11 +11,9 @@ /* INCLUDES ****************************************************************/ -#include -#include -#include - +#ifndef NDEBUG #define NDEBUG +#endif #include #include "i8042prt.h" @@ -147,7 +145,7 @@ BOOLEAN STDCALL I8042MouseResetIsr(PDEVICE_EXTENSION DevExt, DevExt->MouseExists = FALSE; DevExt->MouseState = MouseIdle; DPRINT1("Mouse returned bad reset reply part two: " - "%x (expected 0)\n", Value); + "%x (expected 0)\n", *Value); } return TRUE; case ExpectingGetDeviceIdACK: @@ -312,7 +310,7 @@ BOOLEAN STDCALL I8042MouseResetIsr(PDEVICE_EXTENSION DevExt, return TRUE; case ExpectingSetSamplingRateACK: I8042IsrWritePortMouse(DevExt, - DevExt->MouseAttributes.SampleRate); + (UCHAR)DevExt->MouseAttributes.SampleRate); DevExt->MouseResetState++; return TRUE; case ExpectingSetSamplingRateValueACK: @@ -328,7 +326,7 @@ BOOLEAN STDCALL I8042MouseResetIsr(PDEVICE_EXTENSION DevExt, return TRUE; case ExpectingFinalResolutionACK: I8042IsrWritePortMouse(DevExt, - DevExt->Settings.MouseResolution & 0xff); + (UCHAR)(DevExt->Settings.MouseResolution & 0xff)); DPRINT("%x\n", DevExt->Settings.MouseResolution); DevExt->MouseResetState = ExpectingFinalResolutionValueACK; return TRUE; @@ -383,7 +381,7 @@ VOID STDCALL I8042MouseHandleButtons(PDEVICE_EXTENSION DevExt, { PMOUSE_INPUT_DATA MouseInput = DevExt->MouseBuffer + DevExt->MouseInBuffer; - USHORT NewButtonData = MouseInput->RawButtons & Mask; + USHORT NewButtonData = (USHORT)(MouseInput->RawButtons & Mask); USHORT ButtonDiff = (NewButtonData ^ DevExt->MouseButtonState) & Mask; /* Note that the defines are such: @@ -404,7 +402,7 @@ VOID STDCALL I8042MouseHandleButtons(PDEVICE_EXTENSION DevExt, } VOID STDCALL I8042MouseHandle(PDEVICE_EXTENSION DevExt, - BYTE Output) + UCHAR Output) { PMOUSE_INPUT_DATA MouseInput = DevExt->MouseBuffer + DevExt->MouseInBuffer; @@ -515,10 +513,10 @@ VOID STDCALL I8042MouseHandle(PDEVICE_EXTENSION DevExt, BOOLEAN STDCALL I8042InterruptServiceMouse(struct _KINTERRUPT *Interrupt, VOID *Context) { - BYTE Output, PortStatus; + UCHAR Output, PortStatus; NTSTATUS Status; PDEVICE_EXTENSION DevExt = (PDEVICE_EXTENSION) Context; - UINT Iterations = 0; + ULONG Iterations = 0; do { Status = I8042ReadStatus(&PortStatus); @@ -616,7 +614,7 @@ VOID STDCALL I8042DpcRoutineMouse(PKDPC Dpc, if (!DevExt->MouseData.ClassService) return; - ((MOUSE_CLASS_SERVICE_CALLBACK) DevExt->MouseData.ClassService)( + ((PSERVICE_CALLBACK_ROUTINE) DevExt->MouseData.ClassService)( DevExt->MouseData.ClassDeviceObject, DevExt->MouseBuffer, DevExt->MouseBuffer + MouseInBufferCopy, diff --git a/reactos/drivers/input/i8042prt/ps2pp.c b/reactos/drivers/input/i8042prt/ps2pp.c index e7336497fb8..3b183ec8617 100644 --- a/reactos/drivers/input/i8042prt/ps2pp.c +++ b/reactos/drivers/input/i8042prt/ps2pp.c @@ -9,17 +9,15 @@ /* INCLUDES ****************************************************************/ -#include -#include -#include - +#ifndef NDEBUG #define NDEBUG +#endif #include #include "i8042prt.h" -VOID I8042MouseHandlePs2pp(PDEVICE_EXTENSION DevExt, BYTE Input) +VOID I8042MouseHandlePs2pp(PDEVICE_EXTENSION DevExt, UCHAR Input) { UCHAR PktType; PMOUSE_INPUT_DATA MouseInput = DevExt->MouseBuffer + diff --git a/reactos/drivers/input/i8042prt/registry.c b/reactos/drivers/input/i8042prt/registry.c index efdd1dc7f4f..09abbd6af8a 100644 --- a/reactos/drivers/input/i8042prt/registry.c +++ b/reactos/drivers/input/i8042prt/registry.c @@ -11,11 +11,9 @@ /* INCLUDES ****************************************************************/ -#include -#include -#include - +#ifndef NDEBUG #define NDEBUG +#endif #include #include "i8042prt.h" @@ -38,24 +36,24 @@ VOID STDCALL I8042ReadRegistry(PDRIVER_OBJECT DriverObject, NTSTATUS Status; - DWORD DefaultHeadless = 0; - DWORD DefaultCrashScroll = 0; - DWORD DefaultCrashSysRq = 0; - DWORD DefaultReportResetErrors = 0; - DWORD DefaultPollStatusIterations = 1; - DWORD DefaultResendIterations = 3; - DWORD DefaultPollingIterations = 12000; - DWORD DefaultPollingIterationsMaximum = 12000; - DWORD DefaultKeyboardDataQueueSize = 100; - DWORD DefaultOverrideKeyboardType = 0; - DWORD DefaultOverrideKeyboardSubtype = 0; - DWORD DefaultMouseDataQueueSize = 100; - DWORD DefaultMouseResendStallTime = 1000; - DWORD DefaultMouseSynchIn100ns = 20000000; - DWORD DefaultMouseResolution = 3; - DWORD DefaultSampleRate = 60; - DWORD DefaultNumberOfButtons = 2; - DWORD DefaultEnableWheelDetection = 1; + ULONG DefaultHeadless = 0; + ULONG DefaultCrashScroll = 0; + ULONG DefaultCrashSysRq = 0; + ULONG DefaultReportResetErrors = 0; + ULONG DefaultPollStatusIterations = 1; + ULONG DefaultResendIterations = 3; + ULONG DefaultPollingIterations = 12000; + ULONG DefaultPollingIterationsMaximum = 12000; + ULONG DefaultKeyboardDataQueueSize = 100; + ULONG DefaultOverrideKeyboardType = 0; + ULONG DefaultOverrideKeyboardSubtype = 0; + ULONG DefaultMouseDataQueueSize = 100; + ULONG DefaultMouseResendStallTime = 1000; + ULONG DefaultMouseSynchIn100ns = 20000000; + ULONG DefaultMouseResolution = 3; + ULONG DefaultSampleRate = 60; + ULONG DefaultNumberOfButtons = 2; + ULONG DefaultEnableWheelDetection = 1; RtlInitUnicodeString(&ParametersPath, NULL); ParametersPath.MaximumLength = (wcslen(RegistryPath) * @@ -212,15 +210,15 @@ VOID STDCALL I8042ReadRegistry(PDRIVER_OBJECT DriverObject, NULL); if (!NT_SUCCESS(Status)) { - DPRINT1 ("Can't read registry: %x\n", Status); /* Actually, the defaults are not set when the function * fails, as would happen during setup, so you have to * set them manually anyway... */ RTL_QUERY_REGISTRY_TABLE *Current = Parameters; + DPRINT1 ("Can't read registry: %x\n", Status); while (Current->Name) { - *((DWORD *)Current->EntryContext) = - *((DWORD *)Current->DefaultData); + *((PULONG)Current->EntryContext) = + *((PULONG)Current->DefaultData); Current++; } DPRINT1 ("Manually set defaults\n");