home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Networking / PCCardNetworkSample / MyPortModule.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.2 KB  |  80 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        MyPortModule.c
  3.  
  4.     Contains:    
  5.  
  6.     Written by:     
  7.  
  8.     Copyright:    Copyright © 1998-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/16/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #include <OpenTptModule.h>
  25. #include <OpenTptLinks.h>
  26. #include "EnablerSample.h"
  27. #include "MyPortCalls.h"
  28.  
  29. #pragma import on
  30. OTPortRecord        gPortRecord;
  31.  
  32. //extern void     OfflineThePort(void);
  33. extern void        RegisterThePort(const RegEntryID *cardRef);
  34.  
  35. /*void OfflineThePort(void)
  36. {
  37. #if    DEBUG_WATCH_FUNC    
  38.     DebugStr("\pCustomCardEnabler: OfflineThePort");        
  39. #endif
  40.     if (OTStrLength(gPortRecord.fPortName) > 0)
  41.     {
  42.         OTOfflinePort(gPortRecord.fPortName, nil);
  43.         gPortRecord.fPortName[0] = 0;
  44.     }
  45. }*/
  46.  
  47. void     RegisterThePort(const RegEntryID *cardRef)
  48. {
  49.     UInt16             other = 0;
  50.     size_t            sIndex = 0;
  51.     
  52. #if    DEBUG_WATCH_FUNC    
  53.     DebugStr("\pCustomCardEnabler:  RegisterThePort");        
  54. #endif
  55.     OTMemzero(&gPortRecord, sizeof(gPortRecord));
  56.     OTMemcpy(&gPortRecord.fModuleName, &gDriverName, sizeof(gDriverName) + 1);
  57.     
  58.         // find a unique "other" value for this device
  59.     do
  60.     {
  61.         gPortRecord.fRef = OTCreatePortRef(kOTPCCardBus, kOTEthernetDevice, 0, other++);
  62.     } while ( OTFindPortByRef(gPortRecord.fRef) != 0 );
  63.     
  64.         // now find the associated slot number
  65.     gPortRecord.fSlotID[0] = 0;
  66.  
  67.         // for the fInfoFlag the 0x1 indicates the module is DLPI
  68.         // for a TPI interface, set the value to 0x2
  69.     gPortRecord.fInfoFlags                = 0x1 | kOTPortIsSystemRegistered | kOTModUsesInterrupts;
  70.     gPortRecord.fCapabilities            = kOTFramingEthernet | kOTFramingEthernetIPX | kOTFraming8022;
  71.     gPortRecord.fNumChildPorts            = 0;
  72.     gPortRecord.fPortName[0]                = 0;
  73.     
  74.     OTRegisterPort(&gPortRecord, (void*)cardRef);
  75.         
  76. }
  77.  
  78.  
  79. #pragma import off
  80.