/drivers/staging/wlags49_h2/hcfcfg.h

https://bitbucket.org/slukk/jb-tsm-kernel-4.2 · C Header · 2344 lines · 1361 code · 501 blank · 482 comment · 121 complexity · a7297628c854171096a479aff05cf076 MD5 · raw file

Large files are truncated click here to view the full file

  1. // vim:tw=110:ts=4:
  2. #ifndef HCFCFG_H
  3. #define HCFCFG_H 1
  4. /*************************************************************************************************************
  5. *
  6. * FILE : hcfcfg.tpl // hcfcfg.h
  7. *
  8. * DATE : $Date: 2004/08/05 11:47:10 $ $Revision: 1.6 $
  9. * Original: 2004/04/08 15:18:16 Revision: 1.40 Tag: t20040408_01
  10. * Original: 2004/04/01 15:32:55 Revision: 1.38 Tag: t7_20040401_01
  11. * Original: 2004/03/10 15:39:28 Revision: 1.34 Tag: t20040310_01
  12. * Original: 2004/03/03 14:10:12 Revision: 1.32 Tag: t20040304_01
  13. * Original: 2004/03/02 09:27:12 Revision: 1.30 Tag: t20040302_03
  14. * Original: 2004/02/24 13:00:28 Revision: 1.25 Tag: t20040224_01
  15. * Original: 2004/02/18 17:13:57 Revision: 1.23 Tag: t20040219_01
  16. *
  17. * AUTHOR : Nico Valster
  18. *
  19. * DESC : HCF Customization Macros
  20. * hcfcfg.tpl list all #defines which must be specified to:
  21. * adjust the HCF functions defined in HCF.C to the characteristics of a specific environment
  22. * o maximum sizes for messages
  23. * o Endianess
  24. * Compiler specific macros
  25. * o port I/O macros
  26. * o type definitions
  27. *
  28. * By copying HCFCFG.TPL to HCFCFG.H and -if needed- modifying the #defines the WCI functionality can be
  29. * tailored
  30. *
  31. * Supported environments:
  32. * WVLAN_41 Miniport NDIS 3.1
  33. * WVLAN_42 Packet Microsoft Visual C 1.5
  34. * WVLAN_43 16 bits DOS ODI Microsoft Visual C 1.5
  35. * WVLAN_44 32 bits ODI (__NETWARE_386__) WATCOM
  36. * WVLAN_45 MAC_OS MPW?, Symantec?
  37. * WVLAN_46 Windows CE (_WIN32_WCE) Microsoft ?
  38. * WVLAN_47 LINUX (__LINUX__) GCC, discarded, based on GPL'ed HCF-light
  39. * WVLAN_48 Miniport NDIS 5
  40. * WVLAN_49 LINUX (__LINUX__) GCC, originally based on pre-compiled HCF_library
  41. * migrated to use the HCF sources when Lucent Technologies
  42. * brought the HCF module under GPL
  43. * WVLAN_51 Miniport USB NDIS 5
  44. * WVLAN_52 Miniport NDIS 4
  45. * WVLAN_53 VxWorks END Station driver
  46. * WVLAN_54 VxWorks END Access Point driver
  47. * WVLAN_81 WavePoint BORLAND C
  48. * WCITST Inhouse test tool Microsoft Visual C 1.5
  49. * WSU WaveLAN Station Update Microsoft Visual C ??
  50. * SCO UNIX not yet actually used ? ?
  51. * __ppc OEM supplied ?
  52. * _AM29K OEM supplied ?
  53. * ? OEM supplied Microtec Research 80X86 Compiler
  54. *
  55. **************************************************************************************************************
  56. *
  57. *
  58. * SOFTWARE LICENSE
  59. *
  60. * This software is provided subject to the following terms and conditions,
  61. * which you should read carefully before using the software. Using this
  62. * software indicates your acceptance of these terms and conditions. If you do
  63. * not agree with these terms and conditions, do not use the software.
  64. *
  65. * COPYRIGHT © 1994 - 1995 by AT&T. All Rights Reserved
  66. * COPYRIGHT © 1996 - 2000 by Lucent Technologies. All Rights Reserved
  67. * COPYRIGHT © 2001 - 2004 by Agere Systems Inc. All Rights Reserved
  68. * All rights reserved.
  69. *
  70. * Redistribution and use in source or binary forms, with or without
  71. * modifications, are permitted provided that the following conditions are met:
  72. *
  73. * . Redistributions of source code must retain the above copyright notice, this
  74. * list of conditions and the following Disclaimer as comments in the code as
  75. * well as in the documentation and/or other materials provided with the
  76. * distribution.
  77. *
  78. * . Redistributions in binary form must reproduce the above copyright notice,
  79. * this list of conditions and the following Disclaimer in the documentation
  80. * and/or other materials provided with the distribution.
  81. *
  82. * . Neither the name of Agere Systems Inc. nor the names of the contributors
  83. * may be used to endorse or promote products derived from this software
  84. * without specific prior written permission.
  85. *
  86. * Disclaimer
  87. *
  88. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  89. * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
  90. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
  91. * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
  92. * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
  93. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  94. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  95. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  96. * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
  97. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  98. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  99. * DAMAGE.
  100. *
  101. *
  102. *************************************************************************************************************/
  103. /* Alignment
  104. * Some platforms can access words on odd boundaries (with possibly an performance impact), at other
  105. * platforms such an access may result in a memory access violation.
  106. * It is assumed that everywhere where the HCF casts a char pointer into a word pointer, the alignment
  107. * criteria are met. This put some restrictions on the MSF, which are assumed to be "automatically" fulfilled
  108. * at the applicable platforms
  109. * To assert this assumption, the macro HCF_ALIGN can be defined. The default value is 1, meaning byte
  110. * alignment (or no alignment), a value of 2 means word alignment, a value of 4 means double word alignment
  111. */
  112. /***************************** IN_PORT_STRING_8_16 S a m p l e s *****************************************
  113. // C implementation which let the processor handle the word-at-byte-boundary problem
  114. #define IN_PORT_STRING_8_16( port, addr, n) while ( n-- ) \
  115. { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); ((hcf_8 FAR*)addr)+=2; }
  116. // C implementation which handles the word-at-byte-boundary problem
  117. #define IN_PORT_STRING_8_16( port, addr, n) while ( n-- ) \
  118. { hcf_16 i = IN_PORT_WORD(port); *((hcf_8 FAR*)addr)++ = (hcf_8)i; *((hcf_8 FAR*)addr)++ = (hcf_8)(i>>8);}
  119. // Assembler implementation
  120. #define IN_PORT_STRING_8_16( port, addr, len) __asm \
  121. { \
  122. __asm push di \
  123. __asm push es \
  124. __asm mov cx,len \
  125. __asm les di,addr \
  126. __asm mov dx,port \
  127. __asm rep insw \
  128. __asm pop es \
  129. __asm pop di \
  130. }
  131. ***************************** OUT_PORT_STRING_8_16 S a m p l e s ******************************************
  132. // C implementation which let the processor handle the word-at-byte-boundary problem
  133. #define OUT_PORT_STRING_8_16( port, addr, n) while ( n-- ) \
  134. { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; ((hcf_8 FAR*)addr)+=2; }
  135. // C implementation which handles the word-at-byte-boundary problem
  136. #define OUT_PORT_STRING_8_16( port, addr, n) while ( n-- ) \
  137. { OUT_PORT_WORD( port, *((hcf_8 FAR*)addr) | *(((hcf_8 FAR*)addr)+1)<<8 ); (hcf_8 FAR*)addr+=2; }
  138. // Assembler implementation
  139. #define OUT_PORT_STRING_8_16( port, addr, len) __asm \
  140. { \
  141. __asm push si \
  142. __asm push ds \
  143. __asm mov cx,len \
  144. __asm lds si,addr \
  145. __asm mov dx,port \
  146. __asm rep outsw \
  147. __asm pop ds \
  148. __asm pop si \
  149. }
  150. *************************************************************************************************************/
  151. /************************************************************************************************/
  152. /****************** C O M P I L E R S P E C I F I C M A C R O S ***************************/
  153. /************************************************************************************************/
  154. /*************************************************************************************************
  155. *
  156. * !!!!!!!!!!!!!!!!!!!!!!!!! Note to the HCF-implementor !!!!!!!!!!!!!!!!!!!!!!!!!
  157. * !!!! Do not call these macros with parameters which introduce side effects !!!!
  158. * !!!!!!!!!!!!!!!!!!!!!!!!! Note to the HCF-implementor !!!!!!!!!!!!!!!!!!!!!!!!!
  159. *
  160. *
  161. * By selecting the appropriate Macro definitions by means of modifying the "#ifdef 0/1" lines, the HCF can be
  162. * adjusted for the I/O characteristics of a specific compiler
  163. *
  164. * If needed the macros can be modified or replaced with definitions appropriate for your personal platform.
  165. * If you need to make such changes it is appreciated if you inform Agere Systems
  166. * That way the changes can become part of the next release of the WCI
  167. *
  168. * For convenience of the MSF-programmer, all macros are allowed to modify their parameters (although some
  169. * might argue that this would constitute bad coding practice). This has its implications on the HCF, e.g. as a
  170. * consequence these macros should not be called with parameters which have side effects, e.g auto-increment.
  171. *
  172. * in the Microsoft implementation of inline assembly it is O.K. to corrupt all flags except the direction flag
  173. * and to corrupt all registers except the segment registers and EDI, ESI, ESP and EBP (or their 16 bits
  174. * equivalents). Other environments may have other constraints
  175. *
  176. * in the Intel environment it is O.K to have a word (as a 16 bits quantity) at a byte boundary, hence
  177. * IN_/OUT_PORT_STRING_8_16 can move words between PC-memory and NIC-memory with as only constraint that the
  178. * words are on a word boundary in NIC-memory. This does not hold true for all conceivable environments, e.g.
  179. * an Motorola 68xxx does not allow this. Probably/hopefully the boundary conditions imposed by these type of
  180. * platforms prevent this case from materializing. If this is not the case, OUT_PORT_STRING_8_16 must be coded
  181. * by combining two Host memory hcf_8 values at a time to a single hcf_16 value to be passed to the NIC and
  182. * IN_PORT_STRING_8_16 the single hcf_16 retrieved from the NIC must be split in two hcf_8 values to be stored
  183. * in Host memory (see the sample code above)
  184. *
  185. * The prototypes and functional description of the macros are:
  186. *
  187. * hcf_16 IN_PORT_WORD( hcf_16 port )
  188. * Reads a word (16 bits) from the specified port
  189. *
  190. * void OUT_PORT_WORD( hcf_16 port, hcf_16 value)
  191. * Writes a word (16 bits) to the specified port
  192. *
  193. * hcf_16 IN_PORT_DWORD( hcf_16 port )
  194. * Reads a dword (32 bits) from the specified port
  195. *
  196. * void OUT_PORT_DWORD( hcf_16 port, hcf_32 value)
  197. * Writes a dword (32 bits) to the specified port
  198. *
  199. * void IN_PORT_STRING_8_16( port, addr, len)
  200. * Reads len number of words (16 bits) from NIC memory via the specified port to the (FAR)
  201. * byte-pointer addr in PC-RAM
  202. * Note that len specifies the number of words, NOT the number of bytes
  203. * !!!NOTE, although len specifies the number of words, addr MUST be a char pointer NOTE!!!
  204. * See also the common notes for IN_PORT_STRING_8_16 and OUT_PORT_STRING_8_16
  205. *
  206. * void OUT_PORT_STRING_8_16( port, addr, len)
  207. * Writes len number of words (16 bits) from the (FAR) byte-pointer addr in PC-RAM via the specified
  208. * port to NIC memory
  209. * Note that len specifies the number of words, NOT the number of bytes.
  210. * !!!NOTE, although len specifies the number of words, addr MUST be a char pointer NOTE!!!
  211. *
  212. * The peculiar combination of word-length and char pointers for IN_PORT_STRING_8_16 as well as
  213. * OUT_PORT_STRING_8_16 is justified by the assumption that it offers a more optimal algorithm
  214. *
  215. * void IN_PORT_STRING_32( port, addr, len)
  216. * Reads len number of double-words (32 bits) from NIC memory via the specified port to the (FAR)
  217. * double-word address addr in PC-RAM
  218. *
  219. * void OUT_PORT_STRING_32( port, addr, len)
  220. * Writes len number of double-words (32 bits) from the (FAR) double-word address addr in PC-RAM via
  221. * the specified port to NIC memory
  222. *
  223. * !!!!!!!!!!!!!!!!!!!!!!!!! Note to the HCF-implementor !!!!!!!!!!!!!!!!!!!!!!!!!
  224. * !!!! Do not call these macros with parameters which introduce side effects !!!!
  225. * !!!!!!!!!!!!!!!!!!!!!!!!! Note to the HCF-implementor !!!!!!!!!!!!!!!!!!!!!!!!!
  226. *
  227. *************************************************************************************************/
  228. /**************************** define INT Types ******************************/
  229. typedef unsigned char hcf_8;
  230. typedef unsigned short hcf_16;
  231. typedef unsigned long hcf_32;
  232. /**************************** define I/O Types ******************************/
  233. #define HCF_IO_MEM 0x0001 // memory mapped I/O ( 0: Port I/O )
  234. #define HCF_IO_32BITS 0x0002 // 32Bits support ( 0: only 16 Bits I/O)
  235. /****************************** #define HCF_TYPE ********************************/
  236. #define HCF_TYPE_NONE 0x0000 // No type
  237. #define HCF_TYPE_WPA 0x0001 // WPA support
  238. #define HCF_TYPE_USB 0x0002 // reserved (USB Dongle driver support)
  239. //#define HCF_TYPE_HII 0x0004 // Hermes-II, to discriminate H-I and H-II CFG_HCF_OPT_STRCT
  240. #define HCF_TYPE_WARP 0x0008 // WARP F/W
  241. #define HCF_TYPE_PRELOADED 0x0040 // pre-loaded F/W
  242. #define HCF_TYPE_HII5 0x0080 // Hermes-2.5 H/W
  243. #define HCF_TYPE_CCX 0x0100 // CKIP
  244. #define HCF_TYPE_BEAGLE_HII5 0x0200 // Beagle Hermes-2.5 H/W
  245. #define HCF_TYPE_TX_DELAY 0x4000 // Delayed transmission ( non-DMA only)
  246. /****************************** #define HCF_ASSERT ******************************/
  247. #define HCF_ASSERT_NONE 0x0000 // No assert support
  248. #define HCF_ASSERT_PRINTF 0x0001 // Hermes generated debug info
  249. #define HCF_ASSERT_SW_SUP 0x0002 // logging via Hermes support register
  250. #define HCF_ASSERT_MB 0x0004 // logging via Mailbox
  251. #define HCF_ASSERT_RT_MSF_RTN 0x4000 // dynamically binding of msf_assert routine
  252. #define HCF_ASSERT_LNK_MSF_RTN 0x8000 // statically binding of msf_assert routine
  253. /****************************** #define HCF_ENCAP *******************************/
  254. #define HCF_ENC_NONE 0x0000 // No encapsulation support
  255. #define HCF_ENC 0x0001 // HCF handles En-/Decapsulation
  256. #define HCF_ENC_SUP 0x0002 // HCF supports MSF to handle En-/Decapsulation
  257. /****************************** #define HCF_EXT *********************************/
  258. #define HCF_EXT_NONE 0x0000 // No expanded features
  259. #define HCF_EXT_INFO_LOG 0x0001 // logging of Hermes Info frames
  260. //#define HCF_EXT_INT_TX_OK 0x0002 // RESERVED!!! monitoring successful Tx message
  261. #define HCF_EXT_INT_TX_EX 0x0004 // monitoring unsuccessful Tx message
  262. //#define HCF_EXT_MON_MODE 0x0008 // LEGACY
  263. #define HCF_EXT_TALLIES_FW 0x0010 // support for up to 32 Hermes Engineering tallies
  264. #define HCF_EXT_TALLIES_HCF 0x0020 // support for up to 8 HCF Engineering tallies
  265. #define HCF_EXT_NIC_ACCESS 0x0040 // direct access via Aux-ports and to Hermes registers and commands
  266. #define HCF_EXT_MB 0x0080 // MailBox code expanded
  267. #define HCF_EXT_IFB_STRCT 0x0100 // MSF custom pointer in IFB
  268. #define HCF_EXT_DESC_STRCT 0x0200 // MSF custom pointer in Descriptor
  269. #define HCF_EXT_TX_CONT 0x4000 // Continuous transmit test
  270. #define HCF_EXT_INT_TICK 0x8000 // enables TimerTick interrupt generation
  271. /****************************** #define HCF_SLEEP *******************************/
  272. #define HCF_DDS 0x0001 // Disconnected Deep Sleep
  273. #define HCF_CDS 0x0002 // Connected Deep Sleep
  274. /****************************** #define HCF_TALLIES ******************************/
  275. #define HCF_TALLIES_NONE 0x0000 // No tally support
  276. #define HCF_TALLIES_NIC 0x0001 // Hermes Tallies accumulated in IFB
  277. #define HCF_TALLIES_HCF 0x0002 // HCF Tallies accumulated in IFB
  278. #define HCF_TALLIES_RESET 0x8000 // Tallies in IFB are reset when reported via hcf_get_info
  279. /************************************************************************************************/
  280. /****************************** M I N I P O R T N D I S *************************************/
  281. /************************************************************************************************/
  282. #if defined WVLAN_41 || defined WVLAN_48 || defined WVLAN_52 || defined _WIN32_WCE
  283. #ifndef WVLAN_46
  284. #define HCF_EXT (HCF_EXT_INFO_LOG | HCF_EXT_MB | HCF_EXT_NIC_ACCESS )
  285. #else
  286. #define HCF_EXT ( HCF_EXT_TX_CONT | HCF_EXT_INFO_LOG | HCF_EXT_MB | HCF_EXT_NIC_ACCESS )
  287. #endif
  288. #define HCF_DLV 1 //H-I legacy, superfluous for H-II
  289. #ifdef _WIN32_WCE
  290. #define HCF_IO HCF_IO_MEM
  291. #define HCF_DMA 0 // To enable DMA
  292. #endif
  293. #if _VARIANT == 7
  294. #define HCF_SLEEP HCF_CDS
  295. #endif // _VARIANT == 7
  296. #if _VARIANT == 5 || _VARIANT == 6
  297. #define _WARP
  298. #define _AES
  299. #define HCF_SLEEP HCF_CDS
  300. #if _VARIANT == 6
  301. //! #define _RSN
  302. #endif // _VARIANT == 6
  303. #ifndef _WIN32_WCE
  304. #define HCF_IO HCF_IO_32BITS
  305. #define HCF_DMA 1 // To enable DMA
  306. #endif
  307. #endif // _VARIANT == 5 || _VARIANT == 6
  308. //HWi for migration purposes I defined a define which will be TRUE for ALL drivers
  309. //Meaning that _CCX defined code which we think will get a all driver OK flag can be defined from _CCX to _CCX_OK
  310. #if defined WVLAN_48 // && !defined _WIN32_WCE
  311. #if _VARIANT == 4 || _VARIANT == 6
  312. #define _CCX_OK 1
  313. #endif // _VARIANT == 4 || _VARIANT == 6
  314. #endif // WVLAN_48
  315. //#if !defined WVLAN_46
  316. #if defined WVLAN_48
  317. #if _VARIANT == 4 || _VARIANT == 6
  318. #define _CCX
  319. #define HCF_MAX_MSG_CKIP_PADDING 86 //, use 86 for rx fragmentation. 28 is enuf for MIC+PPK encapsulation
  320. #define HCF_MAX_MSG ( 1514 + HCF_MAX_MSG_CKIP_PADDING ) // need extra padding for CKIP (need to subtract 28 for NDIS)
  321. #endif // _VARIANT == 4 || _VARIANT == 6
  322. #endif // WVLAN_48
  323. //#endif // WVLAN_46
  324. #if !defined WVLAN_46
  325. #define _PEEK
  326. #endif
  327. #ifndef _WIN32_WCE
  328. // ASSERT already used by WinCE...
  329. #ifdef ASSERT
  330. #undef ASSERT
  331. #define ASSERT(x) ASSERTDEBUGMSG((x), (TEXT("SIMULATE ASSERT:")))
  332. #endif
  333. #endif
  334. #if defined WVLAN_41
  335. #define MSF_COMPONENT_ID COMP_ID_MINIPORT_NDIS_31
  336. #endif // WVLAN_41
  337. #if defined WVLAN_48 && !defined _WIN32_WCE
  338. #define MSF_COMPONENT_ID COMP_ID_MINIPORT_NDIS_50
  339. #endif // WVLAN_48 / _WIN32_WCE
  340. #if defined WVLAN_52 && !defined _WIN32_WCE
  341. #define MSF_COMPONENT_ID COMP_ID_MINIPORT_NDIS_40
  342. #endif // WVLAN_52 / _WIN32_WCE
  343. #if defined WVLAN_46
  344. #define MSF_COMPONENT_ID COMP_ID_WIN_CE
  345. #endif // _WIN32_WCE
  346. #define MSF_COMPONENT_VAR _VARIANT
  347. #define T1__HCF_TYPE (HCF_TYPE_NONE)
  348. #define T2__HCF_TYPE (T1__HCF_TYPE)
  349. #ifdef _WARP
  350. #define T3__HCF_TYPE (T2__HCF_TYPE | HCF_TYPE_HII5 | HCF_TYPE_WARP )
  351. #else
  352. #if _VARIANT == 7
  353. #define T3__HCF_TYPE (T2__HCF_TYPE | HCF_TYPE_HII5)
  354. #else // _VARIANT == 7
  355. #define T3__HCF_TYPE (T2__HCF_TYPE)
  356. #endif // _VARIANT == 7
  357. #endif // _WARP
  358. #ifdef _CCX_OK
  359. #define T4__HCF_TYPE (T3__HCF_TYPE | HCF_TYPE_CCX)
  360. #else
  361. #define T4__HCF_TYPE (T3__HCF_TYPE)
  362. #endif // _CCX_OK
  363. //not suitable for H-II #define HCF_CFG_STA_1_BOTTOM 16
  364. // Default WPA in ON for all drivers except for WARP driver
  365. #ifdef _WARP
  366. #define T5__HCF_TYPE (T4__HCF_TYPE)
  367. #else // _WARP
  368. #define T5__HCF_TYPE (T4__HCF_TYPE | HCF_TYPE_WPA)
  369. #endif // _WARP
  370. #define HCF_TYPE (T5__HCF_TYPE)
  371. // This is needed to get aux_ctrl() from the HCF for WlFreezeAndDump()
  372. #if (defined DBG && DBG != 0)
  373. #ifndef STATIC
  374. #define STATIC
  375. #endif
  376. #endif
  377. #if !defined SOFTRONICS_CODE && !defined _APIDLL && !defined _WIN32_WCE
  378. #include <ndis.h>
  379. #endif // SOFTRONICS_CODE / _APIDLL / _WIN32_WCE
  380. #if defined _WIN32_WCE
  381. #include <windows.h>
  382. #include <winnt.h>
  383. #endif // _WIN32_WCE
  384. #include "version.h"
  385. #define MSF_COMPONENT_MAJOR_VER TPI_MAJOR_VERSION
  386. #define MSF_COMPONENT_MINOR_VER TPI_MINOR_VERSION
  387. #if !defined _APIDLL && !defined _WIN32_WCE
  388. __inline UCHAR NDIS_IN_BYTE( ULONG port )
  389. {
  390. UCHAR value;
  391. NdisRawReadPortUchar(port , &value);
  392. return (value);
  393. }
  394. __inline ULONG NDIS_IN_LONG( ULONG port )
  395. {
  396. ULONG value;
  397. NdisRawReadPortUlong(port , &value);
  398. return (value);
  399. }
  400. __inline USHORT NDIS_IN_WORD( ULONG port )
  401. {
  402. USHORT value;
  403. NdisRawReadPortUshort(port , &value);
  404. return (value);
  405. }
  406. #define IN_PORT_DWORD(port) NDIS_IN_LONG( (ULONG) (port) )
  407. #define IN_PORT_WORD(port) NDIS_IN_WORD( (ULONG) (port) )
  408. #define OUT_PORT_DWORD(port, value) NdisRawWritePortUlong((ULONG) (port) , value)
  409. #define OUT_PORT_WORD(port, value) NdisRawWritePortUshort((ULONG) (port) , (USHORT) (value))
  410. #define IN_PORT_STRING_8_16(port, addr, len) IN_PORT_STRING_16(port, addr, len)
  411. #define OUT_PORT_STRING_8_16(port, addr, len) OUT_PORT_STRING_16(port, addr, len)
  412. #define IN_PORT_STRING_32(port, addr, len) { \
  413. NdisRawReadPortBufferUlong(port, addr, (len)); \
  414. }
  415. #define OUT_PORT_STRING_32(port, addr, len) { \
  416. NdisRawWritePortBufferUlong(port, addr, (len)); \
  417. }
  418. #define IN_PORT_STRING_16(port, addr, len) NdisRawReadPortBufferUshort(port, addr, (len));
  419. #define OUT_PORT_STRING_16(port, addr, len) NdisRawWritePortBufferUshort(port, addr, (len));
  420. #endif // _APIDLL / _WIN32_WCE
  421. #if defined _WIN32_WCE
  422. #define HCF_ALIGN 2
  423. #define HCF_MEM_IO 1 // overrule standard Port I/O with Memory mapped I/O
  424. #define HCF_PROT_TIME 49
  425. #define IN_PORT_BYTE CE_IN_PORT_BYTE
  426. #define OUT_PORT_BYTE CE_OUT_PORT_BYTE
  427. #define IN_PORT_WORD CE_IN_PORT_WORD
  428. #define OUT_PORT_WORD CE_OUT_PORT_WORD
  429. #define IN_PORT_STRING_16 CE_IN_PORT_STRING
  430. #define OUT_PORT_STRING_16 CE_OUT_PORT_STRING
  431. extern hcf_8 CE_IN_PORT_BYTE(hcf_32 port);
  432. extern void CE_OUT_PORT_BYTE(hcf_32 port, hcf_8 value);
  433. extern hcf_16 CE_IN_PORT_WORD(hcf_32 port);
  434. extern void CE_OUT_PORT_WORD(hcf_32 port, hcf_16 value);
  435. extern void CE_IN_PORT_STRING(hcf_32 port, void *addr, hcf_16 len);
  436. extern void CE_OUT_PORT_STRING(hcf_32 port, void *addr, hcf_16 len);
  437. #endif
  438. #if defined _DEBUG || (defined DBG && DBG != 0)
  439. #define HCF_ASSERT ( HCF_ASSERT_LNK_MSF_RTN | HCF_ASSERT_RT_MSF_RTN | HCF_ASSERT_PRINTF ) //0xC001
  440. //#define HCF_ASSERT ( HCF_ASSERT_LNK_MSF_RTN | HCF_ASSERT_RT_MSF_RTN | HCF_ASSERT_PRINTF | HCF_ASSERT_MB ) //just to test
  441. #endif // _DEBUG || DBG
  442. #if defined DEBUG || defined _DEBUG || (defined DBG && DBG != 0)
  443. #ifdef _WIN32_WCE
  444. #define DBGA2W(DBGSTR) CeConvertAnsiToUnicodeLen((char*)DBGSTR)
  445. #define OUTPUTDEBUGMSG(dprintf_exp) ((void)((! ZONE_DEBUG) ? 0:ce_debug_out dprintf_exp))
  446. #define ASSERTDEBUGMSG(cond, dprintf_exp) ((void)((cond) ? 0:ce_debug_out dprintf_exp))
  447. #define ZONE_ERROR DEBUGZONE(0)
  448. #define ZONE_WARN DEBUGZONE(1)
  449. #define ZONE_FUNCTION DEBUGZONE(2)
  450. #define ZONE_INIT DEBUGZONE(3)
  451. #define ZONE_INTR DEBUGZONE(4)
  452. #define ZONE_RCV DEBUGZONE(5)
  453. #define ZONE_XMIT DEBUGZONE(6)
  454. #define ZONE_ASSERT DEBUGZONE(7)
  455. #define ZONE_DEBUG DEBUGZONE(8)
  456. #define ZONE_OEM DEBUGZONE(9)
  457. #define ZONE_HCF DEBUGZONE(10)
  458. #define ZONE_PORTIO DEBUGZONE(11)
  459. #define ZONE_LOGTOFILE DEBUGZONE(15)
  460. #else // !(_WIN32_WCE)
  461. #define OUTPUTDEBUGMSG(dprintf_exp) ((void) (DbgPrint dprintf_exp))
  462. // the assertdebugmsg macro will print filename, line followed by a caller-defined text, when cond == 0
  463. #define ASSERTDEBUGMSG(cond, print) ((void)((cond) ? 0: (DbgPrint("%s %s:%d - ", print, __FILE__, __LINE__))))
  464. #define ZONE_ERROR 1
  465. #define ZONE_WARN 1
  466. #define ZONE_FUNCTION 1
  467. #define ZONE_INIT 1
  468. #define ZONE_INTR 1
  469. #define ZONE_RCV 1
  470. #define ZONE_XMIT 1
  471. #define ZONE_ASSERT 1
  472. #define ZONE_DEBUG 1
  473. #define ZONE_OEM 1
  474. #define ZONE_HCF 1
  475. #define ZONE_PORTIO 1
  476. #define ZONE_LOGTOFILE 1
  477. #endif // _WIN32_WCE
  478. #ifndef DBGA2W
  479. #define DBGA2W
  480. #endif // DBGA2W
  481. #else // !(defined DEBUG || defined _DEBUG || (defined DBG && DBG != 0) )
  482. #define OUTPUTDEBUGMSG(dprintf_exp)
  483. #define ASSERTDEBUGMSG(cond, dprintf_exp)
  484. #endif // DEBUG / DBG
  485. #if !defined HCF_MAX_MSG_CKIP_PADDING
  486. #define HCF_MAX_MSG_CKIP_PADDING 0
  487. #endif // HCF_MAX_MSG_CKIP_PADDING
  488. #if !defined HCF_MAX_MSG
  489. #define HCF_MAX_MSG 1514
  490. #endif // HCF_MAX_MSG
  491. #define HCF_LEGACY 1 //;?nv je moet wat
  492. #endif //WVLAN_41 / WVLAN_48 / WVLAN_52 / _WIN32_WCE
  493. /************************************************************************************************/
  494. /**************************** P A C K E T D R I V E R ***************************************/
  495. /********************************** D O S O D I *********************************************/
  496. /************************************************************************************************/
  497. #if defined WVLAN_42 || defined WVLAN_43
  498. #pragma warning ( disable: 4001 )
  499. #define FAR __far //segmented 16 bits mode
  500. #define BASED __based(__segname("_CODE")) //force all the "const" structures in the CODE segment
  501. //#define HCF_IO 0 //no DMA, no 32 bits
  502. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  503. #define HCF_EXT HCF_EXT_MB
  504. #define HCF_PROT_TIME 49 //49*10240 microseconds H/W failure protection timer
  505. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  506. /******************************** CONFIGURATION MANAGEMENT *****************************************/
  507. #ifdef WVLAN_42
  508. #define MSF_COMPONENT_ID COMP_ID_PACKET
  509. #define MSF_COMPONENT_VAR 1
  510. #define MSF_COMPONENT_MAJOR_VER 6
  511. #define MSF_COMPONENT_MINOR_VER 12
  512. #endif // WVLAN_42
  513. #ifdef WVLAN_43
  514. #define MSF_COMPONENT_ID COMP_ID_ODI_16
  515. #define MSF_COMPONENT_VAR 1
  516. #define MSF_COMPONENT_MAJOR_VER 6
  517. #define MSF_COMPONENT_MINOR_VER 10
  518. #endif // WVLAN_43
  519. /************************************** INPUT / OUTPUT **********************************************/
  520. #ifndef H_2_INC
  521. #include <stdio.h>
  522. #include <conio.h>
  523. #if 1 //temorary use functions defined in hcf.c
  524. #ifndef _DEBUG
  525. #pragma intrinsic( _inp, _inpw, _outp, _outpw )
  526. #endif // _DEBUG
  527. #define IN_PORT_WORD(port) ((hcf_16)_inpw( (hcf_io)(port) ))
  528. #define OUT_PORT_WORD(port, value) ((void)_outpw( (hcf_io)(port), value ))
  529. #if 1 // C implementation which let the processor handle the word-at-byte-boundary problem
  530. #define IN_PORT_STRING_8_16( port, addr, n) while (n--) \
  531. { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); ((hcf_8 FAR*)addr)+=2; }
  532. #define OUT_PORT_STRING_8_16( port, addr, n) while (n--) \
  533. { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; ((hcf_8 FAR*)addr)+=2; }
  534. #elif 0 // C implementation which handles the word-at-byte-boundary problem
  535. #define IN_PORT_STRING_8_16( port, addr, n) while ( n-- ) \
  536. { hcf_16 i = IN_PORT_WORD(port); *((hcf_8 FAR*)addr)++ = (hcf_8)i; *((hcf_8 FAR*)addr)++ = (hcf_8)(i>>8);}
  537. #define OUT_PORT_STRING_8_16( port, addr, n) while ( n-- ) \
  538. { OUT_PORT_WORD( port, *((hcf_8 FAR*)addr) | *(((hcf_8 FAR*)addr)+1)<<8 ); (hcf_8 FAR*)addr+=2; }
  539. #else // Assembler implementation
  540. #define IN_PORT_STRING_8_16( port, addr, n) __asm \
  541. { \
  542. __asm push di \
  543. __asm push es \
  544. __asm mov cx,n \
  545. __asm les di,addr \
  546. __asm mov dx,port \
  547. __asm rep insw \
  548. __asm pop es \
  549. __asm pop di \
  550. }
  551. #define OUT_PORT_STRING_8_16( port, addr, n) __asm \
  552. { \
  553. __asm push si \
  554. __asm push ds \
  555. __asm mov cx,n \
  556. __asm lds si,addr \
  557. __asm mov dx,port \
  558. __asm rep outsw \
  559. __asm pop ds \
  560. __asm pop si \
  561. }
  562. #endif // Asm or C implementation
  563. #define IN_PORT_STRING_32( port, addr, n) { int n2 = 2*n; IN_PORT_STRING_8_16(port, addr, n2) }
  564. #define OUT_PORT_STRING_32( port, addr, n) { int n2 = 2*n; OUT_PORT_STRING_8_16(port, addr, n2) }
  565. #endif // 0 //temorary use functions defined in hcf.c
  566. #endif // H_2_INC
  567. #endif // WVLAN_42 / WVLAN_43
  568. /************************************************************************************************/
  569. /**************************** D O S H - I / II L O A D E R **********************************/
  570. /************************************************************************************************/
  571. #if defined H0_LDR || defined H1_LDR || defined H2_LDR || defined H5_LDR
  572. #if defined H0_LDR //implies H-I
  573. #define HCF_DLV 0 //H-I legacy, meaningless under H-II
  574. #define HCF_DLNV 1 //H-I legacy, meaningless under H-II
  575. #endif // H0_LDR
  576. #if defined H1_LDR //implies H-I
  577. #define HCF_DLV 1 //H-I legacy, meaningless under H-II
  578. #define HCF_DLNV 0 //H-I legacy, meaningless under H-II
  579. #endif // H1_LDR / H2_LDR
  580. //#if defined H2_LDR : not needed, H-II defaults are O.K for H2_LDR
  581. #ifdef H5_LDR
  582. #define HCF_TYPE (HCF_TYPE_HII5 | HCF_TYPE_WARP )
  583. //;? why does only this subset of the H_LDRs need HCF_TYPE to be defined here
  584. #endif
  585. #define HCF_ASSERT HCF_ASSERT_LNK_MSF_RTN //support dynamic linking of msf_assert routine
  586. #define HCF_ENCAP 0
  587. #define HCF_INT_ON 0
  588. #define HCF_TALLIES 0
  589. #define MSF_COMPONENT_ID COMP_ID_ODI_16 //;?By lack of any better
  590. #define MSF_COMPONENT_VAR 1
  591. #define MSF_COMPONENT_MAJOR_VER 0
  592. #define MSF_COMPONENT_MINOR_VER 0
  593. #include <stdio.h>
  594. #include <conio.h>
  595. #if defined NDEBUG
  596. #pragma intrinsic( _inp, _inpw, _outp, _outpw )
  597. #endif // NDEBUG
  598. #if 0 //use 0 to replace I/O Macros with logging facility
  599. #define IN_PORT_WORD(port) ((hcf_16)_inpw( (hcf_io)(port) ))
  600. #define OUT_PORT_WORD(port, value) ((void)_outpw( (hcf_io)(port), value ))
  601. #define IN_PORT_STRING_16( port, addr, n) \
  602. while ( n-- ) { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
  603. #define OUT_PORT_STRING_16( port, addr, n) \
  604. while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; (cast)addr += 2; }
  605. #endif //use 0 to replace I/O Macros with logging facility
  606. #endif // H0_LDR / H1_LDR / H2_LDR
  607. /************************************************************************************************/
  608. /**************************** H C F D E M O P R O G R A M ***********************************/
  609. /************************************************************************************************/
  610. #if defined HCF_DEMO
  611. #define HCF_DLV 1 //;?should become the default !defaults to 1 anyway for H-II
  612. //#define HCF_DLNV 0 //defaults to 0 anyway for H-II
  613. #define HCF_ASSERT HCF_ASSERT_LNK_MSF_RTN //support dynamic linking of msf_assert routine
  614. #define HCF_ENCAP 0
  615. #define HCF_INT_ON 0
  616. #define HCF_TALLIES ( HCF_TALLIES_NIC | HCF_TALLIES_HCF )
  617. //#define MSF_COMPONENT_ID NO configuration management
  618. #include <stdio.h>
  619. #include <conio.h>
  620. #if defined NDEBUG
  621. #pragma intrinsic( _inp, _inpw, _outp, _outpw )
  622. #endif // NDEBUG
  623. #if 0 //use 0 to replace I/O Macros with logging facility
  624. #define IN_PORT_WORD(port) ((hcf_16)_inpw( (hcf_io)(port) ))
  625. #define OUT_PORT_WORD(port, value) ((void)_outpw( (hcf_io)(port), value ))
  626. #define IN_PORT_STRING_16( port, addr, n) \
  627. while ( n-- ) { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
  628. #define OUT_PORT_STRING_16( port, addr, n) \
  629. while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; (cast)addr += 2; }
  630. #endif //use 0 to replace I/O Macros with logging facility
  631. #endif // HCF_DEMO
  632. /************************************************************************************************/
  633. /*********************************** M A C O S **********************************************/
  634. /************************************************************************************************/
  635. #if defined WVLAN_45
  636. #include "Version.h"
  637. #define MSF_COMPONENT_ID COMP_ID_MAC_OS
  638. #define MSF_COMPONENT_VAR VARIANT
  639. #define MSF_COMPONENT_MAJOR_VER VERSION_MAJOR
  640. #define MSF_COMPONENT_MINOR_VER VERSION_MINOR
  641. #define MAC_OS 1
  642. #define HCF_BIG_ENDIAN 1 // selects Big Endian (a.k.a. Motorola), most significant byte first
  643. #if defined DEBUG
  644. #define HCF_ASSERT HCF_ASSERT_MB // logging via Mailbox
  645. #endif // DEBUG
  646. #ifdef __cplusplus
  647. extern "C" {
  648. #endif // __cplusplus
  649. extern volatile unsigned char *MacIOaddr;
  650. extern hcf_16 IN_PORT_WORD(hcf_16 port);
  651. extern void OUT_PORT_WORD(hcf_16 port, hcf_16 value);
  652. extern void IN_PORT_STRING_16(hcf_16 port, void *addr, hcf_16 len);
  653. extern void OUT_PORT_STRING_16(hcf_16 port, void *addr, hcf_16 len);
  654. #define SwapBytes(t) (((t) >> 8) + (((t) & 0xff) << 8))
  655. #ifdef __cplusplus
  656. }
  657. #endif // __cplusplus
  658. #endif // WVLAN_45
  659. /************************************************************************************************/
  660. /****************************************** L I N U X *****************************************/
  661. /************************************************************************************************/
  662. #ifdef WVLAN_49
  663. #include <asm/io.h>
  664. //#include <linux/module.h>
  665. #include <wl_version.h>
  666. /* The following macro ensures that no symbols are exported, minimizing the chance of a symbol
  667. collision in the kernel */
  668. //EXPORT_NO_SYMBOLS; //;?this place seems not appropriately to me
  669. //#define HCF_SLEEP (HCF_CDS | HCF_DDS )
  670. #define HCF_SLEEP (HCF_CDS)
  671. //#define HCF_TYPE (HCF_TYPE_HII5|HCF_TYPE_STA|HCF_TYPE_AP)
  672. #ifdef HERMES25
  673. #ifdef WARP
  674. #define HCF_TYPE ( HCF_TYPE_WARP | HCF_TYPE_HII5 )
  675. #else
  676. #define HCF_TYPE HCF_TYPE_HII5
  677. #endif // WARP
  678. #else
  679. #define HCF_TYPE HCF_TYPE_NONE
  680. #endif // HERMES25
  681. #ifdef ENABLE_DMA
  682. #define HCF_DMA 1
  683. #endif // ENABLE_DMA
  684. /* We now need a switch to include support for the Mailbox and other necessary extensions */
  685. #define HCF_EXT ( HCF_EXT_MB | HCF_EXT_INFO_LOG | HCF_EXT_INT_TICK )//get deepsleep exercise going
  686. /* ;? The Linux MSF still uses these definitions; define it here until it's removed */
  687. #ifndef HCF_TYPE_HII
  688. #define HCF_TYPE_HII 0x0004
  689. #endif
  690. #ifndef HCF_TYPE_AP
  691. #define HCF_TYPE_AP 0x0010
  692. #endif
  693. #ifndef HCF_TYPE_STA
  694. #define HCF_TYPE_STA 0x0020
  695. #endif // HCF_TYPE_STA
  696. /* Guarantees word alignment */
  697. #define HCF_ALIGN 2
  698. /* Endian macros CNV_INT_TO_LITTLE() and CNV_LITTLE_TO_INT() were renamed to
  699. CNV_SHORT_TO_LITTLE() and CNV_LITTLE_TO_SHORT() */
  700. #ifndef CNV_INT_TO_LITTLE
  701. #define CNV_INT_TO_LITTLE CNV_SHORT_TO_LITTLE
  702. #endif
  703. #ifndef CNV_LITTLE_TO_INT
  704. #define CNV_LITTLE_TO_INT CNV_LITTLE_TO_SHORT
  705. #endif
  706. #define HCF_ERR_BUSY 0x06
  707. /* UIL defines were removed from the HCF */
  708. #define UIL_SUCCESS HCF_SUCCESS
  709. #define UIL_ERR_TIME_OUT HCF_ERR_TIME_OUT
  710. #define UIL_ERR_NO_NIC HCF_ERR_NO_NIC
  711. #define UIL_ERR_LEN HCF_ERR_LEN
  712. #define UIL_ERR_MIN HCF_ERR_MAX /*end of HCF errors which are passed through to UIL
  713. *** ** *** ****** ***** *** ****** ******* ** *** */
  714. #define UIL_ERR_IN_USE 0x44
  715. #define UIL_ERR_WRONG_IFB 0x46
  716. #define UIL_ERR_MAX 0x7F /*upper boundary of UIL errors without HCF-pendant
  717. ***** ******** ** *** ****** ******* *** ******* */
  718. #define UIL_ERR_BUSY HCF_ERR_BUSY
  719. #define UIL_ERR_DIAG_1 HCF_ERR_DIAG_1
  720. #define UIL_FAILURE 0xFF /* 20010705 nv this relick should be eridicated */
  721. #define UIL_ERR_PIF_CONFLICT 0x40 //obsolete
  722. #define UIL_ERR_INCOMP_DRV 0x41 //obsolete
  723. #define UIL_ERR_DOS_CALL 0x43 //obsolete
  724. #define UIL_ERR_NO_DRV 0x42 //obsolete
  725. #define UIL_ERR_NSTL 0x45 //obsolete
  726. #if 0 //;? #ifdef get this going LATER HERMES25
  727. #define HCF_IO HCF_IO_32BITS
  728. #define HCF_DMA 1
  729. #define HCF_DESC_STRCT_EXT 4
  730. /* Switch for BusMaster DMA support. Note that the above define includes the DMA-specific HCF
  731. code in the build. This define sets the MSF to use DMA; if ENABLE_DMA is not defined, then
  732. port I/O will be used in the build */
  733. #ifndef BUS_PCMCIA
  734. #define ENABLE_DMA
  735. #endif // USE_PCMCIA
  736. #endif // HERMES25
  737. /* Overrule standard WaveLAN Packet Size when in DMA mode */
  738. #ifdef ENABLE_DMA
  739. #define HCF_MAX_PACKET_SIZE 2304
  740. #else
  741. #define HCF_MAX_PACKET_SIZE 1514
  742. #endif // ENABLE_DMA
  743. /* The following sets the component ID, as well as the versioning. See also wl_version.h */
  744. #define MSF_COMPONENT_ID COMP_ID_LINUX
  745. #define MSF_COMPONENT_VAR DRV_VARIANT
  746. #define MSF_COMPONENT_MAJOR_VER DRV_MAJOR_VERSION
  747. #define MSF_COMPONENT_MINOR_VER DRV_MINOR_VERSION
  748. /* Define the following to turn on assertions in the HCF */
  749. //#define HCF_ASSERT 0x8000
  750. #define HCF_ASSERT HCF_ASSERT_LNK_MSF_RTN // statically binding of msf_assert routine
  751. #ifdef USE_BIG_ENDIAN
  752. #define HCF_BIG_ENDIAN 1
  753. #else
  754. #define HCF_BIG_ENDIAN 0
  755. #endif /* USE_BIG_ENDIAN */
  756. /* Define the following if your system uses memory-mapped IO */
  757. //#define HCF_MEM_IO
  758. /* The following defines the standard macros required by the HCF to move data to/from the card */
  759. #define IN_PORT_BYTE(port) ((hcf_8)inb( (hcf_io)(port) ))
  760. #define IN_PORT_WORD(port) ((hcf_16)inw( (hcf_io)(port) ))
  761. #define OUT_PORT_BYTE(port, value) (outb( (hcf_8) (value), (hcf_io)(port) ))
  762. #define OUT_PORT_WORD(port, value) (outw((hcf_16) (value), (hcf_io)(port) ))
  763. #define IN_PORT_STRING_16(port, dst, n) insw((hcf_io)(port), dst, n)
  764. #define OUT_PORT_STRING_16(port, src, n) outsw((hcf_io)(port), src, n)
  765. //#define IN_PORT_STRINGL(port, dst, n) insl((port), (dst), (n))
  766. //#define OUT_PORT_STRINGL(port, src, n) outsl((port), (src), (n))
  767. #define IN_PORT_STRING_32(port, dst, n) insl((port), (dst), (n))
  768. #define OUT_PORT_STRING_32(port, src, n) outsl((port), (src), (n))
  769. #define IN_PORT_HCF32(port) inl( (hcf_io)(port) )
  770. #define OUT_PORT_HCF32(port, value) outl((hcf_32)(value), (hcf_io)(port) )
  771. #define IN_PORT_DWORD(port) IN_PORT_HCF32(port)
  772. #define OUT_PORT_DWORD(port, value) OUT_PORT_HCF32(port, value)
  773. #define IN_PORT_STRING_8_16(port, addr, len) IN_PORT_STRING_16(port, addr, len)
  774. #define OUT_PORT_STRING_8_16(port, addr, len) OUT_PORT_STRING_16(port, addr, len)
  775. #ifndef OUTPUTDEBUGMSG
  776. #define OUTPUTDEBUGMSG(dprintf_exp)
  777. #endif
  778. #ifndef ASSERTDEBUGMSG
  779. #define ASSERTDEBUGMSG(cond, dprintf_exp)
  780. #endif
  781. #ifndef CFG_SCAN_CHANNELS_2GHZ
  782. #define CFG_SCAN_CHANNELS_2GHZ 0xFCC2
  783. #endif /* CFG_SCAN_CHANNELS_2GHZ */
  784. #define HCF_MAX_MSG 1600 //get going ;?
  785. #endif // WVLAN_49
  786. /************************************************************************************************/
  787. /********************************************* Q N X ******************************************/
  788. /************************************************************************************************/
  789. #if defined __QNX__ || defined WVLAN_50
  790. #define MSF_COMPONENT_ID 0 //Although there is no DUI support, we need this to get ...
  791. #define MSF_COMPONENT_VAR 0 //...compatibilty check to function
  792. #define MSF_COMPONENT_MAJOR_VER 0 //...;?this is worth looking into to make this a more
  793. #define MSF_COMPONENT_MINOR_VER 0 //..."defined" I/F so OEMers can figure out what to do
  794. #include <conio.h>
  795. #define IN_PORT_WORD(port) ((hcf_16)inpw( (hcf_io)(port) ))
  796. #define OUT_PORT_WORD(port, value) (outpw( (hcf_io)(port), (hcf_16) (value) ))
  797. /*
  798. #define IN_PORT_STRING_16( port, addr, n) \
  799. while ( n-- ) { *(hcf_16*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
  800. #define OUT_PORT_STRING_16( port, addr, n) \
  801. while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16*)addr ) ; (cast)addr += 2; }
  802. */
  803. #endif // QNX / WVLAN_50
  804. /************************************************************************************************/
  805. /********************************************* B E O S ****************************************/
  806. /************************************************************************************************/
  807. #if defined __BEOS__
  808. #define MSF_COMPONENT_ID 0 //Although there is no DUI support, we need this to get ...
  809. #define MSF_COMPONENT_VAR 0 //...compatibilty check to function
  810. #define MSF_COMPONENT_MAJOR_VER 0 //...;?this is worth looking into to make this a more
  811. #define MSF_COMPONENT_MINOR_VER 0 //..."defined" I/F so OEMers can figure out what to do
  812. #include <drivers/Drivers.h>
  813. #include <drivers/KernelExport.h>
  814. uint8 read_io_8 (int);
  815. void write_io_8 (int, uint8);
  816. uint16 read_io_16 (int);
  817. void write_io_16 (int, uint16);
  818. #define IN_PORT_WORD(port) ((hcf_16)read_io_16( (hcf_io)(port) ))
  819. #define OUT_PORT_WORD(port, value) (write_io_16( (hcf_io)(port), (hcf_16) (value) ))
  820. /*
  821. #define IN_PORT_STRING_16( port, addr, n) \
  822. while ( n-- ) { *(hcf_16*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
  823. #define OUT_PORT_STRING_16( port, addr, n) \
  824. while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16*)addr ) ; (cast)addr += 2; }
  825. */
  826. #endif // __BEOS__
  827. /************************************************************************************************/
  828. /******************************** U S B D O N G L E *****************************************/
  829. /************************************************************************************************/
  830. #if defined USB
  831. #include "gpif.h"
  832. #define MSF_COMPONENT_MAJOR_VER 0
  833. #define MSF_COMPONENT_MINOR_VER 1
  834. #define IN_PORT_WORD(port) (Hermes_IO_Read( (hcf_8)(port)))
  835. #define OUT_PORT_WORD(port, value) (Hermes_IO_Write( (hcf_8)port, /*(hcf_16)*/(value) ) )
  836. /* !!!! NOTE USB supports only 16-bits I/O and no 8-bits I/O
  837. * as a consequence the IN_/OUT_PORT_STRING_16 macros use hcf_16* rather than hcf_8 pointers
  838. * to get more optimal code
  839. * therefore the pointers are incremented by 1 (which means two "bytes") rather than by 2
  840. */
  841. //#define IN_PORT_STRING_16( port, addr, n) while ( n-- ) { *((hcf_16*)addr)++ = IN_PORT_WORD( port ); }
  842. //#define OUT_PORT_STRING_16( port, addr, n) while ( n-- ) { OUT_PORT_WORD( port, *((hcf_16*)addr)++ ); }
  843. #define IN_PORT_STRING_16( port, dst, n) while ( n-- ) { *dst++ = IN_PORT_WORD( port ); }
  844. #define OUT_PORT_STRING_16( port, src, n) while ( n-- ) { OUT_PORT_WORD( port, *src++ ); }
  845. //#define HCF_TYPE ( HCF_TYPE_AP | HCF_TYPE_WPA )
  846. #define HCF_TYPE HCF_TYPE_WPA
  847. #endif // USB
  848. /************************************************************************************************/
  849. /****************************************** FreeBSD *******************************************/
  850. /************************************************************************************************/
  851. #if defined __FREE_BSD__
  852. #define MSF_COMPONENT_ID COMP_ID_FreeBSD
  853. #define MSF_COMPONENT_VAR 1
  854. #define MSF_COMPONENT_MAJOR_VER 1
  855. #define MSF_COMPONENT_MINOR_VER 0
  856. #define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O
  857. #include <machine/cpufunc.h>
  858. #define IN_PORT_WORD(port) ((hcf_16)inw( (hcf_io)(port) ))
  859. #define OUT_PORT_WORD(port, value) (outw((hcf_io)(port), (hcf_16)(value)))
  860. /*
  861. #define IN_PORT_STRING_16( port, addr, n) \
  862. while ( n-- ) { *(hcf_16*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
  863. #define OUT_PORT_STRING_16( port, addr, n) \
  864. while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16*)addr ) ; (cast)addr += 2; }
  865. */
  866. #endif // __FREE_BSD__
  867. /************************************************************************************************/
  868. /********************************* W A V E P O I N T ******************************************/
  869. /************************************************************************************************/
  870. #if defined WVLAN_81 /* BORLANDC */
  871. #define EXTERN_C extern // needed because DHF uses this instead of 'extern'
  872. #define MSF_COMPONENT_ID COMP_ID_AP1
  873. #define MSF_COMPONENT_VAR 1
  874. #define MSF_COMPONENT_MAJOR_VER 4
  875. #define MSF_COMPONENT_MINOR_VER 0
  876. #define HCF_PROT_TIME 49 //49*10240 microseconds H/W failure protection timer
  877. //#define HCF_ASSERT HCF_ASSERT_MB // logging via Mailbox /* debug build only */
  878. #if !defined FAR
  879. #define FAR far // segmented 16 bits mode
  880. #endif // FAR
  881. #define IN_PORT_WORD(port) (inport( (hcf_io)(port) ))
  882. #define OUT_PORT_WORD(port, value) (outport( (hcf_io)(port), value ))
  883. #define IN_PORT_STRING_16(port, addr, len) \
  884. asm { push di; push es; mov cx,len; les di,addr; mov dx,port; rep insw; pop es; pop di }
  885. #define OUT_PORT_STRING_16(port, addr, len) \
  886. asm { push si; push ds; mov cx,len; lds si,addr; mov dx,port; rep outsw; pop ds; pop si }
  887. #endif // WVLAN_81
  888. /************************************************************************************************/
  889. /******************************** W A V E L A U N C H *****************************************/
  890. /************************************************************************************************/
  891. #if defined WVLAUNCH
  892. #include "DriverX.h"
  893. extern HWDEVICE* g_pDevice;
  894. //#define MSF_COMPONENT_ID 0 //;? to get around browser problem
  895. #define IN_PORT_WORD(port) HwInpw( g_pDevice, port )
  896. #define OUT_PORT_WORD(port, value) HwOutpw( g_pDevice, port, value )
  897. // C implementation which let the processor handle the word-at-byte-boundary problem
  898. /*
  899. #define IN_PORT_STRING_16( port, addr, n) \
  900. while ( n-- ) { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
  901. #define OUT_PORT_STRING_16( port, addr, n) \
  902. while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; (cast)addr += 2; }
  903. */
  904. #endif // WVLAUNCH
  905. /************************************************************************************************/
  906. /************************************* W C I T S T *********************************************/
  907. /************************************************************************************************/
  908. #if defined WCITST
  909. #define MSF_COMPONENT_ID 0 //Although there is no DUI support, we need this to get ...
  910. #define MSF_COMPONENT_VAR 0 //...compatibilty check to function
  911. #define MSF_COMPONENT_MAJOR_VER 0 //...;?this is worth looking into to make this a more
  912. #define MSF_COMPONENT_MINOR_VER 0 //..."defined" I/F so OEMers can figure out what to do
  913. //#define HCF_ENCAP HCF_ENC_NONE //to get going
  914. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  915. #define HCF_TYPE (HCF_TYPE_WPA | HCF_TYPE_PRELOADED) // Hermes-I for HCF6, II for HCF7
  916. #define HCF_DMA 1
  917. //#define LLB //!!!!MIC Debug Only
  918. #if defined LLB && !((HCF_TYPE) & HCF_TYPE_WPA)
  919. err: no LLB unless SSN;
  920. #endif // LLB / HCF_TYPE_WPA
  921. //#define HCF_ALIGN 2
  922. #define HCF_DLV 1 //just to change memory layout ????;?
  923. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  924. #define HCF_ASSERT HCF_ASSERT_SW_SUP // logging via Hermes support registerr
  925. //#define HCF_ASSERT HCF_ASSERT_MB // logging via Mailbox
  926. #if defined __GNUC__
  927. #include "stdio.h"
  928. //#include "unistd.h" //ioperm libc5
  929. #include "sys/io.h" //ioperm glibc
  930. #define extern //see IO Port Programming mini-HOWTO
  931. //#include "asm/io.h" //
  932. #define IN_PORT_WORD(port) inw( (hcf_io)(port) )
  933. #define IN_PORT_DWORD(port) inl( (hcf_io)(port) )
  934. #define OUT_PORT_WORD(port, value) outw( (hcf_io)(port), (hcf_16)(value) )
  935. #define OUT_PORT_DWORD(port, value) outl( (hcf_io)(port), (hcf_16)(value) )
  936. #else
  937. #pragma warning ( disable: 4001 )
  938. #define FAR __far // segmented 16 bits mode
  939. #include <stdio.h>
  940. #include <conio.h>
  941. #ifndef _DEBUG
  942. #pragma intrinsic( _inp, _inpw, _outp, _outpw )
  943. #endif // _DEBUG
  944. #ifdef LOG
  945. extern FILE* utm_logfile;
  946. hcf_16 ipw( hcf_16 port );
  947. hcf_8 ipb( hcf_16 port );
  948. void opw( hcf_16 port, hcf_16 value );
  949. void opb( hcf_16 port, hcf_8 value );
  950. #define IN_PORT_WORD(port) ipw( (hcf_io)(port) )
  951. #define OUT_PORT_WORD(port, value) opw( (hcf_io)(port), (hcf_16)(value) )
  952. #else // LOG
  953. #define IN_PORT_WORD(port) ((hcf_16)_inpw( (hcf_io)(port) ))
  954. #define OUT_PORT_WORD(port, value) ((void)_outpw( (hcf_io)(port), value ))
  955. #endif // LOG
  956. #if 1 //ASM example
  957. #define IN_PORT_STRING_16( port, addr, len) __asm \
  958. { \
  959. __asm push di \
  960. __asm push es \
  961. __asm mov cx,len \
  962. __asm les di,addr \
  963. __asm mov dx,port \
  964. __asm rep insw \
  965. __asm pop es \
  966. __asm pop di \
  967. }
  968. #define OUT_PORT_STRING_16( port, addr, len) __asm \
  969. { \
  970. __asm push si \
  971. __asm push ds \
  972. __asm mov cx,len \
  973. __asm lds si,addr \
  974. __asm mov dx,port \
  975. __asm rep outsw \
  976. __asm pop ds \
  977. __asm pop si \
  978. }
  979. #endif // asm example
  980. #endif // __GCC__
  981. #if ! defined IN_PORT_STRING_16
  982. #define IN_PORT_STRING_16( port, addr, n) while (n--) \
  983. { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); ((hcf_16 FAR*)addr)++; }
  984. #define OUT_PORT_STRING_16( port, addr, n) while (n--) \
  985. { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ); ((hcf_16 FAR*)addr)++; }
  986. #endif // IN_PORT_STRING_16
  987. #endif // WCITST
  988. /************************************************************************************************/
  989. /******************************* Motorola Power PC 800 family *********************************/
  990. /************************************************************************************************/
  991. /* known users: LH@I
  992. */
  993. #if defined I_MPC8XX
  994. #define MSF_COMPONENT_VAR 0
  995. #define MSF_COMPONENT_ID 0
  996. #define MSF_COMPONENT_MAJOR_VER 1
  997. #define MSF_COMPONENT_MINOR_VER 0
  998. #define HCF_HSI_VAR 1
  999. #define HCF_BIG_ENDIAN 1
  1000. #define HCF_IO HCF_IO_MEM // overrule standard Port I/O with Memory mapped I/O
  1001. #include "o_portbl.h"
  1002. #include "ipcmcia.h"
  1003. typedef o_uint8_t hcf_8;
  1004. typedef o_uint16_t hcf_16;
  1005. typedef o_uint32_t hcf_32;
  1006. /***************************************************************************/
  1007. #ifdef _lint
  1008. #else
  1009. asm hcf_16 IN_PORT_WORD(int port)
  1010. {
  1011. % reg port
  1012. lhbrx r3,r0,port
  1013. eieio
  1014. }
  1015. #endif // _lint
  1016. #ifdef _lint
  1017. #else
  1018. asm void OUT_PORT_WORD(int port, hcf_16 value)
  1019. {
  1020. % reg port, value
  1021. sthbrx value,r0,port
  1022. eieio
  1023. }
  1024. #endif // _lint
  1025. /***************************************************************************/
  1026. #define IN_PORT_STRING_16(port, addr, len) \
  1027. { \
  1028. unsigned l = (len); \
  1029. hcf_16 *d = (volatile hcf_16 *)(addr); \
  1030. while (l--) \
  1031. { \
  1032. *d++ = *(volatile hcf_16 *)(port); \
  1033. EIEIO(); \
  1034. } \
  1035. }
  1036. #define OUT_PORT_STRING_16(port, addr, len) \
  1037. { \
  1038. unsigned l = (len); \
  1039. hcf_16 *s = (volatile hcf_16 *)(addr); \
  1040. while (l--) \
  1041. { \
  1042. *(volatile hcf_16 *)(port) = *s++; \
  1043. EIEIO(); \
  1044. } \
  1045. }
  1046. #endif // I_MPC8XX
  1047. /************************************************************************************************/
  1048. /********************************** Diab or High C 29K **************************************/
  1049. /**********************************************…