Major additions to usb stack:
1) Improve hardware support in linux_wrapper
2) Add embedded drivers, register them in linux usb stack
3) Add working wrapper for keyboard and mouse devices - now if usbohci
or uhci loads, it will be the first to create KeyboardClass0 and
PointerClass0 devices, so PS/2 keyb/mouse won't work.
4) Added logic for registering miniport at port driver (like Windows'
usb stack does)
Bad things:
1) "multithreading" is still done not the proper way, but ugly way
2) under xbox xpad doesn't work
3) it must be wasting lots of CPU power now, since hub thread doesn't
block while waiting for events
Modified: trunk/reactos/drivers/usb/cromwell/core/hcd-pci.c
Modified: trunk/reactos/drivers/usb/cromwell/core/hub.c
Modified: trunk/reactos/drivers/usb/cromwell/core/message.c
Modified: trunk/reactos/drivers/usb/cromwell/core/urb.c
Modified: trunk/reactos/drivers/usb/cromwell/core/usb.c
Modified: trunk/reactos/drivers/usb/cromwell/core/usbcore.c
Modified: trunk/reactos/drivers/usb/cromwell/core/usbcore.def
Modified: trunk/reactos/drivers/usb/cromwell/core/usbcore.xml
Modified: trunk/reactos/drivers/usb/cromwell/host/ohci_main.c
Modified: trunk/reactos/drivers/usb/cromwell/host/ohci_main.h
Modified: trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h
Modified: trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c
Modified: trunk/reactos/drivers/usb/cromwell/sys/ros_wrapper.c
Modified: trunk/reactos/drivers/usb/cromwell/sys/usbkey.c
Modified: trunk/reactos/drivers/usb/cromwell/usb_wrapper.h
_____
Modified: trunk/reactos/drivers/usb/cromwell/core/hcd-pci.c
--- trunk/reactos/drivers/usb/cromwell/core/hcd-pci.c 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/core/hcd-pci.c 2005-08-12
20:21:22 UTC (rev 17351)
@@ -33,7 +33,7 @@
#include <linux/usb.h>
#include "hcd.h"
#else
-#define DEBUG
+
#include "../usb_wrapper.h"
#include "hcd.h"
#endif
@@ -193,6 +193,10 @@
if ((retval = driver->start (hcd)) < 0)
usb_hcd_pci_remove (dev);
+ //ReactOS-specific: Init core drivers here
+ UsbKeyBoardInit();
+ UsbMouseInit();
+
return retval;
}
EXPORT_SYMBOL (usb_hcd_pci_probe);
_____
Modified: trunk/reactos/drivers/usb/cromwell/core/hub.c
--- trunk/reactos/drivers/usb/cromwell/core/hub.c 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/core/hub.c 2005-08-12
20:21:22 UTC (rev 17351)
@@ -7,7 +7,6 @@
* (C) Copyright 2001 Brad Hards (bhards(a)bigpond.net.au)
*
*/
-#define DEBUG
#if 0
#include <linux/config.h>
#include <linux/kernel.h>
@@ -34,11 +33,13 @@
#include "hcd.h"
#include "hub.h"
+
#else
+
#include "../usb_wrapper.h"
#include "hcd.h"
#include "hub.h"
-#define DEBUG
+
#endif
/* Wakes up khubd */
@@ -152,7 +153,7 @@
default: /* presumably an error */
/* Cause a hub reset after 10 consecutive errors */
- //printe("hub_irq got ...: error %d URB:
%d",hub->error,urb->status);
+ printk("hub_irq got ...: error %d URB:
%d",hub->error,urb->status);
dev_dbg (&hub->intf->dev, "transfer --> %d\n",
urb->status);
if ((++hub->nerrors < 10) || hub->error)
@@ -379,8 +380,8 @@
goto fail;
} else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) {
message = "hub has too many ports!";
- ret = -ENODEV;
- goto fail;
+ // XBOX PATCH hub->descriptor->bNbrPorts = 4;
//ret = -ENODEV;
+ //goto fail;
}
hub_dev = hubdev(dev);
@@ -517,6 +518,7 @@
/* Wake up khubd */
wake_up(&khubd_wait);
+ printk("hub_thread should woke up\n");
hub_power_on(hub);
@@ -597,7 +599,7 @@
/* specs is not defined, but it works */
if ((desc->desc.bInterfaceSubClass != 0) &&
(desc->desc.bInterfaceSubClass != 1)) {
-descriptor_error:
+//descriptor_error:
desc->desc.bInterfaceSubClass =0;
dev_err (&intf->dev, "bad descriptor, ignoring hub\n");
//return -EIO;
@@ -1208,6 +1210,8 @@
// ReactOS: STDCALL is needed here
static int STDCALL hub_thread(void *__hub)
{
+ //LARGE_INTEGER delay;
+
/*
* This thread doesn't need any user-level access,
* so get rid of all our resources
@@ -1219,6 +1223,11 @@
// Initialize khubd spinlock
KeInitializeSpinLock((PKSPIN_LOCK)&hub_event_lock);
+ //delay.QuadPart = -10000000*5; // wait 5 seconds before
powering up
+ //KeDelayExecutionThread(KernelMode, FALSE, &delay);
//wait_us(1);
+
+ printk("hub_thread starting");
+
/* Send me a signal to get me die (for debugging) */
do {
LARGE_INTEGER delay;
@@ -1226,7 +1235,7 @@
/* The following is just for debug */
inc_jiffies(1);
do_all_timers();
- handle_irqs(-1);
+ //handle_irqs(-1);
/* End of debug hack*/
hub_events();
/* The following is just for debug */
_____
Modified: trunk/reactos/drivers/usb/cromwell/core/message.c
--- trunk/reactos/drivers/usb/cromwell/core/message.c 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/core/message.c 2005-08-12
20:21:22 UTC (rev 17351)
@@ -40,7 +40,7 @@
struct usb_api_data awd;
int status;
- printk("usb_start_wait_urb(): urb devnum=%d, timeout=%d,
urb->actual_length=%d\n", urb->dev->devnum, timeout,
urb->actual_length);
+ //printk("usb_start_wait_urb(): urb devnum=%d, timeout=%d,
urb->actual_length=%d\n", urb->dev->devnum, timeout,
urb->actual_length);
init_waitqueue_head((PKEVENT)&awd.wqh);
awd.done = 0;
@@ -58,7 +58,7 @@
remove_wait_queue(&awd.wqh, &wait);
return status;
}
- printk("TRACE 3.1, timeout=%d, awd.done=%d\n", timeout,
awd.done);
+ //printk("TRACE 3.1, timeout=%d, awd.done=%d\n", timeout,
awd.done);
while (timeout && !awd.done)
{
timeout = schedule_timeout(timeout);
@@ -156,7 +156,7 @@
dr->wIndex = cpu_to_le16p(&index);
dr->wLength = cpu_to_le16p(&size);
- printk("usb_control_msg: devnum=%d, size=%d, timeout=%d\n",
dev->devnum, size, timeout);
+ //printk("usb_control_msg: devnum=%d, size=%d, timeout=%d\n",
dev->devnum, size, timeout);
ret = usb_internal_control_msg(dev, pipe, dr, data, size,
timeout);
kfree(dr);
_____
Modified: trunk/reactos/drivers/usb/cromwell/core/urb.c
--- trunk/reactos/drivers/usb/cromwell/core/urb.c 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/core/urb.c 2005-08-12
20:21:22 UTC (rev 17351)
@@ -201,8 +201,8 @@
struct usb_device *dev;
struct usb_operations *op;
int is_out;
- printk("sub dev %p bus %p num %i op %p sub %p\n",
- urb->dev,
urb->dev->bus,urb->dev->devnum,urb->dev->bus->op,
urb->dev->bus->op->submit_urb);
+ //printk("sub dev %p bus %p num %i op %p sub %p\n",
+ // urb->dev,
urb->dev->bus,urb->dev->devnum,urb->dev->bus->op,
urb->dev->bus->op->submit_urb);
if (!urb || urb->hcpriv || !urb->complete)
return -EINVAL;
if (!(dev = urb->dev) ||
_____
Modified: trunk/reactos/drivers/usb/cromwell/core/usb.c
--- trunk/reactos/drivers/usb/cromwell/core/usb.c 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/core/usb.c 2005-08-12
20:21:22 UTC (rev 17351)
@@ -54,8 +54,6 @@
#include "hcd.h"
#endif
-#define DEBUG
-
extern int usb_hub_init(void);
extern void usb_hub_cleanup(void);
extern int usb_major_init(void);
_____
Modified: trunk/reactos/drivers/usb/cromwell/core/usbcore.c
--- trunk/reactos/drivers/usb/cromwell/core/usbcore.c 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/core/usbcore.c 2005-08-12
20:21:22 UTC (rev 17351)
@@ -5,7 +5,18 @@
#include <ddk/ntddk.h>
#include <debug.h>
+#include "../usb_wrapper.h"
+USBPORT_INTERFACE UsbPortInterface;
+
+void STDCALL RegisterPortDriver(PDRIVER_OBJECT pDrvObj,
PUSBPORT_INTERFACE pUsbPortIntf)
+{
+ // copy struct to global var
+ DPRINT("Miniport 0x%08X registered\n", (ULONG)pDrvObj);
+ memcpy(&UsbPortInterface.KbdConnectData,
&pUsbPortIntf->KbdConnectData, sizeof(CONNECT_DATA));
+ memcpy(&UsbPortInterface.MouseConnectData,
&pUsbPortIntf->MouseConnectData, sizeof(CONNECT_DATA));
+}
+
NTSTATUS STDCALL
AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
{
_____
Modified: trunk/reactos/drivers/usb/cromwell/core/usbcore.def
--- trunk/reactos/drivers/usb/cromwell/core/usbcore.def 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/core/usbcore.def 2005-08-12
20:21:22 UTC (rev 17351)
@@ -29,4 +29,5 @@
usb_put_dev@4
usb_disabled@0
usb_hcd_pci_probe@8
-usb_hcd_pci_remove@4
\ No newline at end of file
+usb_hcd_pci_remove@4
+RegisterPortDriver@8
\ No newline at end of file
_____
Modified: trunk/reactos/drivers/usb/cromwell/core/usbcore.xml
--- trunk/reactos/drivers/usb/cromwell/core/usbcore.xml 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/core/usbcore.xml 2005-08-12
20:21:22 UTC (rev 17351)
@@ -2,6 +2,7 @@
<importlibrary definition="usbcore.def" />
<define name="__USE_W32API" />
<define name="DEBUG_MODE" />
+ <define name="DEBUG" />
<include base="ntoskrnl">include</include>
<library>sys_base</library>
<library>ntoskrnl</library>
@@ -16,5 +17,8 @@
<file>buffer_simple.c</file>
<file>usb-debug.c</file>
<file>usbcore.c</file>
+ <file>core_drivers/usbkey.c</file>
+ <file>core_drivers/usbmouse.c</file>
+
<file>usbcore.rc</file>
</module>
_____
Modified: trunk/reactos/drivers/usb/cromwell/host/ohci_main.c
--- trunk/reactos/drivers/usb/cromwell/host/ohci_main.c 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/host/ohci_main.c 2005-08-12
20:21:22 UTC (rev 17351)
@@ -5,6 +5,9 @@
*/
#include <ddk/ntddk.h>
+#include <ddk/ntddkbd.h>
+#include <ddk/ntdd8042.h>
+
#include <debug.h>
#include "../usb_wrapper.h"
#include "../core/hcd.h"
@@ -20,14 +23,74 @@
extern const struct pci_device_id pci_ids[];
-
// This should be removed, but for testing purposes it's here
struct pci_dev *dev;
//struct pci_device_id *dev_id;
+static bool xbox_workaround=false;
+// data for embedded drivers
+CONNECT_DATA KbdClassInformation;
+CONNECT_DATA MouseClassInformation;
+PDEVICE_OBJECT KeyboardFdo = NULL;
+PDEVICE_OBJECT MouseFdo = NULL;
+
#define USB_OHCI_TAG TAG('u','s','b','o')
+NTSTATUS AddDevice_Keyboard(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT
pdo)
+{
+ UNICODE_STRING DeviceName =
RTL_CONSTANT_STRING(L"\\Device\\KeyboardClass0");
+ PDEVICE_OBJECT fdo;
+ NTSTATUS Status;
+
+ Status = IoCreateDevice(DriverObject,
+ 8, // debug
+ &DeviceName,
+ FILE_DEVICE_KEYBOARD,
+ FILE_DEVICE_SECURE_OPEN,
+ TRUE,
+ &fdo);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("IoCreateDevice for usb keyboard driver
failed\n");
+ return Status;
+ }
+ KeyboardFdo = fdo;
+ fdo->Flags &= ~DO_DEVICE_INITIALIZING;
+ DPRINT1("Created keyboard fdo: %p\n", fdo);
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS AddDevice_Mouse(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT
pdo)
+{
+ UNICODE_STRING DeviceName =
RTL_CONSTANT_STRING(L"\\Device\\PointerClass0");
+ PDEVICE_OBJECT fdo;
+ NTSTATUS Status;
+
+ Status = IoCreateDevice(DriverObject,
+ 8, // debug
+ &DeviceName,
+ FILE_DEVICE_MOUSE,
+ FILE_DEVICE_SECURE_OPEN,
+ TRUE,
+ &fdo);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("IoCreateDevice for usb mouse driver failed\n");
+ return Status;
+ }
+ MouseFdo = fdo;
+ fdo->Flags &= ~DO_DEVICE_INITIALIZING;
+
+ DPRINT1("Created mouse fdo: %p\n", fdo);
+
+ return STATUS_SUCCESS;
+}
+
+
NTSTATUS STDCALL AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT
pdo)
{
PDEVICE_OBJECT fdo;
@@ -40,6 +103,11 @@
DPRINT1("ohci: AddDevice called\n");
+ if (xbox_workaround)
+ return STATUS_INSUFFICIENT_RESOURCES; // Fail for any
other host controller than the first
+
+ xbox_workaround = true;
+
// Allocate driver extension now
DriverExtension = IoGetDriverObjectExtension(DriverObject,
DriverObject);
if (DriverExtension == NULL)
@@ -105,9 +173,15 @@
}
DPRINT("Done AddDevice\n");
- return STATUS_SUCCESS;
+
+ // create embedded keyboard driver
+ Status = AddDevice_Keyboard(DriverObject, pdo);
+ Status = AddDevice_Mouse(DriverObject, pdo);
+
+ return Status;
}
+
VOID STDCALL DriverUnload(PDRIVER_OBJECT DriverObject)
{
DPRINT1("DriverUnload()\n");
@@ -196,6 +270,9 @@
NTSTATUS Status; // debug
LONGLONG delay; // debug
+ if (DeviceObject == KeyboardFdo || DeviceObject == MouseFdo)
+ return STATUS_SUCCESS;
+
/*
* Get the initialization data we saved in VideoPortInitialize.
*/
@@ -264,10 +341,12 @@
* Init wrapper with this object
*/
//return InitLinuxWrapper(DeviceObject);
+
+ // debug wait
Status = InitLinuxWrapper(DeviceObject);
- delay = -10000000*60*2; // wait 2 minutes
- KeDelayExecutionThread(KernelMode, FALSE, (LARGE_INTEGER
*)&delay); //wait_us(1);
+ //delay = -10000000*30; // wait 30 secs
+ //KeDelayExecutionThread(KernelMode, FALSE, (LARGE_INTEGER
*)&delay); //wait_us(1);
return Status;
}
@@ -280,6 +359,9 @@
IrpSp = IoGetCurrentIrpStackLocation(Irp);
+ DPRINT("PNP for %p, minorfunc=0x%x\n", DeviceObject,
IrpSp->MinorFunction);
+
+
switch (IrpSp->MinorFunction)
{
case IRP_MN_START_DEVICE:
@@ -331,16 +413,254 @@
return STATUS_SUCCESS;
}
+NTSTATUS STDCALL UsbCoreDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ ULONG MajorFunction =
IoGetCurrentIrpStackLocation(Irp)->MajorFunction;
+
+ DPRINT("usbohci: Dispatching major function 0x%lx\n",
MajorFunction);
+
+ IoCompleteRequest (Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+}
+
+
+NTSTATUS STDCALL UsbCoreInternalDeviceControl(PDEVICE_OBJECT
DeviceObject, PIRP Irp)
+{
+ NTSTATUS Status = STATUS_INVALID_DEVICE_REQUEST;
+
+ DPRINT("INT_IOCTL for %p, code=0x%x\n", DeviceObject,
IoGetCurrentIrpStackLocation(Irp)->Parameters.DeviceIoControl.IoControlC
ode);
+
+ if (DeviceObject == KeyboardFdo)
+ {
+ // it's keyboard's IOCTL
+ PIO_STACK_LOCATION Stk;
+
+ Irp->IoStatus.Information = 0;
+ Stk = IoGetCurrentIrpStackLocation(Irp);
+
+ switch (Stk->Parameters.DeviceIoControl.IoControlCode) {
+ case IOCTL_INTERNAL_KEYBOARD_CONNECT:
+
DPRINT("IOCTL_INTERNAL_KEYBOARD_CONNECT\n");
+ if
(Stk->Parameters.DeviceIoControl.InputBufferLength <
sizeof(CONNECT_DATA)) {
+ DPRINT1("Keyboard
IOCTL_INTERNAL_KEYBOARD_CONNECT "
+ "invalid buffer
size\n");
+ Irp->IoStatus.Status =
STATUS_INVALID_PARAMETER;
+ goto intcontfailure;
+ }
+
+ memcpy(&KbdClassInformation,
+
Stk->Parameters.DeviceIoControl.Type3InputBuffer,
+ sizeof(CONNECT_DATA));
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+
+ case IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER:
+
DPRINT("IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER\n");
+ if
(Stk->Parameters.DeviceIoControl.InputBufferLength < 1) {
+ Irp->IoStatus.Status =
STATUS_INVALID_PARAMETER;
+ goto intcontfailure;
+ }
+/* if (!DevExt->KeyboardInterruptObject) {
+ Irp->IoStatus.Status =
STATUS_DEVICE_NOT_READY;
+ goto intcontfailure;
+ }*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_QUERY_ATTRIBUTES:
+ DPRINT("IOCTL_KEYBOARD_QUERY_ATTRIBUTES\n");
+ if
(Stk->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof(KEYBOARD_ATTRIBUTES)) {
+ DPRINT("Keyboard
IOCTL_KEYBOARD_QUERY_ATTRIBUTES "
+ "invalid buffer
size\n");
+ Irp->IoStatus.Status =
STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+
/*memcpy(Irp->AssociatedIrp.SystemBuffer,
+ &DevExt->KeyboardAttributes,
+ sizeof(KEYBOARD_ATTRIBUTES));*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_QUERY_INDICATORS:
+ DPRINT("IOCTL_KEYBOARD_QUERY_INDICATORS\n");
+ if
(Stk->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof(KEYBOARD_INDICATOR_PARAMETERS)) {
+ DPRINT("Keyboard
IOCTL_KEYBOARD_QUERY_INDICATORS "
+ "invalid buffer
size\n");
+ Irp->IoStatus.Status =
STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+
/*memcpy(Irp->AssociatedIrp.SystemBuffer,
+ &DevExt->KeyboardIndicators,
+
sizeof(KEYBOARD_INDICATOR_PARAMETERS));*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_QUERY_TYPEMATIC:
+ DPRINT("IOCTL_KEYBOARD_QUERY_TYPEMATIC\n");
+ if
(Stk->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof(KEYBOARD_TYPEMATIC_PARAMETERS)) {
+ DPRINT("Keyboard
IOCTL_KEYBOARD_QUERY_TYPEMATIC "
+ "invalid buffer
size\n");
+ Irp->IoStatus.Status =
STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+
/*memcpy(Irp->AssociatedIrp.SystemBuffer,
+ &DevExt->KeyboardTypematic,
+
sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_SET_INDICATORS:
+ DPRINT("IOCTL_KEYBOARD_SET_INDICATORS\n");
+ if
(Stk->Parameters.DeviceIoControl.InputBufferLength <
+ sizeof(KEYBOARD_INDICATOR_PARAMETERS)) {
+ DPRINT("Keyboard
IOCTL_KEYBOARD_SET_INDICTATORS "
+ "invalid buffer
size\n");
+ Irp->IoStatus.Status =
STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+
+ /*memcpy(&DevExt->KeyboardIndicators,
+ Irp->AssociatedIrp.SystemBuffer,
+
sizeof(KEYBOARD_INDICATOR_PARAMETERS));*/
+
+ //DPRINT("%x\n",
DevExt->KeyboardIndicators.LedFlags);
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_SET_TYPEMATIC:
+ DPRINT("IOCTL_KEYBOARD_SET_TYPEMATIC\n");
+ if
(Stk->Parameters.DeviceIoControl.InputBufferLength <
+ sizeof(KEYBOARD_TYPEMATIC_PARAMETERS)) {
+ DPRINT("Keyboard
IOCTL_KEYBOARD_SET_TYPEMATIC "
+ "invalid buffer
size\n");
+ Irp->IoStatus.Status =
STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+
+ /*memcpy(&DevExt->KeyboardTypematic,
+ Irp->AssociatedIrp.SystemBuffer,
+
sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION:
+ /* We should check the UnitID, but it's kind of
pointless as
+ * all keyboards are supposed to have the
same one
+ */
+#if 0
+ if
(Stk->Parameters.DeviceIoControl.OutputBufferLength <
+
sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION)) {
+
DPRINT("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION: "
+ "invalid buffer size
(expected)\n");
+ /* It's to query the buffer
size */
+ Irp->IoStatus.Status =
STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+ Irp->IoStatus.Information =
+
sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION);
+#endif
+
/*memcpy(Irp->AssociatedIrp.SystemBuffer,
+ &IndicatorTranslation,
+
sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION));*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_INTERNAL_I8042_HOOK_KEYBOARD:
+ /* Nothing to do here */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ default:
+ Irp->IoStatus.Status =
STATUS_INVALID_DEVICE_REQUEST;
+ break;
+ }
+
+ intcontfailure:
+ Status = Irp->IoStatus.Status;
+ }
+ else if (DeviceObject == MouseFdo)
+ {
+ // it's mouse's IOCTL
+ PIO_STACK_LOCATION Stk;
+
+ Irp->IoStatus.Information = 0;
+ Stk = IoGetCurrentIrpStackLocation(Irp);
+
+ switch (Stk->Parameters.DeviceIoControl.IoControlCode) {
+ case IOCTL_INTERNAL_MOUSE_CONNECT:
+
DPRINT("IOCTL_INTERNAL_MOUSE_CONNECT\n");
+ if
(Stk->Parameters.DeviceIoControl.InputBufferLength <
sizeof(CONNECT_DATA)) {
+ DPRINT1("Mouse
IOCTL_INTERNAL_MOUSE_CONNECT "
+ "invalid buffer
size\n");
+ Irp->IoStatus.Status =
STATUS_INVALID_PARAMETER;
+ goto intcontfailure2;
+ }
+
+ memcpy(&MouseClassInformation,
+
Stk->Parameters.DeviceIoControl.Type3InputBuffer,
+ sizeof(CONNECT_DATA));
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+
+ default:
+ Irp->IoStatus.Status =
STATUS_SUCCESS;//STATUS_INVALID_DEVICE_REQUEST;
+ break;
+ }
+ intcontfailure2:
+ Status = Irp->IoStatus.Status;
+ }
+ else
+ {
+ DPRINT("We got IOCTL for UsbCore\n");
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+ }
+
+
+ if (Status == STATUS_INVALID_DEVICE_REQUEST) {
+ DPRINT1("Invalid internal device request!\n");
+ }
+
+ if (Status != STATUS_PENDING)
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return Status;
+}
+
+
/*
* Standard DriverEntry method.
*/
NTSTATUS STDCALL
DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath)
{
+ int i;
+ USBPORT_INTERFACE UsbPortInterface;
+
DriverObject->DriverUnload = DriverUnload;
DriverObject->DriverExtension->AddDevice = AddDevice;
+
+ for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
+ DriverObject->MajorFunction[i] = UsbCoreDispatch;
+
DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
+ DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
UsbCoreInternalDeviceControl;
+ // Register in usbcore.sys
+ UsbPortInterface.KbdConnectData = &KbdClassInformation;
+ UsbPortInterface.MouseConnectData = &MouseClassInformation;
+
+ KbdClassInformation.ClassService = NULL;
+ KbdClassInformation.ClassDeviceObject = NULL;
+ MouseClassInformation.ClassService = NULL;
+ MouseClassInformation.ClassDeviceObject = NULL;
+
+ RegisterPortDriver(DriverObject, &UsbPortInterface);
+
return STATUS_SUCCESS;
}
_____
Modified: trunk/reactos/drivers/usb/cromwell/host/ohci_main.h
--- trunk/reactos/drivers/usb/cromwell/host/ohci_main.h 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/host/ohci_main.h 2005-08-12
20:21:22 UTC (rev 17351)
@@ -62,5 +62,7 @@
PDEVICE_OBJECT RootHubPdo;
} OHCI_DEVICE_EXTENSION, *POHCI_DEVICE_EXTENSION;
+#define IOCTL_INTERNAL_KEYBOARD_CONNECT \
+ CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0080, METHOD_NEITHER,
FILE_ANY_ACCESS)
#endif
_____
Modified: trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h
--- trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h
2005-08-12 20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h
2005-08-12 20:21:22 UTC (rev 17351)
@@ -703,13 +703,12 @@
/*----------------------------------------------------------------------
--*/
void STDCALL usb_hcd_pci_remove (struct pci_dev *dev);
-#define my_wait_ms(x) wait_ms(x)
+#define my_wait_ms(x) wait_ms(x) // milliseconds
-#define my_udelay(x) wait_ms(x)
-#define udelay(x) my_udelay(x)
+#define udelay(x) my_udelay(x) // microseconds
#define my_mdelay(x) wait_ms(1+x/1000);
-#define mdelay(x) my_mdelay(x);
+#define mdelay(x) my_mdelay(x); // milliseconds = udelay(1000*x)
#define pci_find_slot(a,b) my_pci_find_slot(a,b)
struct pci_dev *my_pci_find_slot(int a,int b);
@@ -851,3 +850,7 @@
int my_pci_write_config_word(struct pci_dev *, int, u16);
+void UsbKeyBoardInit(void);
+void UsbKeyBoardRemove(void);
+void UsbMouseInit(void);
+void UsbMouseRemove(void);
_____
Modified: trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c
--- trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c
2005-08-12 20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c
2005-08-12 20:21:22 UTC (rev 17351)
@@ -258,7 +258,7 @@
x+=5; // safety
x = x*1000; // to us format
*/
- x = 300; // it's enough for most purposes
+ x = 50; // it's enough for most purposes
while(x>0)
{
@@ -701,7 +701,7 @@
if ((i + block) < pool->blocks_per_page)
{
- DPRINT("pci_pool_alloc(): Allocating
block %p:%d:%d:%d\n", pool, page, map, block);
+ //DPRINT("pci_pool_alloc(): Allocating
block %p:%d:%d:%d\n", pool, page, map, block);
clear_bit(block,
&pool->pages[page].bitmap[map]);
offset = (BITS_PER_LONG * map) + block;
offset *= pool->size;
@@ -763,7 +763,7 @@
set_bit (block, &pool->pages[page].bitmap[map]);
pool->blocks_allocated--;
- DPRINT("pci_pool_free(): alloc'd: %d\n",
pool->blocks_allocated);
+ //DPRINT("pci_pool_free(): alloc'd: %d\n",
pool->blocks_allocated);
}
/*
_____
Modified: trunk/reactos/drivers/usb/cromwell/sys/ros_wrapper.c
--- trunk/reactos/drivers/usb/cromwell/sys/ros_wrapper.c
2005-08-12 20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/sys/ros_wrapper.c
2005-08-12 20:21:22 UTC (rev 17351)
@@ -5,6 +5,20 @@
{
LARGE_INTEGER Interval;
- Interval.QuadPart = -mils*10;
+ DPRINT1("wait_ms(%d)\n", mils);
+
+ Interval.QuadPart = -(mils+1)*10000;
KeDelayExecutionThread(KernelMode, FALSE, &Interval);
+
+// schedule_timeout(1 + mils * HZ / 1000);
}
+
+void my_udelay(int us)
+{
+ LARGE_INTEGER Interval;
+
+ DPRINT1("udelay(%d)\n", us);
+
+ Interval.QuadPart = -us*10;
+ KeDelayExecutionThread(KernelMode, FALSE, &Interval);
+}
_____
Modified: trunk/reactos/drivers/usb/cromwell/sys/usbkey.c
--- trunk/reactos/drivers/usb/cromwell/sys/usbkey.c 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/sys/usbkey.c 2005-08-12
20:21:22 UTC (rev 17351)
@@ -1,9 +1,9 @@
#include "../usb_wrapper.h"
-#define keyboarddebug 0
+#define keyboarddebug 1
#if keyboarddebug
-extern int printe(const char *szFormat, ...);
+//extern int printk(const char *szFormat, ...);
int ycoffset = 0;
#endif
@@ -28,7 +28,7 @@
static void usb_kbd_irq(struct urb *urb, struct pt_regs *regs)
{
struct usb_kbd_info *kbd = urb->context;
- int i;
+ //int i;
if (urb->status) return;
@@ -38,11 +38,11 @@
#if keyboarddebug
- ycoffset += 15;
- ycoffset = ycoffset % 600;
- VIDEO_CURSOR_POSX=20;
- VIDEO_CURSOR_POSY=ycoffset;
- printe(" -%02x %02x %02x %02x %02x
%02x\n",kbd->kbd_pkt[0],kbd->kbd_pkt[1],kbd->kbd_pkt[2],kbd->kbd_pkt[3],
kbd->kbd_pkt[4],kbd->kbd_pkt[5]);
+ //ycoffset += 15;
+ //ycoffset = ycoffset % 600;
+ //VIDEO_CURSOR_POSX=20;
+ //VIDEO_CURSOR_POSY=ycoffset;
+ printk(" -%02x %02x %02x %02x %02x
%02x\n",kbd->kbd_pkt[0],kbd->kbd_pkt[1],kbd->kbd_pkt[2],kbd->kbd_pkt[3],
kbd->kbd_pkt[4],kbd->kbd_pkt[5]);
#endif
usb_submit_urb(urb,GFP_ATOMIC);
@@ -54,11 +54,11 @@
struct urb *urb;
struct usb_device *udev = interface_to_usbdev (intf);
struct usb_endpoint_descriptor *ep_irq_in;
- struct usb_endpoint_descriptor *ep_irq_out;
+ //struct usb_endpoint_descriptor *ep_irq_out;
struct usb_kbd_info *usbk;
- int i, pipe, maxp;
- char *buf;
+ //int i, pipe, maxp;
+ //char *buf;
usbk=(struct usb_kbd_info *)kmalloc(sizeof(struct
usb_kbd_info),0);
if (!usbk) return -1;
@@ -77,8 +77,10 @@
usb_submit_urb(urb,GFP_ATOMIC);
usb_set_intfdata(intf,usbk);
#if keyboarddebug
- printe("USB Keyboard Connected\n");
+ printk("USB Keyboard Connected\n");
#endif
+
+ return 0;
}
@@ -107,12 +109,11 @@
void UsbKeyBoardInit(void)
{
-
//current_remote_key=0;
//sbprintk("Keyboard probe %p ",xremote_probe);
if (usb_register(&usb_kbd_driver) < 0) {
#if keyboarddebug
- printe("Unable to register Keyboard driver");
+ printk("Unable to register Keyboard driver");
#endif
return;
}
_____
Modified: trunk/reactos/drivers/usb/cromwell/usb_wrapper.h
--- trunk/reactos/drivers/usb/cromwell/usb_wrapper.h 2005-08-12
20:11:56 UTC (rev 17350)
+++ trunk/reactos/drivers/usb/cromwell/usb_wrapper.h 2005-08-12
20:21:22 UTC (rev 17351)
@@ -1,13 +1,31 @@
//#include <stdlib.h>
//#include <ntos/types.h>
//#include <ddk/extypes.h>
+
+/*
+ TODO: Do a major cleanup of this file!
+ Lots of definitions should go to corresponding files
+*/
+
#include <ddk/ntddk.h>
+#include <ddk/kbdmou.h>
#include <debug.h>
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) +
((D)<<24))
void wait_ms(int mils);
+void my_udelay(int us);
+// For now this is needed only for correct operation of embedded
keyboard and mouse drvs
+typedef struct _USBPORT_INTERFACE
+{
+ PCONNECT_DATA KbdConnectData;
+ PCONNECT_DATA MouseConnectData;
+} USBPORT_INTERFACE, *PUSBPORT_INTERFACE;
+
+// Register in usbcore.sys
+void STDCALL RegisterPortDriver(PDRIVER_OBJECT, PUSBPORT_INTERFACE);
+
#ifndef _snprintf
int _snprintf(char * buf, size_t cnt, const char *fmt, ...);
#endif