Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

761 lines
25 KiB

  1. /*
  2. (C) Copyright 1998
  3. All rights reserved.
  4. Portions of this software are:
  5. (C) Copyright 1995, 1999 TriplePoint, Inc. -- http://www.TriplePoint.com
  6. License to use this software is granted under the terms outlined in
  7. the TriplePoint Software Services Agreement.
  8. (C) Copyright 1992 Microsoft Corp. -- http://www.Microsoft.com
  9. License to use this software is granted under the terms outlined in
  10. the Microsoft Windows Device Driver Development Kit.
  11. @doc INTERNAL Adapter Adapter_c
  12. @module Adapter.c |
  13. This module implements the interface to the <t MINIPORT_ADAPTER_OBJECT>.
  14. Supports the high-level adapter control functions used by the NDIS WAN
  15. Minport driver. This module isolates most the NDIS specific logical
  16. adapter interfaces. It should require very little change if you follow
  17. this same overall architecture. You should try to isolate your changes
  18. to the <t CARD_OBJECT> that is contained within the logical adapter
  19. <t MINIPORT_ADAPTER_OBJECT>.
  20. @head3 Contents |
  21. @index class,mfunc,func,msg,mdata,struct,enum | Adapter_c
  22. @end
  23. */
  24. #define __FILEID__ MINIPORT_ADAPTER_OBJECT_TYPE
  25. // Unique file ID for error logging
  26. #include "Miniport.h" // Defines all the miniport objects
  27. #if defined(NDIS_LCODE)
  28. # pragma NDIS_LCODE // Windows 95 wants this code locked down!
  29. # pragma NDIS_LDATA
  30. #endif
  31. PMINIPORT_ADAPTER_OBJECT g_Adapters[MAX_ADAPTERS] // @globalv
  32. // Keeps track of all the <t MINIPORT_ADAPTER_OBJECT>s created by the driver.
  33. = { 0 };
  34. DBG_STATIC ULONG g_AdapterInstanceCounter // @globalv
  35. // Keeps track of how many <t MINIPORT_ADAPTER_OBJECT>s are created and
  36. // stored in the <p g_Adapters> array.
  37. = 0;
  38. DBG_STATIC UCHAR g_AnsiDriverName[] // @globalv
  39. // ANSI string used to identify the driver to the system; usually defined
  40. // as VER_PRODUCT_STR.
  41. = VER_PRODUCT_STR;
  42. DBG_STATIC UCHAR g_AnsiVendorDescription[] // @globalv
  43. // ANSI string used to identify the vendor's device to the system; usually
  44. // defined as VER_DEVICE_STR " Adapter".
  45. = VER_DEVICE_STR " Adapter";
  46. /* @doc INTERNAL EXTERNAL Adapter Adapter_c g_AdapterParameters
  47. @topic 5.1 Adapter Parameters |
  48. This section describes the registry parameters read into the
  49. <t MINIPORT_ADAPTER_OBJECT>.
  50. @globalv DBG_STATIC <t PARAM_TABLE> | g_AdapterParameters |
  51. This table defines the registry based parameters to be assigned to data
  52. members of the <t MINIPORT_ADAPTER_OBJECT>.
  53. <f Note>:
  54. If you add any registry based data members to <t MINIPORT_ADAPTER_OBJECT>
  55. you will need to modify <f AdapterReadParameters> and add the parameter
  56. definitions to the <f g_AdapterParameters> table.
  57. */
  58. DBG_STATIC NDIS_STRING g_DefaultAddressList // @globalv
  59. // Default value to be used for AddressList if it's not in the registry.
  60. = INIT_STRING_CONST(VER_DEFAULT_ADDRESSLIST);
  61. DBG_STATIC NDIS_STRING g_DefaultDeviceName // @globalv
  62. // Default value to be used for DeviceName if it's not in the registry.
  63. = INIT_STRING_CONST(VER_PRODUCT_STR);
  64. DBG_STATIC NDIS_STRING g_DefaultMediaType // @globalv
  65. // Default value to be used for MediaType if it's not in the registry.
  66. = INIT_STRING_CONST(VER_DEFAULT_MEDIATYPE);
  67. DBG_STATIC PARAM_TABLE g_AdapterParameters[] =
  68. {
  69. #if !defined(NDIS50_MINIPORT)
  70. PARAM_ENTRY(MINIPORT_ADAPTER_OBJECT,
  71. BusNumber, PARAM_BusNumber,
  72. TRUE, NdisParameterInteger, 0,
  73. 0, 0, 15),
  74. PARAM_ENTRY(MINIPORT_ADAPTER_OBJECT,
  75. BusType, PARAM_BusType,
  76. TRUE, NdisParameterInteger, 0,
  77. 0, Internal, MaximumInterfaceType),
  78. #endif // NDIS50_MINIPORT
  79. PARAM_ENTRY(MINIPORT_ADAPTER_OBJECT,
  80. TapiAddressList, PARAM_AddressList,
  81. FALSE, NdisParameterMultiString, 0,
  82. &g_DefaultAddressList, 0, 0),
  83. PARAM_ENTRY(MINIPORT_ADAPTER_OBJECT,
  84. DeviceName, PARAM_DeviceName,
  85. FALSE, NdisParameterString, 0,
  86. &g_DefaultDeviceName, 0, 0),
  87. PARAM_ENTRY(MINIPORT_ADAPTER_OBJECT,
  88. MediaType, PARAM_MediaType,
  89. FALSE, NdisParameterString, 0,
  90. &g_DefaultMediaType, 0, 0),
  91. PARAM_ENTRY(MINIPORT_ADAPTER_OBJECT,
  92. NoAnswerTimeOut, PARAM_NoAnswerTimeOut,
  93. FALSE, NdisParameterHexInteger, 0,
  94. CARD_NO_ANSWER_TIMEOUT, 5000, 120000),
  95. PARAM_ENTRY(MINIPORT_ADAPTER_OBJECT,
  96. NoAcceptTimeOut, PARAM_NoAcceptTimeOut,
  97. FALSE, NdisParameterHexInteger, 0,
  98. CARD_NO_ACCEPT_TIMEOUT, 1000, 60000),
  99. PARAM_ENTRY(MINIPORT_ADAPTER_OBJECT,
  100. RunningWin95, PARAM_RunningWin95,
  101. FALSE, NdisParameterInteger, 0,
  102. 0, 0, 1),
  103. #if DBG
  104. PARAM_ENTRY(MINIPORT_ADAPTER_OBJECT,
  105. DbgFlags, PARAM_DebugFlags,
  106. FALSE, NdisParameterHexInteger, 0,
  107. DBG_DEFAULTS | DBG_TAPICALL_ON, 0, 0xffffffff),
  108. // TODO: Change the debug flags to meet your needs.
  109. #endif
  110. /* The last entry must be an empty string! */
  111. { { 0 } }
  112. };
  113. /* @doc INTERNAL Adapter Adapter_c AdapterReadParameters
  114. @func
  115. <f AdapterReadParameters> reads the adapter parameters from the registry
  116. and initializes the associated data members. This should only be called
  117. by <f AdapterCreate>.
  118. <f Note>:
  119. If you add any registry based data members to <t MINIPORT_ADAPTER_OBJECT>
  120. you will need to modify <f AdapterReadParameters> and add the parameter
  121. definitions to the <f g_AdapterParameters> table.
  122. @rdesc
  123. <f AdapterReadParameters> returns zero if it is successful.<nl>
  124. Otherwise, a non-zero return value indicates an error condition.
  125. */
  126. DBG_STATIC NDIS_STATUS AdapterReadParameters(
  127. IN PMINIPORT_ADAPTER_OBJECT pAdapter // @parm
  128. // A pointer to the <t MINIPORT_ADAPTER_OBJECT> instance.
  129. )
  130. {
  131. DBG_FUNC("AdapterReadParameters")
  132. NDIS_STATUS Result;
  133. // Holds the result code returned by this function.
  134. ASSERT(pAdapter && pAdapter->ObjectType == MINIPORT_ADAPTER_OBJECT_TYPE);
  135. DBG_ENTER(DbgInfo);
  136. /*
  137. // Parse the registry parameters.
  138. */
  139. Result = ParamParseRegistry(
  140. pAdapter->MiniportAdapterHandle,
  141. pAdapter->WrapperConfigurationContext,
  142. (PUCHAR)pAdapter,
  143. g_AdapterParameters
  144. );
  145. if (Result == NDIS_STATUS_SUCCESS)
  146. {
  147. /*
  148. // Make sure the parameters are valid.
  149. */
  150. if (pAdapter->TODO)
  151. {
  152. DBG_ERROR(DbgInfo,("Invalid value 'TODO'\n",
  153. pAdapter->TODO));
  154. NdisWriteErrorLogEntry(
  155. pAdapter->MiniportAdapterHandle,
  156. NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION,
  157. 3,
  158. pAdapter->TODO,
  159. __FILEID__,
  160. __LINE__
  161. );
  162. Result = NDIS_STATUS_FAILURE;
  163. }
  164. else
  165. {
  166. /*
  167. // Construct the "MediaType\0DeviceName" string for use by TAPI
  168. // on Windows NT.
  169. */
  170. strcpy(pAdapter->ProviderInfo, pAdapter->MediaType.Buffer);
  171. strcpy(pAdapter->ProviderInfo + pAdapter->MediaType.Length + 1,
  172. pAdapter->DeviceName.Buffer);
  173. pAdapter->ProviderInfoSize = pAdapter->MediaType.Length + 1 +
  174. pAdapter->DeviceName.Length + 1;
  175. DBG_NOTICE(DbgInfo,("ProviderInfoMedia='%s\\0%s'\n",
  176. &pAdapter->ProviderInfo[0],
  177. &pAdapter->ProviderInfo[pAdapter->MediaType.Length + 1]
  178. ));
  179. }
  180. }
  181. DBG_RETURN(DbgInfo, Result);
  182. return (Result);
  183. }
  184. /* @doc INTERNAL Adapter Adapter_c AdapterCreateObjects
  185. @func
  186. <f AdapterCreateObjects> calls the create routines for all the objects
  187. contained in <t MINIPORT_ADAPTER_OBJECT>. This should only be called
  188. by <f AdapterCreate>.
  189. <f Note>:
  190. If you add any new objects to <t MINIPORT_ADAPTER_OBJECT> you will need
  191. to modify <f AdapterCreateObjects> and <f AdapterDestroyObjects> so they
  192. will get created and destroyed properly.
  193. @rdesc
  194. <f AdapterCreateObjects> returns zero if it is successful.<nl>
  195. Otherwise, a non-zero return value indicates an error condition.
  196. */
  197. DBG_STATIC NDIS_STATUS AdapterCreateObjects(
  198. IN PMINIPORT_ADAPTER_OBJECT pAdapter // @parm
  199. // A pointer to the <t MINIPORT_ADAPTER_OBJECT> instance.
  200. )
  201. {
  202. DBG_FUNC("AdapterCreateObjects")
  203. NDIS_STATUS Result;
  204. // Holds the result code returned by this function.
  205. ULONG Index;
  206. // Loop counter.
  207. ULONG NumBChannels;
  208. // The number of BChannels supported by the NIC.
  209. PANSI_STRING pTapiAddressList;
  210. // MultiString of RAS address strings.
  211. PUCHAR pTapiLineAddress;
  212. // A pointer to the RAS/TAPI line address assigned to each RAS line.
  213. ASSERT(pAdapter && pAdapter->ObjectType == MINIPORT_ADAPTER_OBJECT_TYPE);
  214. DBG_ENTER(DbgInfo);
  215. /*
  216. // Create the Card object.
  217. */
  218. Result = CardCreate(&pAdapter->pCard, pAdapter);
  219. /*
  220. // Create the DChannel object.
  221. */
  222. if (Result == NDIS_STATUS_SUCCESS)
  223. {
  224. Result = DChannelCreate(&pAdapter->pDChannel, pAdapter);
  225. }
  226. /*
  227. // Allocate space for the BChannels.
  228. */
  229. if (Result == NDIS_STATUS_SUCCESS)
  230. {
  231. NumBChannels = CardNumChannels(pAdapter->pCard);
  232. Result = ALLOCATE_MEMORY(pAdapter->pBChannelArray,
  233. sizeof(PVOID) * NumBChannels,
  234. pAdapter->MiniportAdapterHandle);
  235. }
  236. /*
  237. // Create the BChannel objects.
  238. */
  239. pTapiAddressList = &pAdapter->TapiAddressList;
  240. pTapiLineAddress = pTapiAddressList->Buffer;
  241. for (Index = 0; Result == NDIS_STATUS_SUCCESS &&
  242. Index < NumBChannels; Index++)
  243. {
  244. Result = BChannelCreate(&pAdapter->pBChannelArray[Index],
  245. Index,
  246. pTapiLineAddress,
  247. pAdapter);
  248. /*
  249. // If we run off the end of the address list, we just point at the
  250. // null terminator for the other addresses. This might happen if
  251. // some of the lines were not configured for use with RAS/TAPI.
  252. */
  253. pTapiLineAddress += strlen(pTapiLineAddress) + 1;
  254. if ((pTapiLineAddress - pTapiAddressList->Buffer) >=
  255. pTapiAddressList->Length)
  256. {
  257. --pTapiLineAddress;
  258. }
  259. /*
  260. // Keep track of how many are created.
  261. */
  262. if (Result == NDIS_STATUS_SUCCESS)
  263. {
  264. pAdapter->NumBChannels++;
  265. }
  266. }
  267. DBG_RETURN(DbgInfo, Result);
  268. return (Result);
  269. }
  270. /* @doc INTERNAL Adapter Adapter_c AdapterCreate
  271. @func
  272. <f AdapterCreate> allocates memory for a <t MINIPORT_ADAPTER_OBJECT> and
  273. then initializes the data members to their starting state.
  274. If successful, <p ppAdapter> will be set to point to the newly created
  275. <t MINIPORT_ADAPTER_OBJECT>. Otherwise, <p ppAdapter> will be set to
  276. NULL.
  277. @comm
  278. This function should be called only once when the Miniport is loaded.
  279. Before the Miniport is unloaded, <f AdapterDestroy> must be called to
  280. release the <t MINIPORT_ADAPTER_OBJECT> created by this function.
  281. @rdesc
  282. <f AdapterCreate> returns zero if it is successful.<nl>
  283. Otherwise, a non-zero return value indicates an error condition.
  284. */
  285. NDIS_STATUS AdapterCreate(
  286. OUT PMINIPORT_ADAPTER_OBJECT *ppAdapter, // @parm
  287. // Points to a caller-defined memory location to which this function
  288. // writes the virtual address of the allocated <t MINIPORT_ADAPTER_OBJECT>.
  289. IN NDIS_HANDLE MiniportAdapterHandle, // @parm
  290. // Specifies a handle identifying the miniport's NIC, which is assigned
  291. // by the NDIS library. MiniportInitialize should save this handle; it
  292. // is a required parameter in subsequent calls to NdisXxx functions.
  293. IN NDIS_HANDLE WrapperConfigurationContext // @parm
  294. // Specifies a handle used only during initialization for calls to
  295. // NdisXxx configuration and initialization functions. For example,
  296. // this handle is a required parameter to NdisOpenConfiguration and
  297. // the NdisImmediateReadXxx and NdisImmediateWriteXxx functions.
  298. )
  299. {
  300. DBG_FUNC("AdapterCreate")
  301. NDIS_STATUS Result;
  302. // Holds the result code returned by this function.
  303. PMINIPORT_ADAPTER_OBJECT pAdapter;
  304. // Pointer to our newly allocated object.
  305. DBG_ENTER(DbgInfo);
  306. /*
  307. // Make sure the caller's object pointer is NULL to begin with.
  308. // It will be set later only if everything is successful.
  309. */
  310. *ppAdapter = NULL;
  311. /*
  312. // Allocate memory for the object.
  313. */
  314. Result = ALLOCATE_OBJECT(pAdapter, MiniportAdapterHandle);
  315. if (Result == NDIS_STATUS_SUCCESS)
  316. {
  317. /*
  318. // Zero everything to begin with.
  319. // Then set the object type and assign a unique ID .
  320. */
  321. pAdapter->ObjectType = MINIPORT_ADAPTER_OBJECT_TYPE;
  322. pAdapter->ObjectID = ++g_AdapterInstanceCounter;
  323. ASSERT(g_AdapterInstanceCounter <= MAX_ADAPTERS);
  324. if (g_AdapterInstanceCounter <= MAX_ADAPTERS)
  325. {
  326. g_Adapters[g_AdapterInstanceCounter-1] = pAdapter;
  327. }
  328. /*
  329. // We use the instance number in debug messages to help when debugging
  330. // with multiple adapters.
  331. */
  332. #if DBG
  333. pAdapter->DbgID[0] = (UCHAR) ((pAdapter->ObjectID & 0x0F) + '0');
  334. pAdapter->DbgID[1] = ':';
  335. ASSERT (sizeof(VER_TARGET_STR) <= sizeof(pAdapter->DbgID)-2);
  336. memcpy(&pAdapter->DbgID[2], VER_TARGET_STR, sizeof(VER_TARGET_STR));
  337. #endif
  338. /*
  339. // Initialize the member variables to their default settings.
  340. */
  341. pAdapter->MiniportAdapterHandle = MiniportAdapterHandle;
  342. pAdapter->WrapperConfigurationContext = WrapperConfigurationContext;
  343. /*
  344. // Allocate spin locks to use for MUTEX queue protection.
  345. */
  346. NdisAllocateSpinLock(&pAdapter->EventLock);
  347. NdisAllocateSpinLock(&pAdapter->TransmitLock);
  348. NdisAllocateSpinLock(&pAdapter->ReceiveLock);
  349. /*
  350. // Parse the registry parameters.
  351. */
  352. Result = AdapterReadParameters(pAdapter);
  353. #if DBG
  354. DbgInfo->DbgFlags = pAdapter->DbgFlags;
  355. #endif // DBG
  356. DBG_DISPLAY(("NOTICE: Adapter#%d=0x%X DbgFlags=0x%X\n",
  357. pAdapter->ObjectID, pAdapter, pAdapter->DbgFlags));
  358. /*
  359. // If all goes well, we are ready to create the sub-components.
  360. */
  361. if (Result == NDIS_STATUS_SUCCESS)
  362. {
  363. Result = AdapterCreateObjects(pAdapter);
  364. }
  365. if (Result == NDIS_STATUS_SUCCESS)
  366. {
  367. /*
  368. // All is well, so return the object pointer to the caller.
  369. */
  370. *ppAdapter = pAdapter;
  371. }
  372. else
  373. {
  374. /*
  375. // Something went wrong, so let's make sure everything is
  376. // cleaned up.
  377. */
  378. AdapterDestroy(pAdapter);
  379. }
  380. }
  381. DBG_RETURN(DbgInfo, Result);
  382. return (Result);
  383. }
  384. /* @doc INTERNAL Adapter Adapter_c AdapterDestroyObjects
  385. @func
  386. <f AdapterDestroyObjects> calls the destroy routines for all the objects
  387. contained in <t MINIPORT_ADAPTER_OBJECT>. This should only be called
  388. by <f AdapterDestroy>.
  389. <f Note>:
  390. If you add any new objects to <t MINIPORT_ADAPTER_OBJECT> you will need
  391. to modify <f AdapterCreateObjects> and <f AdapterDestroyObjects> so they
  392. will get created and destroyed properly.
  393. */
  394. DBG_STATIC void AdapterDestroyObjects(
  395. IN PMINIPORT_ADAPTER_OBJECT pAdapter // @parm
  396. // A pointer to the <t MINIPORT_ADAPTER_OBJECT> instance.
  397. )
  398. {
  399. DBG_FUNC("AdapterDestroyObjects")
  400. UINT NumBChannels;
  401. // The number of BChannels supported by the NIC.
  402. ASSERT(pAdapter && pAdapter->ObjectType == MINIPORT_ADAPTER_OBJECT_TYPE);
  403. DBG_ENTER(DbgInfo);
  404. /*
  405. // Destroy the BChannel objects.
  406. */
  407. NumBChannels = pAdapter->NumBChannels;
  408. while (NumBChannels--)
  409. {
  410. BChannelDestroy(pAdapter->pBChannelArray[NumBChannels]);
  411. }
  412. pAdapter->NumBChannels = 0;
  413. /*
  414. // Free space for the BChannels.
  415. */
  416. if (pAdapter->pBChannelArray)
  417. {
  418. NumBChannels = CardNumChannels(pAdapter->pCard);
  419. FREE_MEMORY(pAdapter->pBChannelArray, sizeof(PVOID) * NumBChannels);
  420. }
  421. /*
  422. // Destroy the DChannel object.
  423. */
  424. DChannelDestroy(pAdapter->pDChannel);
  425. /*
  426. // Destroy the Card object.
  427. */
  428. CardDestroy(pAdapter->pCard);
  429. DBG_LEAVE(DbgInfo);
  430. }
  431. /* @doc INTERNAL Adapter Adapter_c AdapterDestroy
  432. @func
  433. <f AdapterDestroy> frees the memory for this <t MINIPORT_ADAPTER_OBJECT>.
  434. All memory allocated by <f AdapterCreate> will be released back to the OS.
  435. */
  436. void AdapterDestroy(
  437. IN PMINIPORT_ADAPTER_OBJECT pAdapter // @parm
  438. // A pointer to the <t MINIPORT_ADAPTER_OBJECT> instance.
  439. )
  440. {
  441. DBG_FUNC("AdapterDestroy")
  442. DBG_ENTER(DbgInfo);
  443. if (pAdapter)
  444. {
  445. ASSERT(pAdapter->ObjectType == MINIPORT_ADAPTER_OBJECT_TYPE);
  446. /*
  447. // Release all objects allocated within this object.
  448. */
  449. AdapterDestroyObjects(pAdapter);
  450. /*
  451. // Destroy any string parameter buffers created by ParamParseRegistry.
  452. */
  453. if (pAdapter->MediaType.Length)
  454. {
  455. FREE_NDISSTRING(pAdapter->MediaType);
  456. }
  457. if (pAdapter->DeviceName.Length)
  458. {
  459. FREE_NDISSTRING(pAdapter->DeviceName);
  460. }
  461. if (pAdapter->TapiAddressList.Length)
  462. {
  463. FREE_NDISSTRING(pAdapter->TapiAddressList);
  464. }
  465. if (pAdapter->EventLock.SpinLock)
  466. {
  467. NdisFreeSpinLock(&pAdapter->EventLock);
  468. }
  469. if (pAdapter->TransmitLock.SpinLock)
  470. {
  471. NdisFreeSpinLock(&pAdapter->TransmitLock);
  472. }
  473. if (pAdapter->ReceiveLock.SpinLock)
  474. {
  475. NdisFreeSpinLock(&pAdapter->ReceiveLock);
  476. }
  477. /*
  478. // Make sure we fail the ASSERT if we see this object again.
  479. */
  480. if (pAdapter->ObjectType <= MAX_ADAPTERS)
  481. {
  482. g_Adapters[pAdapter->ObjectType-1] = NULL;
  483. }
  484. pAdapter->ObjectType = 0;
  485. FREE_OBJECT(pAdapter);
  486. }
  487. DBG_LEAVE(DbgInfo);
  488. }
  489. /* @doc INTERNAL Adapter Adapter_c AdapterInitialize
  490. @func
  491. <f AdapterInitialize> prepares the <t MINIPORT_ADAPTER_OBJECT> and all
  492. its sub-components for use by the NDIS wrapper. Upon successful
  493. completion of this routine, the NIC will be ready to accept requests
  494. from the NDIS wrapper.
  495. @rdesc
  496. <f AdapterInitialize> returns zero if it is successful.<nl>
  497. Otherwise, a non-zero return value indicates an error condition.
  498. */
  499. NDIS_STATUS AdapterInitialize(
  500. IN PMINIPORT_ADAPTER_OBJECT pAdapter // @parm
  501. // A pointer to the <t MINIPORT_ADAPTER_OBJECT> instance.
  502. )
  503. {
  504. DBG_FUNC("AdapterInitialize")
  505. NDIS_STATUS Result;
  506. // Holds the result code returned by this function.
  507. PBCHANNEL_OBJECT pBChannel;
  508. // A Pointer to one of our <t BCHANNEL_OBJECT>'s.
  509. ULONG Index;
  510. // Loop counter.
  511. ASSERT(pAdapter && pAdapter->ObjectType == MINIPORT_ADAPTER_OBJECT_TYPE);
  512. DBG_ENTER(pAdapter);
  513. /*
  514. // Initialize the WAN information structure to match the capabilities of
  515. // the adapter.
  516. */
  517. pAdapter->WanInfo.MaxFrameSize = pAdapter->pCard->BufferSize - NDISWAN_EXTRA_SIZE;
  518. pAdapter->WanInfo.MaxTransmit = pAdapter->pCard->TransmitBuffersPerLink;
  519. /*
  520. // Since we copy the packets to/from adapter RAM, no padding information is
  521. // needed in the WAN packets we get. We can just use adapter RAM as needed.
  522. */
  523. pAdapter->WanInfo.HeaderPadding = 0;
  524. pAdapter->WanInfo.TailPadding = 0;
  525. /*
  526. // Transmits and received are copied to/from adapter RAM so cached memory
  527. // can be used for packet allocation and we don't really care if it's
  528. // physically contiguous or not, as long as it's virtually contiguous.
  529. */
  530. pAdapter->WanInfo.MemoryFlags = 0;
  531. pAdapter->WanInfo.HighestAcceptableAddress = g_HighestAcceptableAddress;
  532. /*
  533. // We only support point to point framing, and we don't need to see the
  534. // address or control fields. The TAPI_PROVIDER bit is set to indicate
  535. // that we can accept the TAPI OID requests.
  536. */
  537. pAdapter->WanInfo.FramingBits = PPP_FRAMING | TAPI_PROVIDER |
  538. PPP_MULTILINK_FRAMING;
  539. /*
  540. // This value is ignored by this driver, but its default behavior is such
  541. // that all these control bytes would appear to be handled transparently.
  542. */
  543. pAdapter->WanInfo.DesiredACCM = 0;
  544. /*
  545. // This value indicates how many point to point connections are allowed
  546. // per adapter. Currently, the WAN wrapper only supports 1 connection
  547. // per NDIS link.
  548. */
  549. pAdapter->WanInfo.Endpoints = pAdapter->NumBChannels;
  550. /*
  551. // Setyup the default call parameters.
  552. */
  553. pAdapter->DefaultLineCallParams.ulTotalSize = sizeof(pAdapter->DefaultLineCallParams);
  554. pAdapter->DefaultLineCallParams.ulBearerMode = LINEBEARERMODE_DATA;
  555. pAdapter->DefaultLineCallParams.ulMinRate = _56KBPS;
  556. pAdapter->DefaultLineCallParams.ulMaxRate = _64KBPS;
  557. pAdapter->DefaultLineCallParams.ulMediaMode = LINEMEDIAMODE_DIGITALDATA;
  558. pAdapter->DefaultLineCallParams.ulCallParamFlags = 0;
  559. pAdapter->DefaultLineCallParams.ulAddressMode = LINEADDRESSMODE_ADDRESSID;
  560. pAdapter->DefaultLineCallParams.ulAddressID = TSPI_ADDRESS_ID;
  561. /*
  562. // Initialize the packet management queues to empty.
  563. */
  564. InitializeListHead(&pAdapter->EventList);
  565. InitializeListHead(&pAdapter->TransmitPendingList);
  566. InitializeListHead(&pAdapter->TransmitCompleteList);
  567. InitializeListHead(&pAdapter->ReceiveCompleteList);
  568. /*
  569. // Setup the timer event handler.
  570. */
  571. NdisMInitializeTimer(&pAdapter->EventTimer,
  572. pAdapter->MiniportAdapterHandle,
  573. MiniportTimer,
  574. pAdapter);
  575. /*
  576. // Initialize the DChannel object.
  577. */
  578. DChannelInitialize(pAdapter->pDChannel);
  579. /*
  580. // Initialize all the BChannel objects.
  581. */
  582. for (Index = 0; Index < pAdapter->NumBChannels; ++Index)
  583. {
  584. pBChannel = GET_BCHANNEL_FROM_INDEX(pAdapter, Index);
  585. BChannelInitialize(pBChannel);
  586. }
  587. /*
  588. // Now, we can initialize the Card object.
  589. */
  590. Result = CardInitialize(pAdapter->pCard);
  591. DBG_RETURN(pAdapter, Result);
  592. return (Result);
  593. }