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