ezusbsys.h
00001 00002 // 00003 // File: ezusbsys.h 00004 // $Archive: /USB/Drivers/ezusbdrv/ezusbsys.h $ 00005 // 00006 // Purpose: 00007 // Header file for the Ezusb USB Device Driver 00008 // 00009 // Environment: 00010 // kernel mode 00011 // 00012 // $Author: Mdn $ 00013 // 00014 // $History: ezusbsys.h $ 00015 // 00016 // ***************** Version 5 ***************** 00017 // User: Mdn Date: 10/06/00 Time: 10:08a 00018 // Updated in $/USB/Drivers/ezusbdrv 00019 // Added IOCTL_EZUSB_SET_FEATURE 00020 // 00021 // ***************** Version 4 ***************** 00022 // User: Mdn Date: 8/17/00 Time: 9:46a 00023 // Updated in $/USB/Drivers/ezusbdrv 00024 // added a generic get descriptor function. 00025 // 00026 // ***************** Version 3 ***************** 00027 // User: Mdn Date: 8/04/00 Time: 11:40a 00028 // Updated in $/USB/Drivers/ezmon 00029 // added support for monitor download to FX2 00030 // 00031 // ***************** Version 2 ***************** 00032 // User: Mdn Date: 7/21/00 Time: 4:27p 00033 // Updated in $/USB/Drivers/ezusbdrv 00034 // Added a Started flag to the device extension. This flag gets set after 00035 // the device has successfully Started. It is used to prevent a potential 00036 // race condition where an application could get a handle (with 00037 // CreateFile()) before the device is completely enumerated. 00038 // 00039 // ***************** Version 1 ***************** 00040 // User: Tpm Date: 6/09/00 Time: 6:32p 00041 // Created in $/USB/Drivers/ezusbdrv 00042 // 00043 // ***************** Version 30 ***************** 00044 // User: Tpm Date: 3/14/00 Time: 4:14p 00045 // Updated in $/EzUsb/Examples/Unsupported/EzMr 00046 // Added commets: 00047 // DEVIOCTL.H is a Microsoft header file. 00048 // DEVIOCTL.H is normally obtained by installing the Windows DDK. 00049 // 00050 // ***************** Version 29 ***************** 00051 // User: Markm Date: 5/18/99 Time: 3:37p 00052 // Updated in $/EzUsb/Drivers/ezusbdrv 00053 // 00054 // ***************** Version 28 ***************** 00055 // User: Markm Date: 2/23/99 Time: 9:50a 00056 // Updated in $/EzUsb/Drivers/ezusbdrv 00057 // Driver now supports ISO IN streaming with a path to user mode. 00058 // 00059 // ***************** Version 27 ***************** 00060 // User: Markm Date: 2/10/99 Time: 3:32p 00061 // Updated in $/EzUsb/Drivers/ezusbdrv 00062 // removed lots of unused protoypes and structures. Added ring buffer 00063 // support functions. 00064 // 00065 // ***************** Version 26 ***************** 00066 // User: Markm Date: 2/01/99 Time: 11:57a 00067 // Updated in $/EzUsb/Drivers/ezusbdrv 00068 // Added preliminary support for ISO streaming. 00069 // 00070 // ***************** Version 25 ***************** 00071 // User: Tpm Date: 10/19/98 Time: 3:45p 00072 // Updated in $/EzUsb/Examples/CTst 00073 // Fix RMA#1 bug: side B fails renum. 00074 // 00075 // ***************** Version 24 ***************** 00076 // User: Tpm Date: 10/01/98 Time: 11:51p 00077 // Updated in $/EzUsb/Examples/Unsupported/EzMr 00078 // Apply Tim's Comments. 00079 // 00080 // ***************** Version 23 ***************** 00081 // User: Tpm Date: 6/26/98 Time: 10:27a 00082 // Updated in $/EzUsb/Examples/EzMr 00083 // Set Version. 00084 // 00085 // ***************** Version 22 ***************** 00086 // User: Tpm Date: 6/26/98 Time: 5:41a 00087 // Updated in $/EzUsb/Examples/EzMr 00088 // Pre-Build. 00089 // 00090 // ***************** Version 21 ***************** 00091 // User: Tpm Date: 6/26/98 Time: 4:01a 00092 // Updated in $/EzUsb/Examples/CTst 00093 // Clean Build. 00094 // 00095 // ***************** Version 20 ***************** 00096 // User: Tpm Date: 6/26/98 Time: 2:41a 00097 // Updated in $/EzUsb/Examples/EzMr 00098 // Clean Build. 00099 // 00100 // ***************** Version 19 ***************** 00101 // User: Tpm Date: 6/25/98 Time: 1:09p 00102 // Updated in $/EzUsb/EzMr 00103 // Add Headers. 00104 // 00105 // ***************** Version 18 ***************** 00106 // User: Tpm Date: 6/25/98 Time: 10:50a 00107 // Updated in $/EzUsb/EzMr 00108 // REL1.1. 00109 // 00110 // ***************** Version 17 ***************** 00111 // User: Markm Date: 4/09/98 Time: 3:01p 00112 // Updated in $/EZUSB/ezusb driver 00113 // Added stuff to support download of Intel Hex records. 00114 // 00115 // ***************** Version 16 ***************** 00116 // User: Markm Date: 4/07/98 Time: 1:53p 00117 // Updated in $/EZUSB/ezusb driver 00118 // Added IOCTL_EZUSB_GET_DRIVER_VERSION 00119 // 00120 // ***************** Version 15 ***************** 00121 // User: Markm Date: 4/06/98 Time: 4:27p 00122 // Updated in $/EZUSB/ezusb driver 00123 // Modified ISO transfer code. 00124 // * Transfer descriptors for the ISO transfer are now sent up to the 00125 // caller along with the actual data, so the caller can get the status of 00126 // the transfer on a packet-by-packet basis. 00127 // * Disabled default values. Caller must specify all fields in the ISO 00128 // control structure. 00129 // * Corrected bug where the Stream and Transfer objects weren't being 00130 // freed. 00131 // 00132 // Added some code to measure the latency of a bulk transfer. 00133 // 00134 // ***************** Version 14 ***************** 00135 // User: Markm Date: 3/19/98 Time: 10:13a 00136 // Updated in $/EZUSB/ezusb driver 00137 // Added IOCTL_EZUSB_ANCHOR_DOWNLOAD to support A0 loads to a specific 00138 // memory offset. 00139 // 00140 // ***************** Version 13 ***************** 00141 // User: Markm Date: 2/26/98 Time: 4:05p 00142 // Updated in $/EZUSB/ezusb driver 00143 // Added protoypes for anchor download and 8051 reset functions. 00144 // Added firmware structure definition. 00145 // Added some EZ-USB register defines. 00146 // 00147 // ***************** Version 11 ***************** 00148 // User: Markm Date: 2/11/98 Time: 9:51a 00149 // Updated in $/EZUSB/ezusb driver 00150 // Added an open file handle count to the device extension. 00151 // 00152 // ***************** Version 10 ***************** 00153 // User: Markm Date: 2/02/98 Time: 3:36p 00154 // Updated in $/EZUSB/ezusb driver 00155 // Added protypes for new functions 00156 // 00157 // ***************** Version 9 ***************** 00158 // User: Markm Date: 1/27/98 Time: 11:37a 00159 // Updated in $/EZUSB/ezusb driver 00160 // Added members to the ISO stream object to allow for user specified 00161 // transfer parameters. 00162 // 00163 // ***************** Version 8 ***************** 00164 // User: Markm Date: 1/22/98 Time: 11:52a 00165 // Updated in $/EZUSB/ezusb driver 00166 // removed unused code. 00167 // added IOCTL's for ISO loopback/read/write 00168 // 00169 // ***************** Version 7 ***************** 00170 // User: Markm Date: 1/18/98 Time: 3:18p 00171 // Updated in $/EZUSB/ezusb driver 00172 // Added new IOCTL's. Added members to the device extension to support 00173 // robust device removal. 00174 // 00175 // ***************** Version 6 ***************** 00176 // User: Markm Date: 1/14/98 Time: 10:30a 00177 // Updated in $/EZUSB/ezusb driver 00178 // Added IOCTL's for handling bulk transfers. 00179 // 00180 // ***************** Version 5 ***************** 00181 // User: Markm Date: 1/02/98 Time: 1:41p 00182 // Updated in $/EZUSB/ezusb driver 00183 // Added support for setting the interface, preliminary code for naming 00184 // pipes, get string descriptor 00185 // 00186 // ***************** Version 4 ***************** 00187 // User: Markm Date: 11/18/97 Time: 3:21p 00188 // Updated in $/EZUSB/ezusb driver 00189 // added abort pipe IOCTL 00190 // 00191 // ***************** Version 3 ***************** 00192 // User: Markm Date: 11/14/97 Time: 4:31p 00193 // Updated in $/EZUSB/ezusb driver 00194 // added code to experiment wth different methods of switiching 00195 // interfaces. 00196 // 00197 // ***************** Version 2 ***************** 00198 // User: Markm Date: 11/07/97 Time: 1:21p 00199 // Updated in $/EZUSB/ezusb driver 00200 // Added Reset Pipe IOCTL 00201 // 00202 // Copyright (c) 1997 Anchor Chips, Inc. May not be reproduced without 00203 // permission. See the license agreement for more details. 00204 // 00206 00207 // 00208 // Vendor specific request code for Anchor Upload/Download 00209 // 00210 // This one is implemented in the core 00211 // 00212 #define ANCHOR_LOAD_INTERNAL 0xA0 00213 00214 // 00215 // These commands are not implemented in the core. Requires firmware 00216 // 00217 #define ANCHOR_LOAD_EXTERNAL 0xA3 00218 #define ANCHOR_ISFX2 0xAC 00219 00220 // 00221 // This is the highest internal RAM address for the AN2131Q 00222 // 00223 #define MAX_INTERNAL_ADDRESS 0x1B3F 00224 00225 #define INTERNAL_RAM(address) ((address <= MAX_INTERNAL_ADDRESS) ? 1 : 0) 00226 // 00227 // EZ-USB Control and Status Register. Bit 0 controls 8051 reset 00228 // 00229 #define CPUCS_REG_EZUSB 0x7F92 00230 #define CPUCS_REG_FX2 0xE600 00231 00232 00233 #ifndef _BYTE_DEFINED 00234 #define _BYTE_DEFINED 00235 typedef unsigned char BYTE; 00236 #endif // !_BYTE_DEFINED 00237 00238 #ifndef _WORD_DEFINED 00239 #define _WORD_DEFINED 00240 typedef unsigned short WORD; 00241 #endif // !_WORD_DEFINED 00242 00243 typedef struct _VENDOR_REQUEST_IN 00244 { 00245 BYTE bRequest; 00246 WORD wValue; 00247 WORD wIndex; 00248 WORD wLength; 00249 BYTE direction; 00250 BYTE bData; 00251 } VENDOR_REQUEST_IN, *PVENDOR_REQUEST_IN; 00252 00254 // 00255 // control structure for bulk and interrupt data transfers 00256 // 00258 typedef struct _BULK_TRANSFER_CONTROL 00259 { 00260 ULONG pipeNum; 00261 } BULK_TRANSFER_CONTROL, *PBULK_TRANSFER_CONTROL; 00262 00263 typedef struct _BULK_LATENCY_CONTROL 00264 { 00265 ULONG bulkPipeNum; 00266 ULONG intPipeNum; 00267 ULONG loops; 00268 } BULK_LATENCY_CONTROL, *PBULK_LATENCY_CONTROL; 00269 00270 00272 // 00273 // control structure isochronous loopback test 00274 // 00276 typedef struct _ISO_LOOPBACK_CONTROL 00277 { 00278 // iso pipe to write to 00279 ULONG outPipeNum; 00280 00281 // iso pipe to read from 00282 ULONG inPipeNum; 00283 00284 // amount of data to read/write from/to the pipe each frame. If not 00285 // specified, the MaxPacketSize of the out pipe is used. 00286 ULONG packetSize; 00287 00288 } ISO_LOOPBACK_CONTROL, *PISO_LOOPBACK_CONTROL; 00289 00291 // 00292 // control structure for sending vendor or class specific requests 00293 // to the control endpoint. 00294 // 00296 typedef struct _VENDOR_OR_CLASS_REQUEST_CONTROL 00297 { 00298 // transfer direction (0=host to device, 1=device to host) 00299 UCHAR direction; 00300 00301 // request type (1=class, 2=vendor) 00302 UCHAR requestType; 00303 00304 // recipient (0=device,1=interface,2=endpoint,3=other) 00305 UCHAR recepient; 00306 // 00307 // see the USB Specification for an explanation of the 00308 // following paramaters. 00309 // 00310 UCHAR requestTypeReservedBits; 00311 UCHAR request; 00312 USHORT value; 00313 USHORT index; 00314 } VENDOR_OR_CLASS_REQUEST_CONTROL, *PVENDOR_OR_CLASS_REQUEST_CONTROL; 00315 00316 typedef struct _SET_FEATURE_CONTROL 00317 { 00318 USHORT FeatureSelector; 00319 USHORT Index; 00320 } SET_FEATURE_CONTROL, *PSET_FEATURE_CONTROL; 00321 00323 // 00324 // control structure for isochronous data transfers 00325 // 00327 typedef struct _ISO_TRANSFER_CONTROL 00328 { 00329 // 00330 // pipe number to perform the ISO transfer to/from. Direction is 00331 // implied by the pipe number. 00332 // 00333 ULONG PipeNum; 00334 // 00335 // ISO packet size. Determines how much data is transferred each 00336 // frame. Should be less than or equal to the maxpacketsize for 00337 // the endpoint. 00338 // 00339 ULONG PacketSize; 00340 // 00341 // Total number of ISO packets to transfer. 00342 // 00343 ULONG PacketCount; 00344 // 00345 // The following two parameters detmine how buffers are managed for 00346 // an ISO transfer. In order to maintain an ISO stream, the driver 00347 // must create at least 2 transfer buffers and ping pong between them. 00348 // BufferCount determines how many buffers the driver creates to ping 00349 // pong between. FramesPerBuffer specifies how many USB frames of data 00350 // are transferred by each buffer. 00351 // 00352 ULONG FramesPerBuffer; // 10 is a good value 00353 ULONG BufferCount; // 2 is a good value 00354 } ISO_TRANSFER_CONTROL, *PISO_TRANSFER_CONTROL; 00355 00356 00358 // 00359 // control structure for Anchor Downloads 00360 // 00362 typedef struct _ANCHOR_DOWNLOAD_CONTROL 00363 { 00364 WORD Offset; 00365 } ANCHOR_DOWNLOAD_CONTROL, *PANCHOR_DOWNLOAD_CONTROL; 00366 00367 #define MAX_INTEL_HEX_RECORD_LENGTH 16 00368 00369 typedef struct _INTEL_HEX_RECORD 00370 { 00371 BYTE Length; 00372 WORD Address; 00373 BYTE Type; 00374 BYTE Data[MAX_INTEL_HEX_RECORD_LENGTH]; 00375 } INTEL_HEX_RECORD, *PINTEL_HEX_RECORD; 00376 00377 typedef struct _SET_INTERFACE_IN 00378 { 00379 UCHAR interfaceNum; 00380 UCHAR alternateSetting; 00381 } SET_INTERFACE_IN, *PSET_INTERFACE_IN; 00382 00383 typedef struct _GET_STRING_DESCRIPTOR_IN 00384 { 00385 UCHAR Index; 00386 USHORT LanguageId; 00387 } GET_STRING_DESCRIPTOR_IN, *PGET_STRING_DESCRIPTOR_IN; 00388 00389 typedef struct _EZUSB_DRIVER_VERSION 00390 { 00391 WORD MajorVersion; 00392 WORD MinorVersion; 00393 WORD BuildVersion; 00394 } EZUSB_DRIVER_VERSION, *PEZUSB_DRIVER_VERSION; 00395 00396 #ifdef DRIVER 00397 00398 typedef struct _RING_BUFFER 00399 { 00400 PUCHAR inPtr; 00401 PUCHAR outPtr; 00402 ULONG totalSize; 00403 ULONG currentSize; 00404 KSPIN_LOCK spinLock; 00405 PUCHAR buffer; 00406 } RING_BUFFER, *PRING_BUFFER; 00407 00408 PRING_BUFFER 00409 AllocRingBuffer( 00410 ULONG Size 00411 ); 00412 00413 VOID 00414 FreeRingBuffer( 00415 PRING_BUFFER ringBuffer 00416 ); 00417 00418 ULONG 00419 ReadRingBuffer( 00420 PRING_BUFFER ringBuffer, 00421 PUCHAR readBuffer, 00422 ULONG numberOfBytesToRead 00423 ); 00424 00425 ULONG 00426 WriteRingBuffer( 00427 PRING_BUFFER ringBuffer, 00428 PUCHAR writeBuffer, 00429 ULONG numberOfBytesToWrite 00430 ); 00431 00432 typedef struct _EZUSB_FIRMWARE 00433 { 00434 // tag contains a string to identify the start of the firmware 00435 // image in the driver binary. Another utilty can then be used 00436 // to replace the firmware image inthe driver without requiring 00437 // a recompile 00438 UCHAR tag[10]; 00439 ULONG size; 00440 UCHAR firmware[]; 00441 } EZUSB_FIRMWARE, *PEZUSB_FIRMWARE; 00442 00443 // 00444 // this is the default number of IRP's to queue for streaming ISO 00445 // data. 00446 // 00447 #define DEFAULT_ISO_BUFFER_COUNT 2 00448 00449 // 00450 // Default number of frames of ISO data transferred by a single ISO 00451 // URB/IRP 00452 // 00453 #define DEFAULT_ISO_FRAMES_PER_BUFFER 10 00454 00455 typedef struct _ISO_STREAM_OBJECT ISO_STREAM_OBJECT, *PISO_STREAM_OBJECT; 00456 00457 typedef struct _ISO_TRANSFER_OBJECT 00458 { 00459 ULONG Frame; 00460 PISO_STREAM_OBJECT StreamObject; 00461 PURB Urb; 00462 PIRP Irp; 00463 KEVENT Done; 00464 } ISO_TRANSFER_OBJECT, *PISO_TRANSFER_OBJECT; 00465 00466 typedef struct _ISO_STREAM_OBJECT 00467 { 00468 PDEVICE_OBJECT DeviceObject; 00469 ULONG PacketSize; 00470 ULONG NumPackets; 00471 PUSBD_PIPE_INFORMATION PipeInfo; 00472 PVOID TransferBuffer; 00473 ULONG TransferBufferLength; 00474 PVOID IsoDescriptorBuffer; 00475 ULONG FramesPerBuffer; 00476 ULONG BufferCount; 00477 ULONG PendingTransfers; 00478 PRING_BUFFER DataRingBuffer; 00479 PRING_BUFFER DescriptorRingBuffer; 00480 PISO_TRANSFER_OBJECT TransferObject; 00481 } ISO_STREAM_OBJECT, *PISO_STREAM_OBJECT; 00482 00483 00484 #define Ezusb_NAME_MAX 64 00485 00486 00487 00488 00489 // 00490 // This is an unused structure in this driver, but is provided here 00491 // so when you extend the driver to deal with USB pipes, you may wish 00492 // to use this structure as an example or model. 00493 // 00494 typedef struct _EZUSB_PIPE { 00495 ULONG Mode; 00496 ULONG Option; 00497 ULONG Param1; 00498 ULONG Param2; 00499 WCHAR Name[Ezusb_NAME_MAX]; 00500 PUSBD_PIPE_INFORMATION PipeInfo; 00501 } EZUSB_PIPE, *PEZUSB_PIPE; 00502 00503 00504 /* 00505 // The interface number on this device that this driver expects to use 00506 // This would be in the bInterfaceNumber field of the Interface Descriptor, hence 00507 // this device driver would need to know this value. 00508 */ 00509 #define SAMPLE_INTERFACE_NBR 0x00 00510 00511 00512 // 00513 // A structure representing the instance information associated with 00514 // this particular device. 00515 // 00516 typedef struct _DEVICE_EXTENSION 00517 { 00518 00519 // physical device object 00520 PDEVICE_OBJECT PhysicalDeviceObject; 00521 00522 // Device object we call when submitting Urbs/Irps to the USB stack 00523 PDEVICE_OBJECT StackDeviceObject; 00524 00525 // Indicates that we have recieved a STOP message 00526 BOOLEAN Stopped; 00527 00528 // Indicates that we are enumerated and configured. Used to hold 00529 // of requests until we are ready for them 00530 BOOLEAN Started; 00531 00532 // Indicates the device needs to be cleaned up (ie., some configuration 00533 // has occurred and needs to be torn down). 00534 BOOLEAN NeedCleanup; 00535 00536 // configuration handle for the configuration the 00537 // device is currently in 00538 USBD_CONFIGURATION_HANDLE ConfigurationHandle; 00539 00540 // ptr to the USB device descriptor 00541 // for this device 00542 PUSB_DEVICE_DESCRIPTOR DeviceDescriptor; 00543 00544 // we support up to one interface 00545 PUSBD_INTERFACE_INFORMATION Interface; 00546 00547 // the number of device handles currently open to the device object. 00548 // Gets incremented by Create and decremented by Close 00549 ULONG OpenHandles; 00550 00551 // Name buffer for our named Functional device object link 00552 WCHAR DeviceLinkNameBuffer[Ezusb_NAME_MAX]; 00553 00554 // This member is used to store the URB status of the 00555 // most recently failed URB. If a USB transfer fails, a caller 00556 // can use IOCTL_EZUSB_GET_LAST_ERROR to retrieve this value. 00557 // There's only room for one, so you better get it quick (or at 00558 // least before the next URB failure occurs). 00559 USBD_STATUS LastFailedUrbStatus; 00560 00561 // use counter for the device. Gets incremented when the driver receives 00562 // a request and gets decremented when a request s completed. 00563 LONG usage; 00564 00565 // this ev gets set when it is ok to remove the device 00566 KEVENT evRemove; 00567 00568 // TRUE if we're trying to remove this device 00569 BOOLEAN removing; 00570 00571 BOOLEAN StopIsoStream; 00572 00573 PRING_BUFFER DataRingBuffer; 00574 PRING_BUFFER DescriptorRingBuffer; 00575 00576 } DEVICE_EXTENSION, *PDEVICE_EXTENSION; 00577 00578 00579 #if DBG 00580 00581 #define Ezusb_KdPrint(_x_) DbgPrint("Ezusb.SYS: "); \ 00582 DbgPrint _x_ ; 00583 #define TRAP() DbgBreakPoint() 00584 #else 00585 #define Ezusb_KdPrint(_x_) 00586 #define TRAP() 00587 #endif 00588 00589 00590 NTSTATUS 00591 Ezusb_Dispatch( 00592 IN PDEVICE_OBJECT DeviceObject, 00593 IN PIRP Irp 00594 ); 00595 00596 VOID 00597 Ezusb_Unload( 00598 IN PDRIVER_OBJECT DriverObject 00599 ); 00600 00601 NTSTATUS 00602 Ezusb_StartDevice( 00603 IN PDEVICE_OBJECT DeviceObject 00604 ); 00605 00606 NTSTATUS 00607 Ezusb_StopDevice( 00608 IN PDEVICE_OBJECT DeviceObject 00609 ); 00610 00611 NTSTATUS 00612 Ezusb_RemoveDevice( 00613 IN PDEVICE_OBJECT DeviceObject 00614 ); 00615 00616 NTSTATUS 00617 Ezusb_CallUSBD( 00618 IN PDEVICE_OBJECT DeviceObject, 00619 IN PURB Urb 00620 ); 00621 00622 NTSTATUS 00623 Ezusb_PnPAddDevice( 00624 IN PDRIVER_OBJECT DriverObject, 00625 IN PDEVICE_OBJECT PhysicalDeviceObject 00626 ); 00627 00628 NTSTATUS 00629 Ezusb_CreateDeviceObject( 00630 IN PDRIVER_OBJECT DriverObject, 00631 IN PDEVICE_OBJECT *DeviceObject, 00632 LONG Instance 00633 ); 00634 00635 NTSTATUS 00636 Ezusb_ConfigureDevice( 00637 IN PDEVICE_OBJECT DeviceObject 00638 ); 00639 00640 NTSTATUS 00641 Ezusb_Create( 00642 IN PDEVICE_OBJECT DeviceObject, 00643 IN PIRP Irp 00644 ); 00645 00646 NTSTATUS 00647 Ezusb_Close( 00648 IN PDEVICE_OBJECT DeviceObject, 00649 IN PIRP Irp 00650 ); 00651 00652 NTSTATUS 00653 Ezusb_Read_Write( 00654 IN PDEVICE_OBJECT DeviceObject, 00655 IN PIRP Irp 00656 ); 00657 00658 NTSTATUS 00659 Ezusb_ProcessIOCTL( 00660 IN PDEVICE_OBJECT DeviceObject, 00661 IN PIRP Irp 00662 ); 00663 00664 NTSTATUS 00665 Ezusb_SelectInterfaces( 00666 IN PDEVICE_OBJECT DeviceObject, 00667 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, 00668 IN PUSBD_INTERFACE_INFORMATION Interface 00669 ); 00670 00671 NTSTATUS 00672 Ezusb_ResetPipe( 00673 IN PDEVICE_OBJECT DeviceObject, 00674 IN ULONG PipeNum 00675 ); 00676 00677 NTSTATUS 00678 Ezusb_AbortPipe( 00679 IN PDEVICE_OBJECT DeviceObject, 00680 IN USBD_PIPE_HANDLE PipeHandle 00681 ); 00682 00683 ULONG 00684 Ezusb_GetCurrentFrameNumber( 00685 IN PDEVICE_OBJECT DeviceObject 00686 ); 00687 00688 NTSTATUS 00689 Ezusb_Read_Write_Direct( 00690 IN PDEVICE_OBJECT DeviceObject, 00691 IN PIRP Irp, 00692 IN BOOLEAN Read 00693 ); 00694 00695 ULONG 00696 Ezusb_DownloadTest( 00697 IN PDEVICE_OBJECT DeviceObject, 00698 IN PVENDOR_REQUEST_IN pVendorRequest 00699 ); 00700 00701 NTSTATUS 00702 Ezusb_ResetParentPort( 00703 IN IN PDEVICE_OBJECT DeviceObject 00704 ); 00705 00706 VOID 00707 Ezusb_Cleanup( 00708 PDEVICE_OBJECT DeviceObject 00709 ); 00710 00711 ULONG 00712 Ezusb_GetDescriptor( 00713 IN PDEVICE_OBJECT fdo, 00714 PVOID DescriptorBuffer, 00715 ULONG BufferLength, 00716 UCHAR DescriptorType 00717 ); 00718 00719 ULONG 00720 Ezusb_GetDeviceDescriptor( 00721 IN PDEVICE_OBJECT DeviceObject, 00722 PVOID pvOutputBuffer 00723 ); 00724 00725 ULONG 00726 Ezusb_GetConfigDescriptor( 00727 IN PDEVICE_OBJECT DeviceObject, 00728 PVOID pvOutputBuffer, 00729 ULONG ulngth 00730 ); 00731 00732 ULONG 00733 Ezusb_VendorRequest( 00734 IN PDEVICE_OBJECT DeviceObject, 00735 PVENDOR_REQUEST_IN pVendorRequest 00736 ); 00737 00738 ULONG 00739 Ezusb_GetCurrentConfig( 00740 IN PDEVICE_OBJECT DeviceObject, 00741 IN PVENDOR_REQUEST_IN pVendorRequest 00742 ); 00743 00744 ULONG 00745 Ezusb_GetCurrentInterface( 00746 IN PDEVICE_OBJECT DeviceObject, 00747 IN PVENDOR_REQUEST_IN pVendorRequest 00748 ); 00749 00750 PUSB_CONFIGURATION_DESCRIPTOR 00751 GetConfigDescriptor( 00752 IN PDEVICE_OBJECT DeviceObject 00753 ); 00754 00755 NTSTATUS 00756 ConfigureDevice( 00757 IN PDEVICE_OBJECT DeviceObject 00758 ); 00759 00760 NTSTATUS 00761 SetInterface( 00762 IN PDEVICE_OBJECT DeviceObject, 00763 IN UCHAR InterfaceNumber, 00764 IN UCHAR AlternateSetting 00765 ); 00766 00767 ULONG 00768 Ezusb_GetStringDescriptor( 00769 IN PDEVICE_OBJECT DeviceObject, 00770 UCHAR Index, 00771 USHORT LanguageId, 00772 PVOID pvOutputBuffer, 00773 ULONG ulLength 00774 ); 00775 00776 NTSTATUS 00777 Ezusb_VendorRequest2( 00778 IN PDEVICE_OBJECT DeviceObject, 00779 IN PIRP Irp 00780 ); 00781 00782 00783 NTSTATUS 00784 ForwardAndWait( 00785 IN PDEVICE_OBJECT DeviceObject, 00786 IN PIRP Irp 00787 ); 00788 00789 00790 NTSTATUS 00791 Ezusb_DefaultPnpHandler( 00792 IN PDEVICE_OBJECT fdo, 00793 IN PIRP Irp 00794 ); 00795 00796 00797 NTSTATUS 00798 Ezusb_DispatchPnp( 00799 IN PDEVICE_OBJECT DeviceObject, 00800 IN PIRP Irp 00801 ); 00802 00803 NTSTATUS 00804 Ezusb_DispatchPower( 00805 IN PDEVICE_OBJECT DeviceObject, 00806 IN PIRP Irp 00807 ); 00808 00809 NTSTATUS 00810 Ezusb_HandleStartDevice( 00811 IN PDEVICE_OBJECT DeviceObject, 00812 IN PIRP Irp 00813 ); 00814 00815 NTSTATUS 00816 Ezusb_HandleRemoveDevice( 00817 IN PDEVICE_OBJECT fdo, 00818 IN PIRP Irp 00819 ); 00820 00821 NTSTATUS 00822 OnRequestComplete( 00823 IN PDEVICE_OBJECT DeviceObject, 00824 IN PIRP Irp, 00825 IN PKEVENT pev 00826 ); 00827 00828 NTSTATUS 00829 CompleteRequest( 00830 IN PIRP Irp, 00831 IN NTSTATUS status, 00832 IN ULONG info 00833 ); 00834 00835 BOOLEAN LockDevice( 00836 IN PDEVICE_OBJECT fdo 00837 ); 00838 00839 void UnlockDevice( 00840 PDEVICE_OBJECT fdo 00841 ); 00842 00843 00844 NTSTATUS InitTransferObject( 00845 IN OUT PISO_STREAM_OBJECT streamObject, 00846 IN ULONG index 00847 ); 00848 00849 NTSTATUS Ezusb_StartIsoTransfer( 00850 IN PDEVICE_OBJECT fdo, 00851 IN PIRP Irp 00852 ); 00853 00854 NTSTATUS IsoTransferComplete( 00855 IN PDEVICE_OBJECT fdo, 00856 IN PIRP Irp, 00857 IN PVOID Context 00858 ); 00859 00860 00861 NTSTATUS Ezusb_AnchorDownload( 00862 PDEVICE_OBJECT fdo, 00863 WORD offset, 00864 PUCHAR downloadBuffer, 00865 ULONG downloadSize 00866 ); 00867 00868 NTSTATUS Ezusb_DownloadIntelHex( 00869 PDEVICE_OBJECT fdo, 00870 PINTEL_HEX_RECORD hexRecord 00871 ); 00872 00873 NTSTATUS Ezusb_8051Reset( 00874 PDEVICE_OBJECT fdo, 00875 UCHAR resetBit 00876 ); 00877 00878 NTSTATUS Ezusb_StartIsoStream( 00879 IN PDEVICE_OBJECT fdo, 00880 IN PIRP Irp 00881 ); 00882 00883 BOOLEAN IsFx2( 00884 IN PDEVICE_OBJECT fdo 00885 ); 00886 00887 NTSTATUS Ezusb_SetFeature( 00888 IN PDEVICE_OBJECT fdo, 00889 IN PSET_FEATURE_CONTROL setFeatureControl 00890 ); 00891 00892 #endif //DRIVER section 00893 00894 00896 // 00897 // IOCTL Definitions 00898 // 00899 // User mode applications wishing to send IOCTLs to a kernel mode driver 00900 // must use this file to set up the correct type of IOCTL code permissions. 00901 // 00902 // Note: this file depends on the file DEVIOCTL.H which contains the macro 00903 // definition for "CTL_CODE" below. Include that file before you include 00904 // this one in your source code. DEVIOCTL.H is a Microsoft header file. 00905 // DEVIOCTL.H is normally obtained by installing the Windows DDK. 00906 // 00908 00909 // 00910 // Set the base of the IOCTL control codes. This is somewhat of an 00911 // arbitrary base number, so you can change this if you want unique 00912 // IOCTL codes. You should consult the Windows NT DDK for valid ranges 00913 // of IOCTL index codes before you choose a base index number. 00914 // 00915 00916 #define Ezusb_IOCTL_INDEX 0x0800 00917 00918 00919 #define IOCTL_Ezusb_GET_PIPE_INFO CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00920 Ezusb_IOCTL_INDEX+0,\ 00921 METHOD_BUFFERED, \ 00922 FILE_ANY_ACCESS) 00923 00924 #define IOCTL_Ezusb_GET_DEVICE_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00925 Ezusb_IOCTL_INDEX+1,\ 00926 METHOD_BUFFERED, \ 00927 FILE_ANY_ACCESS) 00928 00929 #define IOCTL_Ezusb_GET_CONFIGURATION_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00930 Ezusb_IOCTL_INDEX+2,\ 00931 METHOD_BUFFERED, \ 00932 FILE_ANY_ACCESS) 00933 00934 #define IOCTL_Ezusb_BULK_OR_INTERRUPT_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00935 Ezusb_IOCTL_INDEX+3,\ 00936 METHOD_BUFFERED, \ 00937 FILE_ANY_ACCESS) 00938 00939 #define IOCTL_Ezusb_BULK_OR_INTERRUPT_READ CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00940 Ezusb_IOCTL_INDEX+4,\ 00941 METHOD_BUFFERED, \ 00942 FILE_ANY_ACCESS) 00943 00944 #define IOCTL_Ezusb_VENDOR_REQUEST CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00945 Ezusb_IOCTL_INDEX+5,\ 00946 METHOD_BUFFERED, \ 00947 FILE_ANY_ACCESS) 00948 00949 #define IOCTL_Ezusb_GET_CURRENT_CONFIG CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00950 Ezusb_IOCTL_INDEX+6,\ 00951 METHOD_BUFFERED, \ 00952 FILE_ANY_ACCESS) 00953 00954 #define IOCTL_Ezusb_ANCHOR_DOWNLOAD CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00955 Ezusb_IOCTL_INDEX+7,\ 00956 METHOD_BUFFERED, \ 00957 FILE_ANY_ACCESS) 00958 00959 #define IOCTL_Ezusb_RESET CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00960 Ezusb_IOCTL_INDEX+12,\ 00961 METHOD_IN_DIRECT, \ 00962 FILE_ANY_ACCESS) 00963 00964 #define IOCTL_Ezusb_RESETPIPE CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00965 Ezusb_IOCTL_INDEX+13,\ 00966 METHOD_IN_DIRECT, \ 00967 FILE_ANY_ACCESS) 00968 00969 #define IOCTL_Ezusb_ABORTPIPE CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00970 Ezusb_IOCTL_INDEX+15,\ 00971 METHOD_IN_DIRECT, \ 00972 FILE_ANY_ACCESS) 00973 00974 #define IOCTL_Ezusb_SETINTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00975 Ezusb_IOCTL_INDEX+16,\ 00976 METHOD_BUFFERED, \ 00977 FILE_ANY_ACCESS) 00978 00979 #define IOCTL_Ezusb_GET_STRING_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00980 Ezusb_IOCTL_INDEX+17,\ 00981 METHOD_BUFFERED, \ 00982 FILE_ANY_ACCESS) 00983 00984 00985 // 00986 // Perform an IN transfer over the specified bulk or interrupt pipe. 00987 // 00988 // lpInBuffer: BULK_TRANSFER_CONTROL stucture specifying the pipe number to read from 00989 // nInBufferSize: sizeof(BULK_TRANSFER_CONTROL) 00990 // lpOutBuffer: Buffer to hold data read from the device. 00991 // nOutputBufferSize: size of lpOutBuffer. This parameter determines 00992 // the size of the USB transfer. 00993 // lpBytesReturned: actual number of bytes read 00994 // 00995 #define IOCTL_EZUSB_BULK_READ CTL_CODE(FILE_DEVICE_UNKNOWN, \ 00996 Ezusb_IOCTL_INDEX+19,\ 00997 METHOD_OUT_DIRECT, \ 00998 FILE_ANY_ACCESS) 00999 01000 // 01001 // Perform an OUT transfer over the specified bulk or interrupt pipe. 01002 // 01003 // lpInBuffer: BULK_TRANSFER_CONTROL stucture specifying the pipe number to write to 01004 // nInBufferSize: sizeof(BULK_TRANSFER_CONTROL) 01005 // lpOutBuffer: Buffer of data to write to the device 01006 // nOutputBufferSize: size of lpOutBuffer. This parameter determines 01007 // the size of the USB transfer. 01008 // lpBytesReturned: actual number of bytes written 01009 // 01010 #define IOCTL_EZUSB_BULK_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01011 Ezusb_IOCTL_INDEX+20,\ 01012 METHOD_IN_DIRECT, \ 01013 FILE_ANY_ACCESS) 01014 01015 // 01016 // The following IOCTL's are defined as using METHOD_DIRECT_IN buffering. 01017 // This means that the output buffer is directly mapped into system 01018 // space and probed for read access by the driver. This means that it is 01019 // brought into memory if it happens to be paged out to disk. Even though 01020 // the buffer is only probed for read access, it is safe (probably) to 01021 // write to it as well. This read/write capability is used for the loopback 01022 // IOCTL's 01023 // 01024 01025 // TODO Insert Loopback IOCTL's 01026 01027 // 01028 // Retrieve the current USB frame number from the Host Controller 01029 // 01030 // lpInBuffer: NULL 01031 // nInBufferSize: 0 01032 // lpOutBuffer: PULONG to hold current frame number 01033 // nOutputBufferSize: sizeof(PULONG) 01034 // 01035 #define IOCTL_EZUSB_GET_CURRENT_FRAME_NUMBER CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01036 Ezusb_IOCTL_INDEX+21,\ 01037 METHOD_BUFFERED, \ 01038 FILE_ANY_ACCESS) 01039 01040 01041 // 01042 // Performs a vendor or class specific control transfer to EP0. The contents of 01043 // the input parameter determine the type of request. See the USB spec 01044 // for more information on class and vendor control transfers. 01045 // 01046 // lpInBuffer: PVENDOR_OR_CLASS_REQUEST_CONTROL 01047 // nInBufferSize: sizeof(VENDOR_OR_CLASS_REQUEST_CONTROL) 01048 // lpOutBuffer: pointer to a buffer if the request involves a data transfer 01049 // nOutputBufferSize: size of the transfer buffer (corresponds to the wLength 01050 // field of the USB setup packet) 01051 // 01052 #define IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01053 Ezusb_IOCTL_INDEX+22,\ 01054 METHOD_IN_DIRECT, \ 01055 FILE_ANY_ACCESS) 01056 01057 // 01058 // Retrieves the actual USBD_STATUS code for the most recently failed 01059 // URB. 01060 // 01061 // lpInBuffer: NULL 01062 // nInBufferSize: 0 01063 // lpOutBuffer: PULONG to hold the URB status 01064 // nOutputBufferSize: sizeof(ULONG) 01065 // 01066 01067 #define IOCTL_EZUSB_GET_LAST_ERROR CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01068 Ezusb_IOCTL_INDEX+23,\ 01069 METHOD_BUFFERED, \ 01070 FILE_ANY_ACCESS) 01071 01072 // 01073 // Reads from the specified ISO endpoint. (USB IN Transfer) 01074 // 01075 // lpInBuffer: ISO_TRANSFER_CONTROL 01076 // nInBufferSize: sizeof(ISO_TRANSFER_CONTROL) 01077 // lpOutBuffer: buffer to hold data read from the device 01078 // nOutputBufferSize: size of the read buffer. 01079 // 01080 // 01081 // 01082 01083 #define IOCTL_EZUSB_ISO_READ CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01084 Ezusb_IOCTL_INDEX+25,\ 01085 METHOD_OUT_DIRECT, \ 01086 FILE_ANY_ACCESS) 01087 01088 // 01089 // Writes to the specified ISO endpoint. (USB OUT Transfer) 01090 // 01091 // lpInBuffer: ISO_TRANSFER_CONTROL 01092 // nInBufferSize: sizeof(ISO_TRANSFER_CONTROL) 01093 // lpOutBuffer: buffer to hold data to write to the device 01094 // nOutputBufferSize: size of the write buffer. 01095 // 01096 // 01097 // 01098 01099 #define IOCTL_EZUSB_ISO_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01100 Ezusb_IOCTL_INDEX+26,\ 01101 METHOD_IN_DIRECT, \ 01102 FILE_ANY_ACCESS) 01103 01104 // 01105 // Performs and Anchor Download. 01106 // 01107 // lpInBuffer: PANCHOR_DOWNLOAD_CONTROL 01108 // nInBufferSize: sizeof(ANCHOR_DOWNLOAD_CONTROL) 01109 // lpOutBuffer: pointer to a buffer of data to download to the device 01110 // nOutputBufferSize: size of the transfer buffer 01111 // 01112 #define IOCTL_EZUSB_ANCHOR_DOWNLOAD CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01113 Ezusb_IOCTL_INDEX+27,\ 01114 METHOD_IN_DIRECT, \ 01115 FILE_ANY_ACCESS) 01116 01117 // 01118 // Returns driver version information 01119 // 01120 // lpInBuffer: NULL 01121 // nInBufferSize: 0 01122 // lpOutBuffer: PEZUSB_DRIVER_VERSION 01123 // nOutputBufferSize: sizeof(EZUSB_DRIVER_VERSION) 01124 // 01125 #define IOCTL_EZUSB_GET_DRIVER_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01126 Ezusb_IOCTL_INDEX+29,\ 01127 METHOD_BUFFERED, \ 01128 FILE_ANY_ACCESS) 01129 01130 #define IOCTL_EZUSB_START_ISO_STREAM CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01131 Ezusb_IOCTL_INDEX+30,\ 01132 METHOD_BUFFERED, \ 01133 FILE_ANY_ACCESS) 01134 01135 #define IOCTL_EZUSB_STOP_ISO_STREAM CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01136 Ezusb_IOCTL_INDEX+31,\ 01137 METHOD_BUFFERED, \ 01138 FILE_ANY_ACCESS) 01139 01140 #define IOCTL_EZUSB_READ_ISO_BUFFER CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01141 Ezusb_IOCTL_INDEX+32,\ 01142 METHOD_OUT_DIRECT, \ 01143 FILE_ANY_ACCESS) 01144 01145 #define IOCTL_EZUSB_SET_FEATURE CTL_CODE(FILE_DEVICE_UNKNOWN, \ 01146 Ezusb_IOCTL_INDEX+33,\ 01147 METHOD_BUFFERED, \ 01148 FILE_ANY_ACCESS)
Generated on Tue Nov 24 19:04:59 2009 for CREAM TEA -- MCP/TARGET Readout by
1.3.9.1