home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK2.toast / Development Kits / USBDDK_v1.0.1_updated / Examples / USBSampleStorageDriver / SampleStorageHeader.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-29  |  4.2 KB  |  146 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        StorageDriverHeader.c
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10.  
  11. */
  12.  
  13.  
  14.  
  15. #include <Types.h>
  16. #include <Devices.h>
  17. #include <DriverServices.h>
  18. #include <USB.h>
  19.  
  20. #include "SampleStorageDriver.h"
  21. #include "SampleStorageVersion.h"
  22. #include "SampleStorageDeviceID.h"
  23.  
  24. //------------------------------------------------------
  25. //
  26. // Protos
  27. //
  28. //------------------------------------------------------
  29. OSStatus StorageDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc);
  30. OSStatus StorageDriverInitDevice(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  31. OSStatus StorageDriverInitInterface( UInt32 interfaceNum, USBInterfaceDescriptor *interfaceDesc, USBDeviceDescriptor *deviceDesc, USBDeviceRef device);
  32. OSStatus StorageDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr desc );
  33. OSStatus    StorageDriverNotifyProc(UInt32     notification, void *pointer);
  34.  
  35. //------------------------------------------------------
  36. //
  37. //    This is the driver description structure that the expert looks for first.
  38. //  If it's here, the information within is used to match the driver
  39. //  to the device whose descriptor was passed to the expert.
  40. //    Information in this block is also used by the expert when an
  41. //  entry is created in the Name Registry.
  42. //
  43. //------------------------------------------------------
  44. USBDriverDescription    TheUSBDriverDescription = 
  45. {
  46.     // Signature info
  47.     kTheUSBDriverDescriptionSignature,    // 'usbd'
  48.     kInitialUSBDriverDescriptor,            // 0
  49.     
  50.     // Device Info
  51.     kDriverVendorID,                            // USB Vendor ID
  52.     kDriverProductID,                        // USB Product ID.
  53.     0,                                                // Release Number of Device
  54.     0,                                                // Protocol Info.
  55.     
  56.     // Interface Info    (* I don't think this would always be required...*)                
  57.     0,                                                // Configuration Value
  58.     0,                                                // Interface Number
  59.     0,                                                // Interface Class
  60.     0,                                             // Interface SubClass
  61.     0,                                                // Interface Protocol
  62.         
  63.     
  64.     // Driver Info    
  65.     "\pUSB Storage Class",                    // Driver name for Name Registry
  66.     kDriverClassID,                // Device Class  (from USBDeviceDefines.h)
  67.     kDriverSubClassID,                                                // Device Subclass for version 13 and later of Shuttle firmware
  68.     kStorageHexMajorVers, kStorageHexMinorVers, kStorageReleaseStage, kStorageCurrentRelease,        // version of driver = 0.0d0
  69.     
  70.     // Driver Loading Info
  71.     0x00000000                                    // Flags (currently undefined)
  72. };
  73.     
  74. USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
  75. {
  76.     kClassDriverPluginVersion,                // Version of this structure
  77.     StorageDriverValidateHW,                // Hardware Validation Procedure
  78.     StorageDriverInitDevice,                // Initialization Procedure
  79.     StorageDriverInitInterface,            // Interface Initialization Procedure
  80.     StorageDriverFinalize,                    // Finalization Procedure
  81.     StorageDriverNotifyProc,                // Driver Notification Procedure
  82. };
  83.  
  84. // Hardware Validation
  85. // Called upon load by Expert
  86. OSStatus 
  87. StorageDriverValidateHW(    USBDeviceRef            device,
  88.                                     USBDeviceDescriptor    *desc)
  89. {
  90.     device = 0;
  91.     desc = 0;
  92.     return (OSStatus)noErr;
  93. }
  94.  
  95.  
  96. // Initialization function
  97. // Called upon load by Expert
  98. OSStatus 
  99. StorageDriverInitDevice(    USBDeviceRef                device,
  100.                                     USBDeviceDescriptorPtr    pDesc,
  101.                                     UInt32                        busPowerAvailable)
  102. {
  103.     busPowerAvailable = 0;
  104.     
  105.     StorageDriverEntry(device, pDesc, NULL );
  106.     
  107.     return (OSStatus)noErr;
  108. }
  109.  
  110. // StorageDriverInitInterface function
  111. // Called to initialize driver for an individual interface - either by expert or
  112. // internally by driver
  113. OSStatus
  114. StorageDriverInitInterface(    UInt32                         interfaceNum, 
  115.                                         USBInterfaceDescriptor    *interfaceDesc, 
  116.                                         USBDeviceDescriptor        *deviceDesc, 
  117.                                         USBDeviceRef                 device)
  118. {
  119.     interfaceNum = 0;
  120.  
  121.     StorageDriverEntry(device, deviceDesc, interfaceDesc );
  122.     
  123.     return (OSStatus)noErr;
  124. }
  125.  
  126. // Termination function
  127. // Called by Expert when driver is being shut down
  128. OSStatus
  129. StorageDriverFinalize(    USBDeviceRef                device,
  130.                                 USBDeviceDescriptorPtr    desc )
  131. {
  132. #pragma unused(device)
  133. #pragma unused(desc)
  134.  
  135.     StorageClassDriverFinalize();
  136.  
  137.     return (OSStatus)noErr;
  138. }
  139.  
  140. OSStatus    
  141. StorageDriverNotifyProc(UInt32    notification,
  142.                                 void*        pointer)
  143. {
  144.     return(StorageClassDriverNotifyProc(notification, pointer));
  145. }
  146.