home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Mac OS USB DDK_v1.0.1 / Examples / PrinterClassDriver / PrintDriverShell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-03  |  3.9 KB  |  145 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.     File:        PrintDriverShell.c
  4.  
  5.     Contains:    Toms wrapper for BT's hub driver. Just the header block etc
  6.  
  7.     Version:    
  8.  
  9. */
  10.  
  11. #include <Types.h>
  12. #include <Devices.h>
  13. #include <DriverServices.h>
  14. #include <USB.h>
  15.  
  16. #include "PrinterClassDriver.h"
  17.  
  18. //------------------------------------------------------
  19. //
  20. // Protos
  21. //
  22. //------------------------------------------------------
  23. OSStatus printDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc);
  24. OSStatus printDriverInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  25. OSStatus printDriverInitInterface( UInt32 interfaceNum, USBInterfaceDescriptor *interfaceDesc, USBDeviceDescriptor *deviceDesc, USBDeviceRef device);
  26. OSStatus printDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr desc );
  27. OSStatus    printDriverNotifyProc(UInt32     notification, void *pointer);
  28.  
  29. //------------------------------------------------------
  30. //
  31. //    This is the driver description structure that the expert looks for first.
  32. //  If it's here, the information within is used to match the driver
  33. //  to the device whose descriptor was passed to the expert.
  34. //    Information in this block is also used by the expert when an
  35. //  entry is created in the Name Registry.
  36. //
  37. //------------------------------------------------------
  38. enum {
  39.     kMajorRev = 0,
  40.     kMinorAndBugRev = 0,
  41.     kStage = developStage,
  42.     kNonRelRev = 0
  43. };
  44.  
  45.  
  46. USBDriverDescription    TheUSBDriverDescription = 
  47. {
  48.     // Signature info
  49.     kTheUSBDriverDescriptionSignature,
  50.     kInitialUSBDriverDescriptor,
  51.     
  52.     // Device Info
  53.     0,                                        // vendor = not device specific
  54.     0,                                        // product = not device specific
  55.     0,                                        // version of product = not device specific
  56.     0,                                        // protocol = not device specific
  57.     
  58.     // Interface Info    (* I don't think this would always be required...*)                
  59.     0,                                        // Configuration Value
  60.     0,                                        // Interface Number
  61.     kUSBPrintClass,                    // Device Class  (from USBDeviceDefines.h)
  62.     kUSBPrintSubClass,                // Device Subclass 
  63.     0,                                        // Interface Protocol
  64.         
  65.     
  66.     // Driver Info    
  67.     "\pUSBPrint",                        // Driver name for Name Registry
  68.     kUSBPrintClass,                    // Device Class  (from USBDeviceDefines.h)
  69.     kUSBPrintSubClass,                // Device Subclass 
  70.     kMajorRev, kMinorAndBugRev, kStage, kNonRelRev,        // version of driver
  71.     
  72.     // Driver Loading Info
  73.     0x00000000                                // Flags (currently undefined)
  74. };
  75.  
  76.     
  77. USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
  78. {
  79.     kClassDriverPluginVersion,            // Version of this structure
  80.     printDriverValidateHW,                // Hardware Validation Procedure
  81.     printDriverInitialize,                // Initialization Procedure
  82.     printDriverInitInterface,                // Interface Initialization Procedure
  83.     printDriverFinalize,                    // Finalization Procedure
  84.     printDriverNotifyProc,                // Driver Notification Procedure
  85. };
  86.  
  87. // Hardware Validation
  88. // Called upon load by Expert
  89. OSStatus 
  90. printDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
  91. {
  92.     device = 0;
  93.     desc = 0;
  94.     return (OSStatus)noErr;
  95. }
  96.  
  97.  
  98. // Initialization function
  99. // Called upon load by Expert
  100. OSStatus 
  101. printDriverInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc,
  102.                                     UInt32 busPowerAvailable)
  103. {
  104.     busPowerAvailable = 0;
  105.     
  106.     PrintDriverEntry(device, pDesc, NULL );
  107.     return (OSStatus)noErr;
  108. }
  109.  
  110. // printDriverInitInterface function
  111. // Called to initialize driver for an individual interface - either by expert or
  112. // internally by driver
  113. OSStatus
  114. printDriverInitInterface(
  115.             UInt32                         interfaceNum, 
  116.             USBInterfaceDescriptor    *interfaceDesc, 
  117.             USBDeviceDescriptor        *deviceDesc, 
  118.             USBDeviceRef                 device)
  119. {
  120.     interfaceNum = 0;
  121.  
  122.     PrintDriverEntry(device, deviceDesc, interfaceDesc );
  123.     
  124.     return (OSStatus)noErr;
  125. }
  126.  
  127. // Termination function
  128. // Called by Expert when driver is being shut down
  129. OSStatus
  130. printDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr desc )
  131. {
  132. #pragma unused(device)
  133. #pragma unused(desc)
  134.  
  135.     return PrintDriverFinalize();
  136. }
  137.  
  138. OSStatus    
  139. printDriverNotifyProc(UInt32     notification, void *pointer)
  140. {
  141.     pointer = 0;
  142.     notification = 0;
  143.     return(noErr);
  144. }
  145.