




免费预览已结束,剩余260页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/ File: ezusbsys.c/ $Archive: /USB/Drivers/ezusbdrv/ezusbsys.c $/ Purpose:/ General purpose USB device driver/ Environment:/ kernel mode/ $Author: Mdn $/ $History: ezusbsys.c $ / / * Version 6 */ User: Mdn Date: 9/17/01 Time: 10:54a/ Updated in $/USB/Drivers/ezusbdrv/ Fixed memory leak bug in ISO streaming code. Was setting the/ PendingTransfers variable to the wrong value and not properly freeing/ after stopping the ISO stream./ / * Version 5 */ User: Mdn Date: 10/06/00 Time: 10:08a/ Updated in $/USB/Drivers/ezusbdrv/ Added IOCTL_EZUSB_SET_FEATURE/ / * Version 4 */ User: Mdn Date: 8/17/00 Time: 9:46a/ Updated in $/USB/Drivers/ezusbdrv/ added a generic get descriptor function./ / * Version 3 */ User: Mdn Date: 8/04/00 Time: 11:41a/ Updated in $/USB/Drivers/ezmon/ added support for monitor download to FX2/ / * Version 2 */ User: Mdn Date: 7/21/00 Time: 4:27p/ Updated in $/USB/Drivers/ezusbdrv/ Added a Started flag to the device extension. This flag gets set after/ the device has successfully Started. It is used to prevent a potential/ race condition where an application could get a handle (with/ CreateFile() before the device is completely enumerated./ / * Version 1 */ User: Tpm Date: 6/09/00 Time: 6:32p/ Created in $/USB/Drivers/ezusbdrv/ / * Version 42 */ User: Mdn Date: 5/05/00 Time: 10:24a/ Updated in $/EzUsb/Drivers/ezusbdrv/ comments/ / * Version 41 */ User: Mdn Date: 4/18/00 Time: 2:45p/ Updated in $/EzUsb/Drivers/ezusbdrv/ fixed memory leak where I wasnt freeing an URB allocated for/ vendor/class requests./ / * Version 40 */ User: Mdn Date: 1/21/00 Time: 10:03a/ Updated in $/EzUsb/Drivers/ezusbdrv/ modified device removal code to send an abort message to all pipes/ before proceding with device removal. This solves the deadlock problem/ that can occur when a transfer is pending and the device receives a/ remove message. Before this change, the driver would block the removal/ indefinitely waiting for all pending transfers to complete./ / * Version 39 */ User: Markm Date: 12/17/99 Time: 11:17a/ Updated in $/EzUsb/Drivers/ezusbdrv/ Removed interface select workaround for an obscure OSR2.1 bug since the/ driver no longer supports Win95. Changed interface select so that it/ selects the first interface/alternate setting in the config descriptor./ Before, it was hardcoded to select interface 0, AS 0. This should/ allow the driver to handle composite devices more easily, although I/ havent tested it./ / * Version 38 */ User: Markm Date: 10/06/99 Time: 1:18p/ Updated in $/EzUsb/Drivers/ezusbdrv/ Made changes to Power IRP handling to fix the blue screen on shutdown/ that was occuring under Win2K. Specifically, started using PoXXX()/ calls for handling power IRPs. See code comments in/ Ezusb_DispatchPower(). The PoXXX() calls are not supported by Win95, so/ as of this revision, the driver will no longer work with Windows 95./ / * Version 37 */ User: Markm Date: 5/18/99 Time: 3:37p/ Updated in $/EzUsb/Drivers/ezusbdrv/ / * Version 36 */ User: Markm Date: 4/29/99 Time: 9:48a/ Updated in $/EzUsb/Drivers/ezusbdrv/ Fixed IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST so that it correctly returns/ the number of bytes transferred./ / * Version 35 */ User: Markm Date: 4/16/99 Time: 3:39p/ Updated in $/EzUsb/Drivers/ezusbdrv/ more minor changes to get rid of compiler warnings./ / * Version 34 */ User: Markm Date: 4/12/99 Time: 10:26a/ Updated in $/EzUsb/Drivers/ezusbdrv/ minor changes to get rid of compiler warnings./ / * Version 33 */ User: Markm Date: 3/25/99 Time: 4:16p/ Updated in $/EzUsb/Drivers/ezusbdrv/ Fixed a bug in the surprise removal code I just added. I was returning/ from the PnP dispatch function without unlocking the device object./ / * Version 32 */ User: Markm Date: 3/25/99 Time: 2:03p/ Updated in $/EzUsb/Drivers/ezusbdrv/ Added code to allow unplugs (surprise removal) under NT5 without/ notifying the user./ / * Version 31 */ User: Markm Date: 2/23/99 Time: 9:50a/ Updated in $/EzUsb/Drivers/ezusbdrv/ Driver now supports ISO IN streaming with a path to user mode./ / * Version 30 */ User: Markm Date: 2/10/99 Time: 3:31p/ Updated in $/EzUsb/Drivers/ezusbdrv/ removed lots of unused code. Added ring buffer support functions./ / * Version 29 */ User: Markm Date: 2/01/99 Time: 11:57a/ Updated in $/EzUsb/Drivers/ezusbdrv/ Added preliminary support for ISO streaming./ / * Version 28 */ User: Markm Date: 6/12/98 Time: 4:23p/ Updated in $/EzUsb/Drivers/ezusbdrv/ modified pipe reset and abort code so that the driver will work/ correctly under Windows 95 OSR2.1. For Win98, MS changed the size of/ the URB_PIPE_REQUEST structure. They added an extra ulong to it. So,/ a driver compiled with the 98 DDk and run under 95 will send the wrong/ URB size. The solution is to check the USBDI version whenever I do a/ pipe reset or abort. If the USBDI version is pre-win98, I subtract 4/ from the size of the urb. / / * Version 27 */ User: Markm Date: 4/10/98 Time: 2:52p/ Updated in $/EZUSB/ezmon/ Modified Intel Hex download code to stop the 8051 before downloading to/ internal RAM./ / * Version 26 */ User: Markm Date: 4/09/98 Time: 4:39p/ Updated in $/EZUSB/ezusb driver/ Was not returning status information for ISO transfers. Now it does!/ / * Version 25 */ User: Markm Date: 4/09/98 Time: 4:39p/ Updated in $/EZUSB/ezmon/ changes for monitor version of driver/ / * Version 24 */ User: Markm Date: 4/09/98 Time: 3:09p/ Updated in $/EZUSB/ezusb driver/ nothing much/ / * Version 23 */ User: Markm Date: 4/09/98 Time: 3:00p/ Updated in $/EZUSB/ezusb driver/ Added function to download Intel Hex File records to EZ-USB. For now,/ this function is only used by the conditional build of the driver that/ automatically downloads the Keil monitor./ / * Version 22 */ User: Markm Date: 4/07/98 Time: 1:52p/ Updated in $/EZUSB/ezusb driver/ Added IOCTL_EZUSB_GET_DRIVER_VERSION/ / * Version 21 */ User: Markm Date: 4/06/98 Time: 4:26p/ Updated in $/EZUSB/ezusb driver/ Modified ISO transfer code./ * Transfer descriptors for the ISO transfer are now sent up to the/ caller along with the actual data, so the caller can get the status of/ the transfer on a packet-by-packet basis. / * Disabled default values. Caller must specify all fields in the ISO/ control structure./ * Corrected bug where the Stream and Transfer objects werent being/ freed./ / Added some code to measure the latency of a bulk transfer./ / * Version 20 */ User: Markm Date: 3/19/98 Time: 10:13a/ Updated in $/EZUSB/ezusb driver/ Added IOCTL_EZUSB_ANCHOR_DOWNLOAD to support A0 loads to a specific/ memory offset./ / * Version 19 */ User: Markm Date: 2/26/98 Time: 4:04p/ Updated in $/EZUSB/ezusb driver/ Added functions to perform anchor downloads and 8051 reset./ Added conditionally compiled code to support a special version of the/ driver that will automatically download the Keil 8051 monitor after/ device attachment./ / * Version 18 */ User: Markm Date: 2/25/98 Time: 2:09p/ Updated in $/EZUSB/ezusb driver/ changes for adding version resource to the driver/ / * Version 17 */ User: Markm Date: 2/11/98 Time: 9:51a/ Updated in $/EZUSB/ezusb driver/ 1. Added code to handle IRP_MN_CLOSE./ 2. Now maintain a count of open file handles in the device extension./ 3. Added workaround in Ezusb_SelectInterfaces() to avoid system hangs/ during device removal under OSR2.1. See comments there./ / * Version 16 */ User: Markm Date: 2/02/98 Time: 3:35p/ Updated in $/EZUSB/ezusb driver/ / * Version 15 */ User: Markm Date: 1/27/98 Time: 11:36a/ Updated in $/EZUSB/ezusb driver/ Modified ISO transfer code so that the number of transfer buffers and/ the number of ISO frames per buffer can be specified by the caller./ / * Version 14 */ User: Markm Date: 1/26/98 Time: 10:11a/ Updated in $/EZUSB/ezusb driver/ 1) modified device removal code that was crashing OSR2.1. MS sample/ code says that during device removal, the remove IRP should be passed/ down the stack, and then the deviceobject should be deleted. This/ causes a bugcheck under OSR2.1. Reversing the order of these/ operations fixes the problem./ 2) hardcoded the initial alternate setting to 2. It was set to 1, but/ this was also causing system crashes under OSR 2.1 during device/ removal. Still under investigation./ / * Version 13 */ User: Markm Date: 1/22/98 Time: 11:50a/ Updated in $/EZUSB/ezusb driver/ Fixed a bug in the device removal handler. It wasnt deleteting the/ symbolic link for the deviceobject after removal./ Removed lots of unused code./ Rewrote ISO loopback test code./ Wrote new ISO read/write functions./ / * Version 12 */ User: Markm Date: 1/18/98 Time: 3:20p/ Updated in $/EZUSB/ezusb driver/ renamed variables. DeviceExtension becomes pdx and DeviceObject/ becomes fdo./ rewrote handlers for device removal. Cleaned up power management/ dispatch. Added code to maintain a usage count for the device./ / * Version 11 */ User: Markm Date: 1/15/98 Time: 4:36p/ Updated in $/EZUSB/ezusb driver/ Added/ IOCTL_EZUSB_GET_CURRENT_FRAME_NUMBER/ IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST/ IOCTL_EZUSB_GET_LAST_ERROR/ preliminary code for handling device removal gracefully./ / * Version 10 */ User: Markm Date: 1/14/98 Time: 10:29a/ Updated in $/EZUSB/ezusb driver/ Cleanup./ New functions for handling bulk transfers./ / * Version 9 */ User: Markm Date: 1/08/98 Time: 5:14p/ Updated in $/EZUSB/ezusb driver/ major changes to PnP IRP handling. lots of reformatting./ / * Version 8 */ User: Markm Date: 1/02/98 Time: 1:41p/ Updated in $/EZUSB/ezusb driver/ Added support for setting the interface, preliminary code for naming/ pipes, get string descriptor/ / * Version 7 */ User: Markm Date: 11/18/97 Time: 4:40p/ Updated in $/EZUSB/ezusb driver/ Added abort pipe IOCTL/ Added function to dump a buffer to the debuger/ Added experimental file I/O code (from Brad Carpenter)/ / * Version 6 */ User: Markm Date: 11/17/97 Time: 9:37a/ Updated in $/EZUSB/ezusb driver/ fixed bug where I set the pipesize/ / * Version 5 */ User: Markm Date: 11/14/97 Time: 4:53p/ Updated in $/EZUSB/ezusb driver/ started using USBD_CreateConfigurationRequestEx/ / * Version 4 */ User: Markm Date: 11/14/97 Time: 4:31p/ Updated in $/EZUSB/ezusb driver/ added code to experiment wth different methods of switiching/ interfaces./ / * Version 3 */ User: Markm Date: 11/07/97 Time: 1:23p/ Updated in $/EZUSB/ezusb driver/ added sourcesafe keywords/ / Copyright (c) 1997 Anchor Chips, Inc. May not be reproduced without/ permission. See the license agreement for more details./ #define DRIVER/ Include files needed for WDM driver support/#include #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 ezusbsys.h/ incude file containing driver version/#include version.h#ifdef DOWNLOAD_KEIL_MONITORextern INTEL_HEX_RECORD mon_ext_sio1_ezusb;extern INTEL_HEX_RECORD mon_ext_sio1_fx2;extern INTEL_HEX_RECORD loader;#endif / ifdef DOWNLOAD_KEIL_MONITORvoidDumpBuffer(PVOID pvBuffer, ULONG length);NTSTATUSDriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath )/*+Routine Description: Installable driver initialization entry point. This is where the driver is called when the driver is being loaded by the I/O system. This entry point is called directly by the I/O system.Arguments: DriverObject - pointer to the driver object RegistryPath - pointer to a unicode string representing the path to driver-specific key in the registryReturn Value: STATUS_SUCCESS if successful, STATUS_UNSUCCESSFUL otherwise-*/ NTSTATUS ntStatus = STATUS_SUCCESS; PDEVICE_OBJECT deviceObject = NULL; Ezusb_KdPrint (entering (Ezusb) DriverEntry (Build: %s/%sn,_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-MajorFunctionIRP_MJ_CREATE = Ezusb_Create; DriverObject-MajorFunctionIRP_MJ_CLOSE = Ezusb_Close; DriverObject-DriverUnload = Ezusb_Unload; DriverObject-MajorFunctionIRP_MJ_DEVICE_CONTROL = Ezusb_ProcessIOCTL; DriverObject-MajorFunctionIRP_MJ_PNP = Ezusb_DispatchPnp; DriverObject-MajorFunctionIRP_MJ_POWER = Ezusb_DispatchPower; DriverObject-DriverExtension-AddDevice = Ezusb_PnPAddDevice; Ezusb_KdPrint (exiting (Ezusb) DriverEntry (%x)n, ntStatus); return ntStatus;NTSTATUSEzusb_DefaultPnpHandler( IN PDEVICE_OBJECT fdo, IN PIRP Irp ) PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo-DeviceExtension; IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(pdx-StackDeviceObject, Irp);/ func Handle completion of a request by a lower-level driver/ parm Functional device object/ parm I/O request which has completed/ parm Context argument supplied to IoSetCompletionRoutine, namely address of/ KEVENT object on which ForwardAndWait is waiting/ comm This is the completion routine used for requests forwarded by ForwardAndWait. It/ sets the event object and thereby awakens ForwardAndWait./ comm Note that its *not* necessary for this particular completion routine to test/ the PendingReturned flag in the IRP and then call IoMarkIrpPending. You do that in many/ completion routines because the dispatch routine cant know soon enough that the/ lower layer has returned STATUS_PENDING. In our case, were never going to pass a/ STATUS_PENDING back up the driver chain, so we dont need to worry about this.NTSTATUS OnRequestComplete( IN PDEVICE_OBJECT fdo, IN PIRP Irp, IN PKEVENT pev )/*+Routine Description: Handle completion of a request by a lower-level driverArguments: 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 waitingReturn Value: STATUS_MORE_PROCESSING_REQUIRED-*/ KeSetEvent(pev, 0, FALSE); return STATUS_MORE_PROCESSING_REQUIRED;NTSTATUSForwardAndWait( IN PDEVICE_OBJECT fdo, IN PIRP Irp )/*+Routine Description: Forward request to lower level and await completion The only purpos
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年度财务顾问财务顾问顾问团队能力提升服务协议
- 2025年度对外贸易合同二:国际贸易绿色包装与环保材料采购合同
- 2025版十九组太阳能路灯工程智能化管理系统开发合同
- 2025年度地产代理合同:长租公寓项目
- 2025版室内设计师墙纸师傅定制施工合作协议书
- 贵州省兴仁县2025年上半年事业单位公开遴选试题含答案分析
- 2025版沿街商铺租赁合同(含装修设计、广告投放及物业增值服务)
- 2025版企业间知识产权质押借款合同标准文本
- 2025版临时工劳务合同标准范本
- 2025年光伏发电项目电气设施安装施工合同
- 宾馆前台培训课件
- 消防安全专项施工方案及应急预案
- WST856-2025安全注射标准解读
- MSA-GRR数据自动生成工具
- 沉香种植可行性研究报告
- 光纤通信施工难点措施
- 2025年XRF考试题目及答案
- 2025年《健康知识》竞赛题库含试题及答案
- 资质备案管理办法
- 心之所向·素履以往+课件-2025-2026学年高三上学期开学第一课主题班会
- 潘毅中医基础理论教学课件
评论
0/150
提交评论