Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame^] | 2 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /** ------------------------------------------------------------------------- * |
| 23 | ------------------------------------------------------------------------- * |
| 24 | |
| 25 | |
| 26 | \file palApi.h |
| 27 | |
| 28 | \brief Exports and types for the Platform Abstraction Layer interfaces. |
| 29 | |
| 30 | $Id$ |
| 31 | |
| 32 | Copyright (C) 2006 Airgo Networks, Incorporated |
| 33 | This file contains all the interfaces for thge Platform Abstration Layer |
| 34 | functions. It is intended to be included in all modules that are using |
| 35 | the PAL interfaces. |
| 36 | |
| 37 | ========================================================================== */ |
| 38 | #ifndef PALAPI_H__ |
| 39 | #define PALAPI_H__ |
| 40 | |
| 41 | #include "halTypes.h" |
| 42 | #include "palPipes.h" |
| 43 | //#include "palErrIsr.h" |
| 44 | //#include "halFrameInfo.h" |
| 45 | |
| 46 | /** |
| 47 | \mainpage Platform Abstraction Layer (PAL) |
| 48 | |
| 49 | \section intro Introduction |
| 50 | |
| 51 | palApi is the Platform Abstration Layer. |
| 52 | |
| 53 | This is the latest attempt to abstract the entire Platform, including the |
| 54 | hardware, chip, OS and Bus into a generic API. We are doing this to give |
| 55 | the MAC the ability to call |
| 56 | generic APIs that will allow the MAC to function in an abstract manner |
| 57 | with any Airgo chipset, on any supported OS (Windows and Linux for now) |
| 58 | across any system bus interface (PCI, PCIe, Cardbus, USB, etc.). |
| 59 | |
| 60 | \todo |
| 61 | - palReadRegister: register read |
| 62 | -# add an Open/Close abstraction to accomodate the PAL before the entire MAC is loaded. |
| 63 | -# Review with Linux folks to see this basic scructure works for them. |
| 64 | -# Figure out how to organize the directory structure |
| 65 | - palMemory: memory read/write |
| 66 | - include async versions of read/write register |
| 67 | - palTx: an abstraction for transmit frames that manages the Td and Tm rings |
| 68 | - palRx: an abstracion for receiving frames from a chip across any of the supported buses |
| 69 | - palInterrupt: abstract the interrupts into the HAL |
| 70 | |
| 71 | |
| 72 | \section impl_notes Implementation Notes |
| 73 | |
| 74 | \subsection subsection_codeStructure Code strucure |
| 75 | |
| 76 | */ |
| 77 | |
| 78 | |
| 79 | /** --------------------------------------------------------------------------- |
| 80 | |
| 81 | \fn palReadRegister |
| 82 | |
| 83 | \brief chip and bus agnostic funtion to read a register value |
| 84 | |
| 85 | \param hHdd - HDD context handle |
| 86 | |
| 87 | \param regAddress - address (offset) of the register to be read from the start |
| 88 | of register space. |
| 89 | |
| 90 | \param pRegValue - pointer to the memory where the register contents are written |
| 91 | |
| 92 | \return eHalStatus - status of the register read. Note that this function |
| 93 | can fail. In particular, when the card is removed, this function will return |
| 94 | a failure. |
| 95 | |
| 96 | -------------------------------------------------------------------------------*/ |
| 97 | eHalStatus palReadRegister( tHddHandle hHdd, tANI_U32 regAddress, tANI_U32 *pRegValue ); |
| 98 | |
| 99 | |
| 100 | /** --------------------------------------------------------------------------- |
| 101 | |
| 102 | \fn palWriteRegister |
| 103 | |
| 104 | \brief chip and bus agnostic funtion to write a register value |
| 105 | |
| 106 | \param hHdd - HDD context handle |
| 107 | |
| 108 | \param regAddress - address (offset) of the register to be read from the start |
| 109 | of register space. |
| 110 | |
| 111 | \param pRegValue - pointer to the value being written into the register |
| 112 | |
| 113 | \return eHalStatus - status of the register read. Note that this function |
| 114 | can fail. In particular, when the card is removed, this function will return |
| 115 | a failure. |
| 116 | |
| 117 | -------------------------------------------------------------------------------*/ |
| 118 | eHalStatus palWriteRegister( tHddHandle hHdd, tANI_U32 regAddress, tANI_U32 regValue ); |
| 119 | |
| 120 | /** --------------------------------------------------------------------------- |
| 121 | |
| 122 | \fn palAsyncWriteRegister |
| 123 | |
| 124 | \brief chip and bus agnostic async funtion to write a register value |
| 125 | |
| 126 | \param hHdd - HDD context handle |
| 127 | |
| 128 | \param regAddress - address (offset) of the register to be written from the start |
| 129 | of register space. |
| 130 | |
| 131 | \param regValue - value being written into the register |
| 132 | |
| 133 | \return eHalStatus - status of the register write. Note that this function |
| 134 | can fail. In particular, when the card is removed, this function will return |
| 135 | a failure. |
| 136 | |
| 137 | -------------------------------------------------------------------------------*/ |
| 138 | |
| 139 | eHalStatus palAsyncWriteRegister( tHddHandle hHdd, tANI_U32 regAddress, tANI_U32 regValue ); |
| 140 | |
| 141 | |
| 142 | /** --------------------------------------------------------------------------- |
| 143 | |
| 144 | \fn palReadDeviceMemory |
| 145 | |
| 146 | \brief chip and bus agnostic funtion to read memory from the chip |
| 147 | |
| 148 | \param hHdd - HDD context handle |
| 149 | |
| 150 | \param memOffset - address (offset) of the memory from the top of the |
| 151 | memory map (as exposed to the host) where the memory will be read from. |
| 152 | |
| 153 | \param pBuffer - pointer to a buffer where the memory will be placed in host |
| 154 | memory space after retreived from the chip. |
| 155 | |
| 156 | \param numBytes - the number of bytes to be read. |
| 157 | |
| 158 | \return eHalStatus - status of the memory read. Note that this function |
| 159 | can fail. In particular, when the card is removed, this function will return |
| 160 | a failure. |
| 161 | |
| 162 | -------------------------------------------------------------------------------*/ |
| 163 | eHalStatus palReadDeviceMemory( tHddHandle hHdd, tANI_U32 memOffset, tANI_U8 *pBuffer, tANI_U32 numBytes ); |
| 164 | |
| 165 | /** --------------------------------------------------------------------------- |
| 166 | |
| 167 | \fn palWriteDeviceMemory |
| 168 | |
| 169 | \brief chip and bus agnostic funtion to write memory to the chip |
| 170 | |
| 171 | \param hHdd - HDD context handle |
| 172 | |
| 173 | \param memOffset - address (offset) of the memory from the top of the on-chip |
| 174 | memory that will be written. |
| 175 | |
| 176 | \param pBuffer - pointer to a buffer that has the source data that will be |
| 177 | written to the chip. |
| 178 | |
| 179 | \param numBytes - the number of bytes to be written. |
| 180 | |
| 181 | \return eHalStatus - status of the memory read. Note that this function |
| 182 | can fail. In particular, when the card is removed, this function will return |
| 183 | a failure. |
| 184 | |
| 185 | -------------------------------------------------------------------------------*/ |
| 186 | eHalStatus palWriteDeviceMemory( tHddHandle hHdd, tANI_U32 memOffset, tANI_U8 *pBuffer, tANI_U32 numBytes ); |
| 187 | |
| 188 | |
| 189 | /** --------------------------------------------------------------------------- |
| 190 | |
| 191 | \fn palAllocateMemory |
| 192 | |
| 193 | \brief OS agnostic funtion to allocate host memory. |
| 194 | |
| 195 | \note Host memory that needs to be shared between the host and the |
| 196 | device needs to be allocated with the palAllocateSharedMemory() |
| 197 | and free'd with palFreeSharedMemory() functions. |
| 198 | |
| 199 | \param hHdd - HDD context handle |
| 200 | |
| 201 | \param ppMemory - pointer to a void pointer where the address of the |
| 202 | memory allocated will be placed upon return from this function. |
| 203 | |
| 204 | \param numBytes - the number of bytes to allocate. |
| 205 | |
| 206 | \return eHalStatus - status of the register read. Note that this function |
| 207 | can fail. In the case of a failure, a non-successful return code will be |
| 208 | returned and no memory will be allocated (the *ppMemory will be NULL so don't |
| 209 | try to use it unless the status returns success). |
| 210 | |
| 211 | -------------------------------------------------------------------------------*/ |
| 212 | #ifdef MEMORY_DEBUG |
| 213 | #define palAllocateMemory(hHdd, ppMemory, numBytes) palAllocateMemory_debug(hHdd, ppMemory, numBytes, __FILE__, __LINE__) |
| 214 | eHalStatus palAllocateMemory_debug( tHddHandle hHdd, void **ppMemory, tANI_U32 numBytes, char* fileName, tANI_U32 lineNum ); |
| 215 | #else |
| 216 | eHalStatus palAllocateMemory( tHddHandle hHdd, void **ppMemory, tANI_U32 numBytes ); |
| 217 | #endif |
| 218 | |
| 219 | |
| 220 | /** --------------------------------------------------------------------------- |
| 221 | |
| 222 | \fn palFreeMemory |
| 223 | |
| 224 | \brief OS agnostic funtion to free host memory that was allocated with |
| 225 | palAllcoateMemory() calls. |
| 226 | |
| 227 | \note Host memory that needs to be shared between the host and the |
| 228 | device needs to be allocated with the palAllocateSharedMemory() |
| 229 | and free'd with palFreeSharedMemory() functions. |
| 230 | |
| 231 | \param hHdd - HDD context handle |
| 232 | |
| 233 | \param pMemory - pointer to memory that will be free'd. |
| 234 | |
| 235 | \return eHalStatus - status of the register read. Note that this function |
| 236 | can fail. In the case of a failure, a non-successful return code will be |
| 237 | returned and no memory will be allocated (the *ppMemory will be NULL so don't |
| 238 | try to use it unless the status returns success). |
| 239 | |
| 240 | -------------------------------------------------------------------------------*/ |
| 241 | eHalStatus palFreeMemory( tHddHandle hHdd, void *pMemory ); |
| 242 | |
| 243 | |
| 244 | |
| 245 | /** --------------------------------------------------------------------------- |
| 246 | |
| 247 | \fn palFillMemory |
| 248 | |
| 249 | \brief OS agnostic funtion to fill host memory with a specified byte value |
| 250 | |
| 251 | \param hHdd - HDD context handle |
| 252 | |
| 253 | \param pMemory - pointer to memory that will be filled. |
| 254 | |
| 255 | \param numBytes - the number of bytes to be filled. |
| 256 | |
| 257 | \param fillValue - the byte to be written to fill the memory with. |
| 258 | |
| 259 | \return eHalStatus - status of the register read. Note that this function |
| 260 | can fail. In the case of a failure, a non-successful return code will be |
| 261 | returned and no memory will be allocated (the *ppMemory will be NULL so don't |
| 262 | try to use it unless the status returns success). |
| 263 | |
| 264 | -------------------------------------------------------------------------------*/ |
| 265 | eHalStatus palFillMemory( tHddHandle hHdd, void *pMemory, tANI_U32 numBytes, tANI_BYTE fillValue ); |
| 266 | |
| 267 | /** --------------------------------------------------------------------------- |
| 268 | |
| 269 | \fn palCopyMemory |
| 270 | |
| 271 | \brief OS agnostic funtion to copy host memory from one location to another |
| 272 | |
| 273 | \param hHdd - HDD context handle |
| 274 | |
| 275 | \param pSrc - pointer to source memory location (to copy from) |
| 276 | |
| 277 | \param pSrc - pointer to destination memory location (to copy to) |
| 278 | |
| 279 | \param numBytes - the number of bytes to be be copied. |
| 280 | |
| 281 | \return eHalStatus - status of the memory copy |
| 282 | |
| 283 | -------------------------------------------------------------------------------*/ |
| 284 | eHalStatus palCopyMemory( tHddHandle hHdd, void *pDst, const void *pSrc, tANI_U32 numBytes ); |
| 285 | |
| 286 | /** --------------------------------------------------------------------------- |
| 287 | |
| 288 | \fn palFillMemory |
| 289 | |
| 290 | \brief OS agnostic funtion to fill host memory with a specified byte value |
| 291 | |
| 292 | \param hHdd - HDD context handle |
| 293 | |
| 294 | \param pMemory - pointer to memory that will be filled. |
| 295 | |
| 296 | \param numBytes - the number of bytes to be filled. |
| 297 | |
| 298 | \param fillValue - the byte to be written to fill the memory with. |
| 299 | |
| 300 | \return eHalStatus - status of the register read. Note that this function |
| 301 | can fail. In the case of a failure, a non-successful return code will be |
| 302 | returned and no memory will be allocated (the *ppMemory will be NULL so don't |
| 303 | try to use it unless the status returns success). |
| 304 | |
| 305 | -------------------------------------------------------------------------------*/ |
| 306 | ANI_INLINE_FUNCTION |
| 307 | eHalStatus palZeroMemory( tHddHandle hHdd, void *pMemory, tANI_U32 numBytes ) |
| 308 | { |
| 309 | return( palFillMemory( hHdd, pMemory, numBytes, 0 ) ); |
| 310 | } |
| 311 | |
| 312 | |
| 313 | /** --------------------------------------------------------------------------- |
| 314 | |
| 315 | \fn palEqualMemory |
| 316 | |
| 317 | \brief OS agnostic funtion to compare two pieces of memory, similar to |
| 318 | memcmp function in standard C. |
| 319 | |
| 320 | \param hHdd - HDD context handle |
| 321 | |
| 322 | \param pMemory1 - pointer to one location in memory to compare. |
| 323 | |
| 324 | \param pMemory2 - pointer to second location in memory to compare. |
| 325 | |
| 326 | \param numBytes - the number of bytes to compare. |
| 327 | |
| 328 | \return tANI_BOOLEAN - returns a boolean value that tells if the memory |
| 329 | locations are equal or now equal. |
| 330 | |
| 331 | -------------------------------------------------------------------------------*/ |
| 332 | tANI_BOOLEAN palEqualMemory( tHddHandle hHdd, void *pMemory1, void *pMemory2, tANI_U32 numBytes ); |
| 333 | |
| 334 | /** --------------------------------------------------------------------------- |
| 335 | |
| 336 | \fn palFillDeviceMemory |
| 337 | |
| 338 | \brief OS agnostic funtion to fill device memory with a specified |
| 339 | 32bit value |
| 340 | |
| 341 | \param hHdd - HDD context handle |
| 342 | |
| 343 | \param memOffset - offset of the memory on the device to fill. |
| 344 | |
| 345 | \param numBytes - the number of bytes to be filled. |
| 346 | |
| 347 | \param fillValue - the byte pattern to fill into memory on the device |
| 348 | |
| 349 | \return eHalStatus - status of the register read. Note that this function |
| 350 | can fail. |
| 351 | |
| 352 | eHAL_STATUS_DEVICE_MEMORY_LENGTH_ERROR - length of the device memory is not |
| 353 | a multiple of 4 bytes. |
| 354 | |
| 355 | eHAL_STATUS_DEVICE_MEMORY_MISALIGNED - memory address is not aligned on a |
| 356 | 4 byte boundary. |
| 357 | |
| 358 | \note return failure if the memOffset is not 32bit aligned and not a |
| 359 | multiple of 4 bytes (the device does not support anything else). |
| 360 | |
| 361 | -------------------------------------------------------------------------------*/ |
| 362 | eHalStatus palFillDeviceMemory( tHddHandle hHdd, tANI_U32 memOffset, tANI_U32 numBytes, tANI_BYTE fillValue ); |
| 363 | |
| 364 | |
| 365 | /** --------------------------------------------------------------------------- |
| 366 | |
| 367 | \fn palZeroDeviceMemory |
| 368 | |
| 369 | \brief OS agnostic funtion to fill device memory with a specified byte value |
| 370 | |
| 371 | \param hHdd - HDD context handle |
| 372 | |
| 373 | \param memOffset - offset of the memory on the device to fill. |
| 374 | |
| 375 | \param numBytes - the number of bytes to be filled. |
| 376 | |
| 377 | \param fillValue - the 32bit pattern to fill the memory with. |
| 378 | |
| 379 | \return eHalStatus - status of the register read. Note that this function |
| 380 | can fail. |
| 381 | |
| 382 | eHAL_STATUS_DEVICE_MEMORY_LENGTH_ERROR - length of the device memory is not |
| 383 | a multiple of 4 bytes. |
| 384 | |
| 385 | eHAL_STATUS_DEVICE_MEMORY_MISALIGNED - memory address is not aligned on a |
| 386 | 4 byte boundary. |
| 387 | |
| 388 | \note return failure if the memOffset is not 32bit aligned and not a |
| 389 | multiple of 4 bytes (the device does not support anything else). |
| 390 | |
| 391 | -------------------------------------------------------------------------------*/ |
| 392 | ANI_INLINE_FUNCTION |
| 393 | eHalStatus palZeroDeviceMemory( tHddHandle hHdd, tANI_U32 memOffset, tANI_U32 numBytes ) |
| 394 | { |
| 395 | return( palFillDeviceMemory( hHdd, memOffset, numBytes, 0 ) ); |
| 396 | } |
| 397 | |
| 398 | /*---------------------------------------------------------------------------------- |
| 399 | |
| 400 | Allocate a packet for sending through the Tx APIs. |
| 401 | |
| 402 | \param hHdd - HDD context handle |
| 403 | |
| 404 | \param frmType - Frame type |
| 405 | |
| 406 | \param size |
| 407 | |
| 408 | \param data - |
| 409 | |
| 410 | \param ppPacket - |
| 411 | |
| 412 | \return eHalStatus - |
| 413 | ----------------------------------------------------------------------------------*/ |
| 414 | eHalStatus palPktAlloc(tHddHandle hHdd, eFrameType frmType, tANI_U16 size, void **data, void **ppPacket) ; |
| 415 | |
| 416 | |
| 417 | // This should return Ssome sort of status..... |
| 418 | void palPktFree( tHddHandle hHdd, eFrameType frmType, void* buf, void *pPacket); |
| 419 | |
| 420 | |
| 421 | |
| 422 | //PAL lock functions |
| 423 | //pHandle -- pointer to a caller allocated tPalSpinLockHandle object |
| 424 | eHalStatus palSpinLockAlloc( tHddHandle hHdd, tPalSpinLockHandle *pHandle ); |
| 425 | //hSpinLock -- a handle returned by palSpinLockAlloc |
| 426 | eHalStatus palSpinLockFree( tHddHandle hHdd, tPalSpinLockHandle hSpinLock ); |
| 427 | //hSpinLock -- a handle returned by palSpinLockAlloc |
| 428 | eHalStatus palSpinLockTake( tHddHandle hHdd, tPalSpinLockHandle hSpinLock ); |
| 429 | //hSpinLock -- a handle returned by palSpinLockAlloc |
| 430 | eHalStatus palSpinLockGive( tHddHandle hHdd, tPalSpinLockHandle hSpinLock ); |
| 431 | //PAL lock functions end |
| 432 | |
| 433 | |
| 434 | //This function send a message to MAC, |
| 435 | //pMsgBuf is a buffer allocated by caller. The actual structure varies base on message type |
| 436 | //The beginning of the buffer can always map to tSirMbMsg |
| 437 | //This function must take care of padding if it is required for the OS |
| 438 | eHalStatus palSendMBMessage(tHddHandle hHdd, void *pBuf); |
| 439 | |
| 440 | extern void palGetUnicastStats(tHddHandle hHdd, tANI_U32 *tx, tANI_U32 *rx); |
| 441 | |
| 442 | |
| 443 | /*---------------------------------------------------------------------------------- |
| 444 | this function is to return a tick count (one tick = ~10ms). It is used to calculate |
| 445 | time difference. |
| 446 | |
| 447 | \param hHdd - HDD context handle |
| 448 | |
| 449 | \return tick count. |
| 450 | ----------------------------------------------------------------------------------*/ |
| 451 | tANI_U32 palGetTickCount(tHddHandle hHdd); |
| 452 | |
| 453 | /** --------------------------------------------------------------------------- |
| 454 | |
| 455 | \fn palReadRegMemory |
| 456 | |
| 457 | \brief chip and bus agnostic function to read memory from the PHY register space as memory |
| 458 | i.e. to read more than 4 bytes from the contiguous register space |
| 459 | |
| 460 | \param hHdd - HDD context handle |
| 461 | |
| 462 | \param memOffset - address (offset) of the memory from the top of the |
| 463 | memory map (as exposed to the host) where the memory will be read from. |
| 464 | |
| 465 | \param pBuffer - pointer to a buffer where the memory will be placed in host |
| 466 | memory space after retreived from the chip. |
| 467 | |
| 468 | \param numBytes - the number of bytes to be read. |
| 469 | |
| 470 | \return eHalStatus - status of the memory read. Note that this function |
| 471 | can fail. In particular, when the card is removed, this function will return |
| 472 | a failure. |
| 473 | |
| 474 | -------------------------------------------------------------------------------*/ |
| 475 | eHalStatus palReadRegMemory( tHddHandle hHdd, tANI_U32 memOffset, tANI_U8 *pBuffer, tANI_U32 numBytes ); |
| 476 | |
| 477 | /** --------------------------------------------------------------------------- |
| 478 | |
| 479 | \fn palAsyncWriteRegMemory |
| 480 | |
| 481 | \brief chip and bus agnostic function to write memory to the PHY register space as memory |
| 482 | i.e. to write more than 4 bytes from the contiguous register space. In USB interface, this |
| 483 | API does the write asynchronously. |
| 484 | |
| 485 | \param hHdd - HDD context handle |
| 486 | |
| 487 | \param memOffset - address (offset) of the memory from the top of the on-chip |
| 488 | memory that will be written. |
| 489 | |
| 490 | \param pBuffer - pointer to a buffer that has the source data that will be |
| 491 | written to the chip. |
| 492 | |
| 493 | \param numBytes - the number of bytes to be written. |
| 494 | |
| 495 | \return eHalStatus - status of the memory read. Note that this function |
| 496 | can fail. In particular, when the card is removed, this function will return |
| 497 | a failure. |
| 498 | |
| 499 | -------------------------------------------------------------------------------*/ |
| 500 | eHalStatus palAsyncWriteRegMemory( tHddHandle hHdd, tANI_U32 memOffset, tANI_U8 *pBuffer, tANI_U32 numBytes ); |
| 501 | |
| 502 | /** --------------------------------------------------------------------------- |
| 503 | |
| 504 | \fn palWriteRegMemory |
| 505 | \brief chip and bus agnostic function to write memory to the PHY register space as memory |
| 506 | i.e. to write more than 4 bytes from the contiguous register space. The difference from the |
| 507 | above routine is, in USB interface, this routine performs the write synchronously where as |
| 508 | the above routine performs it asynchronously. |
| 509 | |
| 510 | \param hHdd - HDD context handle |
| 511 | |
| 512 | \param memOffset - address (offset) of the memory from the top of the on-chip |
| 513 | memory that will be written. |
| 514 | |
| 515 | \param pBuffer - pointer to a buffer that has the source data that will be |
| 516 | written to the chip. |
| 517 | |
| 518 | \param numBytes - the number of bytes to be written. |
| 519 | |
| 520 | \return eHalStatus - status of the memory read. Note that this function |
| 521 | can fail. In particular, when the card is removed, this function will return |
| 522 | a failure. |
| 523 | |
| 524 | -------------------------------------------------------------------------------*/ |
| 525 | eHalStatus palWriteRegMemory( tHddHandle hHdd, tANI_U32 memOffset, tANI_U8 *pBuffer, tANI_U32 numBytes ); |
| 526 | |
| 527 | |
| 528 | /** --------------------------------------------------------------------------- |
| 529 | |
| 530 | \fn palWaitRegVal |
| 531 | |
| 532 | \brief is a blocking function which reads the register and waits for the given number of iterations |
| 533 | until the read value matches the waitRegVal. The delay between is perIterWaitInNanoSec(in nanoseconds) |
| 534 | |
| 535 | \param hHdd - HDD context handle |
| 536 | |
| 537 | \param reg - address of the register to be read |
| 538 | |
| 539 | \param mask - mask to be applied for the read value |
| 540 | |
| 541 | \param waitRegVal - expected value from the register after applying the mask. |
| 542 | |
| 543 | \param perIterWaitInNanoSec - delay between the two iterations in nanoseconds |
| 544 | |
| 545 | \param numIter - max number of reads before the timeout |
| 546 | |
| 547 | \param pReadRegVal - the value read from the register |
| 548 | |
| 549 | \return eHalStatus - status of the memory read. Note that this function |
| 550 | can fail. In particular, when the card is removed, this function will return |
| 551 | a failure. |
| 552 | |
| 553 | -------------------------------------------------------------------------------*/ |
| 554 | eHalStatus palWaitRegVal( tHddHandle hHdd, tANI_U32 reg, tANI_U32 mask, |
| 555 | tANI_U32 waitRegVal, tANI_U32 perIterWaitInNanoSec, |
| 556 | tANI_U32 numIter, tANI_U32 *pReadRegVal ); |
| 557 | |
| 558 | /** --------------------------------------------------------------------------- |
| 559 | |
| 560 | \fn palReadModifyWriteReg |
| 561 | |
| 562 | \brief chip and bus agnostic function to read a PHY register apply the given masks(AND and OR masks) |
| 563 | and writes back the new value to the register |
| 564 | |
| 565 | \param hHdd - HDD context handle |
| 566 | |
| 567 | \param reg - address of the register to be modified. |
| 568 | |
| 569 | \param andMask - The value read will be ANDed with this mask |
| 570 | |
| 571 | \parma orMask - The value after applying the andMask will be ORed with this value |
| 572 | |
| 573 | \return eHalStatus - status of the memory read. Note that this function |
| 574 | can fail. In particular, when the card is removed, this function will return |
| 575 | a failure. |
| 576 | |
| 577 | -------------------------------------------------------------------------------*/ |
| 578 | eHalStatus palReadModifyWriteReg( tHddHandle hHdd, tANI_U32 reg, tANI_U32 andMask, tANI_U32 orMask ); |
| 579 | |
| 580 | //PAL semaphore functions |
| 581 | eHalStatus palSemaphoreAlloc( tHddHandle hHdd, tPalSemaphoreHandle *pHandle, tANI_S32 count ); |
| 582 | eHalStatus palSemaphoreFree( tHddHandle hHdd, tPalSemaphoreHandle hSemaphore ); |
| 583 | eHalStatus palSemaphoreTake( tHddHandle hHdd, tPalSemaphoreHandle hSemaphore ); |
| 584 | eHalStatus palSemaphoreGive( tHddHandle hHdd, tPalSemaphoreHandle hSemaphore ); |
| 585 | eHalStatus palMutexAlloc( tHddHandle hHdd, tPalSemaphoreHandle *pHandle) ; |
| 586 | eHalStatus palMutexAllocLocked( tHddHandle hHdd, tPalSemaphoreHandle *pHandle) ; |
| 587 | |
| 588 | //PAL irq/softirq |
| 589 | eAniBoolean pal_in_interrupt(void) ; |
| 590 | void pal_local_bh_disable(void) ; |
| 591 | void pal_local_bh_enable(void) ; |
| 592 | |
| 593 | //PAL byte swap |
| 594 | tANI_U32 pal_be32_to_cpu(tANI_U32 x) ; |
| 595 | tANI_U32 pal_cpu_to_be32(tANI_U32 x) ; |
| 596 | tANI_U16 pal_be16_to_cpu(tANI_U16 x) ; |
| 597 | tANI_U16 pal_cpu_to_be16(tANI_U16 x) ; |
| 598 | |
| 599 | |
| 600 | #if defined( ANI_LITTLE_BYTE_ENDIAN ) |
| 601 | |
| 602 | // Need to eliminate these and use the ani_cpu_to_le, etc. macros.... |
| 603 | ANI_INLINE_FUNCTION unsigned long i_htonl( unsigned long ul ) |
| 604 | { |
| 605 | return( ( ( ul & 0x000000ff ) << 24 ) | |
| 606 | ( ( ul & 0x0000ff00 ) << 8 ) | |
| 607 | ( ( ul & 0x00ff0000 ) >> 8 ) | |
| 608 | ( ( ul & 0xff000000 ) >> 24 ) ); |
| 609 | } |
| 610 | |
| 611 | ANI_INLINE_FUNCTION unsigned short i_htons( unsigned short us ) |
| 612 | { |
| 613 | return( ( ( us >> 8 ) & 0x00ff ) + ( ( us << 8 ) & 0xff00 ) ); |
| 614 | } |
| 615 | |
| 616 | ANI_INLINE_FUNCTION unsigned short i_ntohs( unsigned short us ) |
| 617 | { |
| 618 | return( i_htons( us ) ); |
| 619 | } |
| 620 | |
| 621 | ANI_INLINE_FUNCTION unsigned long i_ntohl( unsigned long ul ) |
| 622 | { |
| 623 | return( i_htonl( ul ) ); |
| 624 | } |
| 625 | |
| 626 | #endif //#if defined( ANI_LITTLE_BYTE_ENDIAN ) |
| 627 | |
| 628 | |
| 629 | /** --------------------------------------------------------------------------- |
| 630 | |
| 631 | \fn pal_set_U32 |
| 632 | |
| 633 | \brief Assign 32-bit unsigned value to a byte array base on CPU's endianness. |
| 634 | |
| 635 | \note Caller must validate the byte array has enough space to hold the vlaue |
| 636 | |
| 637 | \param ptr - Starting address of a byte array |
| 638 | |
| 639 | \param value - The value to assign to the byte array |
| 640 | |
| 641 | \return - The address to the byte after the assignment. This may or may not |
| 642 | be valid. Caller to verify. |
| 643 | |
| 644 | -------------------------------------------------------------------------------*/ |
| 645 | ANI_INLINE_FUNCTION tANI_U8 * pal_set_U32(tANI_U8 *ptr, tANI_U32 value) |
| 646 | { |
| 647 | #if defined( ANI_BIG_BYTE_ENDIAN ) |
| 648 | *(ptr) = ( tANI_U8 )( value >> 24 ); |
| 649 | *(ptr + 1) = ( tANI_U8 )( value >> 16 ); |
| 650 | *(ptr + 2) = ( tANI_U8 )( value >> 8 ); |
| 651 | *(ptr + 3) = ( tANI_U8 )( value ); |
| 652 | #else |
| 653 | *(ptr + 3) = ( tANI_U8 )( value >> 24 ); |
| 654 | *(ptr + 2) = ( tANI_U8 )( value >> 16 ); |
| 655 | *(ptr + 1) = ( tANI_U8 )( value >> 8 ); |
| 656 | *(ptr) = ( tANI_U8 )( value ); |
| 657 | #endif |
| 658 | |
| 659 | return (ptr + 4); |
| 660 | } |
| 661 | |
| 662 | |
| 663 | /** --------------------------------------------------------------------------- |
| 664 | |
| 665 | \fn pal_set_U16 |
| 666 | |
| 667 | \brief Assign 16-bit unsigned value to a byte array base on CPU's endianness. |
| 668 | |
| 669 | \note Caller must validate the byte array has enough space to hold the vlaue |
| 670 | |
| 671 | \param ptr - Starting address of a byte array |
| 672 | |
| 673 | \param value - The value to assign to the byte array |
| 674 | |
| 675 | \return - The address to the byte after the assignment. This may or may not |
| 676 | be valid. Caller to verify. |
| 677 | |
| 678 | -------------------------------------------------------------------------------*/ |
| 679 | ANI_INLINE_FUNCTION tANI_U8 * pal_set_U16(tANI_U8 *ptr, tANI_U16 value) |
| 680 | { |
| 681 | #if defined( ANI_BIG_BYTE_ENDIAN ) |
| 682 | *(ptr) = ( tANI_U8 )( value >> 8 ); |
| 683 | *(ptr + 1) = ( tANI_U8 )( value ); |
| 684 | #else |
| 685 | *(ptr + 1) = ( tANI_U8 )( value >> 8 ); |
| 686 | *(ptr) = ( tANI_U8 )( value ); |
| 687 | #endif |
| 688 | |
| 689 | return (ptr + 2); |
| 690 | } |
| 691 | |
| 692 | |
| 693 | /** --------------------------------------------------------------------------- |
| 694 | |
| 695 | \fn pal_get_U16 |
| 696 | |
| 697 | \brief Retrieve a 16-bit unsigned value from a byte array base on CPU's endianness. |
| 698 | |
| 699 | \note Caller must validate the byte array has enough space to hold the vlaue |
| 700 | |
| 701 | \param ptr - Starting address of a byte array |
| 702 | |
| 703 | \param pValue - Pointer to a caller allocated buffer for 16 bit value. Value is to assign |
| 704 | to this location. |
| 705 | |
| 706 | \return - The address to the byte after the assignment. This may or may not |
| 707 | be valid. Caller to verify. |
| 708 | |
| 709 | -------------------------------------------------------------------------------*/ |
| 710 | ANI_INLINE_FUNCTION tANI_U8 * pal_get_U16(tANI_U8 *ptr, tANI_U16 *pValue) |
| 711 | { |
| 712 | #if defined( ANI_BIG_BYTE_ENDIAN ) |
| 713 | *pValue = (((tANI_U16) (*ptr << 8)) | |
| 714 | ((tANI_U16) (*(ptr+1)))); |
| 715 | #else |
| 716 | *pValue = (((tANI_U16) (*(ptr+1) << 8)) | |
| 717 | ((tANI_U16) (*ptr))); |
| 718 | #endif |
| 719 | |
| 720 | return (ptr + 2); |
| 721 | } |
| 722 | |
| 723 | |
| 724 | /** --------------------------------------------------------------------------- |
| 725 | |
| 726 | \fn pal_get_U32 |
| 727 | |
| 728 | \brief Retrieve a 32-bit unsigned value from a byte array base on CPU's endianness. |
| 729 | |
| 730 | \note Caller must validate the byte array has enough space to hold the vlaue |
| 731 | |
| 732 | \param ptr - Starting address of a byte array |
| 733 | |
| 734 | \param pValue - Pointer to a caller allocated buffer for 32 bit value. Value is to assign |
| 735 | to this location. |
| 736 | |
| 737 | \return - The address to the byte after the assignment. This may or may not |
| 738 | be valid. Caller to verify. |
| 739 | |
| 740 | -------------------------------------------------------------------------------*/ |
| 741 | ANI_INLINE_FUNCTION tANI_U8 * pal_get_U32(tANI_U8 *ptr, tANI_U32 *pValue) |
| 742 | { |
| 743 | #if defined( ANI_BIG_BYTE_ENDIAN ) |
| 744 | *pValue = ( (tANI_U32)(*(ptr) << 24) | |
| 745 | (tANI_U32)(*(ptr+1) << 16) | |
| 746 | (tANI_U32)(*(ptr+2) << 8) | |
| 747 | (tANI_U32)(*(ptr+3)) ); |
| 748 | #else |
| 749 | *pValue = ( (tANI_U32)(*(ptr+3) << 24) | |
| 750 | (tANI_U32)(*(ptr+2) << 16) | |
| 751 | (tANI_U32)(*(ptr+1) << 8) | |
| 752 | (tANI_U32)(*(ptr)) ); |
| 753 | #endif |
| 754 | |
| 755 | return (ptr + 4); |
| 756 | } |
| 757 | |
| 758 | |
| 759 | #endif |