阅读:1392回复:3
调试驱动时出现的问题
我在用softice调试驱动时,发现单步运行总是在几条语句里,根本执行不到程序里面。不知道有那位知道,能否指点一二。谢谢了!
|
|
沙发#
发布于:2004-08-11 18:26
贴出你的原代码及相应的汇编代码。
|
|
|
板凳#
发布于:2004-08-11 20:16
haha,是在一个循环里把,除了单步还有跳出循环和函数呀
|
|
|
地板#
发布于:2004-08-12 15:40
我看来是得好好看看softice的命令了.还想问一下,调试驱动是不是还要先编好一个应用程序呀?以下是我的源程序:
一共有usbtest.rc \ usbtest.c\ Init.c\ Power.c\ Pnp.c\ Dispatch.c\ loader.c\ firmware.c 等程序 ////////////////////////////////////////////////////////////////////////////// // Ezusb Camera Driver ///////////////////////////////////////////////////////////////////////////// // dispatch.c: I/O IRP handlers ///////////////////////////////////////////////////////////////////////////// // Ezusb_Create CreateFile calls // Ezusb_Close CloseHandle calls ///////////////////////////////////////////////////////////////////////////// // Version history // 15-Oct-2002 1.0.0 FJX creation ///////////////////////////////////////////////////////////////////////////// #include <wdm.h> #include "stdarg.h" #include "stdio.h" #include "usbdi.h" #include "usbdlib.h" #include "usbtest.h" ///////////////////////////////////////////////////////////////////////////// // Ezusb_Create: // // Description: // Handle IRP_MJ_CREATE requests // // Arguments: // Pointer to our FDO // Pointer to the IRP // IrpStack->Parameters.Create.xxx has create parameters // IrpStack->FileObject->FileName has file name of device // // Return Value: // This function returns STATUS_XXX //////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_Create( IN PDEVICE_OBJECT fdo, IN PIRP Irp) { NTSTATUS ntStatus; PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION )fdo->DeviceExtension; Ezusb_KdPrint(("Enter Ezusb_Create()\n")); if (!pdx->Started) { return STATUS_UNSUCCESSFUL; } // increment the open handle counter pdx->OpenHandles++; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0; // Create all the symbolic links here ntStatus = Irp->IoStatus.Status; IoCompleteRequest (Irp, IO_NO_INCREMENT ); return ntStatus; } ///////////////////////////////////////////////////////////////////////////// // Ezusb_Close: // // Description: // Handle IRP_MJ_CLOSE requests // Allow closes to complete if device not started // // Arguments: // Pointer to our FDO // Pointer to the IRP // // Return Value: // This function returns STATUS_XXX /////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_Close( IN PDEVICE_OBJECT fdo, IN PIRP Irp) { NTSTATUS ntStatus; PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION )fdo->DeviceExtension; Ezusb_KdPrint(("Enter Ezusb_Close()\n")); // decrement the open handle counter pdx->OpenHandles--; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0; ntStatus = Irp->IoStatus.Status; IoCompleteRequest (Irp, IO_NO_INCREMENT ); return ntStatus; } ////////////////////////////////////////////////////////////////////////////// // Ezusb Camera Driver ///////////////////////////////////////////////////////////////////////////// // firmware.c: The firmware array below should be replaced with your own firmware. ///////////////////////////////////////////////////////////////////////////// // Version history // 15-Oct-2002 1.0.0 FJX creation ///////////////////////////////////////////////////////////////////////////// #include <wdm.h> #include "usbdi.h" #include "usbdlib.h" #include "usbtest.h" INTEL_HEX_RECORD firmware[] = { 16, 0x5d4, 0, {0x90,0x7f,0xde,0x74,0x04,0xf0,0xe4,0x90,0x7f,0xdd,0xf0,0x90,0x7f,0xb2,0x74,0x05}, 16, 0x5e4, 0, {0xf0,0xa3,0x74,0x45,0xf0,0x90,0x7f,0xaf,0xe0,0x44,0x02,0xf0,0xe0,0x54,0xfb,0xf0}, 1, 0x5f4, 0, {0x22}, 16, 0x545, 0, {0x75,0x2d,0x20,0x75,0x2e,0x00,0x90,0x7f,0xb8,0xe0,0x20,0xe1,0x2e,0x90,0x7f,0x93}, 16, 0x555, 0, {0xe0,0x44,0x20,0xf0,0x90,0x7f,0xe2,0x74,0x40,0xf0,0x90,0x7f,0xe3,0x74,0x7e,0xf0}, 16, 0x565, 0, {0x90,0x7f,0xe4,0x74,0x00,0xf0,0x90,0x7f,0xe5,0x7f,0x08,0xf0,0xf0,0xf0,0xf0,0xf0}, 12, 0x575, 0, {0xf0,0xf0,0xf0,0xdf,0xf6,0x90,0x7f,0xb9,0x74,0x40,0xf0,0x22}, 9, 0x5f5, 0, {0x90,0x7f,0xaf,0xe0,0x44,0x08,0xf0,0xd3,0x22}, 2, 0x5fe, 0, {0xd3,0x22}, 2, 0x731, 0, {0xd3,0x22}, 8, 0x721, 0, {0x90,0x7f,0xea,0xe0,0xf5,0x0f,0xd3,0x22}, 14, 0x705, 0, {0x90,0x7f,0x00,0xe5,0x0f,0xf0,0x90,0x7f,0xb5,0x74,0x01,0xf0,0xd3,0x22}, 8, 0x729, 0, {0x90,0x7f,0xea,0xe0,0xf5,0x0e,0xd3,0x22}, 14, 0x713, 0, {0x90,0x7f,0x00,0xe5,0x0e,0xf0,0x90,0x7f,0xb5,0x74,0x01,0xf0,0xd3,0x22}, 2, 0x733, 0, {0xd3,0x22}, 2, 0x735, 0, {0xd3,0x22}, 2, 0x737, 0, {0xd3,0x22}, 2, 0x739, 0, {0xd3,0x22}, 16, 0x693, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0xd2,0x01,0x53,0x91,0xef,0x90,0x7f,0xab,0x74,0x01}, 8, 0x6a3, 0, {0xf0,0xd0,0x82,0xd0,0x83,0xd0,0xe0,0x32}, 16, 0x6c3, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0x53,0x91,0xef,0x90,0x7f,0xab,0x74,0x04,0xf0,0xd0}, 6, 0x6d3, 0, {0x82,0xd0,0x83,0xd0,0xe0,0x32}, 16, 0x6d9, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0x53,0x91,0xef,0x90,0x7f,0xab,0x74,0x02,0xf0,0xd0}, 6, 0x6e9, 0, {0x82,0xd0,0x83,0xd0,0xe0,0x32}, 16, 0x6ef, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0x53,0x91,0xef,0x90,0x7f,0xab,0x74,0x10,0xf0,0xd0}, 6, 0x6ff, 0, {0x82,0xd0,0x83,0xd0,0xe0,0x32}, 1, 0x42, 0, {0x32}, 16, 0x6ab, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0xd2,0x03,0x53,0x91,0xef,0x90,0x7f,0xab,0x74,0x08}, 8, 0x6bb, 0, {0xf0,0xd0,0x82,0xd0,0x83,0xd0,0xe0,0x32}, 1, 0x73b, 0, {0x32}, 1, 0x73c, 0, {0x32}, 1, 0x73d, 0, {0x32}, 1, 0x73e, 0, {0x32}, 1, 0x73f, 0, {0x32}, 1, 0x740, 0, {0x32}, 1, 0x741, 0, {0x32}, 1, 0x742, 0, {0x32}, 1, 0x743, 0, {0x32}, 1, 0x744, 0, {0x32}, 1, 0x745, 0, {0x32}, 1, 0x746, 0, {0x32}, 1, 0x747, 0, {0x32}, 1, 0x748, 0, {0x32}, 1, 0x749, 0, {0x32}, 1, 0x74a, 0, {0x32}, 16, 0x495, 0, {0x12,0x01,0x00,0x01,0x00,0x00,0x00,0x40,0x47,0x05,0x02,0x10,0x01,0x00,0x00,0x00}, 16, 0x4a5, 0, {0x00,0x01,0x09,0x02,0x20,0x00,0x01,0x01,0x00,0xa0,0x00,0x09,0x04,0x00,0x00,0x02}, 16, 0x4b5, 0, {0xff,0x00,0x00,0x00,0x07,0x05,0x02,0x02,0x40,0x00,0x00,0x07,0x05,0x82,0x02,0x40}, 16, 0x4c5, 0, {0x00,0x00,0x04,0x03,0x09,0x04,0x1a,0x03,0x41,0x00,0x6e,0x00,0x63,0x00,0x68,0x00}, 16, 0x4d5, 0, {0x6f,0x00,0x72,0x00,0x20,0x00,0x43,0x00,0x68,0x00,0x69,0x00,0x70,0x00,0x73,0x00}, 16, 0x4e5, 0, {0x1c,0x03,0x45,0x00,0x5a,0x00,0x2d,0x00,0x55,0x00,0x53,0x00,0x42,0x00,0x20,0x00}, 14, 0x4f5, 0, {0x44,0x00,0x65,0x00,0x76,0x00,0x69,0x00,0x63,0x00,0x65,0x00,0x00,0x00}, 16, 0x340, 0, {0xc2,0x03,0xc2,0x00,0xc2,0x02,0xc2,0x01,0x12,0x05,0xd4,0x7e,0x04,0x7f,0x95,0x8e}, 16, 0x350, 0, {0x08,0x8f,0x09,0x75,0x0a,0x04,0x75,0x0b,0xa7,0x75,0x0c,0x04,0x75,0x0d,0xc7,0xee}, 16, 0x360, 0, {0x54,0xe0,0x70,0x03,0x02,0x04,0x4b,0x75,0x29,0x00,0x75,0x2a,0x80,0x8e,0x2b,0x8f}, 16, 0x370, 0, {0x2c,0xc3,0x74,0x01,0x9f,0xff,0x74,0x05,0x9e,0xcf,0x24,0x02,0xcf,0x34,0x00,0xfe}, 16, 0x380, 0, {0xe4,0x8f,0x28,0x8e,0x27,0xf5,0x26,0xf5,0x25,0xf5,0x24,0xf5,0x23,0xf5,0x22,0xf5}, 16, 0x390, 0, {0x21,0xaf,0x28,0xae,0x27,0xad,0x26,0xac,0x25,0xab,0x24,0xaa,0x23,0xa9,0x22,0xa8}, 16, 0x3a0, 0, {0x21,0xc3,0x12,0x05,0x9a,0x50,0x2a,0xe5,0x2a,0x25,0x24,0xf5,0x82,0xe5,0x29,0x35}, 16, 0x3b0, 0, {0x23,0xf5,0x83,0x74,0xcd,0xf0,0xe4,0xfa,0xf9,0xf8,0xe5,0x24,0x24,0x01,0xf5,0x24}, 16, 0x3c0, 0, {0xea,0x35,0x23,0xf5,0x23,0xe9,0x35,0x22,0xf5,0x22,0xe8,0x35,0x21,0xf5,0x21,0x80}, 16, 0x3d0, 0, {0xc0,0xe4,0xf5,0x24,0xf5,0x23,0xf5,0x22,0xf5,0x21,0xaf,0x28,0xae,0x27,0xad,0x26}, 16, 0x3e0, 0, {0xac,0x25,0xab,0x24,0xaa,0x23,0xa9,0x22,0xa8,0x21,0xc3,0x12,0x05,0x9a,0x50,0x35}, 16, 0x3f0, 0, {0xae,0x23,0xaf,0x24,0xe5,0x2c,0x2f,0xf5,0x82,0xe5,0x2b,0x3e,0xf5,0x83,0xe0,0xfd}, 16, 0x400, 0, {0xe5,0x2a,0x2f,0xf5,0x82,0xe5,0x29,0x3e,0xf5,0x83,0xed,0xf0,0xe4,0xfa,0xf9,0xf8}, 16, 0x410, 0, {0xef,0x24,0x01,0xf5,0x24,0xea,0x3e,0xf5,0x23,0xe9,0x35,0x22,0xf5,0x22,0xe8,0x35}, 16, 0x420, 0, {0x21,0xf5,0x21,0x80,0xb5,0x85,0x29,0x08,0x85,0x2a,0x09,0x74,0x95,0x24,0x80,0xff}, 16, 0x430, 0, {0x74,0x04,0x34,0xff,0xfe,0xc3,0xe5,0x0b,0x9f,0xf5,0x0b,0xe5,0x0a,0x9e,0xf5,0x0a}, 16, 0x440, 0, {0xc3,0xe5,0x0d,0x9f,0xf5,0x0d,0xe5,0x0c,0x9e,0xf5,0x0c,0xd2,0xe8,0x43,0xd8,0x20}, 16, 0x450, 0, {0x90,0x7f,0x95,0xe0,0x44,0xc0,0xf0,0x90,0x7f,0xaf,0xe0,0x44,0x01,0xf0,0x90,0x7f}, 16, 0x460, 0, {0xae,0xe0,0x44,0x1d,0xf0,0xd2,0xaf,0x53,0x8e,0xf8,0x30,0x01,0x05,0x12,0x00,0x46}, 16, 0x470, 0, {0xc2,0x01,0x30,0x03,0x1a,0x12,0x05,0xf5,0x50,0x15,0xc2,0x03,0x12,0x06,0x58,0x20}, 16, 0x480, 0, {0x00,0x07,0x90,0x7f,0xd6,0xe0,0x20,0xe7,0xf3,0x12,0x06,0x79,0x12,0x05,0xfe,0x12}, 4, 0x490, 0, {0x05,0x45,0x80,0xd6}, 1, 0x494, 0, {0x22}, 16, 0x46, 0, {0x90,0x7f,0xe9,0xe0,0x70,0x03,0x02,0x01,0xe5,0x14,0x70,0x03,0x02,0x02,0x61,0x24}, 16, 0x56, 0, {0xfe,0x70,0x03,0x02,0x02,0xd8,0x24,0xfb,0x70,0x03,0x02,0x01,0xdf,0x14,0x70,0x03}, 16, 0x66, 0, {0x02,0x01,0xd9,0x14,0x70,0x03,0x02,0x01,0xcd,0x14,0x70,0x03,0x02,0x01,0xd3,0x24}, 16, 0x76, 0, {0x05,0x60,0x03,0x02,0x03,0x2c,0x12,0x07,0x31,0x40,0x03,0x02,0x03,0x38,0x90,0x7f}, 16, 0x86, 0, {0xeb,0xe0,0x24,0xfe,0x60,0x19,0x14,0x60,0x45,0x24,0x02,0x60,0x03,0x02,0x01,0xc3}, 16, 0x96, 0, {0xe5,0x08,0x90,0x7f,0xd4,0xf0,0xe5,0x09,0x90,0x7f,0xd5,0xf0,0x02,0x03,0x38,0x90}, 16, 0xa6, 0, {0x7f,0xea,0xe0,0xff,0x12,0x05,0x03,0xaa,0x06,0xa9,0x07,0x7b,0x01,0x8b,0x2d,0x8a}, 16, 0xb6, 0, {0x2e,0x89,0x2f,0xea,0x49,0x60,0x0d,0xee,0x90,0x7f,0xd4,0xf0,0xef,0x90,0x7f,0xd5}, 16, 0xc6, 0, {0xf0,0x02,0x03,0x38,0x90,0x7f,0xb4,0xe0,0x44,0x01,0xf0,0x02,0x03,0x38,0x90,0x7f}, 16, 0xd6, 0, {0xea,0xe0,0xff,0x12,0x00,0x03,0xaa,0x06,0xa9,0x07,0x7b,0x01,0x8b,0x2d,0x8a,0x2e}, 9, 0xe6, 0, {0x89,0x2f,0xea,0x49,0x70,0x03,0x02,0x01,0xb9}, 16, 0xef, 0, {0xab,0x2d,0x8b,0x34,0x8a,0x35,0x89,0x36,0x12,0x05,0x81,0xf5,0x37,0x90,0x7f,0xee}, 16, 0xff, 0, {0xe0,0xff,0xe5,0x37,0xd3,0x9f,0x40,0x03,0xe0,0xf5,0x37,0xe5,0x37,0x70,0x03,0x02}, 16, 0x10f, 0, {0x01,0xab,0xe4,0xf5,0x33,0xf5,0x32,0xf5,0x31,0xf5,0x30,0xe5,0x37,0xc3,0x94,0x40}, 16, 0x11f, 0, {0x50,0x04,0xaf,0x37,0x80,0x02,0x7f,0x40,0xe4,0xfc,0xfd,0xfe,0xab,0x33,0xaa,0x32}, 16, 0x12f, 0, {0xa9,0x31,0xa8,0x30,0xc3,0x12,0x05,0x9a,0x50,0x36,0xe5,0x36,0x25,0x33,0xf5,0x82}, 16, 0x13f, 0, {0xe5,0x35,0x35,0x32,0xf5,0x83,0xe0,0xff,0x74,0x00,0x25,0x33,0xf5,0x82,0xe4,0x34}, 16, 0x14f, 0, {0x7f,0xf5,0x83,0xef,0xf0,0xe4,0xfa,0xf9,0xf8,0xe5,0x33,0x24,0x01,0xf5,0x33,0xea}, 16, 0x15f, 0, {0x35,0x32,0xf5,0x32,0xe9,0x35,0x31,0xf5,0x31,0xe8,0x35,0x30,0xf5,0x30,0x80,0xab}, 16, 0x16f, 0, {0xe5,0x37,0xc3,0x94,0x40,0x50,0x04,0xaf,0x37,0x80,0x02,0x7f,0x40,0x90,0x7f,0xb5}, 16, 0x17f, 0, {0xef,0xf0,0xe5,0x37,0xc3,0x94,0x40,0x50,0x04,0xaf,0x37,0x80,0x02,0x7f,0x40,0xc3}, 16, 0x18f, 0, {0xe5,0x37,0x9f,0xf5,0x37,0x74,0x40,0x25,0x36,0xf5,0x36,0xe4,0x35,0x35,0xf5,0x35}, 16, 0x19f, 0, {0x90,0x7f,0xb4,0xe0,0x20,0xe2,0x03,0x02,0x01,0x0a,0x80,0xf4,0xe4,0x90,0x7f,0xb5}, 7, 0x1af, 0, {0xf0,0x90,0x7f,0xb4,0x74,0x02,0xf0}, 16, 0x1b6, 0, {0x02,0x03,0x38,0x90,0x7f,0xb4,0xe0,0x44,0x01,0xf0,0x02,0x03,0x38,0x90,0x7f,0xb4}, 16, 0x1c6, 0, {0xe0,0x44,0x01,0xf0,0x02,0x03,0x38,0x12,0x07,0x13,0x02,0x03,0x38,0x12,0x07,0x29}, 16, 0x1d6, 0, {0x02,0x03,0x38,0x12,0x07,0x21,0x02,0x03,0x38,0x12,0x07,0x05,0x02,0x03,0x38,0x12}, 16, 0x1e6, 0, {0x07,0x33,0x40,0x03,0x02,0x03,0x38,0x90,0x7f,0xe8,0xe0,0x24,0x7f,0x60,0x24,0x14}, 16, 0x1f6, 0, {0x60,0x31,0x24,0x02,0x70,0x5b,0xa2,0x00,0xe4,0x33,0xff,0x25,0xe0,0xff,0xa2,0x02}, 16, 0x206, 0, {0xe4,0x33,0x4f,0x90,0x7f,0x00,0xf0,0xe4,0xa3,0xf0,0x90,0x7f,0xb5,0x74,0x02,0xf0}, 16, 0x216, 0, {0x02,0x03,0x38,0xe4,0x90,0x7f,0x00,0xf0,0xa3,0xf0,0x90,0x7f,0xb5,0x74,0x02,0xf0}, 16, 0x226, 0, {0x02,0x03,0x38,0x90,0x7f,0xec,0xe0,0xf4,0x54,0x80,0xff,0xc4,0x54,0x0f,0xff,0xe0}, 16, 0x236, 0, {0x54,0x07,0x2f,0x25,0xe0,0x24,0xb4,0xf5,0x82,0xe4,0x34,0x7f,0xf5,0x83,0xe0,0x54}, 16, 0x246, 0, {0x01,0x90,0x7f,0x00,0xf0,0xe4,0xa3,0xf0,0x90,0x7f,0xb5,0x74,0x02,0xf0,0x02,0x03}, 16, 0x256, 0, {0x38,0x90,0x7f,0xb4,0xe0,0x44,0x01,0xf0,0x02,0x03,0x38,0x12,0x07,0x35,0x40,0x03}, 16, 0x266, 0, {0x02,0x03,0x38,0x90,0x7f,0xe8,0xe0,0x24,0xfe,0x60,0x1d,0x24,0x02,0x60,0x03,0x02}, 16, 0x276, 0, {0x03,0x38,0x90,0x7f,0xea,0xe0,0xb4,0x01,0x05,0xc2,0x00,0x02,0x03,0x38,0x90,0x7f}, 16, 0x286, 0, {0xb4,0xe0,0x44,0x01,0xf0,0x02,0x03,0x38,0x90,0x7f,0xea,0xe0,0x70,0x3b,0x90,0x7f}, 16, 0x296, 0, {0xec,0xe0,0xf4,0x54,0x80,0xff,0xc4,0x54,0x0f,0xff,0xe0,0x54,0x07,0x2f,0x25,0xe0}, 16, 0x2a6, 0, {0x24,0xb4,0xf5,0x82,0xe4,0x34,0x7f,0xf5,0x83,0xe4,0xf0,0x90,0x7f,0xec,0xe0,0x54}, 16, 0x2b6, 0, {0x80,0xff,0x13,0x13,0x13,0x54,0x1f,0xff,0xe0,0x54,0x07,0x2f,0x90,0x7f,0xd7,0xf0}, 3, 0x2c6, 0, {0xe4,0xf5,0x34}, 16, 0x2c9, 0, {0xe0,0x44,0x20,0xf0,0x80,0x69,0x90,0x7f,0xb4,0xe0,0x44,0x01,0xf0,0x80,0x60,0x12}, 16, 0x2d9, 0, {0x07,0x37,0x50,0x5b,0x90,0x7f,0xe8,0xe0,0x24,0xfe,0x60,0x18,0x24,0x02,0x70,0x4f}, 16, 0x2e9, 0, {0x90,0x7f,0xea,0xe0,0xb4,0x01,0x04,0xd2,0x00,0x80,0x44,0x90,0x7f,0xb4,0xe0,0x44}, 16, 0x2f9, 0, {0x01,0xf0,0x80,0x3b,0x90,0x7f,0xea,0xe0,0x70,0x20,0x90,0x7f,0xec,0xe0,0xf4,0x54}, 16, 0x309, 0, {0x80,0xff,0xc4,0x54,0x0f,0xff,0xe0,0x54,0x07,0x2f,0x25,0xe0,0x24,0xb4,0xf5,0x82}, 16, 0x319, 0, {0xe4,0x34,0x7f,0xf5,0x83,0x74,0x01,0xf0,0x80,0x15,0x90,0x7f,0xb4,0xe0,0x44,0x01}, 16, 0x329, 0, {0xf0,0x80,0x0c,0x12,0x07,0x39,0x50,0x07,0x90,0x7f,0xb4,0xe0,0x44,0x01,0xf0,0x90}, 6, 0x339, 0, {0x7f,0xb4,0xe0,0x44,0x02,0xf0}, 1, 0x33f, 0, {0x22}, 3, 0x33, 0, {0x02,0x00,0x2f}, 4, 0x2f, 0, {0x53,0xd8,0xef,0x32}, 16, 0x679, 0, {0x90,0x7f,0xd6,0xe0,0x30,0xe7,0x12,0xe0,0x44,0x01,0xf0,0x7f,0x14,0x7e,0x00,0x12}, 10, 0x689, 0, {0x05,0xab,0x90,0x7f,0xd6,0xe0,0x54,0xfe,0xf0,0x22}, 16, 0x658, 0, {0x90,0x7f,0xd6,0xe0,0x44,0x80,0xf0,0x43,0x87,0x01,0x00,0x00,0x00,0x00,0x00,0x22}, 2, 0x3, 0, {0xa9,0x07}, 16, 0x5, 0, {0xae,0x0c,0xaf,0x0d,0x8f,0x82,0x8e,0x83,0xa3,0xe0,0x64,0x03,0x70,0x17,0xad,0x01}, 16, 0x15, 0, {0x19,0xed,0x70,0x01,0x22,0x8f,0x82,0x8e,0x83,0xe0,0x7c,0x00,0x2f,0xfd,0xec,0x3e}, 9, 0x25, 0, {0xfe,0xaf,0x05,0x80,0xdf,0x7e,0x00,0x7f,0x00}, 1, 0x2e, 0, {0x22}, 16, 0x503, 0, {0xe4,0xfe,0xac,0x0a,0xad,0x0b,0x8d,0x82,0x8c,0x83,0xa3,0xe0,0x64,0x02,0x70,0x2d}, 16, 0x513, 0, {0xab,0x06,0x0e,0xeb,0xb5,0x07,0x05,0xaf,0x05,0xae,0x04,0x22,0x8d,0x82,0x8c,0x83}, 16, 0x523, 0, {0xa3,0xa3,0xe0,0xf5,0x38,0xa3,0xe0,0xf5,0x39,0x62,0x38,0xe5,0x38,0x62,0x39,0xe5}, 16, 0x533, 0, {0x39,0x62,0x38,0x2d,0xfb,0xe5,0x38,0x3c,0xfc,0xad,0x03,0x80,0xc9,0x7e,0x00,0x7f}, 1, 0x543, 0, {0x00}, 1, 0x544, 0, {0x22}, 16, 0x5ab, 0, {0x8e,0x2d,0x8f,0x2e,0x90,0x7f,0x92,0xe0,0x30,0xe3,0x0b,0xe5,0x2e,0x25,0xe0,0xf5}, 16, 0x5bb, 0, {0x2e,0xe5,0x2d,0x33,0xf5,0x2d,0xe5,0x2e,0x15,0x2e,0xae,0x2d,0x70,0x02,0x15,0x2d}, 9, 0x5cb, 0, {0x4e,0x60,0x05,0x12,0x06,0x68,0x80,0xee,0x22}, 16, 0x668, 0, {0x74,0x00,0xf5,0x86,0x90,0xfd,0xa5,0x7c,0x05,0xa3,0xe5,0x82,0x45,0x83,0x70,0xf9}, 1, 0x678, 0, {0x22}, 3, 0x43, 0, {0x02,0x06,0x00}, 16, 0x600, 0, {0x02,0x06,0x93,0x00,0x02,0x06,0xd9,0x00,0x02,0x06,0xc3,0x00,0x02,0x06,0xab,0x00}, 16, 0x610, 0, {0x02,0x06,0xef,0x00,0x02,0x00,0x42,0x00,0x02,0x07,0x3b,0x00,0x02,0x07,0x3c,0x00}, 16, 0x620, 0, {0x02,0x07,0x3d,0x00,0x02,0x07,0x3e,0x00,0x02,0x07,0x3f,0x00,0x02,0x07,0x40,0x00}, 16, 0x630, 0, {0x02,0x07,0x41,0x00,0x02,0x07,0x42,0x00,0x02,0x07,0x43,0x00,0x02,0x07,0x44,0x00}, 16, 0x640, 0, {0x02,0x07,0x45,0x00,0x02,0x07,0x46,0x00,0x02,0x07,0x47,0x00,0x02,0x07,0x48,0x00}, 8, 0x650, 0, {0x02,0x07,0x49,0x00,0x02,0x07,0x4a,0x00}, 3, 0x0, 0, {0x02,0x00,0x36}, 12, 0x36, 0, {0x78,0x7f,0xe4,0xf6,0xd8,0xfd,0x75,0x81,0x39,0x02,0x03,0x40}, 16, 0x581, 0, {0xbb,0x01,0x06,0x89,0x82,0x8a,0x83,0xe0,0x22,0x50,0x02,0xe7,0x22,0xbb,0xfe,0x02}, 9, 0x591, 0, {0xe3,0x22,0x89,0x82,0x8a,0x83,0xe4,0x93,0x22}, 16, 0x59a, 0, {0xeb,0x9f,0xf5,0xf0,0xea,0x9e,0x42,0xf0,0xe9,0x9d,0x42,0xf0,0xe8,0x9c,0x45,0xf0}, 1, 0x5aa, 0, {0x22}, 0, 0x0, 1, {0} }; ////////////////////////////////////////////////////////////////////////////// // Ezusb Camera Driver ///////////////////////////////////////////////////////////////////////////// // init.c: Driver initialization code ///////////////////////////////////////////////////////////////////////////// // DriverEntry Initialisation entry point // Ezusb_Unload Unload driver routine ///////////////////////////////////////////////////////////////////////////// // Version history // 15-Oct-2002 1.0.0 FJX creation ///////////////////////////////////////////////////////////////////////////// #include <wdm.h> #include "stdarg.h" #include "stdio.h" #include "usbdi.h" #include "usbdlib.h" #include "usbtest.h" ///////////////////////////////////////////////////////////////////////////// // DriverEntry: // // Description: // This function initializes the driver, and creates // any objects needed to process I/O requests. // // Arguments: // DriverObject - Pointer to the Driver object // RegistryPath - Registry path string for driver service key // // Return Value: // STATUS_SUCCESS if successful, // STATUS_UNSUCCESSFUL otherwise ///////////////////////////////////////////////////////////////////// NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { NTSTATUS ntStatus = STATUS_SUCCESS; PDEVICE_OBJECT deviceObject = NULL; Ezusb_KdPrint (("entering (Ezusb) DriverEntry (Build: %s/%s\n",__DATE__,__TIME__)); // // Create dispatch points for the various events handled by this // driver. For example, device I/O control calls (e.g., when a Win32 // application calls the DeviceIoControl function) will be dispatched to // routine specified below in the IRP_MJ_DEVICE_CONTROL case. // DriverObject->MajorFunction[IRP_MJ_CREATE] = Ezusb_Create; DriverObject->MajorFunction[IRP_MJ_CLOSE] = Ezusb_Close; DriverObject->DriverUnload = Ezusb_Unload; DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = Ezusb_ProcessIOCTL; DriverObject->MajorFunction[IRP_MJ_PNP] = Ezusb_DispatchPnp; DriverObject->MajorFunction[IRP_MJ_POWER] = Ezusb_DispatchPower; DriverObject->DriverExtension->AddDevice = Ezusb_PnPAddDevice; Ezusb_KdPrint (("exiting (Ezusb) DriverEntry (%x)\n", ntStatus)); return ntStatus; } ////////////////////////////////////////////////////////////////////////////// // Ezusb_Unload // // Description: // Unload the driver by removing any remaining objects, etc. // // Arguments: // Pointer to the Driver object // // Return Value: // None ////////////////////////////////////////////////////////////////////// VOID Ezusb_Unload(IN PDRIVER_OBJECT DriverObject) { Ezusb_KdPrint (("enter Ezusb_Unload\n")); Ezusb_KdPrint (("exit Ezusb_Unload\n")); } ////////////////////////////////////////////////////////////////////////////// // Ezusb Camera Driver ///////////////////////////////////////////////////////////////////////////// // loader.c: This firmware implements the ANCHOR_LOAD_EXTERNAL vendor specific command. // Firmware Intel Hex Records generated by hex2c. ///////////////////////////////////////////////////////////////////////////// // Version history // 15-Oct-2002 1.0.0 FJX creation ///////////////////////////////////////////////////////////////////////////// #include <wdm.h> #include "usbdi.h" #include "usbdlib.h" #include "usbtest.h" INTEL_HEX_RECORD loader[] = { 16, 0x146c, 0, {0xc2,0x00,0x90,0x7f,0xa5,0xe0,0x54,0x18,0xff,0x13,0x13,0x13,0x54,0x1f,0x44,0x50}, 16, 0x147c, 0, {0xf5,0x1c,0x13,0x92,0x01,0xd2,0xe8,0x90,0x7f,0xab,0x74,0xff,0xf0,0x90,0x7f,0xa9}, 16, 0x148c, 0, {0xf0,0x90,0x7f,0xaa,0xf0,0x53,0x91,0xef,0x90,0x7f,0x95,0xe0,0x44,0xc0,0xf0,0x90}, 16, 0x149c, 0, {0x7f,0xaf,0xe0,0x44,0x01,0xf0,0x90,0x7f,0xae,0xe0,0x44,0x05,0xf0,0xd2,0xaf,0x12}, 13, 0x14ac, 0, {0x17,0x5f,0x30,0x00,0xfd,0x12,0x11,0x00,0xc2,0x00,0x80,0xf6,0x22}, 16, 0x1100, 0, {0x90,0x7f,0xe9,0xe0,0x24,0x5d,0x60,0x0d,0x14,0x70,0x03,0x02,0x12,0x44,0x24,0x02}, 16, 0x1110, 0, {0x60,0x03,0x02,0x12,0x4a,0x90,0x7f,0xea,0xe0,0x75,0x08,0x00,0xf5,0x09,0xa3,0xe0}, 16, 0x1120, 0, {0xfe,0xe4,0x25,0x09,0xf5,0x09,0xee,0x35,0x08,0xf5,0x08,0x90,0x7f,0xee,0xe0,0x75}, 16, 0x1130, 0, {0x0a,0x00,0xf5,0x0b,0xa3,0xe0,0xfe,0xe4,0x25,0x0b,0xf5,0x0b,0xee,0x35,0x0a,0xf5}, 16, 0x1140, 0, {0x0a,0x90,0x7f,0xe8,0xe0,0x64,0xc0,0x60,0x03,0x02,0x11,0xd4,0xe5,0x0b,0x45,0x0a}, 16, 0x1150, 0, {0x70,0x03,0x02,0x12,0x4a,0xc3,0xe5,0x0b,0x94,0x40,0xe5,0x0a,0x94,0x00,0x50,0x08}, 16, 0x1160, 0, {0x85,0x0a,0x0c,0x85,0x0b,0x0d,0x80,0x06,0x75,0x0c,0x00,0x75,0x0d,0x40,0x90,0x7f}, 16, 0x1170, 0, {0xe9,0xe0,0xb4,0xa3,0x25,0xae,0x0c,0xaf,0x0d,0xaa,0x08,0xa9,0x09,0x7b,0x01,0xc0}, 16, 0x1180, 0, {0x03,0xc0,0x02,0xc0,0x01,0x7a,0x7f,0x79,0x00,0x78,0x00,0x7c,0x7f,0xad,0x03,0xd0}, 16, 0x1190, 0, {0x01,0xd0,0x02,0xd0,0x03,0x12,0x13,0x56,0x80,0x0f,0xaf,0x09,0xae,0x08,0xad,0x0d}, 16, 0x11a0, 0, {0x7a,0x7f,0x79,0x00,0x7b,0x00,0x12,0x15,0xa4,0x90,0x7f,0xb5,0xe5,0x0d,0xf0,0xe5}, 16, 0x11b0, 0, {0x0d,0x25,0x09,0xf5,0x09,0xe5,0x0c,0x35,0x08,0xf5,0x08,0xc3,0xe5,0x0b,0x95,0x0d}, 16, 0x11c0, 0, {0xf5,0x0b,0xe5,0x0a,0x95,0x0c,0xf5,0x0a,0x90,0x7f,0xb4,0xe0,0x20,0xe2,0x03,0x02}, 16, 0x11d0, 0, {0x11,0x4c,0x80,0xf4,0x90,0x7f,0xe8,0xe0,0x64,0x40,0x70,0x6e,0xe5,0x0b,0x45,0x0a}, 16, 0x11e0, 0, {0x60,0x68,0xe4,0x90,0x7f,0xc5,0xf0,0x90,0x7f,0xb4,0xe0,0x20,0xe3,0xf9,0x90,0x7f}, 16, 0x11f0, 0, {0xc5,0xe0,0x75,0x0c,0x00,0xf5,0x0d,0x90,0x7f,0xe9,0xe0,0xb4,0xa3,0x15,0xae,0x0c}, 16, 0x1200, 0, {0xaf,0x0d,0xa8,0x09,0xac,0x08,0x7d,0x01,0x7b,0x01,0x7a,0x7e,0x79,0xc0,0x12,0x13}, 16, 0x1210, 0, {0x56,0x80,0x0f,0xaf,0x09,0xae,0x08,0xad,0x0d,0x7a,0x7f,0x79,0x00,0x7b,0x00,0x12}, 16, 0x1220, 0, {0x14,0xb9,0xe5,0x0d,0x25,0x09,0xf5,0x09,0xe5,0x0c,0x35,0x08,0xf5,0x08,0xc3,0xe5}, 16, 0x1230, 0, {0x0b,0x95,0x0d,0xf5,0x0b,0xe5,0x0a,0x95,0x0c,0xf5,0x0a,0x90,0x7f,0xb4,0xe0,0x44}, 10, 0x1240, 0, {0x02,0xf0,0x80,0x98,0x90,0x7f,0xea,0xe0,0xf5,0x1c}, 1, 0x124a, 0, {0x22}, 6, 0x1558, 0, {0xab,0x07,0xaa,0x06,0xac,0x05}, 16, 0x155e, 0, {0xe4,0xfd,0x30,0x01,0x11,0xea,0xff,0xae,0x05,0x0d,0xee,0x24,0x00,0xf5,0x82,0xe4}, 16, 0x156e, 0, {0x34,0xe0,0xf5,0x83,0xef,0xf0,0xeb,0xae,0x05,0x0d,0x74,0x00,0x2e,0xf5,0x82,0xe4}, 16, 0x157e, 0, {0x34,0xe0,0xf5,0x83,0xeb,0xf0,0xaf,0x05,0x0d,0x74,0x00,0x2f,0xf5,0x82,0xe4,0x34}, 16, 0x158e, 0, {0xe0,0xf5,0x83,0xec,0xf0,0xaf,0x1c,0x7a,0xe0,0x7b,0x00,0x12,0x17,0x20,0x7f,0x0a}, 5, 0x159e, 0, {0x7e,0x00,0x12,0x17,0x3c}, 1, 0x15a3, 0, {0x22}, 10, 0x14b9, 0, {0x8e,0x0e,0x8f,0x0f,0x8d,0x10,0x8a,0x11,0x8b,0x12}, 16, 0x14c3, 0, {0xe4,0xf5,0x13,0xe5,0x13,0xc3,0x95,0x10,0x50,0x20,0x05,0x0f,0xe5,0x0f,0xae,0x0e}, 16, 0x14d3, 0, {0x70,0x02,0x05,0x0e,0x14,0xff,0xe5,0x12,0x25,0x13,0xf5,0x82,0xe4,0x35,0x11,0xf5}, 10, 0x14e3, 0, {0x83,0xe0,0xfd,0x12,0x15,0x58,0x05,0x13,0x80,0xd9}, 1, 0x14ed, 0, {0x22}, 10, 0x15a4, 0, {0x8e,0x0e,0x8f,0x0f,0x8d,0x10,0x8a,0x11,0x8b,0x12}, 16, 0x15ae, 0, {0xe4,0xfd,0x30,0x01,0x12,0xe5,0x0e,0xff,0xae,0x05,0x0d,0xee,0x24,0x03,0xf5,0x82}, 16, 0x15be, 0, {0xe4,0x34,0xe0,0xf5,0x83,0xef,0xf0,0xe5,0x0f,0xae,0x05,0x0d,0x74,0x03,0x2e,0xf5}, 16, 0x15ce, 0, {0x82,0xe4,0x34,0xe0,0xf5,0x83,0xe5,0x0f,0xf0,0xaf,0x1c,0x7a,0xe0,0x7b,0x03,0x12}, 13, 0x15de, 0, {0x17,0x20,0xaf,0x1c,0xad,0x10,0xab,0x12,0xaa,0x11,0x12,0x17,0x04}, 1, 0x15eb, 0, {0x22}, 16, 0x166e, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0xc0,0x85,0xc0,0x84,0xc0,0x86,0x75,0x86,0x00,0xd2}, 16, 0x167e, 0, {0x00,0x53,0x91,0xef,0x90,0x7f,0xab,0x74,0x01,0xf0,0xd0,0x86,0xd0,0x84,0xd0,0x85}, 7, 0x168e, 0, {0xd0,0x82,0xd0,0x83,0xd0,0xe0,0x32}, 16, 0x1644, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0xc0,0x85,0xc0,0x84,0xc0,0x86,0x75,0x86,0x00,0x90}, 16, 0x1654, 0, {0x7f,0xc4,0xe4,0xf0,0x53,0x91,0xef,0x90,0x7f,0xab,0x74,0x04,0xf0,0xd0,0x86,0xd0}, 10, 0x1664, 0, {0x84,0xd0,0x85,0xd0,0x82,0xd0,0x83,0xd0,0xe0,0x32}, 16, 0x1695, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0xc0,0x85,0xc0,0x84,0xc0,0x86,0x75,0x86,0x00,0x53}, 16, 0x16a5, 0, {0x91,0xef,0x90,0x7f,0xab,0x74,0x02,0xf0,0xd0,0x86,0xd0,0x84,0xd0,0x85,0xd0,0x82}, 5, 0x16b5, 0, {0xd0,0x83,0xd0,0xe0,0x32}, 16, 0x16ba, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0xc0,0x85,0xc0,0x84,0xc0,0x86,0x75,0x86,0x00,0x53}, 16, 0x16ca, 0, {0x91,0xef,0x90,0x7f,0xab,0x74,0x10,0xf0,0xd0,0x86,0xd0,0x84,0xd0,0x85,0xd0,0x82}, 5, 0x16da, 0, {0xd0,0x83,0xd0,0xe0,0x32}, 1, 0x14ff, 0, {0x32}, 16, 0x16df, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0xc0,0x85,0xc0,0x84,0xc0,0x86,0x75,0x86,0x00,0x53}, 16, 0x16ef, 0, {0x91,0xef,0x90,0x7f,0xab,0x74,0x08,0xf0,0xd0,0x86,0xd0,0x84,0xd0,0x85,0xd0,0x82}, 5, 0x16ff, 0, {0xd0,0x83,0xd0,0xe0,0x32}, 1, 0x1767, 0, {0x32}, 1, 0x1768, 0, {0x32}, 1, 0x1769, 0, {0x32}, 1, 0x176a, 0, {0x32}, 1, 0x176b, 0, {0x32}, 1, 0x176c, 0, {0x32}, 1, 0x176d, 0, {0x32}, 1, 0x176e, 0, {0x32}, 1, 0x176f, 0, {0x32}, 1, 0x1770, 0, {0x32}, 1, 0x1771, 0, {0x32}, 1, 0x1772, 0, {0x32}, 1, 0x1773, 0, {0x32}, 1, 0x1774, 0, {0x32}, 1, 0x1775, 0, {0x32}, 1, 0x1776, 0, {0x32}, 3, 0x43, 0, {0x02,0x15,0x00}, 16, 0x1500, 0, {0x02,0x16,0x6e,0x00,0x02,0x16,0x95,0x00,0x02,0x16,0x44,0x00,0x02,0x16,0xdf,0x00}, 16, 0x1510, 0, {0x02,0x16,0xba,0x00,0x02,0x14,0xff,0x00,0x02,0x17,0x67,0x00,0x02,0x17,0x68,0x00}, 16, 0x1520, 0, {0x02,0x17,0x69,0x00,0x02,0x17,0x6a,0x00,0x02,0x17,0x6b,0x00,0x02,0x17,0x6c,0x00}, 16, 0x1530, 0, {0x02,0x17,0x6d,0x00,0x02,0x17,0x6e,0x00,0x02,0x17,0x6f,0x00,0x02,0x17,0x70,0x00}, 16, 0x1540, 0, {0x02,0x17,0x71,0x00,0x02,0x17,0x72,0x00,0x02,0x17,0x73,0x00,0x02,0x17,0x74,0x00}, 8, 0x1550, 0, {0x02,0x17,0x75,0x00,0x02,0x17,0x76,0x00}, 16, 0x173c, 0, {0x8e,0x14,0x8f,0x15,0xe5,0x15,0x15,0x15,0xae,0x14,0x70,0x02,0x15,0x14,0x4e,0x60}, 7, 0x174c, 0, {0x05,0x12,0x14,0xee,0x80,0xee,0x22}, 8, 0x175f, 0, {0xe4,0xf5,0x1b,0xd2,0xe9,0xd2,0xaf,0x22}, 16, 0x1619, 0, {0xa9,0x07,0xe5,0x1b,0x70,0x23,0x90,0x7f,0xa5,0xe0,0x44,0x80,0xf0,0xe9,0x25,0xe0}, 16, 0x1629, 0, {0x90,0x7f,0xa6,0xf0,0x8d,0x16,0xaf,0x03,0xa9,0x07,0x75,0x17,0x01,0x8a,0x18,0x89}, 11, 0x1639, 0, {0x19,0xe4,0xf5,0x1a,0x75,0x1b,0x01,0xd3,0x22,0xc3,0x22}, 16, 0x15ec, 0, {0xa9,0x07,0xe5,0x1b,0x70,0x25,0x90,0x7f,0xa5,0xe0,0x44,0x80,0xf0,0xe9,0x25,0xe0}, 16, 0x15fc, 0, {0x44,0x01,0x90,0x7f,0xa6,0xf0,0x8d,0x16,0xaf,0x03,0xa9,0x07,0x75,0x17,0x01,0x8a}, 13, 0x160c, 0, {0x18,0x89,0x19,0xe4,0xf5,0x1a,0x75,0x1b,0x03,0xd3,0x22,0xc3,0x22}, 3, 0x4b, 0, {0x02,0x13,0x7f}, 16, 0x137f, 0, {0xc0,0xe0,0xc0,0x83,0xc0,0x82,0xc0,0x85,0xc0,0x84,0xc0,0x86,0x75,0x86,0x00,0xc0}, 16, 0x138f, 0, {0xd0,0x75,0xd0,0x00,0xc0,0x00,0xc0,0x01,0xc0,0x02,0xc0,0x03,0xc0,0x06,0xc0,0x07}, 16, 0x139f, 0, {0x90,0x7f,0xa5,0xe0,0x30,0xe2,0x06,0x75,0x1b,0x06,0x02,0x14,0x4e,0x90,0x7f,0xa5}, 16, 0x13af, 0, {0xe0,0x20,0xe1,0x0c,0xe5,0x1b,0x64,0x02,0x60,0x06,0x75,0x1b,0x07,0x02,0x14,0x4e}, 16, 0x13bf, 0, {0xaf,0x1b,0xef,0x24,0xfe,0x60,0x48,0x14,0x60,0x2c,0x24,0xfe,0x60,0x77,0x24,0x04}, 16, 0x13cf, 0, {0x60,0x03,0x02,0x14,0x4e,0xab,0x17,0xaa,0x18,0xa9,0x19,0xaf,0x1a,0x05,0x1a,0x8f}, 16, 0x13df, 0, {0x82,0x75,0x83,0x00,0x12,0x12,0x4b,0x90,0x7f,0xa6,0xf0,0xe5,0x1a,0x65,0x16,0x70}, 16, 0x13ef, 0, {0x5e,0x75,0x1b,0x05,0x80,0x59,0x90,0x7f,0xa6,0xe0,0xab,0x17,0xaa,0x18,0xa9,0x19}, 16, 0x13ff, 0, {0xae,0x1a,0x8e,0x82,0x75,0x83,0x00,0x12,0x12,0x78,0x75,0x1b,0x02,0x80,0x40,0xe5}, 16, 0x140f, 0, {0x16,0x24,0xfe,0xb5,0x1a,0x07,0x90,0x7f,0xa5,0xe0,0x44,0x20,0xf0,0xe5,0x16,0x14}, 16, 0x141f, 0, {0xb5,0x1a,0x0a,0x90,0x7f,0xa5,0xe0,0x44,0x40,0xf0,0x75,0x1b,0x00,0x90,0x7f,0xa6}, 16, 0x142f, 0, {0xe0,0xab,0x17,0xaa,0x18,0xa9,0x19,0xae,0x1a,0x8e,0x82,0x75,0x83,0x00,0x12,0x12}, 16, 0x143f, 0, {0x78,0x05,0x1a,0x80,0x0a,0x90,0x7f,0xa5,0xe0,0x44,0x40,0xf0,0x75,0x1b,0x00,0x53}, 16, 0x144f, 0, {0x91,0xdf,0xd0,0x07,0xd0,0x06,0xd0,0x03,0xd0,0x02,0xd0,0x01,0xd0,0x00,0xd0,0xd0}, 13, 0x145f, 0, {0xd0,0x86,0xd0,0x84,0xd0,0x85,0xd0,0x82,0xd0,0x83,0xd0,0xe0,0x32}, 16, 0x1704, 0, {0x12,0x15,0xec,0xe5,0x1b,0x24,0xfa,0x60,0x0e,0x14,0x60,0x06,0x24,0x07,0x70,0xf3}, 12, 0x1714, 0, {0xd3,0x22,0xe4,0xf5,0x1b,0xd3,0x22,0xe4,0xf5,0x1b,0xd3,0x22}, 16, 0x1720, 0, {0x12,0x16,0x19,0xe5,0x1b,0x24,0xfa,0x60,0x0e,0x14,0x60,0x06,0x24,0x07,0x70,0xf3}, 12, 0x1730, 0, {0xd3,0x22,0xe4,0xf5,0x1b,0xd3,0x22,0xe4,0xf5,0x1b,0xd3,0x22}, 16, 0x14ee, 0, {0x74,0x00,0xf5,0x86,0x90,0xfd,0xa5,0x7c,0x05,0xa3,0xe5,0x82,0x45,0x83,0x70,0xf9}, 1, 0x14fe, 0, {0x22}, 3, 0x0, 0, {0x02,0x17,0x53}, 12, 0x1753, 0, {0x78,0x7f,0xe4,0xf6,0xd8,0xfd,0x75,0x81,0x20,0x02,0x14,0x6c}, 16, 0x124b, 0, {0xbb,0x01,0x0c,0xe5,0x82,0x29,0xf5,0x82,0xe5,0x83,0x3a,0xf5,0x83,0xe0,0x22,0x50}, 16, 0x125b, 0, {0x06,0xe9,0x25,0x82,0xf8,0xe6,0x22,0xbb,0xfe,0x06,0xe9,0x25,0x82,0xf8,0xe2,0x22}, 13, 0x126b, 0, {0xe5,0x82,0x29,0xf5,0x82,0xe5,0x83,0x3a,0xf5,0x83,0xe4,0x93,0x22}, 16, 0x1278, 0, {0xf8,0xbb,0x01,0x0d,0xe5,0x82,0x29,0xf5,0x82,0xe5,0x83,0x3a,0xf5,0x83,0xe8,0xf0}, 16, 0x1288, 0, {0x22,0x50,0x06,0xe9,0x25,0x82,0xc8,0xf6,0x22,0xbb,0xfe,0x05,0xe9,0x25,0x82,0xc8}, 2, 0x1298, 0, {0xf2,0x22}, 16, 0x129a, 0, {0xe7,0x09,0xf6,0x08,0xdf,0xfa,0x80,0x46,0xe7,0x09,0xf2,0x08,0xdf,0xfa,0x80,0x3e}, 16, 0x12aa, 0, {0x88,0x82,0x8c,0x83,0xe7,0x09,0xf0,0xa3,0xdf,0xfa,0x80,0x32,0xe3,0x09,0xf6,0x08}, 16, 0x12ba, 0, {0xdf,0xfa,0x80,0x6e,0xe3,0x09,0xf2,0x08,0xdf,0xfa,0x80,0x66,0x88,0x82,0x8c,0x83}, 16, 0x12ca, 0, {0xe3,0x09,0xf0,0xa3,0xdf,0xfa,0x80,0x5a,0x89,0x82,0x8a,0x83,0xe0,0xa3,0xf6,0x08}, 16, 0x12da, 0, {0xdf,0xfa,0x80,0x4e,0x89,0x82,0x8a,0x83,0xe0,0xa3,0xf2,0x08,0xdf,0xfa,0x80,0x42}, 16, 0x12ea, 0, {0x80,0xd2,0x80,0xfa,0x80,0xc6,0x80,0xd4,0x80,0x55,0x80,0xf2,0x80,0x29,0x80,0x10}, 16, 0x12fa, 0, {0x80,0xa6,0x80,0xea,0x80,0x9a,0x80,0xa8,0x80,0xda,0x80,0xe2,0x80,0xca,0x80,0x29}, 16, 0x130a, 0, {0x88,0x84,0x8c,0x85,0x89,0x82,0x8a,0x83,0xe4,0x93,0xa3,0x05,0x86,0xf0,0xa3,0x05}, 16, 0x131a, 0, {0x86,0xdf,0xf5,0xde,0xf3,0x80,0x0b,0x89,0x82,0x8a,0x83,0xe4,0x93,0xa3,0xf6,0x08}, 16, 0x132a, 0, {0xdf,0xf9,0xec,0xfa,0xa9,0xf0,0xed,0xfb,0x22,0x88,0x84,0x8c,0x85,0x89,0x82,0x8a}, 16, 0x133a, 0, {0x83,0xe0,0xa3,0x05,0x86,0xf0,0xa3,0x05,0x86,0xdf,0xf6,0xde,0xf4,0x80,0xe3,0x89}, 16, 0x134a, 0, {0x82,0x8a,0x83,0xe4,0x93,0xa3,0xf2,0x08,0xdf,0xf9,0x80,0xd6,0x88,0xf0,0xed,0x24}, 16, 0x135a, 0, {0x02,0xb4,0x04,0x00,0x50,0xcc,0xf5,0x82,0xeb,0x24,0x02,0xb4,0x04,0x00,0x50,0xc2}, 16, 0x136a, 0, {0x23,0x23,0x45,0x82,0xf5,0x82,0xef,0x4e,0x60,0xb8,0xef,0x60,0x01,0x0e,0xe5,0x82}, 5, 0x137a, 0, {0x23,0x90,0x12,0xea,0x73}, 0, 0x0, 1, {0} }; ////////////////////////////////////////////////////////////////////////////// // Ezusb Camera Driver ///////////////////////////////////////////////////////////////////////////// // pnp.c: Plug and Play IRP handlers ///////////////////////////////////////////////////////////////////////////// // Ezusb_DefaultPnpHandler Default Pnp Handler // Ezusb_PnPAddDevice Add device routine // Ezusb_CreateDeviceObject Creates a Functional DeviceObject // Ezusb_DispatchPnp Process Plug and Play IRPs sent to this device. // Ezusb_HandleStartDevice Handle PnP start device // Ezusb_HandleRemoveDevice Handle PnP remove device // OnRequestComplete Handle completion of a request by a lower-level driver // ForwardAndWait Forward request to lower level and await completion // CompleteRequest Mark I/O request complete // LockDevice Lock out PnP remove request // UnlockDevice Unlock device allow PnP remove request // ///////////////////////////////////////////////////////////////////////////// // Version history // 15-Oct-2002 1.0.0 FJX creation ///////////////////////////////////////////////////////////////////////////// #include <wdm.h> #include "stdarg.h" #include "stdio.h" #include "usbdi.h" #include "usbdlib.h" #include "usbtest.h" ///////////////////////////////////////////////////////////////////////////// // Ezusb_PnPAddDevice: // // Description: // Cope with a new PnP device being added here. // Usually just attach to the top of the driver stack. // Do not talk to device here! // // Arguments: // Pointer to the Driver object // Pointer to Physical Device Object // // Return Value: // This function returns STATUS_XXX /////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_PnPAddDevice( IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject) { NTSTATUS ntStatus = STATUS_SUCCESS; PDEVICE_OBJECT deviceObject = NULL; PDEVICE_EXTENSION pdx; int instance; Ezusb_KdPrint(("enter Ezusb_PnPAddDevice\n")); #define MAX_EZUSB_DEVICES 8 // // create our functional device object (FDO). This driver supports multiple ezusb devices. // This loop will look for an available instance number. Keep incrementing the instance // until a call to Ezusb_CreateDeviceObject succeeds. // instance = 0; do { ntStatus = Ezusb_CreateDeviceObject(DriverObject, &deviceObject, instance); instance++; } while (!NT_SUCCESS(ntStatus) && (instance < MAX_EZUSB_DEVICES)); if (NT_SUCCESS(ntStatus)) { pdx = deviceObject->DeviceExtension; // // Non plug and play drivers usually create the device object in // driver entry, and the I/O manager autimatically clears this flag. // Since we are creating the device object ourselves in response to // a PnP START_DEVICE IRP, we need to clear this flag ourselves. // deviceObject->Flags &= ~DO_DEVICE_INITIALIZING; // // This driver uses direct I/O for read/write requests // deviceObject->Flags |= DO_DIRECT_IO; deviceObject->Flags |= DO_POWER_PAGABLE; // // // store away the Physical device Object // pdx->PhysicalDeviceObject=PhysicalDeviceObject; // // Attach to the StackDeviceObject. This is the device object that what we // use to send Irps and Urbs down the USB software stack // pdx->StackDeviceObject = IoAttachDeviceToDeviceStack(deviceObject, PhysicalDeviceObject); ASSERT (pdx->StackDeviceObject != NULL); pdx->LastFailedUrbStatus = 0; pdx->usage = 1; // locked until RemoveDevice KeInitializeEvent(&pdx->evRemove, NotificationEvent, FALSE); // set when use count drops to zero } Ezusb_KdPrint(("exit Ezusb_PnPAddDevice (%x)\n", ntStatus)); return ntStatus; } ///////////////////////////////////////////////////////////////////////////// // Ezusb_CreateDeviceObject: // // Routine Description: // Creates a Functional DeviceObject // // Arguments: // DriverObject - pointer to the driver object for device // DeviceObject - pointer to DeviceObject pointer to return // created device object. // Instance - instnace of the device create. // // Return Value: // STATUS_SUCCESS if successful, // STATUS_UNSUCCESSFUL otherwise //////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_CreateDeviceObject( IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT *DeviceObject, LONG Instance ) { NTSTATUS ntStatus; WCHAR deviceLinkBuffer[] = L"\\DosDevices\\Ezusb-0"; UNICODE_STRING deviceLinkUnicodeString; WCHAR deviceNameBuffer[] = L"\\Device\\Ezusb-0"; UNICODE_STRING deviceNameUnicodeString; PDEVICE_EXTENSION pdx; STRING deviceName; Ezusb_KdPrint(("enter Ezusb_CreateDeviceObject instance = %d\n", Instance)); // // fix up device names based on Instance // deviceLinkBuffer[18] = (USHORT) ('0' + Instance); deviceNameBuffer[14] = (USHORT) ('0' + Instance); Ezusb_KdPrint(("Create Device name (%ws)\n", deviceNameBuffer)); RtlInitUnicodeString (&deviceNameUnicodeString, deviceNameBuffer); // //Print out the unicode string //NOTE: We must first convert the string to Unicode due to a bug in the Debugger that does not allow // Unicode Strings to be printed to the debug device. // deviceName.Buffer = NULL; ntStatus = RtlUnicodeStringToAnsiString (&deviceName, &deviceNameUnicodeString, TRUE); if (NT_SUCCESS(ntStatus)) { Ezusb_KdPrint(("Create Device Name (%s)\n", deviceName.Buffer)); RtlFreeAnsiString (&deviceName); } else { Ezusb_KdPrint(("Unicode to Ansi str failed w/ ntStatus: 0x%x\n",ntStatus)); } ntStatus = IoCreateDevice (DriverObject, sizeof (DEVICE_EXTENSION), &deviceNameUnicodeString, FILE_DEVICE_UNKNOWN, 0, FALSE, DeviceObject); if (NT_SUCCESS(ntStatus)) { // Initialize our device extension pdx = (PDEVICE_EXTENSION) ((*DeviceObject)->DeviceExtension); RtlCopyMemory(pdx->DeviceLinkNameBuffer, deviceLinkBuffer, sizeof(deviceLinkBuffer)); pdx->OpenHandles = 0; pdx->ConfigurationHandle = NULL; pdx->DeviceDescriptor = NULL; pdx->NeedCleanup = FALSE; pdx->DataRingBuffer = NULL; pdx->DescriptorRingBuffer = NULL; pdx->Started = FALSE; // Initialize our interface pdx->Interface = NULL; RtlInitUnicodeString (&deviceLinkUnicodeString, deviceLinkBuffer); Ezusb_KdPrint(("Create DosDevice name (%ws)\n", deviceLinkBuffer)); ntStatus = IoCreateSymbolicLink (&deviceLinkUnicodeString, &deviceNameUnicodeString); } Ezusb_KdPrint(("exit Ezusb_CreateDeviceObject (%x)\n", ntStatus)); return ntStatus; } ///////////////////////////////////////////////////////////////////////////// // Ezusb_DispatchPnp: // // Description: // Handle IRP_MJ_PNP requests // // Arguments: // Pointer to our FDO // Pointer to the IRP // Various minor codes // IrpStack->Parameters.QueryDeviceRelations // IrpStack->Parameters.QueryInterface // IrpStack->Parameters.DeviceCapabilities // IrpStack->Parameters.FilterResourceRequirements // IrpStack->Parameters.ReadWriteConfig // IrpStack->Parameters.SetLock // IrpStack->Parameters.QueryId // IrpStack->Parameters.QueryDeviceText // IrpStack->Parameters.UsageNotification // // Return Value: // This function returns STATUS_XXX ////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_DispatchPnp( IN PDEVICE_OBJECT fdo, IN PIRP Irp) { PIO_STACK_LOCATION irpStack; PDEVICE_EXTENSION pdx = fdo->DeviceExtension; ULONG fcn; NTSTATUS ntStatus; Ezusb_KdPrint (("Enter Ezusb_DispatchPnp\n")); if (!LockDevice(fdo)) return CompleteRequest(Irp, STATUS_DELETE_PENDING, 0); // // Get a pointer to the current location in the Irp. This is where // the function codes and parameters are located. // irpStack = IoGetCurrentIrpStackLocation (Irp); ASSERT(irpStack->MajorFunction == IRP_MJ_PNP); fcn = irpStack->MinorFunction; switch (fcn) { case IRP_MN_START_DEVICE: Ezusb_KdPrint (("IRP_MN_START_DEVICE\n")); ntStatus = Ezusb_HandleStartDevice(fdo,Irp); if (ntStatus == STATUS_SUCCESS) { pdx->Started = TRUE; } break; //IRP_MN_START_DEVICE case IRP_MN_STOP_DEVICE: Ezusb_KdPrint (("IRP_MN_STOP_DEVICE\n")); // // first pass the request down the stack // Ezusb_DefaultPnpHandler(fdo,Irp); ntStatus = Ezusb_StopDevice(fdo); break; //IRP_MN_STOP_DEVICE case IRP_MN_REMOVE_DEVICE: Ezusb_KdPrint (("IRP_MN_REMOVE_DEVICE\n")) ntStatus = Ezusb_HandleRemoveDevice(fdo,Irp); break; //IRP_MN_REMOVE_DEVICE case IRP_MN_QUERY_CAPABILITIES: { PDEVICE_CAPABILITIES pdc = irpStack->Parameters.DeviceCapabilities.Capabilities; Ezusb_KdPrint (("IRP_MN_QUERY_CAPABILITIES\n")) // Check to be sure we know how to handle this version of the capabilities structure if (pdc->Version < 1) { ntStatus = Ezusb_DefaultPnpHandler(fdo, Irp); break; } ntStatus = ForwardAndWait(fdo, Irp); if (NT_SUCCESS(ntStatus)) { // IRP succeeded pdc = irpStack->Parameters.DeviceCapabilities.Capabilities; // setting this field prevents NT5 from notifying the user when the // device is removed. pdc->SurpriseRemovalOK = TRUE; } // IRP succeeded ntStatus = CompleteRequest(Irp, ntStatus, Irp->IoStatus.Information); } break; //IRP_MN_QUERY_CAPABILITIES // // All other PNP IRP's are just passed down the stack by the default handler // default: Ezusb_KdPrint (("Passing down unhandled PnP IOCTL 0x%x\n", fcn)); ntStatus = Ezusb_DefaultPnpHandler(fdo, Irp); } // switch MinorFunction if (fcn != IRP_MN_REMOVE_DEVICE) UnlockDevice(fdo); Ezusb_KdPrint (("Exit Ezusb_DispatchPnp %x\n", ntStatus)); return ntStatus; } ///////////////////////////////////////////////////////////////////////////// // Ezusb_HandleStartDevice: Handle PnP start device //////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_HandleStartDevice( IN PDEVICE_OBJECT fdo, IN PIRP Irp) { NTSTATUS ntStatus; // // First let all lower-level drivers handle this request. // ntStatus = ForwardAndWait(fdo, Irp); if (!NT_SUCCESS(ntStatus)) return CompleteRequest(Irp, ntStatus, Irp->IoStatus.Information); // // now do whatever we need to do to start the device // ntStatus = Ezusb_StartDevice(fdo); return CompleteRequest(Irp, ntStatus, 0); } ///////////////////////////////////////////////////////////////////////////// // Ezusb_HandleRemoveDevice: Handle PnP remove device //////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_HandleRemoveDevice( IN PDEVICE_OBJECT fdo, IN PIRP Irp) { NTSTATUS ntStatus; PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension; ULONG i; // set the removing flag to prevent any new I/O's pdx->removing = TRUE; // brute force - send an abort pipe message to all pipes to cancel any // pending transfers. this should solve the problem of the driver blocking // on a REMOVE message because there is a pending transfer. for (i = 0; i < pdx->Interface->NumberOfPipes; i++) { Ezusb_AbortPipe(fdo,(USBD_PIPE_HANDLE) pdx->Interface->Pipes.PipeHandle); } UnlockDevice(fdo); // once for LockDevice at start of dispatch UnlockDevice(fdo); // once for initialization during AddDevice KeWaitForSingleObject(&pdx->evRemove, Executive, KernelMode, FALSE, NULL); Ezusb_RemoveDevice(fdo); ntStatus = Ezusb_DefaultPnpHandler(fdo, Irp); return ntStatus; // lower-level completed IoStatus already } ///////////////////////////////////////////////////////////////////////////// // Support routines ///////////////////////////////////////////////////////////////////////////// // Ezusb_DefaultPnpHandler: Default PnP handler to pass to next stack device ///////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_DefaultPnpHandler( IN PDEVICE_OBJECT fdo, IN PIRP Irp) { PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension; IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(pdx->StackDeviceObject, Irp); } ///////////////////////////////////////////////////////////////////////////// // OnRequestComplete // Routine Description: // Handle completion of a request by a lower-level driver // // Arguments: // DriverObject - Functional device object // Irp - I/O request which has completed // pev - Context argument supplied to IoSetCompletionRoutine, namely address of // KEVENT object on which ForwardAndWait is waiting // // Return Value: // STATUS_MORE_PROCESSING_REQUIRED //////////////////////////////////////////////////////////////////////////// NTSTATUS OnRequestComplete( IN PDEVICE_OBJECT fdo, IN PIRP Irp, IN PKEVENT pev ) { KeSetEvent(pev, 0, FALSE); return STATUS_MORE_PROCESSING_REQUIRED; } ///////////////////////////////////////////////////////////////////////////// // CompleteRequest // Routine Description: // Mark I/O request complete // // Arguments: // Irp - I/O request in question // status - Standard status code // info Additional information related to status code // // Return Value: // STATUS_SUCCESS if successful, // STATUS_UNSUCCESSFUL otherwise ///////////////////////////////////////////////////////////////////////////// NTSTATUS CompleteRequest( IN PIRP Irp, IN NTSTATUS status, IN ULONG info ) { Irp->IoStatus.Status = status; Irp->IoStatus.Information = info; IoCompleteRequest(Irp, IO_NO_INCREMENT); return status; } ///////////////////////////////////////////////////////////////////////////// // ForwardAndWait: Forward IRP and wait for it to complete // Routine Description: // Forward request to lower level and await completion // // The only purpose of this routine in this particular driver is to pass down // IRP_MN_START_DEVICE requests and wait for the PDO to handle them. // // The processor must be at PASSIVE IRQL because this function initializes // and waits for non-zero time on a kernel event object. // // Arguments: // fdo - pointer to a device object // Irp - pointer to an I/O Request Packet // // Return Value: // STATUS_SUCCESS if successful, // STATUS_UNSUCCESSFUL otherwise //////////////////////////////////////////////////////////////////////////////////////// NTSTATUS ForwardAndWait( IN PDEVICE_OBJECT fdo, IN PIRP Irp) { KEVENT event; PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension; NTSTATUS ntStatus; ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); // // Initialize a kernel event object to use in waiting for the lower-level // driver to finish processing the object. // KeInitializeEvent(&event, NotificationEvent, FALSE); IoCopyCurrentIrpStackLocationToNext(Irp); IoSetCompletionRoutine(Irp, (PIO_COMPLETION_ROUTINE) OnRequestComplete, (PVOID) &event, TRUE, TRUE, TRUE); ntStatus = IoCallDriver(pdx->StackDeviceObject, Irp); if (ntStatus == STATUS_PENDING) { KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); ntStatus = Irp->IoStatus.Status; } return ntStatus; } ///////////////////////////////////////////////////////////////////////////// // LockDevice: Lock out PnP remove request //////////////////////////////////////////////////////////////////////////// BOOLEAN LockDevice( IN PDEVICE_OBJECT fdo) { PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension; // Increment use count on our device object LONG usage = InterlockedIncrement(&pdx->usage); // AddDevice initialized the use count to 1, so it ought to be bigger than // one now. HandleRemoveDevice sets the "removing" flag and decrements the // use count, possibly to zero. So if we find a use count of "1" now, we // should also find the "removing" flag set. ASSERT(usage > 1 || pdx->removing); // If device is about to be removed, restore the use count and return FALSE. // If we're in a race with HandleRemoveDevice (maybe running on another CPU), // the sequence we've followed is guaranteed to avoid a mistaken deletion of // the device object. If we test "removing" after HandleRemoveDevice sets it, // we'll restore the use count and return FALSE. In the meantime, if // HandleRemoveDevice decremented the count to 0 before we did our increment, // its thread will have set the remove event. Otherwise, we'll decrement to 0 // and set the event. Either way, HandleRemoveDevice will wake up to finish // removing the device, and we'll return FALSE to our caller. // // If, on the other hand, we test "removing" before HandleRemoveDevice sets it, // we'll have already incremented the use count past 1 and will return TRUE. // Our caller will eventually call UnlockDevice, which will decrement the use // count and might set the event HandleRemoveDevice is waiting on at that point. if (pdx->removing) { if (InterlockedDecrement(&pdx->usage) == 0) KeSetEvent(&pdx->evRemove, 0, FALSE); return FALSE; } return TRUE; } ///////////////////////////////////////////////////////////////////////////// // UnlockDevice: Unlock device allow PnP remove request //////////////////////////////////////////////////////////////////////////// void UnlockDevice(PDEVICE_OBJECT fdo) { PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension; LONG usage = InterlockedDecrement(&pdx->usage); ASSERT(usage >= 0); if (usage == 0) { // removing device ASSERT(pdx->removing); // HandleRemoveDevice should already have set this KeSetEvent(&pdx->evRemove, 0, FALSE); } // removing device } ////////////////////////////////////////////////////////////////////////////// // Ezusb Camera Driver ///////////////////////////////////////////////////////////////////////////// // Power.c: Power IRP handlers ///////////////////////////////////////////////////////////////////////////// // Ezusb_DispatchPower Process the IRPs sent to this device. ///////////////////////////////////////////////////////////////////////////// // Version history // 16-Oct-2002 1.0.0 FJX creation ///////////////////////////////////////////////////////////////////////////// #include <wdm.h> #include "stdarg.h" #include "stdio.h" #include "usbdi.h" #include "usbdlib.h" #include "usbtest.h" ///////////////////////////////////////////////////////////////////////////// // Ezusb_DispatchPower: // // Routine Description: // Process the IRPs sent to this device. // // Arguments: // fdo - pointer to a device object // Irp - pointer to an I/O Request Packet // // Return Value: // NTSTATUS /////////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_DispatchPower( IN PDEVICE_OBJECT fdo, IN PIRP Irp ) { PIO_STACK_LOCATION irpStack, nextStack; PDEVICE_EXTENSION pdx = fdo->DeviceExtension; NTSTATUS ntStatus; Ezusb_KdPrint (("Enter Ezusb_DispatchPower\n")); Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0; // // Get a pointer to the current location in the Irp. This is where // the function codes and parameters are located. // irpStack = IoGetCurrentIrpStackLocation (Irp); Ezusb_KdPrint (("IRP_MJ_POWER MIN=0x%x Type=0x%x State=0x%x\n",irpStack->MinorFunction, irpStack->Parameters.Power.Type, irpStack->Parameters.Power.State.DeviceState)); switch (irpStack->MinorFunction) { case IRP_MN_SET_POWER: switch (irpStack->Parameters.Power.Type) { case SystemPowerState: break; //SystemPowerState case DevicePowerState: switch (irpStack->Parameters.Power.State.DeviceState) { case PowerDeviceD3: Ezusb_KdPrint (("IRP_MN_SET_D3\n")); break; case PowerDeviceD2: Ezusb_KdPrint (("IRP_MN_SET_D2\n")); break; case PowerDeviceD1: Ezusb_KdPrint (("IRP_MN_SET_D1\n")); break; case PowerDeviceD0: Ezusb_KdPrint (("IRP_MN_SET_D0\n")); break; } // switch on Power.State.DeviceState break; //DevicePowerState }// switch on Power.Type break; //IRP_MN_SET_POWER case IRP_MN_QUERY_POWER: // Look at what type of power query this is switch (irpStack->Parameters.Power.Type) { case SystemPowerState: break; //SystemPowerState case DevicePowerState: switch (irpStack->Parameters.Power.State.DeviceState) { case PowerDeviceD2: Ezusb_KdPrint (("IRP_MN_QUERY_D2\n")); break; case PowerDeviceD1: Ezusb_KdPrint (("IRP_MN_QUERY_D1\n")); break; case PowerDeviceD3: Ezusb_KdPrint (("IRP_MN_QUERY_D3\n")); break; } //switch on Power.State.DeviceState break; //DevicePowerState }//switch on Power.Type break; //IRP_MN_QUERY_POWER default: // A PnP Minor Function was not handled Ezusb_KdPrint (("Power IOCTL not handled\n")); } /* switch MinorFunction*/ nextStack = IoGetNextIrpStackLocation(Irp); ASSERT(nextStack != NULL); RtlCopyMemory(nextStack, irpStack, sizeof(IO_STACK_LOCATION)); // // All PNP_POWER messages get passed to the StackDeviceObject that // we were given in PnPAddDevice. // // This stack device object is managed by the USB software subsystem, // and so this IRP must be propagated to the owning device driver for // that stack device object, so that driver in turn can perform any // device state management (e.g., remove its device object, etc.). // Ezusb_KdPrint (("Passing Power Irp down\n")); // // Notes on passing power IRPs down: Using IoCallDriver() to pass // down power IRPs worked until Windows 2000. Using this method // with Win2K causes a blue screen at system shutdown. Because of this, // I am modifying the driver to use the more correct PoXXX() functions // to handle power IRPs. Unfortunately, the PoXXX() calls weren't // added until the kernel until after the release of Windows 95 OSR2. // So, a driver using these calls will not load on a Windows 95 system. // If you need to use this driver under Windows 95. then you must // #define WIN95. // #ifdef WIN95 ntStatus = IoCallDriver(pdx->StackDeviceObject, Irp); #else PoStartNextPowerIrp(Irp); ntStatus = PoCallDriver(pdx->StackDeviceObject,Irp); #endif // // If lower layer driver marked the Irp as pending then reflect that by // calling IoMarkIrpPending. // if (ntStatus == STATUS_PENDING) { IoMarkIrpPending(Irp); Ezusb_KdPrint (("Power Irp came back with STATUS_PENDING (%x)\n", ntStatus)); } else { Ezusb_KdPrint (("Power Irp came back, status = %x\n", ntStatus)); } // if ntStatus is PENDING goto Ezusb_Dispatch_Done; Ezusb_Dispatch_Done: Ezusb_KdPrint (("Exit Ezusb_DispatchPower %x\n", ntStatus)); return ntStatus; } ////////////////////////////////////////////////////////////////////////////// // Ezusb Camera Driver ///////////////////////////////////////////////////////////////////////////// // ezusbsys.c: ezusb access routines ///////////////////////////////////////////////////////////////////////////// // Ezusb_StartDevice Start the device // Ezusb_StopDevice Stop device // Ezusb_RemoveDevice Remove device // Ezusb_ProcessIOCTL DeviceIoControl codes are handled // Ezusb_CallUSBD Passes a Usb Request Block (URB) to the USB class driver (USBD) // Ezusb_ConfigureDevice Configures the USB device // Ezusb_SelectInterfaces Initializes an Ezusb Device // Ezusb_Read_Write // Ezusb_GetDescriptor Gets a device descriptor // Ezusb_GetDeviceDescriptor // Ezusb_GetConfigDescriptor Gets a configuration descriptor // Ezusb_GetOtherSpeedConfigDescriptor // Ezusb_GetStringDescriptor Gets the specified string descriptor // Ezusb_VendorRequest2 // Ezusb_VendorRequest // Ezusb_ResetPipe Reset a given USB pipe. // Ezusb_AbortPipe cancel pending transfers for a pipe // Ezusb_GetCurrentFrameNumber // Ezusb_ResetParentPort Reset the our parent port // Ezusb_DownloadTest // GetConfigDescriptor // ConfigureDevice Configures the USB device // SetInterface // DumpBuffer // IsoTransferComplete // Ezusb_StartIsoTransfer // IsoStreamTransferComplete // Ezusb_StartIsoStream // InitTransferObject // Ezusb_8051Reset // Ezusb_AnchorDownload // Ezusb_DownloadIntelHex // AllocRingBuffer // FreeRingBuffer // ReadRingBuffer // WriteRingBuffer // Ezusb_SetFeature Set Feature control transfer ///////////////////////////////////////////////////////////////////////////// // Version history // 15-Oct-2002 1.0.0 FJX creation ///////////////////////////////////////////////////////////////////////////// // Include files needed for WDM driver support #include <wdm.h> #include "stdarg.h" #include "stdio.h" // Include files needed for USB support #include "usbdi.h" #include "usbdlib.h" // Include file for the Ezusb Device #include "usbtest.h" // incude file containing driver version #include "version.h" extern INTEL_HEX_RECORD loader[]; extern INTEL_HEX_RECORD firmware[]; void DumpBuffer(PVOID pvBuffer, ULONG length); ///////////////////////////////////////////////////////////////////////////// // Ezusb_StartDevice: Start the device // Routine Description: // Initializes a given instance of the Ezusb Device on the USB. // // Arguments: // fdo - pointer to the device object for this instance of a // Ezusb Device // // Return Value: // NT status code //////////////////////////////////////////////////////////////////////////// NTSTATUS Ezusb_StartDevice( IN PDEVICE_OBJECT fdo ) { PDEVICE_EXTENSION pdx; NTSTATUS ntStatus; PUSB_DEVICE_DESCRIPTOR deviceDescriptor = NULL; PURB urb; ULONG siz; Ezusb_KdPrint (("enter Ezusb_StartDevice\n")); pdx = fdo->DeviceExtension; pdx->NeedCleanup = TRUE; /* // Get some memory from then non paged pool (fixed, locked system memory) // for use by the USB Request Block (urb) for the specific USB Request we // will be performing below (a USB device request). */ urb = ExAllocatePool( NonPagedPool, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST)); if (urb) { siz = sizeof(USB_DEVICE_DESCRIPTOR); // Get some non paged memory for the device descriptor contents deviceDescriptor = ExAllocatePool(NonPagedPool, siz); if (deviceDescriptor) { // Use a macro in the standard USB header files to build the URB UsbBuildGetDescriptorRequest(urb, (USHORT) sizeof (struct _URB_CONTROL_DESCRIPTOR_REQUEST), USB_DEVICE_DESCRIPTOR_TYPE, 0, 0, deviceDescriptor, NULL, siz, NULL); // Get the device descriptor ntStatus = Ezusb_CallUSBD(fdo, urb); // Dump out the descriptor info to the debugger if (NT_SUCCESS(ntStatus)) { Ezusb_KdPrint (("Device Descriptor = %x, len %x\n", deviceDescriptor, urb->UrbControlDescriptorRequest.TransferBufferLength)); Ezusb_KdPrint (("Ezusb Device Descriptor:\n")); Ezusb_KdPrint (("-------------------------\n")); Ezusb_KdPrint (("bLength %d\n", deviceDescriptor->bLength)); Ezusb_KdPrint (("bDescriptorType 0 |
|
|