| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2011, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bdma.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/5 $ |
|---|
| 12 | * $brcm_Date: 3/21/11 6:37p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/dma/7400/bdma.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/5 3/21/11 6:37p vanessah |
|---|
| 21 | * SW7420-1431: support oflarge DMA descriptor list subset |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/4 2/22/11 7:48a vanessah |
|---|
| 24 | * SW7550-670: add Sharf DMA support |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/3 2/2/11 10:25a vanessah |
|---|
| 27 | * SW7550-670: add Sharf DMA support |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/2 7/11/08 3:47p syang |
|---|
| 30 | * PR 43729: rm code for old crypto hw arch |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/74 7/11/08 11:49a syang |
|---|
| 33 | * PR 43729: make bdma.h chip independent |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/72 7/7/08 1:57p syang |
|---|
| 36 | * PR42353: Update for 7325 |
|---|
| 37 | * |
|---|
| 38 | * Hydra_Software_Devel/71 5/29/08 2:07p syang |
|---|
| 39 | * PR 43118: add support for 7335 |
|---|
| 40 | * |
|---|
| 41 | * Hydra_Software_Devel/70 4/23/08 2:05p rpan |
|---|
| 42 | * PR34854: Enable scatter-gathering support for 3548 and 3556. |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/69 2/22/08 9:51a rpan |
|---|
| 45 | * PR39458: Initial work for bcm3556. |
|---|
| 46 | * |
|---|
| 47 | * Hydra_Software_Devel/68 2/21/08 1:38p rpan |
|---|
| 48 | * PR34854: Initial work for bcm3548. |
|---|
| 49 | * |
|---|
| 50 | * Hydra_Software_Devel/67 12/21/07 3:50p syang |
|---|
| 51 | * PR 34606: add 7405 into the list that support scatter gather |
|---|
| 52 | * |
|---|
| 53 | * Hydra_Software_Devel/66 12/11/07 10:55a syang |
|---|
| 54 | * PR 34606: more small clean up after big rewriting |
|---|
| 55 | * |
|---|
| 56 | * Hydra_Software_Devel/65 12/7/07 6:39p syang |
|---|
| 57 | * PR 34606: move SetCrypto to Tran level from Engine level for better |
|---|
| 58 | * sharing by threads of the same progress |
|---|
| 59 | * |
|---|
| 60 | * Hydra_Software_Devel/64 12/7/07 4:10p syang |
|---|
| 61 | * PR 34606: rewrite more than half of code to support hw sharing for |
|---|
| 62 | * kernel and user-mode sides |
|---|
| 63 | * |
|---|
| 64 | * Hydra_Software_Devel/63 11/20/07 10:50p tdo |
|---|
| 65 | * PR36882: Add dma PI support for 7335 |
|---|
| 66 | * |
|---|
| 67 | * Hydra_Software_Devel/62 10/25/07 11:21a syang |
|---|
| 68 | * PR 34606: clean up comments |
|---|
| 69 | * |
|---|
| 70 | * Hydra_Software_Devel/61 10/24/07 1:44p syang |
|---|
| 71 | * PR 34606: update for 7038 |
|---|
| 72 | * |
|---|
| 73 | * Hydra_Software_Devel/60 10/23/07 1:38p syang |
|---|
| 74 | * PR 34606: fix compile error |
|---|
| 75 | * |
|---|
| 76 | * Hydra_Software_Devel/59 10/23/07 12:00p syang |
|---|
| 77 | * PR 34606: update dma PI to support IP streamer usage mode |
|---|
| 78 | * |
|---|
| 79 | * Hydra_Software_Devel/1 9/25/03 7:16p syang |
|---|
| 80 | * init version, from scratch |
|---|
| 81 | * |
|---|
| 82 | ***************************************************************************/ |
|---|
| 83 | #ifndef BDMA_H__ |
|---|
| 84 | #define BDMA_H__ |
|---|
| 85 | |
|---|
| 86 | #include "bchp.h" /* Chip information */ |
|---|
| 87 | #include "breg_mem.h" /* Chip register access (memory mapped). */ |
|---|
| 88 | #include "bmem.h" /* Chip memory access. */ |
|---|
| 89 | #include "bint.h" /* L2 Interrupt Manager */ |
|---|
| 90 | |
|---|
| 91 | #ifdef __cplusplus |
|---|
| 92 | extern "C" { |
|---|
| 93 | #endif |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | /**************************** Module Overview: ***************************** |
|---|
| 97 | BDMA module provides porting interface API for higher level software to |
|---|
| 98 | control hardware DMA engines. The API exposes hardware functionalities and |
|---|
| 99 | hides the hardware and software details. It is targeted for Hydra core based |
|---|
| 100 | chip, and is also intended to fit future chips. |
|---|
| 101 | |
|---|
| 102 | There might be multiple memory DMA engines and/or PCI DMA engines in a chip. |
|---|
| 103 | A memory DMA engine is used to move data from one location in DRAM to |
|---|
| 104 | another location in DRAM. And a PCI DMA engine is used to move data between |
|---|
| 105 | DRAM and any PCI device connected to PCI bus. |
|---|
| 106 | |
|---|
| 107 | Both memory DMA engine and PCI DMA engine are represented as sub-modules of |
|---|
| 108 | the BDMA software module. |
|---|
| 109 | |
|---|
| 110 | In order to control a specific hardware DMA engine, higher level software |
|---|
| 111 | should first open a BDMA module handle by calling BDMA_Open, and use this |
|---|
| 112 | module handle to create a sub-module handle to the DMA engine by calling |
|---|
| 113 | either BDMA_Mem_Create2 or BDMA_Pci_Create2. The sub-module handle could |
|---|
| 114 | then be used to setup the DMA engine and perform DMA data transfer using the |
|---|
| 115 | sub-module functions. All sub-module functions are prefixed with BDMA_Mem_ |
|---|
| 116 | or BDMA_Pci_. |
|---|
| 117 | |
|---|
| 118 | User could DMA transfer a list of contiguous blocks in one transfer action. |
|---|
| 119 | In order to do this, user needs to create a transfer handle to represent the |
|---|
| 120 | transfer action, then to use it to set block info for each block, to start |
|---|
| 121 | the transfer, and finally to get the transfer status. A transfer handle is a |
|---|
| 122 | sub-module of a DMA engine. |
|---|
| 123 | |
|---|
| 124 | Two API functions are provided to start a DMA transfer, one for "start" |
|---|
| 125 | only (then the result should be checked actively by user), and another for |
|---|
| 126 | "start and call back" (then the result will be informed by a callback when |
|---|
| 127 | the transfer is done). |
|---|
| 128 | |
|---|
| 129 | The "started" transfer might be queued in BDMA first and then be issued to |
|---|
| 130 | hardware in turn. |
|---|
| 131 | |
|---|
| 132 | During a DMA data transfer, both memory and PCI DMA engines could be |
|---|
| 133 | programmed to perform translation between little endian and big endian with |
|---|
| 134 | either byte aligned swap or short aligned swap. Memory DMA engine could |
|---|
| 135 | also perform encryption or decryption. The crypto is set with |
|---|
| 136 | BDMA_Mem_Tran_SetCrypto. |
|---|
| 137 | |
|---|
| 138 | Both memory and PCI DMA engines maintain a current state of engine configure |
|---|
| 139 | of swap mode, or max burst size. Each DMA transfer uses the current |
|---|
| 140 | configure state. |
|---|
| 141 | |
|---|
| 142 | The transfer handle could be re-used after a DMA transfer is started and |
|---|
| 143 | finished, for convenience and better performance. If there is no change to a |
|---|
| 144 | block info, it does not need to be re-set too. |
|---|
| 145 | |
|---|
| 146 | BDMA module is interrupt safe, in the sense that DMA transfer could be |
|---|
| 147 | performed from both interrupt handler or a non-interrupt context such as |
|---|
| 148 | user mode process. An exception is that in interrupt handler the completion |
|---|
| 149 | of a DMA transfer can not be waited, and therefore call back has to been |
|---|
| 150 | used if the "done info" needs to be processed. |
|---|
| 151 | |
|---|
| 152 | In order to support interrupt safety, two sets of transfer API functions are |
|---|
| 153 | provided, one set for non-interrupt context such as user mode process, and |
|---|
| 154 | another set used in interrupt handler or critical session. The second set of |
|---|
| 155 | API functions are named with an extra suffix "_isr". |
|---|
| 156 | |
|---|
| 157 | BDMA is also thread safe. BDMA transfer functions could also be called from |
|---|
| 158 | more than one threads. |
|---|
| 159 | |
|---|
| 160 | However, user must ensure that interrupt handler (and its subroutines) and |
|---|
| 161 | code in critical session only calls BDMA API functions with suffix "_isr" |
|---|
| 162 | and functions in non-interrupt context only calls BDMA API functions without |
|---|
| 163 | that suffix. |
|---|
| 164 | |
|---|
| 165 | And also, if different engine configure are used in different thread or |
|---|
| 166 | interrupt handler, higher level software has to use extra mechanism (such |
|---|
| 167 | as mutex, but not critical session) to synchronize the API function call in |
|---|
| 168 | order to ensure that the right configure is applied to each DMA transfer. |
|---|
| 169 | |
|---|
| 170 | When a DMA engine sub-module handle or the DMA module handle is no longer |
|---|
| 171 | needed, it should be destroyed or closed. |
|---|
| 172 | |
|---|
| 173 | A hardware DMA engine might also be shared by multiple users from both user |
|---|
| 174 | mode side and kernel side. |
|---|
| 175 | |
|---|
| 176 | In this case, BDMA API functions should be called independently by each DMA |
|---|
| 177 | user to create BDMA_Handle, BDMA_Mem/Pci_Handle, and BDMA_Mem/Pci_Tran_Handle, |
|---|
| 178 | to set block info, and to start a DMA transfer. The result could later be |
|---|
| 179 | polled by the application, or be informed by call-back. |
|---|
| 180 | |
|---|
| 181 | Each user (application) hence runs an independent instance of BDMA as if it |
|---|
| 182 | owns the DMA hardware engine without knowing the sharing issue. Each BDMA |
|---|
| 183 | instance in the system manages its own software context and DMA descriptor |
|---|
| 184 | buffer. Only when a transfer is started in hardware, the user provided call |
|---|
| 185 | back functions are used to lock the hardware from accessing by other BDMA |
|---|
| 186 | instance, and to release it. |
|---|
| 187 | |
|---|
| 188 | Please refer to BDMA_Mem_Handle and BDMA_Pci_Handle and API functions for |
|---|
| 189 | more usage information. |
|---|
| 190 | |
|---|
| 191 | Notes: |
|---|
| 192 | ------ |
|---|
| 193 | Before using BDMA, higher level software must connect and enable level 1 |
|---|
| 194 | interrupt. BDMA automatically creates call back with BINT for level 2 |
|---|
| 195 | interrupt. Level 1 is left to higher level because it is platform dependent. |
|---|
| 196 | The L1 interrupt bit for both memory dma and PCI dma is bit HIF_CPU_INTR in |
|---|
| 197 | register HIF_CPU_INTR1_INTR_W0_STATUS. |
|---|
| 198 | |
|---|
| 199 | Design notes: |
|---|
| 200 | |
|---|
| 201 | o The SDRAM address used in our API functions is in memory bus address, |
|---|
| 202 | rather than virtual address. Virtual address might look more convenient |
|---|
| 203 | to user, but using bus address helps to ensure that the DMA transferred |
|---|
| 204 | memory block physically exists and is contiguous, and it is very easy |
|---|
| 205 | to get the bus address by BMEM_ConvertAddressToOffset if the memory |
|---|
| 206 | block is allocated by BMEM_AllocAligned or BMEM_Alloc. |
|---|
| 207 | o Having user to pass in an array of block info might simplify the |
|---|
| 208 | process of transferring a list of block (i.e. transfer handle creating, |
|---|
| 209 | block info setting, and finally starting), into a single function call. |
|---|
| 210 | However, reading data from user provided buffer of indefinite length |
|---|
| 211 | often causes problem, because the buffer pointer and length can not be |
|---|
| 212 | validated before crashing the sub-system. Our current design is more |
|---|
| 213 | robust, and it saves the time of copying from user's buffer into |
|---|
| 214 | internal DMA description. |
|---|
| 215 | o Transfer Id is also considered, but we decided to use transfer handle. |
|---|
| 216 | One difference to the user between transfer Id and handle is that, |
|---|
| 217 | transfer Id does not need to be explicitly destroyed, but transfer |
|---|
| 218 | handle does. Therefore transfer handle needs one more API function |
|---|
| 219 | call for each transfer. However, transfer Id can not be reused, |
|---|
| 220 | its records disappear automatically, and user can not control it. |
|---|
| 221 | Another question is that what is the right behavior if the "start" |
|---|
| 222 | returns an error, such as "invalid parameter" and "engine busy"? |
|---|
| 223 | o Another implementation option we considered is to have a "done" wait |
|---|
| 224 | loop in the BDMA module. We finally decided no to because user might |
|---|
| 225 | needs to wait longer than what we could have coded and still needs to |
|---|
| 226 | implement a user's waiting loop. |
|---|
| 227 | |
|---|
| 228 | ****************************************************************************/ |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | /*************************************************************************** |
|---|
| 232 | Summary: |
|---|
| 233 | The handle for the DMA module. |
|---|
| 234 | |
|---|
| 235 | Description: |
|---|
| 236 | This is an opaque handle that application created with BDMA_Open. |
|---|
| 237 | BDMA_Handle represents the context of the BDMA module. It is needed |
|---|
| 238 | before using any other API functions of DMA module. The higher level |
|---|
| 239 | software is responsive to ensure that there exists only one BDMA_Handle |
|---|
| 240 | per chip. |
|---|
| 241 | |
|---|
| 242 | When the DMA module handle is no longer needed, it should be closed |
|---|
| 243 | by BDMA_Close. |
|---|
| 244 | |
|---|
| 245 | See also: |
|---|
| 246 | BDMA_Open, BDMA_Close |
|---|
| 247 | BDMA_Mem_Handle, BDMA_Mem_Create2 |
|---|
| 248 | BDMA_Pci_Handle, BDMA_Pci_Create2 |
|---|
| 249 | ****************************************************************************/ |
|---|
| 250 | typedef struct BDMA_P_Context *BDMA_Handle; |
|---|
| 251 | |
|---|
| 252 | /*************************************************************************** |
|---|
| 253 | Summary: |
|---|
| 254 | This enumeration represents swap mode. |
|---|
| 255 | |
|---|
| 256 | Description: |
|---|
| 257 | BDMA_SwapMode is an enumeration which represents all swap modes supported |
|---|
| 258 | during a DMA transfer. Swapping is mainly used to transfer little endian |
|---|
| 259 | data to big endian, or the other way around. |
|---|
| 260 | |
|---|
| 261 | See Also: |
|---|
| 262 | BDMA_Mem_SetByteSwapMode, BDMA_Pci_SetSwapMode |
|---|
| 263 | ***************************************************************************/ |
|---|
| 264 | typedef enum BDMA_SwapMode |
|---|
| 265 | { |
|---|
| 266 | BDMA_SwapMode_eNoSwap, /* default, no swap */ |
|---|
| 267 | BDMA_SwapMode_e0123To2301, /* short aligned: swap shorts in uint32_t */ |
|---|
| 268 | BDMA_SwapMode_e0123To3210, /* byte aligned: swap bytes in uint32_t */ |
|---|
| 269 | BDMA_SwapMode_eInvalid |
|---|
| 270 | } |
|---|
| 271 | BDMA_SwapMode; |
|---|
| 272 | |
|---|
| 273 | /*************************************************************************** |
|---|
| 274 | Summary: |
|---|
| 275 | This enumeration represents the endian format of the data. |
|---|
| 276 | |
|---|
| 277 | Description: |
|---|
| 278 | BDMA_Endian is an enumeration which represents the two possible endian |
|---|
| 279 | formats, big-endian and little endian. |
|---|
| 280 | |
|---|
| 281 | See Also: |
|---|
| 282 | BDMA_Mem_SetByteSwapMode |
|---|
| 283 | ***************************************************************************/ |
|---|
| 284 | typedef enum BDMA_Endian |
|---|
| 285 | { |
|---|
| 286 | BDMA_Endian_eLittle, /* little endian format */ |
|---|
| 287 | BDMA_Endian_eBig, /* big endian format */ |
|---|
| 288 | BDMA_Endian_eInvalid |
|---|
| 289 | } |
|---|
| 290 | BDMA_Endian; |
|---|
| 291 | |
|---|
| 292 | /*************************************************************************** |
|---|
| 293 | Summary: |
|---|
| 294 | This enumeration represents the status of a transfer |
|---|
| 295 | |
|---|
| 296 | Description: |
|---|
| 297 | BDMA_TranStatus is an enumeration which represents the status of a |
|---|
| 298 | transfer. |
|---|
| 299 | |
|---|
| 300 | If an invalid key selection for encrypt / decrypt in a memory DMA transfer, |
|---|
| 301 | BDMA_TranStatus_eFailed would be returned for the status query of the |
|---|
| 302 | transfer. |
|---|
| 303 | |
|---|
| 304 | See Also: |
|---|
| 305 | BDMA_Mem_GetTranStatus, BDMA_Mem_GetTranStatus_isr |
|---|
| 306 | BDMA_Pci_GetTranStatus, BDMA_Pci_GetTranStatus_isr |
|---|
| 307 | ***************************************************************************/ |
|---|
| 308 | typedef enum |
|---|
| 309 | { |
|---|
| 310 | BDMA_TranStatus_eSucceeded, /* Done in HW, successfully */ |
|---|
| 311 | BDMA_TranStatus_eFailed, /* Done in HW, but failed */ |
|---|
| 312 | BDMA_TranStatus_eInProgress, /* Processed in HW right now */ |
|---|
| 313 | BDMA_TranStatus_eQueued, /* Starting API called, not sent to HW yet. */ |
|---|
| 314 | BDMA_TranStatus_eCreated, /* Tran created, Starting API not called yet */ |
|---|
| 315 | BDMA_TranStatus_eUnknown /* Unknown, maybe a invalid Tran handle used */ |
|---|
| 316 | } |
|---|
| 317 | BDMA_TranStatus; |
|---|
| 318 | |
|---|
| 319 | /*************************************************************************** |
|---|
| 320 | Summary: |
|---|
| 321 | Function pointer type of user call back functions used to lock and |
|---|
| 322 | release a hardware DMA engine. |
|---|
| 323 | |
|---|
| 324 | Description: |
|---|
| 325 | The call back functions used in the case that multiple BDMA instances |
|---|
| 326 | exist in the system. They are coded by the user, and are passed to BDMA |
|---|
| 327 | when a dma engine sub-module handle is created. |
|---|
| 328 | |
|---|
| 329 | There are two call-back functions of this type, TryLock and ReleaseLock. |
|---|
| 330 | |
|---|
| 331 | If multiple BDMA instances exist, before writing dma requests into dma |
|---|
| 332 | (hardware) engine, each BDMA instance needs to check the hardware status |
|---|
| 333 | and to make sure that the hardware is not in use by another instance. |
|---|
| 334 | To ensure that the hardware status is not changed in the mean time by |
|---|
| 335 | another BDMA instance, TryLock is used to lock the hardware before this |
|---|
| 336 | BDMA instance reads the hardware registers. ReleaseLock is immediately |
|---|
| 337 | used after the dma requests are written to hardware, or after it is |
|---|
| 338 | decided that the hardware is still in use by another BDMA instance. If |
|---|
| 339 | the dma request can not be written into hardware this time, BDMA would |
|---|
| 340 | try again with result-polling from application, or with a dma-done _isr |
|---|
| 341 | service. |
|---|
| 342 | |
|---|
| 343 | TryLock should return true if and only if it is successful. The return |
|---|
| 344 | value from ReleaseLock is not used. |
|---|
| 345 | |
|---|
| 346 | The lock time is short, and it does not depend on the DMA hardware |
|---|
| 347 | execution. However, a user mode application could still be preempted |
|---|
| 348 | after it gets the lock and before it releases it. In this case, a |
|---|
| 349 | kernel mode dma user could not get the lock and hence dma service until |
|---|
| 350 | the user mode application resumes execution and releases the lock. In |
|---|
| 351 | the mean time, the hardware engine could indeed have been idle. |
|---|
| 352 | |
|---|
| 353 | TryLock could increase the user mode application to higher priority so |
|---|
| 354 | that the application will unlikely be preempted. RleaseLock should then |
|---|
| 355 | drop it to its original priority. How high priority the application |
|---|
| 356 | should be raised to by TryLock? It is up to the application to decide. |
|---|
| 357 | |
|---|
| 358 | For a simple implementation, TryLock and ReleaseLock could use a |
|---|
| 359 | hardware semaphore (such as BCHP_SUN_TOP_CTRL_SEMAPHORE_15). A hardware |
|---|
| 360 | semaphore is a special register with some simple logic. The simple logic |
|---|
| 361 | ensures that a non-zero value can be successfully written into it if and |
|---|
| 362 | only if it currently has value "0". |
|---|
| 363 | |
|---|
| 364 | In TryLock a unique non-zero user-id is written to the semaphore register, |
|---|
| 365 | then the semaphore register value is read back. If the read back value |
|---|
| 366 | matches the written value (user-id), it means that is has got the |
|---|
| 367 | semaphore. RelaeseLock could simply write value "0" into the semaphore |
|---|
| 368 | register to release it. |
|---|
| 369 | |
|---|
| 370 | See Also: |
|---|
| 371 | BDMA_Mem_Settings, BDMA_Pci_Settings, |
|---|
| 372 | BDMA_Mem_Create2, BDMA_Pci_Create2 |
|---|
| 373 | ****************************************************************************/ |
|---|
| 374 | typedef bool (* BDMA_LockCallbackFunc)( void * pvParm1, int iParm2 ); |
|---|
| 375 | |
|---|
| 376 | /*************************************************************************** |
|---|
| 377 | Summary: |
|---|
| 378 | This function opens and initializes the DMA module BDMA. |
|---|
| 379 | |
|---|
| 380 | Description: |
|---|
| 381 | Before any thing could be done to a DMA engine in the chip, a DMA module |
|---|
| 382 | handle, BDMA_Handle, must be opened. From this handle, the sub-module |
|---|
| 383 | handle of memory DMA engine and/or PCI DMA engine could be created. |
|---|
| 384 | |
|---|
| 385 | It is user's responsibility to ensure that there is only one BDMA module |
|---|
| 386 | handle opened per chip. |
|---|
| 387 | |
|---|
| 388 | This BDMA module handle should eventually be closed by calling BDMA_Close, |
|---|
| 389 | when it is no longer needed. |
|---|
| 390 | |
|---|
| 391 | Input: |
|---|
| 392 | hChip - The chip handle that application created earlier during chip |
|---|
| 393 | initialization sequence. This handle is used for getting chip |
|---|
| 394 | information, chip revision, and miscellaneous chip configurations. |
|---|
| 395 | |
|---|
| 396 | hRegister - The register handle that application created earlier during |
|---|
| 397 | chip initialization sequence. This handle is used to access chip |
|---|
| 398 | registers (DMA registers). |
|---|
| 399 | |
|---|
| 400 | hMemory - The local memory manager module handle. DMA descriptors |
|---|
| 401 | are allocated in local memory with hMemory. |
|---|
| 402 | |
|---|
| 403 | hInterrupt - The level2 interrupt handle that application created |
|---|
| 404 | earlier chip initialization sequence. This handle is use to install |
|---|
| 405 | level 2 interrupt callback. |
|---|
| 406 | |
|---|
| 407 | Output: |
|---|
| 408 | phDma - The opened DMA module handle. |
|---|
| 409 | |
|---|
| 410 | Returns: |
|---|
| 411 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 412 | BERR_SUCCESS - Successfully opened BDMA. |
|---|
| 413 | |
|---|
| 414 | See Also: |
|---|
| 415 | BDMA_Close |
|---|
| 416 | BDMA_Mem_Create2 |
|---|
| 417 | BDMA_Pci_Create2 |
|---|
| 418 | **************************************************************************/ |
|---|
| 419 | BERR_Code BDMA_Open( |
|---|
| 420 | BDMA_Handle * phDma, |
|---|
| 421 | BCHP_Handle hChip, |
|---|
| 422 | BREG_Handle hRegister, |
|---|
| 423 | BMEM_Handle hMemory, |
|---|
| 424 | BINT_Handle hInterrupt ); |
|---|
| 425 | |
|---|
| 426 | /*************************************************************************** |
|---|
| 427 | Summary: |
|---|
| 428 | Close the BDMA handle. |
|---|
| 429 | |
|---|
| 430 | Description: |
|---|
| 431 | Once this function is called the BDMA handle can no longer be used. |
|---|
| 432 | |
|---|
| 433 | All DMA sub-module handles should be destroyed before closing the BDMA |
|---|
| 434 | module handle by BDMA_Close. |
|---|
| 435 | |
|---|
| 436 | Input: |
|---|
| 437 | hDma - The BDMA handle to be closed. |
|---|
| 438 | |
|---|
| 439 | Output: |
|---|
| 440 | |
|---|
| 441 | Returns: |
|---|
| 442 | BERR_INVALID_PARAMETER - hDma is not a valid BDMA handle. |
|---|
| 443 | BERR_SUBMODULE_EXIST - There is still DMA sub-module handle not destroyed. |
|---|
| 444 | BERR_SUCCESS - Successfully destroyed. |
|---|
| 445 | |
|---|
| 446 | See Also: |
|---|
| 447 | BDMA_Open |
|---|
| 448 | BDMA_Mem_Destroy |
|---|
| 449 | BDMA_Pci_Destroy |
|---|
| 450 | **************************************************************************/ |
|---|
| 451 | BERR_Code BDMA_Close( |
|---|
| 452 | BDMA_Handle hDma ); |
|---|
| 453 | |
|---|
| 454 | |
|---|
| 455 | /*************************************************************************** |
|---|
| 456 | * Sub-Module: Memory DMA |
|---|
| 457 | **************************************************************************/ |
|---|
| 458 | |
|---|
| 459 | /*************************************************************************** |
|---|
| 460 | Summary: |
|---|
| 461 | Memory DMA engine sub-module handle, or Memory DMA handle for simplicity. |
|---|
| 462 | |
|---|
| 463 | Description: |
|---|
| 464 | This is an opaque handle that represents and controls one HW memory DMA |
|---|
| 465 | engine. It is needed when the memory DMA engine is configured or used. |
|---|
| 466 | |
|---|
| 467 | It is created with BDMA_Mem_Create2. |
|---|
| 468 | |
|---|
| 469 | The typical process to configure and use a memory DMA engine is as |
|---|
| 470 | follows: |
|---|
| 471 | |
|---|
| 472 | o Open the DMA module handle. |
|---|
| 473 | o A sub-module handle to the memory DMA engine is created. |
|---|
| 474 | o Configure memory DMA engine (sub-module), such as swapping mode, |
|---|
| 475 | and crypto setting. |
|---|
| 476 | o Call BDMA_Mem_Tran_Create2 to create a memory DMA transfer handle. |
|---|
| 477 | o Set the block info (such as source address, destination address, and |
|---|
| 478 | block size) for each data block to be transferred by calling |
|---|
| 479 | BDMA_Mem_Tran_SetDmaBlockInfo. |
|---|
| 480 | o Start the transfer by BDMA_Mem_Tran_StartDma, or |
|---|
| 481 | BDMA_Mem_Tran_StartDmaAndCallBack. |
|---|
| 482 | o Process the "DMA done" information. Depending on which starting API |
|---|
| 483 | function was called above, BDMA_Mem_Tran_StartDma or |
|---|
| 484 | BDMA_Mem_Tran_StartDmaAndCallBack, the "DMA done" information could |
|---|
| 485 | either be acquired by actively calling BDMA_Mem_Tran_GetStatus or |
|---|
| 486 | be informated by a call back from BDMA. |
|---|
| 487 | |
|---|
| 488 | There is one engine configure API function BDMA_Mem_SetByteSwapMode for |
|---|
| 489 | memory DMA sub-module, and one transfer configure API function |
|---|
| 490 | BDMA_Mem_Tran_SetCrypto for memory DMA transfer sub-module. The sub- |
|---|
| 491 | modules maintain a current state of configure. Each setting modifies the |
|---|
| 492 | current state and is applied to the future calls to |
|---|
| 493 | BDMA_Mem_Tran_SetDmaBlockInfo. This implies that in a transfer each block |
|---|
| 494 | could have different engine configure. |
|---|
| 495 | |
|---|
| 496 | We put current state of crypto setting into transfer, because it is |
|---|
| 497 | more likely to change from transfer to transfer, but swap mode is not. |
|---|
| 498 | |
|---|
| 499 | After the engine is configured, user could also perform a DMA transfer |
|---|
| 500 | in an interrupt handler or critical session, using the API function set |
|---|
| 501 | named with a "_isr" suffix. |
|---|
| 502 | |
|---|
| 503 | When a DMA engine sub-module handle is no longer needed, it should be |
|---|
| 504 | destroyed with BDMA_Mem_Destroy. |
|---|
| 505 | |
|---|
| 506 | Please refer to the DMA module overview for more usage info. |
|---|
| 507 | |
|---|
| 508 | See Also: |
|---|
| 509 | BDMA, BDMA_Handle |
|---|
| 510 | BDMA_Mem_Create2, BDMA_Mem_Destroy |
|---|
| 511 | BDMA_Mem_SetByteSwapMode, BDMA_Mem_Tran_SetCrypto |
|---|
| 512 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 513 | BDMA_Mem_Tran_StartDma, BDMA_Mem_Tran_StartDmaAndCallBack |
|---|
| 514 | BDMA_Mem_Tran_GetStatus |
|---|
| 515 | BDMA_Mem_Tran_Reset, BDMA_Mem_Tran_Destroy |
|---|
| 516 | BDMA_Mem_Tran_Create2_isr, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 517 | BDMA_Mem_Tran_StartDmaAndCallBack_isr |
|---|
| 518 | BDMA_Mem_Tran_GetStatus_isr |
|---|
| 519 | BDMA_Mem_Tran_Reset_isr, BDMA_Mem_Tran_Destroy_isr |
|---|
| 520 | ***************************************************************************/ |
|---|
| 521 | typedef struct BDMA_P_Mem_Context *BDMA_Mem_Handle; |
|---|
| 522 | |
|---|
| 523 | /*************************************************************************** |
|---|
| 524 | Summary: |
|---|
| 525 | This enumeration represents memory dma engines. |
|---|
| 526 | |
|---|
| 527 | Description: |
|---|
| 528 | BDMA_MemDmaEngine is an enumeration which represents all HW memory dma |
|---|
| 529 | engines there exist in the chip. It is used to indicate which HW engine |
|---|
| 530 | to use when a memory dma handle is created by BDMA_Mem_Create2. |
|---|
| 531 | |
|---|
| 532 | See Also: |
|---|
| 533 | BDMA_Mem_Create2 |
|---|
| 534 | ***************************************************************************/ |
|---|
| 535 | typedef enum BDMA_MemDmaEngine |
|---|
| 536 | { |
|---|
| 537 | BDMA_MemDmaEngine_e0, /* mem dma engine 0 */ |
|---|
| 538 | BDMA_MemDmaEngine_e1, /* mem dma engine 1 */ |
|---|
| 539 | BDMA_MemDmaEngine_eUnknown |
|---|
| 540 | } |
|---|
| 541 | BDMA_MemDmaEngine; |
|---|
| 542 | |
|---|
| 543 | /*************************************************************************** |
|---|
| 544 | Summary: |
|---|
| 545 | This enumeration represents crypto mode. |
|---|
| 546 | |
|---|
| 547 | Description: |
|---|
| 548 | When memory DMA engine is transfering a block of data, it could be |
|---|
| 549 | programmed to perform encryption and decryption. BDMA_CryptMode |
|---|
| 550 | represents all crypto modes supported during a DMA transfer. |
|---|
| 551 | |
|---|
| 552 | See Also: |
|---|
| 553 | BDMA_Mem_Tran_SetCrypto |
|---|
| 554 | ***************************************************************************/ |
|---|
| 555 | typedef enum BDMA_CryptMode |
|---|
| 556 | { |
|---|
| 557 | BDMA_CryptMode_eNoCrypt, /* default, crypto HW disabled */ |
|---|
| 558 | BDMA_CryptMode_eBlock, /* always encrypt/decrypt 16 block */ |
|---|
| 559 | BDMA_CryptMode_eMpeg, /* recognize mpeg transport packet */ |
|---|
| 560 | BDMA_CryptMode_eDirecTv, /* recognize DirecTv transport packet */ |
|---|
| 561 | BDMA_CryptMode_eInvalid |
|---|
| 562 | } |
|---|
| 563 | BDMA_CryptMode; |
|---|
| 564 | |
|---|
| 565 | /*************************************************************************** |
|---|
| 566 | Summary: |
|---|
| 567 | This structure describes the settings for BDMA_Mem_Handle |
|---|
| 568 | |
|---|
| 569 | Description: |
|---|
| 570 | BDMA_Mem_Settings is a structure that is used to describe the public |
|---|
| 571 | settings of a memory dma engine. The settings are in engine scope. |
|---|
| 572 | |
|---|
| 573 | ulTotalNumBlocks - The maximum number of blocks could be supported |
|---|
| 574 | by this dma engine in total. Its default value is 256. |
|---|
| 575 | |
|---|
| 576 | ulMaxNumBlocksPerTran - The maxium number of blocks per transfer. Its |
|---|
| 577 | default value is 128. |
|---|
| 578 | |
|---|
| 579 | bSupportCallBack - When multiple BDMA instance exist in the system, |
|---|
| 580 | only one instance can support call-back mode. bSupportCallBack indicates |
|---|
| 581 | whether this BDMA instance is the unique one that can support call-back |
|---|
| 582 | mode. Its default value is true. |
|---|
| 583 | |
|---|
| 584 | pTryLock - User provided call back function that is called to lock the |
|---|
| 585 | hardware memory dma engine from accessing by other BDMA instances. Its |
|---|
| 586 | default value is NULL. |
|---|
| 587 | |
|---|
| 588 | pReleaseLock - User provided call back function that is called to release |
|---|
| 589 | the lock so that the hardware memory dma engine could be accessed by |
|---|
| 590 | other BDMA instances. Its default value is NULL. |
|---|
| 591 | |
|---|
| 592 | pvParm1 - Pointer to a user defined struct. It is passed to (*pTryLock) |
|---|
| 593 | and (*pReleaseLock) as a parameter. Its default value is NULL. |
|---|
| 594 | |
|---|
| 595 | iParm2 - Second user parameter for the lock call-back functions. It is |
|---|
| 596 | passed to (*pTryLock)and (*pReleaseLock) as a parameter. Its default value |
|---|
| 597 | is 0. |
|---|
| 598 | |
|---|
| 599 | If there is only one BDMA instance in the system, bSupportCallBack, |
|---|
| 600 | pTryLock, pReleaseLock, pvParm1, iParm2 should be left with default value. |
|---|
| 601 | |
|---|
| 602 | See Also: |
|---|
| 603 | BDMA_Mem_Create2, BDMA_Mem_GetDefaultSettings |
|---|
| 604 | ***************************************************************************/ |
|---|
| 605 | typedef struct BDMA_Mem_Settings |
|---|
| 606 | { |
|---|
| 607 | uint32_t ulTotalNumBlocks; |
|---|
| 608 | uint32_t ulMaxNumBlocksPerTran; |
|---|
| 609 | |
|---|
| 610 | /* settings for the case of multiple BDMA instances */ |
|---|
| 611 | BDMA_LockCallbackFunc pTryLock_isr; |
|---|
| 612 | BDMA_LockCallbackFunc pReleaseLock_isr; |
|---|
| 613 | void * pvParm1; |
|---|
| 614 | int iParm2; |
|---|
| 615 | bool bSupportCallBack; |
|---|
| 616 | } |
|---|
| 617 | BDMA_Mem_Settings; |
|---|
| 618 | |
|---|
| 619 | /*************************************************************************** |
|---|
| 620 | Summary: |
|---|
| 621 | Creates a sub-module handle to memory DMA engine. |
|---|
| 622 | |
|---|
| 623 | Description: |
|---|
| 624 | This API function is used to create a BDMA_Mem_Handle to represent and |
|---|
| 625 | control a specific HW memory dma engine. It is required by memory DMA < |
|---|
| 626 | sub-module functions in order to configure the DMA engine and perform |
|---|
| 627 | DMA transfer. |
|---|
| 628 | |
|---|
| 629 | If the sub-module handle has already been created for the same HW engine |
|---|
| 630 | with the same BDMA, error is returned. This function also initializes |
|---|
| 631 | the sub-module to default configure. |
|---|
| 632 | |
|---|
| 633 | Before BDMA_Mem_Create2 is called, BDMA_Mem's inherent default setting |
|---|
| 634 | structure should be queried by BDMA_Mem_GetDefaultSettings, modified and |
|---|
| 635 | then passed to BDMA_Mem_Create2. This avoid compatibilty problem if more |
|---|
| 636 | elements are added into BDMA_Mem_Settings in the future, and save |
|---|
| 637 | application tedious work of filling in the configuration structure. |
|---|
| 638 | |
|---|
| 639 | Refer to BDMA_Mem_Handle description for detailed usage info. |
|---|
| 640 | |
|---|
| 641 | Input: |
|---|
| 642 | hDma - Handle to the BDMA module. |
|---|
| 643 | eEngine - The HW memory dma engine controlled by this BDMA_Mem_Handle |
|---|
| 644 | pSettings - The basic settings. Defaut setting is used if pSettings is |
|---|
| 645 | NULL. |
|---|
| 646 | |
|---|
| 647 | Output: |
|---|
| 648 | phMemDma - The created memory DMA sub-module handle. If failure |
|---|
| 649 | occurred phMemDma will holds NULL. |
|---|
| 650 | |
|---|
| 651 | Returns: |
|---|
| 652 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 653 | BERR_SUCCESS - Successfully created the handle. |
|---|
| 654 | |
|---|
| 655 | See Also: |
|---|
| 656 | BDMA_Mem_Destroy, BDMA_Mem_GetDefaultSettings |
|---|
| 657 | **************************************************************************/ |
|---|
| 658 | BERR_Code BDMA_Mem_Create2( |
|---|
| 659 | BDMA_Handle hDma, |
|---|
| 660 | BDMA_MemDmaEngine eEngine, |
|---|
| 661 | BDMA_Mem_Settings * pSettings, |
|---|
| 662 | BDMA_Mem_Handle * phMemDma ); |
|---|
| 663 | |
|---|
| 664 | /*************************************************************************** |
|---|
| 665 | Summary: |
|---|
| 666 | Destroys the sub-module handle of the memory DMA engine. |
|---|
| 667 | |
|---|
| 668 | Description: |
|---|
| 669 | Once this function is called the sub-module handle can no longer be |
|---|
| 670 | used. |
|---|
| 671 | |
|---|
| 672 | Memory DMA engine sub-module handle should be destroyed before closing |
|---|
| 673 | the main module handle BDMA_Handle by BDMA_Close. |
|---|
| 674 | |
|---|
| 675 | Input: |
|---|
| 676 | hMemDma - The memory DMA engine sub-module handle to destroy. |
|---|
| 677 | |
|---|
| 678 | Output: |
|---|
| 679 | |
|---|
| 680 | Returns: |
|---|
| 681 | BERR_INVALID_PARAMETER - hMemDma is not a valid memory DMA engine |
|---|
| 682 | sub-module handle. |
|---|
| 683 | BERR_SUCCESS - Successfully destroyed |
|---|
| 684 | |
|---|
| 685 | See Also: |
|---|
| 686 | BDMA_Mem_Create2 |
|---|
| 687 | **************************************************************************/ |
|---|
| 688 | BERR_Code BDMA_Mem_Destroy( |
|---|
| 689 | BDMA_Mem_Handle hMemDma ); |
|---|
| 690 | |
|---|
| 691 | /*************************************************************************** |
|---|
| 692 | Summary: |
|---|
| 693 | This function gets BDMA_Mem's inherent default setting structure. |
|---|
| 694 | |
|---|
| 695 | Description: |
|---|
| 696 | BDMA_Mem's inherent default setting structure could be queried by this |
|---|
| 697 | API function prior to BDMA_Mem_Create2, modified and then passed to |
|---|
| 698 | BDMA_Mem_Create2. This avoid compatibilty problem if more elements are |
|---|
| 699 | added into BDMA_Mem_Settings in the future, and save application tedious |
|---|
| 700 | work of filling in the configuration structure. |
|---|
| 701 | |
|---|
| 702 | It extremely inportant that pDefSettings has been assigned to a valid |
|---|
| 703 | struct buffer address by user before this function is called. |
|---|
| 704 | |
|---|
| 705 | Input: |
|---|
| 706 | <None> |
|---|
| 707 | |
|---|
| 708 | Output: |
|---|
| 709 | pDefSettings - A copy of default settings structure. |
|---|
| 710 | |
|---|
| 711 | Returns: |
|---|
| 712 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 713 | BERR_SUCCESS - Successfully get VDC default settings. |
|---|
| 714 | |
|---|
| 715 | See Also: |
|---|
| 716 | BDMA_Mem_Create2. |
|---|
| 717 | **************************************************************************/ |
|---|
| 718 | BERR_Code BDMA_Mem_GetDefaultSettings |
|---|
| 719 | ( BDMA_Mem_Settings *pDefSettings ); |
|---|
| 720 | |
|---|
| 721 | /*************************************************************************** |
|---|
| 722 | Summary: |
|---|
| 723 | Set the data endian and swap mode. |
|---|
| 724 | |
|---|
| 725 | Description: |
|---|
| 726 | When memory DMA engine is transferring a block of data, it reads data |
|---|
| 727 | from and writes data into memory according to data endian. And right |
|---|
| 728 | before the writing operation, data could be applied either byte aligned |
|---|
| 729 | swap or short aligned swap inside a 32 bits word. This function sets |
|---|
| 730 | the data endian and the swap mode. |
|---|
| 731 | |
|---|
| 732 | The data endian affects which bytes to pick in a 32 bits word when a |
|---|
| 733 | non-word-aligned source address is used, and determines the order of |
|---|
| 734 | bytes in a word to send to the byte stream for further operation such |
|---|
| 735 | as encrypt, and the order of bytes in a word to store into memory. |
|---|
| 736 | |
|---|
| 737 | The sub-module maintains a current state of read endian and swap mode. |
|---|
| 738 | Each setting modifies the current state and is applied to the future |
|---|
| 739 | calls to BDMA_Mem_Tran_SetDmaBlockInfo(_isr), unless it is reset again. |
|---|
| 740 | This implies that in a transfer each block could have different read |
|---|
| 741 | endian and swap mode. |
|---|
| 742 | |
|---|
| 743 | Input: |
|---|
| 744 | hMemDma - Sub-module handle to the memory DMA engine to modify. |
|---|
| 745 | eDataEndian - Data endian (little or big endian) format in memory. |
|---|
| 746 | eSwapMode - Swap mode enum |
|---|
| 747 | |
|---|
| 748 | Output: |
|---|
| 749 | |
|---|
| 750 | Returns: |
|---|
| 751 | BERR_SUCCESS - Swap mode is set successfully. |
|---|
| 752 | BERR_INVALID_PARAMETER - One of the input parameters was invalid. |
|---|
| 753 | |
|---|
| 754 | See Also: |
|---|
| 755 | BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 756 | ****************************************************************************/ |
|---|
| 757 | BERR_Code BDMA_Mem_SetByteSwapMode( |
|---|
| 758 | BDMA_Mem_Handle hMemDma, |
|---|
| 759 | BDMA_Endian eDataEndian, |
|---|
| 760 | BDMA_SwapMode eSwapMode ); |
|---|
| 761 | |
|---|
| 762 | |
|---|
| 763 | /*************************************************************************** |
|---|
| 764 | * Sub-Module: Transfer of Memory DMA |
|---|
| 765 | **************************************************************************/ |
|---|
| 766 | |
|---|
| 767 | /*************************************************************************** |
|---|
| 768 | Summary: |
|---|
| 769 | Memory DMA Transfer sub-module handle. |
|---|
| 770 | |
|---|
| 771 | Description: |
|---|
| 772 | A memory DMA transfer is a sub-module of the Memory DMA engine (again a |
|---|
| 773 | sub-module of BDMA). BDMA_Mem_Tran_Handle is an opaque handle that holds |
|---|
| 774 | the context for a memory DMA transfer. It is created by |
|---|
| 775 | BDMA_Mem_Tran_Create2. |
|---|
| 776 | |
|---|
| 777 | To perform a transfer with the memory DMA engine (sub-module), a memory |
|---|
| 778 | DMA transfer handle must be created first, then the transfer handle could |
|---|
| 779 | be used to set block info, to start, and to get the status. |
|---|
| 780 | |
|---|
| 781 | A transfer typically requests to dma a list of contiguous blocks. Each |
|---|
| 782 | contiguous block is represented by a dma descriptor for hardware. The |
|---|
| 783 | transfer is then described by a list of linked dma descriptors. When |
|---|
| 784 | "block info" is set for a block, it is set to the corresponding dma |
|---|
| 785 | descriptor. |
|---|
| 786 | |
|---|
| 787 | A transfer handle could be reused after it is started and finished. It is |
|---|
| 788 | solely user's responsibility to ensure that each block has the right |
|---|
| 789 | addresses, swap mode and crypto setting. |
|---|
| 790 | |
|---|
| 791 | A transfer handle has to be explicitly destroyed when it is no longer |
|---|
| 792 | needed. Otherwise the max limit of the number of active transfer blocks |
|---|
| 793 | would be easily reached, that means new transfer creation would fail. |
|---|
| 794 | |
|---|
| 795 | Please refer to BDMA_Mem_Handle description and the DMA module overview |
|---|
| 796 | for more usage info. |
|---|
| 797 | |
|---|
| 798 | See Also: |
|---|
| 799 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 800 | BDMA_Mem_Tran_StartDma, BDMA_Mem_Tran_StartDmaAndCallBack |
|---|
| 801 | BDMA_Mem_Tran_GetStatus |
|---|
| 802 | BDMA_Mem_Tran_Destroy, BDMA_Mem_Tran_Reset |
|---|
| 803 | BDMA_Mem_Tran_Create2_isr, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 804 | BDMA_Mem_Tran_StartDmaAndCallBack_isr |
|---|
| 805 | BDMA_Mem_Tran_GetStatus_isr |
|---|
| 806 | BDMA_Mem_Tran_Destroy_isr, BDMA_Mem_Tran_Reset_isr |
|---|
| 807 | BDMA_Mem_Handle, BDMA |
|---|
| 808 | ***************************************************************************/ |
|---|
| 809 | typedef struct BDMA_P_Mem_TranContext *BDMA_Mem_Tran_Handle; |
|---|
| 810 | |
|---|
| 811 | /*************************************************************************** |
|---|
| 812 | Summary: |
|---|
| 813 | Function pointer type of user DMA interrupt call back function. |
|---|
| 814 | |
|---|
| 815 | Description: |
|---|
| 816 | The call back function is coded by the user, is passed to BDMA when a |
|---|
| 817 | Tran is started with BDMA_Mem_Tran_StartDmaAndCallBack, and is called |
|---|
| 818 | by BDMA after the Tran is completed, in interrupt hanlder mode, to |
|---|
| 819 | process the "dma done info. |
|---|
| 820 | |
|---|
| 821 | It should take three parameters. One is the "user data buffer pointer", |
|---|
| 822 | passed to the transfer starting API function. It is for user to pass |
|---|
| 823 | user defined data structure to the call back function, in order to |
|---|
| 824 | process the "done info". The other two are the transfer handle and |
|---|
| 825 | eStatus, which are provided by the DMA module and are used to specify |
|---|
| 826 | which transfer just finished and the transfer status. |
|---|
| 827 | |
|---|
| 828 | See Also: |
|---|
| 829 | BDMA_Mem_Tran_StartDmaAndCallBack, BDMA_Mem_Tran_StartDmaAndCallBack_isr |
|---|
| 830 | ****************************************************************************/ |
|---|
| 831 | typedef void (* BDMA_Mem_CallbackFunc)( void * pUserCallBackParam,\ |
|---|
| 832 | BDMA_Mem_Tran_Handle hTran, \ |
|---|
| 833 | BDMA_TranStatus eStatus ); |
|---|
| 834 | |
|---|
| 835 | /*************************************************************************** |
|---|
| 836 | Summary: |
|---|
| 837 | Create a transfer handle. |
|---|
| 838 | |
|---|
| 839 | Description: |
|---|
| 840 | This API function is used to create the transfer handle. |
|---|
| 841 | |
|---|
| 842 | BDMA_Mem_Tran_Create2 takes an input parameter ulNumBlocks, to specify |
|---|
| 843 | the max number of contiguous data blocks this transfer is to transfer. |
|---|
| 844 | It should NOT be bigger than ulMaxNumBlocksPerTran in the |
|---|
| 845 | BDMA_Mem_Settings passed to BDMA_Mem_Create2. |
|---|
| 846 | |
|---|
| 847 | A transfer handle could be reused after it is started and finished, and a |
|---|
| 848 | transfer handle has to be explicitly destroyed when it is no longer |
|---|
| 849 | needed. |
|---|
| 850 | |
|---|
| 851 | When a block info is set with BDMA_Mem_Tran_SetDmaBlockInfo, it is written |
|---|
| 852 | into a descriptor in the memory, and the descriptor is later read by HW. |
|---|
| 853 | Either cached address or non-cached address could be used by BDMA when the |
|---|
| 854 | descriptor is written. A true value for bCachedDesc indicates cached |
|---|
| 855 | address should be used. |
|---|
| 856 | |
|---|
| 857 | When cached address is used for the descriptor writting, it will be |
|---|
| 858 | flushed into memory by BDMA_Mem_Tran_StartDmaAndCallBack or |
|---|
| 859 | BDMA_Mem_Tran_StartDma. |
|---|
| 860 | |
|---|
| 861 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 862 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 863 | |
|---|
| 864 | Input: |
|---|
| 865 | hMemDma - Sub-module handle to the memory DMA engine to perform the DMA |
|---|
| 866 | transfer. |
|---|
| 867 | ulNumBlocks - Max number of blocks in this transfer. |
|---|
| 868 | bCachedDesc - Whether use cached address to modify dma descriptor. |
|---|
| 869 | |
|---|
| 870 | Output: |
|---|
| 871 | phTran - The transfer handle created. |
|---|
| 872 | |
|---|
| 873 | Returns: |
|---|
| 874 | BERR_SUCCESS - The transfer handle is created successfully. |
|---|
| 875 | BDMA_ERR_SIZE_OUT_RANGE - ulNumBlocks is 0 or bigger than the allowed. |
|---|
| 876 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 877 | |
|---|
| 878 | See Also: |
|---|
| 879 | BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 880 | BDMA_Mem_Tran_StartDma, BDMA_Mem_Tran_StartDmaAndCallBack |
|---|
| 881 | BDMA_Mem_Tran_GetStatus |
|---|
| 882 | BDMA_Mem_Tran_Destroy, BDMA_Mem_Tran_Reset |
|---|
| 883 | BDMA_Mem_Tran_Create2_isr |
|---|
| 884 | ****************************************************************************/ |
|---|
| 885 | BERR_Code BDMA_Mem_Tran_Create2( |
|---|
| 886 | BDMA_Mem_Handle hMemDma, |
|---|
| 887 | uint32_t ulNumBlocks, |
|---|
| 888 | bool bCachedDesc, |
|---|
| 889 | BDMA_Mem_Tran_Handle * phTran ); |
|---|
| 890 | |
|---|
| 891 | /*************************************************************************** |
|---|
| 892 | Summary: |
|---|
| 893 | Set encryption / decryption. |
|---|
| 894 | |
|---|
| 895 | Description: |
|---|
| 896 | During a DMA data transfer, Memory DMA engines could be configured to |
|---|
| 897 | perform encryption or decryption. This API function is used to set the |
|---|
| 898 | crypto. |
|---|
| 899 | |
|---|
| 900 | In the case that eCryptMode is BDMA_CryptMode_eNoCrypt, the crypto HW |
|---|
| 901 | module is disabled and the setting to ulKeySlot has no effect. |
|---|
| 902 | |
|---|
| 903 | If eCryptMode has other valid value, the crypto HW is enabled and |
|---|
| 904 | eCryptMode specifies how the crypto treats the transport packet |
|---|
| 905 | boundaries (refer to BDMA_CryptMode for detail). |
|---|
| 906 | |
|---|
| 907 | Further, when scatter-gather SCRAM operation is enabled by bSgEnable, the |
|---|
| 908 | dma engine will treat the data stream section of a list of dma blocks as a |
|---|
| 909 | whole for encrypt or decrypt purpose. The stream section starts from the |
|---|
| 910 | beginning of the block marked as scatter-gather start point, and ends at |
|---|
| 911 | the end of the block marked as scatter-gather end point. bSgEnable can not |
|---|
| 912 | change between the scatter-gather start point and end point. |
|---|
| 913 | |
|---|
| 914 | The rest of the crypto configuration, such as what crypto operation |
|---|
| 915 | (either encryption or decryption) to perform, what crypto algorithm and |
|---|
| 916 | what key value to use during crypto operation, was programmed into a key |
|---|
| 917 | slot with the security module. ulKeySlot selects the key slot to use for |
|---|
| 918 | the crypto. |
|---|
| 919 | |
|---|
| 920 | There are 16 key slots in a 7401 chip for the moment. The value (between |
|---|
| 921 | 0 and 15) of ulKeySlot passed to this function must be the same one used |
|---|
| 922 | in the security module when the key slot was programmed. |
|---|
| 923 | |
|---|
| 924 | The sub-module maintains a current state of crypt mode and key selection. |
|---|
| 925 | Each setting modifies the current state and is applied to the future |
|---|
| 926 | calls to BDMA_Mem_Tran_SetDmaBlockInfo(_isr), unless it is reset again. |
|---|
| 927 | This implies that in a transfer each block could use different crypto key. |
|---|
| 928 | |
|---|
| 929 | Application software is responsible to program the selected key slot with |
|---|
| 930 | the security module. If the key slot is not configured well, the dma result |
|---|
| 931 | is undetermined. |
|---|
| 932 | |
|---|
| 933 | Input: |
|---|
| 934 | hTran - The transfer handle to set crypto. |
|---|
| 935 | BDMA_CryptMode - Crypto mode. If it is BDMA_CryptMode_eNoCrypt, crypto is |
|---|
| 936 | disabled. Otherwise it specifies how transport packet boundary is treated. |
|---|
| 937 | ulKeySlot - Key slot (between 0 and 15) selected for the crypto. |
|---|
| 938 | bSgEnable - Enable scatter-gather SCRAM operation. |
|---|
| 939 | |
|---|
| 940 | Output: |
|---|
| 941 | |
|---|
| 942 | Returns: |
|---|
| 943 | BERR_SUCCESS - crypto setting is set successfully. |
|---|
| 944 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 945 | |
|---|
| 946 | See Also: |
|---|
| 947 | BDMA_Mem_Tran_SetCrypto_isr, |
|---|
| 948 | BDMA_Mem_Tran_SetSgStartEnd, BDMA_Mem_Tran_SetSgStartEnd_isr, |
|---|
| 949 | BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 950 | ****************************************************************************/ |
|---|
| 951 | BERR_Code BDMA_Mem_Tran_SetCrypto( |
|---|
| 952 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 953 | BDMA_CryptMode eCryptMode, |
|---|
| 954 | uint32_t ulKeySlot, |
|---|
| 955 | bool bSgEnable); |
|---|
| 956 | |
|---|
| 957 | /*************************************************************************** |
|---|
| 958 | Summary: |
|---|
| 959 | Set the block info for one block of a DMA transfer. |
|---|
| 960 | |
|---|
| 961 | Description: |
|---|
| 962 | Before a dma transfer can be started, block info has to be set for the |
|---|
| 963 | blocks with block index from 0 to (ulNumActBlocks - 1) (ulNumActBlocks |
|---|
| 964 | is the the number of currently active blocks, passed as a parameter of |
|---|
| 965 | BDMA_Mem_Tran_StartDma or BDMA_Mem_Tran_StartDmaAndCallBack). This API |
|---|
| 966 | function is used to set block info into HW dma descriptor for one block. |
|---|
| 967 | |
|---|
| 968 | ulBlockId is the index of the block, in the block list of the transfer |
|---|
| 969 | represented by hTran. It starts from 0. |
|---|
| 970 | |
|---|
| 971 | The source and destination address are in memory bus address space. They |
|---|
| 972 | are 28 bits unsigned integer number in 7401 chip. It is more likely that |
|---|
| 973 | they are converted from virtual memory mapped address using |
|---|
| 974 | BMEM_ConvertAddressToOffset and the virtual address is returned by |
|---|
| 975 | BMEM_AllocAligned or BMEM_Alloc. |
|---|
| 976 | |
|---|
| 977 | Both addresses and block size are byte aligned. Max block size is |
|---|
| 978 | 0xfff,ffff (16 MByte). Source and destination region overlap with |
|---|
| 979 | (ulSrcBusAddr < ulDstBusAddr < ulSrcBusAddr+ulBlockSize) is not allowed. |
|---|
| 980 | |
|---|
| 981 | Encryption and decryption algorithms typically work on memory size of |
|---|
| 982 | multiple 8 bytes or 16 bytes, and certain residue mode, such as residue |
|---|
| 983 | clear termination or OFB, might be used for the remaining bytes in the |
|---|
| 984 | block. |
|---|
| 985 | |
|---|
| 986 | Please notice that when a non-word-aligned source address is used, the |
|---|
| 987 | read endian determine which bytes to read in a 32 bits word. |
|---|
| 988 | |
|---|
| 989 | The current state of read endian, swap mode maintained in the dma engine, |
|---|
| 990 | and the current state of crypto setting maintained in hTran, are used |
|---|
| 991 | during the transfer of this block. |
|---|
| 992 | |
|---|
| 993 | If the Tran is re-used, and there is no change to this block info ( |
|---|
| 994 | including the state of read endian ...), there is no need to set info |
|---|
| 995 | for this block again. However, user should pay extra attention to correct |
|---|
| 996 | the previous setting to scatter-gather start/stop points for each active |
|---|
| 997 | block, unless BDMA_Mem_Tran_Reset/_isr has been used to set them into |
|---|
| 998 | default values. |
|---|
| 999 | |
|---|
| 1000 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 1001 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 1002 | |
|---|
| 1003 | Input: |
|---|
| 1004 | hTran - The transfer handle to set block info. |
|---|
| 1005 | ulBlockId - The block index in the block list of this transfer, it starts |
|---|
| 1006 | from 0. |
|---|
| 1007 | ulDstBusAddr - Destination address in memory bus address space. |
|---|
| 1008 | ulSrcBusAddr - Source address in memory bus address space. |
|---|
| 1009 | ulBlockSize - This block size in bytes. |
|---|
| 1010 | bCryptInit - Whether initialize the encryption / decryption or continue |
|---|
| 1011 | the encryption / decryption from previous block. |
|---|
| 1012 | |
|---|
| 1013 | Output: |
|---|
| 1014 | |
|---|
| 1015 | Returns: |
|---|
| 1016 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 1017 | BDMA_ERR_OVERLAP - Source and destination region overlap. |
|---|
| 1018 | BDMA_ERR_SIZE_OUT_RANGE - ulBlockSize is bigger than 16 MByte. |
|---|
| 1019 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1020 | |
|---|
| 1021 | See Also: |
|---|
| 1022 | BDMA_Mem_Tran_Create2 |
|---|
| 1023 | BDMA_Mem_Tran_StartDma, BDMA_Mem_Tran_StartDmaAndCallBack |
|---|
| 1024 | BDMA_Mem_SetByteSwapMode, BDMA_Mem_Tran_SetCrypto |
|---|
| 1025 | BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 1026 | ****************************************************************************/ |
|---|
| 1027 | BERR_Code BDMA_Mem_Tran_SetDmaBlockInfo( |
|---|
| 1028 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1029 | uint32_t ulBlockId, |
|---|
| 1030 | uint32_t ulDstBusAddr, |
|---|
| 1031 | uint32_t ulSrcBusAddr, |
|---|
| 1032 | uint32_t ulBlockSize, |
|---|
| 1033 | bool bCryptInit ); |
|---|
| 1034 | |
|---|
| 1035 | /*************************************************************************** |
|---|
| 1036 | Summary: |
|---|
| 1037 | Mark one block as the start point and/or end point of scatter-gather. |
|---|
| 1038 | |
|---|
| 1039 | Description: |
|---|
| 1040 | When crypto and scatter-gather SCRAM operation are enabled, the dma engine |
|---|
| 1041 | will treat the data stream section of a list of dma blocks as a whole for |
|---|
| 1042 | encrypt or decrypt purpose. The stream section starts from the beginning |
|---|
| 1043 | of the block marked as scatter-gather start point, and ends at the end of |
|---|
| 1044 | the block marked as scatter-gather end point. |
|---|
| 1045 | |
|---|
| 1046 | This API function is used to mark the block with ID of ulBlockId as scatter- |
|---|
| 1047 | gather start and/or end point. |
|---|
| 1048 | |
|---|
| 1049 | Input: |
|---|
| 1050 | hTran - The transfer handle to set block info. |
|---|
| 1051 | ulBlockId - The block index in the block list of this transfer, it starts |
|---|
| 1052 | from 0. |
|---|
| 1053 | bStartSgScram - mark this block as scatter-gather start point. |
|---|
| 1054 | bEndSgScram - mark this block as scatter-gather end point. |
|---|
| 1055 | |
|---|
| 1056 | Output: |
|---|
| 1057 | |
|---|
| 1058 | Returns: |
|---|
| 1059 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 1060 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1061 | |
|---|
| 1062 | See Also: |
|---|
| 1063 | BDMA_Mem_Tran_SetCrypto, BDMA_Mem_Tran_SetDmaBlockInfo, |
|---|
| 1064 | BDMA_Mem_Tran_SetSgStartEnd_isr |
|---|
| 1065 | ****************************************************************************/ |
|---|
| 1066 | BERR_Code BDMA_Mem_Tran_SetSgStartEnd( |
|---|
| 1067 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1068 | uint32_t ulBlockId, |
|---|
| 1069 | bool bStartSgScram, |
|---|
| 1070 | bool bEndSgScram ); |
|---|
| 1071 | |
|---|
| 1072 | /*************************************************************************** |
|---|
| 1073 | Summary: |
|---|
| 1074 | Start a DMA transfer. |
|---|
| 1075 | |
|---|
| 1076 | Description: |
|---|
| 1077 | This API function is used to start a DMA transfer. |
|---|
| 1078 | |
|---|
| 1079 | BDMA_Mem_Tran_StartDma takes, as an input parameter, hTran to specify the |
|---|
| 1080 | transfer to start. |
|---|
| 1081 | |
|---|
| 1082 | As starting a transfer with this API function, user needs to implement a |
|---|
| 1083 | status checking and sleeping loop, to wait for the completion of the |
|---|
| 1084 | DMA transfer, and then to process the "done" info. |
|---|
| 1085 | |
|---|
| 1086 | Before a dma transfer can be started, block info has to be set with |
|---|
| 1087 | BDMA_Mem_Tran_SetDmaBlockInfo for all blocks with block index from 0 to |
|---|
| 1088 | (ulNumActBlocks - 1). ulNumActBlocks should be bigger than 0, and less |
|---|
| 1089 | than or equal to ulNumBlocks passed to BDMA_Mem_Tran_Create2. |
|---|
| 1090 | |
|---|
| 1091 | If this Tran is reused, user should pay extra attention to correct the |
|---|
| 1092 | the previous setting to scatter-gather start/stop points for each active |
|---|
| 1093 | block, unless BDMA_Mem_Tran_Reset/_isr has been used to set them into |
|---|
| 1094 | default values. |
|---|
| 1095 | |
|---|
| 1096 | when the dma hardware engine is shared by multiple BDMA instances, the |
|---|
| 1097 | transfer might be queued into software until the hardware is no longer in |
|---|
| 1098 | use by another BDMA instance. User provided lock call back functions are |
|---|
| 1099 | used to ensure atomic access to the hardware dma engine. |
|---|
| 1100 | |
|---|
| 1101 | If cached address is used for the descriptor writting, it will be |
|---|
| 1102 | flushed into memory inside BDMA_Mem_Tran_StartDma. |
|---|
| 1103 | |
|---|
| 1104 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 1105 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 1106 | |
|---|
| 1107 | Input: |
|---|
| 1108 | hTran - The transfer handle to start. |
|---|
| 1109 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 1110 | dma transfered with this start call. |
|---|
| 1111 | |
|---|
| 1112 | Output: |
|---|
| 1113 | |
|---|
| 1114 | Returns: |
|---|
| 1115 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 1116 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1117 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 1118 | BDMA_ERR_ENGINE_BUSY - The engine is busy. |
|---|
| 1119 | |
|---|
| 1120 | See Also: |
|---|
| 1121 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_SetDmaBlockInfo, |
|---|
| 1122 | BDMA_Mem_Tran_GetStatus, |
|---|
| 1123 | BDMA_LockCallbackFunc, BDMA_Mem_Settings, |
|---|
| 1124 | BDMA_Mem_Tran_StartDmaAndCallBack |
|---|
| 1125 | ****************************************************************************/ |
|---|
| 1126 | BERR_Code BDMA_Mem_Tran_StartDma( |
|---|
| 1127 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1128 | uint32_t ulNumActBlocks ); |
|---|
| 1129 | |
|---|
| 1130 | /*************************************************************************** |
|---|
| 1131 | Summary: |
|---|
| 1132 | Start a DMA transfer from a specific address. |
|---|
| 1133 | |
|---|
| 1134 | Description: |
|---|
| 1135 | This API function is used to start a DMA transfer from some address.Refer |
|---|
| 1136 | to BDMA_Mem_Tran_StartDma for more details. |
|---|
| 1137 | |
|---|
| 1138 | Input: |
|---|
| 1139 | hTran - The transfer handle to start. |
|---|
| 1140 | ulFirstBlock - specific starting address |
|---|
| 1141 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 1142 | dma transfered with this start call. |
|---|
| 1143 | |
|---|
| 1144 | Output: |
|---|
| 1145 | |
|---|
| 1146 | Returns: |
|---|
| 1147 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 1148 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1149 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 1150 | BDMA_ERR_ENGINE_BUSY - The engine is busy. |
|---|
| 1151 | |
|---|
| 1152 | ****************************************************************************/ |
|---|
| 1153 | |
|---|
| 1154 | BERR_Code BDMA_Mem_Tran_StartDmaSubset( |
|---|
| 1155 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1156 | uint32_t ulFirstBlock, |
|---|
| 1157 | uint32_t ulNumActBlocks ); |
|---|
| 1158 | /*************************************************************************** |
|---|
| 1159 | Summary: |
|---|
| 1160 | Start a DMA transfer and register a call back function. |
|---|
| 1161 | |
|---|
| 1162 | Description: |
|---|
| 1163 | This API function is used to start a DMA transfer, and to register a call |
|---|
| 1164 | back function to be called when the transfer finishes. This API function |
|---|
| 1165 | can be used only if "true" is set to bSupportCallBack in the struct |
|---|
| 1166 | BDMA_Mem_Settings passed to BDMA_Mem_Create2, otherwise error is returned. |
|---|
| 1167 | |
|---|
| 1168 | It takes, as input parameters, hTran to specify the transfer to start, |
|---|
| 1169 | a call back function pointer, and a user data buffer pointer. Then the |
|---|
| 1170 | call back function will be called by the "DMA done" interrupt handler |
|---|
| 1171 | of the module, when the transfer finishes. |
|---|
| 1172 | |
|---|
| 1173 | The call back function is ideally coded by the user. It should take three |
|---|
| 1174 | parameters. One is the "user data buffer pointer", passed to this API |
|---|
| 1175 | function. It is for user to pass user defined data structure to the call |
|---|
| 1176 | back function, in order to process the "done info". Another two are |
|---|
| 1177 | transfer handle hTran and eStatus, which are provided by the DMA module |
|---|
| 1178 | and are used to specify which transfer just finished and its status. |
|---|
| 1179 | |
|---|
| 1180 | Before a dma transfer can be started, block info has to be set with |
|---|
| 1181 | BDMA_Mem_Tran_SetDmaBlockInfo for all blocks with block index from 0 to |
|---|
| 1182 | (ulNumActBlocks - 1). ulNumActBlocks should be bigger than 0, and less |
|---|
| 1183 | than or equal to ulNumBlocks passed to BDMA_Mem_Tran_Create2. |
|---|
| 1184 | |
|---|
| 1185 | If this Tran is reused, user should pay extra attention to correct the |
|---|
| 1186 | the previous setting to scatter-gather start/stop points for each active |
|---|
| 1187 | block, unless BDMA_Mem_Tran_Reset/_isr has been used to set them into |
|---|
| 1188 | default values. |
|---|
| 1189 | |
|---|
| 1190 | when the dma hardware engine is shared by multiple BDMA instances, the |
|---|
| 1191 | transfer might be queued into software until the hardware is no longer in |
|---|
| 1192 | use by another BDMA instance. User provided lock call back functions are |
|---|
| 1193 | used to ensure atomic access to the hardware dma engine. |
|---|
| 1194 | |
|---|
| 1195 | If cached address is used for the descriptor writting, it will be |
|---|
| 1196 | flushed into memory inside BDMA_Mem_Tran_StartDmaAndCallBack. |
|---|
| 1197 | |
|---|
| 1198 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 1199 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 1200 | |
|---|
| 1201 | Input: |
|---|
| 1202 | hTran - The transfer handle to start. |
|---|
| 1203 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 1204 | dma transfered with this start call. |
|---|
| 1205 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 1206 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 1207 | |
|---|
| 1208 | Output: |
|---|
| 1209 | |
|---|
| 1210 | Returns: |
|---|
| 1211 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 1212 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 1213 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1214 | |
|---|
| 1215 | See Also: |
|---|
| 1216 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 1217 | BDMA_Mem_Tran_GetStatus |
|---|
| 1218 | BDMA_LockCallbackFunc, BDMA_Mem_Settings, |
|---|
| 1219 | BDMA_Mem_Tran_StartDma |
|---|
| 1220 | BDMA_Mem_Tran_StartDmaAndCallBack_isr |
|---|
| 1221 | ****************************************************************************/ |
|---|
| 1222 | BERR_Code BDMA_Mem_Tran_StartDmaAndCallBack( |
|---|
| 1223 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1224 | uint32_t ulNumActBlocks, |
|---|
| 1225 | BDMA_Mem_CallbackFunc pDoneCallBack_isr, |
|---|
| 1226 | void * pUserCallBackParam ); |
|---|
| 1227 | /*************************************************************************** |
|---|
| 1228 | Summary: |
|---|
| 1229 | Start a DMA transfer and register a call back function. |
|---|
| 1230 | |
|---|
| 1231 | Description: |
|---|
| 1232 | This API function is used to start a DMA transfer |
|---|
| 1233 | |
|---|
| 1234 | Input: |
|---|
| 1235 | hTran - The transfer handle to start. |
|---|
| 1236 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 1237 | dma transfered with this start call. |
|---|
| 1238 | ulFirstBlock - specific starting address |
|---|
| 1239 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 1240 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 1241 | |
|---|
| 1242 | Output: |
|---|
| 1243 | |
|---|
| 1244 | Returns: |
|---|
| 1245 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 1246 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 1247 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1248 | |
|---|
| 1249 | See Also: |
|---|
| 1250 | BDMA_LockCallbackFunc, BDMA_Mem_Settings, |
|---|
| 1251 | BDMA_Mem_Tran_StartDma |
|---|
| 1252 | BDMA_Mem_Tran_StartDmaAndCallBack_isr |
|---|
| 1253 | BDMA_Mem_Tran_StartDmaSubset |
|---|
| 1254 | ****************************************************************************/ |
|---|
| 1255 | BERR_Code BDMA_Mem_Tran_StartDmaSubsetAndCallBack( |
|---|
| 1256 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1257 | uint32_t ulFirstBlock, |
|---|
| 1258 | uint32_t ulNumActBlocks, |
|---|
| 1259 | BDMA_Mem_CallbackFunc pCallBackFunc_isr, |
|---|
| 1260 | void * pUserCallBackParam ); |
|---|
| 1261 | |
|---|
| 1262 | /*************************************************************************** |
|---|
| 1263 | Summary: |
|---|
| 1264 | Query the status of a transfer. |
|---|
| 1265 | |
|---|
| 1266 | Description: |
|---|
| 1267 | In order to perform a DMA transfer, user first creates a transfer handle, |
|---|
| 1268 | then uses it to set each block info, to start the DMA transfer, and |
|---|
| 1269 | finally to get the transfer status. This API function is used to get the |
|---|
| 1270 | status of a DMA transfer. |
|---|
| 1271 | |
|---|
| 1272 | Input: |
|---|
| 1273 | hTran - The transfer handle to query status for. |
|---|
| 1274 | |
|---|
| 1275 | Output: |
|---|
| 1276 | peTranStatus - Transfer status returned. |
|---|
| 1277 | |
|---|
| 1278 | Returns: |
|---|
| 1279 | BERR_SUCCESS - Valid status is returned. |
|---|
| 1280 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1281 | |
|---|
| 1282 | See Also: |
|---|
| 1283 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 1284 | BDMA_Mem_Tran_StartDma, BDMA_Mem_Tran_StartDmaAndCallBack |
|---|
| 1285 | BDMA_Mem_Tran_GetStatus_isr |
|---|
| 1286 | ****************************************************************************/ |
|---|
| 1287 | BERR_Code BDMA_Mem_Tran_GetStatus( |
|---|
| 1288 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1289 | BDMA_TranStatus * peTranStatus ); |
|---|
| 1290 | |
|---|
| 1291 | /*************************************************************************** |
|---|
| 1292 | Summary: |
|---|
| 1293 | Destroy a DMA transfer handle. |
|---|
| 1294 | |
|---|
| 1295 | Description: |
|---|
| 1296 | This API function is used to destroy a no-longer needed DMA transfer |
|---|
| 1297 | handle. It frees the resources occupied by this transfer handle. After |
|---|
| 1298 | a transfer handle is destroyed, it can no-longer be used to set block, |
|---|
| 1299 | to start, or to get transfer status. |
|---|
| 1300 | |
|---|
| 1301 | BDMA_Mem_Tran_Destroy takes, as an input parameter, hTran to specify the |
|---|
| 1302 | transfer handle to destroy. |
|---|
| 1303 | |
|---|
| 1304 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 1305 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 1306 | |
|---|
| 1307 | Input: |
|---|
| 1308 | hTran - The transfer handle to destroy. |
|---|
| 1309 | |
|---|
| 1310 | Output: |
|---|
| 1311 | |
|---|
| 1312 | Returns: |
|---|
| 1313 | BERR_SUCCESS - Transfer handle is destroyed. |
|---|
| 1314 | BERR_INVALID_PARAMETER - The input hTran is invalid. |
|---|
| 1315 | |
|---|
| 1316 | See Also: |
|---|
| 1317 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_Reset, |
|---|
| 1318 | BDMA_Mem_Tran_GetStatus |
|---|
| 1319 | BDMA_Mem_Tran_Destroy_isr |
|---|
| 1320 | ****************************************************************************/ |
|---|
| 1321 | BERR_Code BDMA_Mem_Tran_Destroy( |
|---|
| 1322 | BDMA_Mem_Tran_Handle hTran ); |
|---|
| 1323 | |
|---|
| 1324 | /*************************************************************************** |
|---|
| 1325 | Summary: |
|---|
| 1326 | Reset a DMA transfer handle. |
|---|
| 1327 | |
|---|
| 1328 | Description: |
|---|
| 1329 | This API function is used to reset DMA transfer handle to its initially |
|---|
| 1330 | created state. |
|---|
| 1331 | |
|---|
| 1332 | For an initially created or reset transfer handle, the module ensures |
|---|
| 1333 | that block info is set for each transfered blocks, when it is started. |
|---|
| 1334 | Without resetting, user needs to pay extra attention, to ensure that |
|---|
| 1335 | all un-reset block info have correct addresses and configures. |
|---|
| 1336 | |
|---|
| 1337 | BDMA_Mem_Tran_Reset takes, as an input parameter, hTran to specify the |
|---|
| 1338 | transfer handle to reset. |
|---|
| 1339 | |
|---|
| 1340 | After a transfer handle is reset, its status is reset to |
|---|
| 1341 | BDMA_TranStatus_eCreated. |
|---|
| 1342 | |
|---|
| 1343 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 1344 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 1345 | |
|---|
| 1346 | Input: |
|---|
| 1347 | hTran - The transfer handle to reset. |
|---|
| 1348 | |
|---|
| 1349 | Output: |
|---|
| 1350 | |
|---|
| 1351 | Returns: |
|---|
| 1352 | BERR_SUCCESS - The transfer handle is reset successfully. |
|---|
| 1353 | BERR_INVALID_PARAMETER - The input hTran is invalid. |
|---|
| 1354 | |
|---|
| 1355 | See Also: |
|---|
| 1356 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_Destroy, |
|---|
| 1357 | BDMA_Mem_Tran_GetStatus |
|---|
| 1358 | BDMA_Mem_Tran_Reset_isr |
|---|
| 1359 | ****************************************************************************/ |
|---|
| 1360 | BERR_Code BDMA_Mem_Tran_Reset( |
|---|
| 1361 | BDMA_Mem_Tran_Handle hTran ); |
|---|
| 1362 | |
|---|
| 1363 | /*************************************************************************** |
|---|
| 1364 | Summary: |
|---|
| 1365 | Create a transfer handle. |
|---|
| 1366 | |
|---|
| 1367 | Description: |
|---|
| 1368 | This is the "_isr" version of BDMA_Mem_Tran_Create2. It is used in |
|---|
| 1369 | interrupt handler or critical session. For more description refer to |
|---|
| 1370 | BDMA_Mem_Tran_Create2. |
|---|
| 1371 | |
|---|
| 1372 | Input: |
|---|
| 1373 | hMemDma - Sub-module handle to the memory DMA engine to perform the DMA |
|---|
| 1374 | transfer. |
|---|
| 1375 | ulNumBlocks - Max number of blocks in this transfer. |
|---|
| 1376 | bCachedDesc - Whether use cached address to modify dma descriptor. |
|---|
| 1377 | |
|---|
| 1378 | Output: |
|---|
| 1379 | phTran - The transfer handle created. |
|---|
| 1380 | |
|---|
| 1381 | Returns: |
|---|
| 1382 | BERR_SUCCESS - The transfer handle is created successfully. |
|---|
| 1383 | BDMA_ERR_SIZE_OUT_RANGE - ulNumBlocks is 0 or bigger than the allowed. |
|---|
| 1384 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1385 | |
|---|
| 1386 | See Also: |
|---|
| 1387 | BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 1388 | BDMA_Mem_Tran_StartDmaAndCallBack_isr |
|---|
| 1389 | BDMA_Mem_Tran_GetStatus_isr |
|---|
| 1390 | BDMA_Mem_Tran_Destroy_isr, BDMA_Mem_Tran_Reset_isr |
|---|
| 1391 | BDMA_Mem_Tran_Create2 |
|---|
| 1392 | ****************************************************************************/ |
|---|
| 1393 | BERR_Code BDMA_Mem_Tran_Create2_isr( |
|---|
| 1394 | BDMA_Mem_Handle hMemDma, |
|---|
| 1395 | uint32_t ulNumBlocks, |
|---|
| 1396 | bool bCachedDesc, |
|---|
| 1397 | BDMA_Mem_Tran_Handle * phTran ); |
|---|
| 1398 | |
|---|
| 1399 | /*************************************************************************** |
|---|
| 1400 | Summary: |
|---|
| 1401 | Set encryption / decryption. |
|---|
| 1402 | |
|---|
| 1403 | Description: |
|---|
| 1404 | This is the "_isr" version of BDMA_Mem_Tran_SetCrypto. It is used in |
|---|
| 1405 | interrupt handler or critical session. For more description refer to |
|---|
| 1406 | BDMA_Mem_Tran_SetCrypto. |
|---|
| 1407 | |
|---|
| 1408 | Input: |
|---|
| 1409 | hTran - The transfer handle to set crypto. |
|---|
| 1410 | BDMA_CryptMode - Crypto mode. If it is BDMA_CryptMode_eNoCrypt, crypto is |
|---|
| 1411 | disabled. Otherwise it specifies how transport packet boundary is treated. |
|---|
| 1412 | ulKeySlot - Key slot (between 0 and 15) selected for the crypto. |
|---|
| 1413 | bSgEnable - Enable scatter-gather SCRAM operation. |
|---|
| 1414 | |
|---|
| 1415 | Output: |
|---|
| 1416 | |
|---|
| 1417 | Returns: |
|---|
| 1418 | BERR_SUCCESS - crypto setting is set successfully. |
|---|
| 1419 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1420 | |
|---|
| 1421 | See Also: |
|---|
| 1422 | BDMA_Mem_Tran_SetCrypto, |
|---|
| 1423 | BDMA_Mem_Tran_SetSgStartEnd, BDMA_Mem_Tran_SetSgStartEnd_isr, |
|---|
| 1424 | BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 1425 | ****************************************************************************/ |
|---|
| 1426 | BERR_Code BDMA_Mem_Tran_SetCrypto_isr( |
|---|
| 1427 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1428 | BDMA_CryptMode eCryptMode, |
|---|
| 1429 | uint32_t ulKeySlot, |
|---|
| 1430 | bool bSgEnable); |
|---|
| 1431 | |
|---|
| 1432 | /*************************************************************************** |
|---|
| 1433 | Summary: |
|---|
| 1434 | Set the block info for one block of a DMA transfer. |
|---|
| 1435 | |
|---|
| 1436 | Description: |
|---|
| 1437 | This is the "_isr" version of BDMA_Mem_Tran_SetDmaBlockInfo. It is used in |
|---|
| 1438 | interrupt handler or critical session. For more description refer to |
|---|
| 1439 | BDMA_Mem_Tran_SetDmaBlockInfo. |
|---|
| 1440 | |
|---|
| 1441 | Input: |
|---|
| 1442 | hTran - The transfer handle to set block info. |
|---|
| 1443 | ulBlockId - The block index in the block list of this transfer. |
|---|
| 1444 | ulDstBusAddr - Destination address in memory bus address space. |
|---|
| 1445 | ulSrcBusAddr - Source address in memory bus address space. |
|---|
| 1446 | ulBlockSize - This block size in bytes. |
|---|
| 1447 | bCryptInit - Whether initialize the encryption / decryption or continue |
|---|
| 1448 | the encryption / decryption from previous block. |
|---|
| 1449 | |
|---|
| 1450 | Output: |
|---|
| 1451 | |
|---|
| 1452 | Returns: |
|---|
| 1453 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 1454 | BDMA_ERR_OVERLAP - Source and destination region overlap. |
|---|
| 1455 | BDMA_ERR_SIZE_OUT_RANGE - ulBlockSize is bigger than 16 MByte. |
|---|
| 1456 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1457 | |
|---|
| 1458 | See Also: |
|---|
| 1459 | BDMA_Mem_Tran_Create2 |
|---|
| 1460 | BDMA_Mem_Tran_StartDma, BDMA_Mem_Tran_StartDmaAndCallBack |
|---|
| 1461 | BDMA_Mem_SetByteSwapMode, BDMA_Mem_Tran_SetCrypto_isr |
|---|
| 1462 | BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 1463 | ****************************************************************************/ |
|---|
| 1464 | BERR_Code BDMA_Mem_Tran_SetDmaBlockInfo_isr( |
|---|
| 1465 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1466 | uint32_t ulBlockId, |
|---|
| 1467 | uint32_t ulDstBusAddr, |
|---|
| 1468 | uint32_t ulSrcBusAddr, |
|---|
| 1469 | uint32_t ulBlockSize, |
|---|
| 1470 | bool bCryptInit ); |
|---|
| 1471 | |
|---|
| 1472 | /*************************************************************************** |
|---|
| 1473 | Summary: |
|---|
| 1474 | Mark one block as the start point and/or end point of scatter-gather. |
|---|
| 1475 | |
|---|
| 1476 | Description: |
|---|
| 1477 | This is the "_isr" version of BDMA_Mem_Tran_SetSgStartEnd. It is used in |
|---|
| 1478 | interrupt handler or critical session. For more description refer to |
|---|
| 1479 | BDMA_Mem_Tran_SetSgStartEnd. |
|---|
| 1480 | |
|---|
| 1481 | Input: |
|---|
| 1482 | hTran - The transfer handle to set block info. |
|---|
| 1483 | ulBlockId - The block index in the block list of this transfer, it starts |
|---|
| 1484 | from 0. |
|---|
| 1485 | bStartSgScram - mark this block as scatter-gather start point. |
|---|
| 1486 | bEndSgScram - mark this block as scatter-gather end point. |
|---|
| 1487 | |
|---|
| 1488 | Output: |
|---|
| 1489 | |
|---|
| 1490 | Returns: |
|---|
| 1491 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 1492 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1493 | |
|---|
| 1494 | See Also: |
|---|
| 1495 | BDMA_Mem_Tran_SetCrypto_isr, BDMA_Mem_Tran_SetDmaBlockInfo_isr, |
|---|
| 1496 | BDMA_Mem_Tran_SetSgStartEnd |
|---|
| 1497 | ****************************************************************************/ |
|---|
| 1498 | BERR_Code BDMA_Mem_Tran_SetSgStartEnd_isr( |
|---|
| 1499 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1500 | uint32_t ulBlockId, |
|---|
| 1501 | bool bStartSgScram, |
|---|
| 1502 | bool bEndSgScram ); |
|---|
| 1503 | |
|---|
| 1504 | /*************************************************************************** |
|---|
| 1505 | Summary: |
|---|
| 1506 | Start a DMA transfer and register a call back function. |
|---|
| 1507 | |
|---|
| 1508 | Description: |
|---|
| 1509 | This is the "_isr" version of BDMA_Mem_Tran_StartDmaAndCallBack. It is used |
|---|
| 1510 | in interrupt handler or critical session. For more description refer to |
|---|
| 1511 | BDMA_Mem_Tran_StartDmaAndCallBack. |
|---|
| 1512 | |
|---|
| 1513 | Input: |
|---|
| 1514 | hTran - The transfer handle to start. |
|---|
| 1515 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 1516 | dma transfered with this start call. |
|---|
| 1517 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 1518 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 1519 | |
|---|
| 1520 | Output: |
|---|
| 1521 | |
|---|
| 1522 | Returns: |
|---|
| 1523 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 1524 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 1525 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1526 | |
|---|
| 1527 | See Also: |
|---|
| 1528 | BDMA_Mem_Tran_Create2_isr, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 1529 | BDMA_Mem_Tran_GetStatus_isr |
|---|
| 1530 | BDMA_Mem_Tran_StartDmaAndCallBack |
|---|
| 1531 | ****************************************************************************/ |
|---|
| 1532 | BERR_Code BDMA_Mem_Tran_StartDmaAndCallBack_isr( |
|---|
| 1533 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1534 | uint32_t ulNumActBlocks, |
|---|
| 1535 | BDMA_Mem_CallbackFunc pDoneCallBack_isr, |
|---|
| 1536 | void * pUserCallBackParam ); |
|---|
| 1537 | |
|---|
| 1538 | /*************************************************************************** |
|---|
| 1539 | Summary: |
|---|
| 1540 | Query the status of a transfer. |
|---|
| 1541 | |
|---|
| 1542 | Description: |
|---|
| 1543 | This is the "_isr" version of BDMA_Mem_Tran_GetStatus. It is used in |
|---|
| 1544 | interrupt handler or critical session. For more description refer to |
|---|
| 1545 | BDMA_Mem_Tran_GetStatus. |
|---|
| 1546 | |
|---|
| 1547 | Input: |
|---|
| 1548 | hTran - The transfer handle to query status for. |
|---|
| 1549 | |
|---|
| 1550 | Output: |
|---|
| 1551 | peTranStatus - Transfer status returned. |
|---|
| 1552 | |
|---|
| 1553 | Returns: |
|---|
| 1554 | BERR_SUCCESS - Valid status is returned. |
|---|
| 1555 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 1556 | |
|---|
| 1557 | See Also: |
|---|
| 1558 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 1559 | BDMA_Mem_Tran_StartDma, BDMA_Mem_Tran_StartDmaAndCallBack |
|---|
| 1560 | BDMA_Mem_Tran_GetStatus_isr |
|---|
| 1561 | ****************************************************************************/ |
|---|
| 1562 | BERR_Code BDMA_Mem_Tran_GetStatus_isr( |
|---|
| 1563 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 1564 | BDMA_TranStatus * peTranStatus ); |
|---|
| 1565 | |
|---|
| 1566 | /*************************************************************************** |
|---|
| 1567 | Summary: |
|---|
| 1568 | Destroy a DMA transfer handle. |
|---|
| 1569 | |
|---|
| 1570 | Description: |
|---|
| 1571 | This is the "_isr" version of BDMA_Mem_Tran_Destroy. It is used in |
|---|
| 1572 | interrupt handler or critical session. For more description refer to |
|---|
| 1573 | BDMA_Mem_Tran_Destroy. |
|---|
| 1574 | |
|---|
| 1575 | Input: |
|---|
| 1576 | hTran - The transfer handle to destroy. |
|---|
| 1577 | |
|---|
| 1578 | Output: |
|---|
| 1579 | |
|---|
| 1580 | Returns: |
|---|
| 1581 | BERR_SUCCESS - Transfer handle is destroyed. |
|---|
| 1582 | BERR_INVALID_PARAMETER - The input hTran is invalid. |
|---|
| 1583 | |
|---|
| 1584 | See Also: |
|---|
| 1585 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_Reset, |
|---|
| 1586 | BDMA_Mem_Tran_GetStatus |
|---|
| 1587 | BDMA_Mem_Tran_Destroy_isr |
|---|
| 1588 | ****************************************************************************/ |
|---|
| 1589 | BERR_Code BDMA_Mem_Tran_Destroy_isr( |
|---|
| 1590 | BDMA_Mem_Tran_Handle hTran ); |
|---|
| 1591 | |
|---|
| 1592 | /*************************************************************************** |
|---|
| 1593 | Summary: |
|---|
| 1594 | Reset a DMA transfer handle. |
|---|
| 1595 | |
|---|
| 1596 | Description: |
|---|
| 1597 | This is the "_isr" version of BDMA_Mem_Tran_Reset. It is used in |
|---|
| 1598 | interrupt handler or critical session. For more description refer to |
|---|
| 1599 | BDMA_Mem_Tran_Reset. |
|---|
| 1600 | |
|---|
| 1601 | Input: |
|---|
| 1602 | hTran - The transfer handle to reset. |
|---|
| 1603 | |
|---|
| 1604 | Output: |
|---|
| 1605 | |
|---|
| 1606 | Returns: |
|---|
| 1607 | BERR_SUCCESS - The transfer handle is reset successfully. |
|---|
| 1608 | BERR_INVALID_PARAMETER - The input hTran is invalid. |
|---|
| 1609 | |
|---|
| 1610 | See Also: |
|---|
| 1611 | BDMA_Mem_Tran_Create2, BDMA_Mem_Tran_Destroy, |
|---|
| 1612 | BDMA_Mem_Tran_GetStatus |
|---|
| 1613 | BDMA_Mem_Tran_Reset_isr |
|---|
| 1614 | ****************************************************************************/ |
|---|
| 1615 | BERR_Code BDMA_Mem_Tran_Reset_isr( |
|---|
| 1616 | BDMA_Mem_Tran_Handle hTran ); |
|---|
| 1617 | |
|---|
| 1618 | |
|---|
| 1619 | /*************************************************************************** |
|---|
| 1620 | * Sub-Module: PCI DMA |
|---|
| 1621 | **************************************************************************/ |
|---|
| 1622 | |
|---|
| 1623 | /*************************************************************************** |
|---|
| 1624 | Summary: |
|---|
| 1625 | PCI DMA engine sub-module handle, or PCI DMA handle for simplicity. |
|---|
| 1626 | |
|---|
| 1627 | Description: |
|---|
| 1628 | This is an opaque handle that represents and controls one HW PCI DMA |
|---|
| 1629 | engine. It is needed when the PCI DMA engine is configured or used. |
|---|
| 1630 | |
|---|
| 1631 | It is created with BDMA_Pci_Create2. |
|---|
| 1632 | |
|---|
| 1633 | The typical process to configure and use a PCI DMA engine is as |
|---|
| 1634 | follows: |
|---|
| 1635 | |
|---|
| 1636 | o Open the DMA module handle. |
|---|
| 1637 | o A sub-module handle to the PCI DMA engine is created. |
|---|
| 1638 | o Configure PCI DMA engine (sub-module), such as swapping mode, max |
|---|
| 1639 | burst size. |
|---|
| 1640 | o Call BDMA_Pci_Tran_Create2 to create a PCI DMA transfer handle. |
|---|
| 1641 | o Set the block info (such as memory bus address, PCI bus address, |
|---|
| 1642 | transfer direction, and block size) for each data block to be |
|---|
| 1643 | transferred by calling BDMA_Pci_Tran_SetBlockInfo. |
|---|
| 1644 | o Start the transfer by BDMA_Pci_Tran_StartDma, or |
|---|
| 1645 | BDMA_Pci_Tran_StartDmaAndCallBack. |
|---|
| 1646 | o Process the "DMA done" information. Depending on which starting API |
|---|
| 1647 | function was called above, BDMA_Pci_Tran_StartDma or |
|---|
| 1648 | BDMA_Pci_Tran_StartDmaAndCallBack, the "DMA done" information could |
|---|
| 1649 | either be acquired by actively calling BDMA_Pci_Tran_GetStatus, or |
|---|
| 1650 | informed by a call back from BDMA. |
|---|
| 1651 | |
|---|
| 1652 | There are two engine configure API functions for PCI DMA sub-module, |
|---|
| 1653 | BDMA_Pci_SetSwapMode and BDMA_Pci_SetMaxBurstSize. The sub-module |
|---|
| 1654 | maintains a current state of configure. Each setting modifies current |
|---|
| 1655 | state. Current swap mode is applied when BDMA_Pci_Tran_SetBlockInfo is |
|---|
| 1656 | called in the future, unless it is reset again. This means that in a |
|---|
| 1657 | transfer each block could have different swap mode. But Current max |
|---|
| 1658 | burst size is applied to future calls of BDMA_Pci_Tran_StartDma and |
|---|
| 1659 | BDMA_Pci_Tran_StartDmaAndCallBack, that means the blocks of one transfer |
|---|
| 1660 | have to use the same max burst size. |
|---|
| 1661 | |
|---|
| 1662 | After the engine is configured, user could also perform a DMA transfer |
|---|
| 1663 | in an interrupt handler or critical session, using the API function set |
|---|
| 1664 | named with an "_isr" suffix. |
|---|
| 1665 | |
|---|
| 1666 | When a DMA engine sub-module handle is no longer needed, it should be |
|---|
| 1667 | destroyed with BDMA_Pci_Destroy. |
|---|
| 1668 | |
|---|
| 1669 | Please refer to the DMA module overview for more usage info. |
|---|
| 1670 | |
|---|
| 1671 | See Also: |
|---|
| 1672 | DMA, BDMA_Handle |
|---|
| 1673 | BDMA_Pci_Create2, BDMA_Pci_Destroy |
|---|
| 1674 | BDMA_Pci_SetSwapMode |
|---|
| 1675 | BDMA_Pci_Tran_Create2, BDMA_Pci_Tran_SetBlockInfo |
|---|
| 1676 | BDMA_Pci_Tran_StartDma, BDMA_Pci_Tran_StartDmaAndCallBack |
|---|
| 1677 | BDMA_Pci_Tran_GetStatus |
|---|
| 1678 | BDMA_Pci_Tran_Reset, BDMA_Pci_Tran_Destroy |
|---|
| 1679 | BDMA_Pci_Tran_Create2_isr, BDMA_Pci_Tran_SetBlockInfo_isr |
|---|
| 1680 | BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 1681 | BDMA_Pci_Tran_GetStatus_isr |
|---|
| 1682 | BDMA_Pci_Tran_Reset_isr, BDMA_Pci_Tran_Destroy_isr |
|---|
| 1683 | ***************************************************************************/ |
|---|
| 1684 | typedef struct BDMA_P_Pci_Context *BDMA_Pci_Handle; |
|---|
| 1685 | |
|---|
| 1686 | /*************************************************************************** |
|---|
| 1687 | Summary: |
|---|
| 1688 | This enumeration represents pci dma engines. |
|---|
| 1689 | |
|---|
| 1690 | Description: |
|---|
| 1691 | BDMA_PciDmaEngine is an enumeration which represents all HW pci dma |
|---|
| 1692 | engines there exist in the chip. It is used to indicate which HW engine |
|---|
| 1693 | to use when a PCI dma handle is created by BDMA_Pci_Create2. |
|---|
| 1694 | |
|---|
| 1695 | See Also: |
|---|
| 1696 | BDMA_Pci_Create2 |
|---|
| 1697 | ***************************************************************************/ |
|---|
| 1698 | typedef enum BDMA_PciDmaEngine |
|---|
| 1699 | { |
|---|
| 1700 | BDMA_PciDmaEngine_e0, /* pci dma engine 0 */ |
|---|
| 1701 | BDMA_PciDmaEngine_eUnknown |
|---|
| 1702 | } |
|---|
| 1703 | BDMA_PciDmaEngine; |
|---|
| 1704 | |
|---|
| 1705 | /*************************************************************************** |
|---|
| 1706 | Summary: |
|---|
| 1707 | This enumeration represents DMA max burst size. |
|---|
| 1708 | |
|---|
| 1709 | Description: |
|---|
| 1710 | BDMA_MaxBurstSize is an enumeration which represents supported DMA max |
|---|
| 1711 | burst sizes during DMA transfer. |
|---|
| 1712 | |
|---|
| 1713 | See Also: |
|---|
| 1714 | BDMA_Pci_SetMaxBurstSize |
|---|
| 1715 | ***************************************************************************/ |
|---|
| 1716 | typedef enum BDMA_MaxBurstSize |
|---|
| 1717 | { |
|---|
| 1718 | BDMA_MaxBurstSize_eBurst16, /* max burst size 16 */ |
|---|
| 1719 | BDMA_MaxBurstSize_eBurst1, /* single transfer, no burst */ |
|---|
| 1720 | BDMA_MaxBurstSize_eInvalid |
|---|
| 1721 | } |
|---|
| 1722 | BDMA_MaxBurstSize; |
|---|
| 1723 | |
|---|
| 1724 | /*************************************************************************** |
|---|
| 1725 | Summary: |
|---|
| 1726 | This enumeration represents the direction of a PCI DMA transfer. |
|---|
| 1727 | |
|---|
| 1728 | Description: |
|---|
| 1729 | BDMA_TranDir is an enumeration which represents the transfer direction |
|---|
| 1730 | of a block in a PCI DMA transfer. |
|---|
| 1731 | |
|---|
| 1732 | See Also: |
|---|
| 1733 | BDMA_Pci_Tran_SetBlockInfo, BDMA_Pci_Tran_SetBlockInfo_isr |
|---|
| 1734 | ***************************************************************************/ |
|---|
| 1735 | typedef enum BDMA_TranDir |
|---|
| 1736 | { |
|---|
| 1737 | BDMA_TranDir_eSdramToPciDevice, /* from SDRAM to a PCI device */ |
|---|
| 1738 | BDMA_TranDir_ePciDeviceToSdram, /* from a PCI device to SDRAM */ |
|---|
| 1739 | BDMA_TranDir_eInvalid |
|---|
| 1740 | } |
|---|
| 1741 | BDMA_TranDir; |
|---|
| 1742 | |
|---|
| 1743 | /*************************************************************************** |
|---|
| 1744 | Summary: |
|---|
| 1745 | This structure describes the settings for BDMA_Pci_Handle |
|---|
| 1746 | |
|---|
| 1747 | Description: |
|---|
| 1748 | BDMA_Pci_Settings is a structure that is used to describe the public |
|---|
| 1749 | settings of a pci dma engine. The settings are in engine scope. |
|---|
| 1750 | |
|---|
| 1751 | ulTotalNumBlocks - The maximum number of blocks could be supported |
|---|
| 1752 | by this dma engine in total. Its default value is 256. |
|---|
| 1753 | |
|---|
| 1754 | ulMaxNumBlocksPerTran - The maxium number of blocks per transfer. Its |
|---|
| 1755 | default value is 128. |
|---|
| 1756 | |
|---|
| 1757 | bSupportCallBack - When multiple BDMA instance exist in the system, |
|---|
| 1758 | only one instance can support call-back mode. bSupportCallBack indicates |
|---|
| 1759 | whether this BDMA instance is the unique one that can support call-back |
|---|
| 1760 | mode. Its default value is true. |
|---|
| 1761 | |
|---|
| 1762 | pTryLock - User provided call back function that is called to lock the |
|---|
| 1763 | hardware pci dma engine from accessing by other BDMA instances. Its |
|---|
| 1764 | default value is NULL. |
|---|
| 1765 | |
|---|
| 1766 | pReleaseLock - User provided call back function that is called to release |
|---|
| 1767 | the lock so that the hardware pci dma engine could be accessed by |
|---|
| 1768 | other BDMA instances. Its default value is NULL. |
|---|
| 1769 | |
|---|
| 1770 | pvParm1 - Pointer to a user defined struct. It is passed to (*pTryLock) |
|---|
| 1771 | and (*pReleaseLock) as a parameter. Its default value is NULL. |
|---|
| 1772 | |
|---|
| 1773 | iParm2 - Second user parameter for the lock call-back functions. It is |
|---|
| 1774 | passed to (*pTryLock)and (*pReleaseLock) as a parameter. Its default value |
|---|
| 1775 | is 0. |
|---|
| 1776 | |
|---|
| 1777 | If there is only one BDMA instance in the system, bSupportCallBack, |
|---|
| 1778 | pTryLock, pReleaseLock, pvParm1, iParm2 should be left with default value. |
|---|
| 1779 | |
|---|
| 1780 | See Also: |
|---|
| 1781 | BDMA_Pci_Create2, BDMA_Pci_GetDefaultSettings |
|---|
| 1782 | ***************************************************************************/ |
|---|
| 1783 | typedef struct BDMA_Pci_Settings |
|---|
| 1784 | { |
|---|
| 1785 | uint32_t ulTotalNumBlocks; |
|---|
| 1786 | uint32_t ulMaxNumBlocksPerTran; |
|---|
| 1787 | |
|---|
| 1788 | /* settings for the case of multiple PCI dma usage from multiple BDMA instances */ |
|---|
| 1789 | BDMA_LockCallbackFunc pTryLock; |
|---|
| 1790 | BDMA_LockCallbackFunc pReleaseLock; |
|---|
| 1791 | void * pvParm1; |
|---|
| 1792 | int iParm2; |
|---|
| 1793 | bool bSupportCallBack; |
|---|
| 1794 | } |
|---|
| 1795 | BDMA_Pci_Settings; |
|---|
| 1796 | |
|---|
| 1797 | /*************************************************************************** |
|---|
| 1798 | Summary: |
|---|
| 1799 | Creates a sub-module handle to PCI DMA engine. |
|---|
| 1800 | |
|---|
| 1801 | Description: |
|---|
| 1802 | This API function is used to create a BDMA_Pci_Handle to represent and |
|---|
| 1803 | control a specific HW PCI dma engine. It is required by PCI DMA sub- |
|---|
| 1804 | module functions in order to configure the DMA engine and perform |
|---|
| 1805 | DMA transfer. |
|---|
| 1806 | |
|---|
| 1807 | If the sub-module handle has already been created for the same HW engine, |
|---|
| 1808 | error is returned. This function also initializes the sub-module to |
|---|
| 1809 | default configure. |
|---|
| 1810 | |
|---|
| 1811 | Before BDMA_Pci_Create2 is called, BDMA_Pci's inherent default setting |
|---|
| 1812 | structure should be queried by BDMA_Pci_GetDefaultSettings, modified and |
|---|
| 1813 | then passed to BDMA_Pci_Create2. This avoid compatibilty problem if more |
|---|
| 1814 | elements are added into BDMA_Pci_Settings in the future, and save |
|---|
| 1815 | application tedious work of filling in the configuration structure. |
|---|
| 1816 | |
|---|
| 1817 | Refer to BDMA_Pci_Handle description for detailed usage info. |
|---|
| 1818 | |
|---|
| 1819 | Input: |
|---|
| 1820 | hDma - Handle to the BDMA module. |
|---|
| 1821 | eEngine - The HW pci dma engine controlled by this BDMA_Pci_Handle. |
|---|
| 1822 | pSettings - The basic settings. Default setting is used if pSettings is |
|---|
| 1823 | NULL. |
|---|
| 1824 | |
|---|
| 1825 | Output: |
|---|
| 1826 | phPciDma - The created PCI DMA sub-module handle. If failure |
|---|
| 1827 | occurred phPciDma will holds NULL. |
|---|
| 1828 | |
|---|
| 1829 | Returns: |
|---|
| 1830 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 1831 | BERR_SUCCESS - Successfully created the handle. |
|---|
| 1832 | |
|---|
| 1833 | See Also: |
|---|
| 1834 | BDMA_Pci_Destroy |
|---|
| 1835 | **************************************************************************/ |
|---|
| 1836 | BERR_Code BDMA_Pci_Create2( |
|---|
| 1837 | BDMA_Handle hDma, |
|---|
| 1838 | BDMA_PciDmaEngine eEngine, |
|---|
| 1839 | BDMA_Pci_Settings * pSettings, |
|---|
| 1840 | BDMA_Pci_Handle * phPciDma ); |
|---|
| 1841 | |
|---|
| 1842 | /*************************************************************************** |
|---|
| 1843 | Summary: |
|---|
| 1844 | Destroys the sub-module handle of the PCI DMA engine. |
|---|
| 1845 | |
|---|
| 1846 | Description: |
|---|
| 1847 | Once this function is called the sub-module handle can no longer be |
|---|
| 1848 | used. |
|---|
| 1849 | |
|---|
| 1850 | PCI DMA engine sub-module handle should be destroyed before closing |
|---|
| 1851 | the main module handle BDMA_Handle by BDMA_Close. |
|---|
| 1852 | |
|---|
| 1853 | Input: |
|---|
| 1854 | hPciDma - The PCI DMA engine sub-module handle to destroy. |
|---|
| 1855 | |
|---|
| 1856 | Output: |
|---|
| 1857 | |
|---|
| 1858 | Returns: |
|---|
| 1859 | BERR_INVALID_PARAMETER - hPciDma is not a valid PCI DMA engine sub- |
|---|
| 1860 | module handle. |
|---|
| 1861 | BERR_SUCCESS - Successfully destroyed |
|---|
| 1862 | |
|---|
| 1863 | See Also: |
|---|
| 1864 | BDMA_Pci_Create2 |
|---|
| 1865 | **************************************************************************/ |
|---|
| 1866 | BERR_Code BDMA_Pci_Destroy( |
|---|
| 1867 | BDMA_Pci_Handle hPciDma ); |
|---|
| 1868 | |
|---|
| 1869 | /*************************************************************************** |
|---|
| 1870 | Summary: |
|---|
| 1871 | This function gets BDMA_Pci's inherent default setting structure. |
|---|
| 1872 | |
|---|
| 1873 | Description: |
|---|
| 1874 | BDMA_Pci's inherent default setting structure could be queried by this |
|---|
| 1875 | API function prior to BDMA_Pci_Create2, modified and then passed to |
|---|
| 1876 | BDMA_Pci_Create2. This avoid compatibilty problem if more elements are |
|---|
| 1877 | added into BDMA_Pci_Settings in the future, and save application tedious |
|---|
| 1878 | work of filling in the configuration structure. |
|---|
| 1879 | |
|---|
| 1880 | It extremely inportant that pDefSettings has been assigned to a valid |
|---|
| 1881 | struct buffer address by user before this function is called. |
|---|
| 1882 | |
|---|
| 1883 | Input: |
|---|
| 1884 | <None> |
|---|
| 1885 | |
|---|
| 1886 | Output: |
|---|
| 1887 | pDefSettings - A copy of default settings structure. |
|---|
| 1888 | |
|---|
| 1889 | Returns: |
|---|
| 1890 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 1891 | BERR_SUCCESS - Successfully get VDC default settings. |
|---|
| 1892 | |
|---|
| 1893 | See Also: |
|---|
| 1894 | BDMA_Pci_Create2. |
|---|
| 1895 | **************************************************************************/ |
|---|
| 1896 | BERR_Code BDMA_Pci_GetDefaultSettings |
|---|
| 1897 | ( BDMA_Pci_Settings *pDefSettings ); |
|---|
| 1898 | |
|---|
| 1899 | /*************************************************************************** |
|---|
| 1900 | Summary: |
|---|
| 1901 | Set the swap mode. |
|---|
| 1902 | |
|---|
| 1903 | Description: |
|---|
| 1904 | During a DMA data transfer, PCI DMA engines could be programmed to |
|---|
| 1905 | perform translation between little endian and big endian with either |
|---|
| 1906 | byte aligned swap or short aligned swap. This function sets the swap |
|---|
| 1907 | mode. |
|---|
| 1908 | |
|---|
| 1909 | The sub-module maintains a current state of swap mode. Each setting |
|---|
| 1910 | modifies the current state and is applied to the future calls to |
|---|
| 1911 | BDMA_Pci_Tran_SetBlockInfo(_isr), unless it is reset again. This |
|---|
| 1912 | means that in a transfer each block could have different swap mode. |
|---|
| 1913 | |
|---|
| 1914 | Input: |
|---|
| 1915 | hPciDma - Sub-module handle to the PCI DMA engine to modify. |
|---|
| 1916 | eSwapMode - Swap mode enum |
|---|
| 1917 | |
|---|
| 1918 | Output: |
|---|
| 1919 | |
|---|
| 1920 | Returns: |
|---|
| 1921 | BERR_SUCCESS - Swap mode is set successfully. |
|---|
| 1922 | BERR_INVALID_PARAMETER - One of the input parameters was invalid. |
|---|
| 1923 | |
|---|
| 1924 | See Also: |
|---|
| 1925 | BDMA_Pci_Tran_SetBlockInfo, BDMA_Pci_Tran_SetBlockInfo_isr |
|---|
| 1926 | ****************************************************************************/ |
|---|
| 1927 | BERR_Code BDMA_Pci_SetSwapMode( |
|---|
| 1928 | BDMA_Pci_Handle hPciDma, |
|---|
| 1929 | BDMA_SwapMode eSwapMode ); |
|---|
| 1930 | |
|---|
| 1931 | /*************************************************************************** |
|---|
| 1932 | Summary: |
|---|
| 1933 | Set the max burst size during DMA transfer. |
|---|
| 1934 | |
|---|
| 1935 | Description: |
|---|
| 1936 | During a DMA data transfer, PCI DMA engines could be programmed to |
|---|
| 1937 | perform burst access on PCI bus. This function specifies the max burst |
|---|
| 1938 | size. PCI DMA engine might does burst access with burst size smaller |
|---|
| 1939 | than the max burst size specified here, depending on the memory bus and |
|---|
| 1940 | PCI bus traffic. |
|---|
| 1941 | |
|---|
| 1942 | The sub-module maintains a current state of max burst size. Each |
|---|
| 1943 | setting modifies the current state and is applied to the future calls |
|---|
| 1944 | of BDMA_Pci_Tran_StartDma/StartDmaAndCallBack(_isr), this means that the |
|---|
| 1945 | blocks of one transfer have to use the same max burst size. |
|---|
| 1946 | |
|---|
| 1947 | Input: |
|---|
| 1948 | hPciDma - Sub-module handle to the PCI DMA engine to modify. |
|---|
| 1949 | eMaxBurstSize - Max burst size on PCI bus during DMA transfer. |
|---|
| 1950 | |
|---|
| 1951 | Output: |
|---|
| 1952 | |
|---|
| 1953 | Returns: |
|---|
| 1954 | BERR_SUCCESS - Max burst size is set successfully. |
|---|
| 1955 | BERR_INVALID_PARAMETER - One of the input parameters was invalid. |
|---|
| 1956 | |
|---|
| 1957 | See Also: |
|---|
| 1958 | BDMA_Pci_Tran_StartDma, BDMA_Pci_Tran_StartDmaAndCallBack |
|---|
| 1959 | BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 1960 | ****************************************************************************/ |
|---|
| 1961 | BERR_Code BDMA_Pci_SetMaxBurstSize( |
|---|
| 1962 | BDMA_Pci_Handle hPciDma, |
|---|
| 1963 | BDMA_MaxBurstSize eMaxBurstSize ); |
|---|
| 1964 | |
|---|
| 1965 | |
|---|
| 1966 | /*************************************************************************** |
|---|
| 1967 | * Sub-Module: Transfer of PCI DMA |
|---|
| 1968 | **************************************************************************/ |
|---|
| 1969 | |
|---|
| 1970 | /*************************************************************************** |
|---|
| 1971 | Summary: |
|---|
| 1972 | PCI DMA Transfer sub-module handle. |
|---|
| 1973 | |
|---|
| 1974 | Description: |
|---|
| 1975 | A PCI DMA transfer is a sub-module of the PCI DMA engine (a sub-module of |
|---|
| 1976 | BDMA). BDMA_Pci_Tran_Handle is an opaque handle that holds the context |
|---|
| 1977 | for a PCI DMA transfer. It is created with BDMA_Pci_Tran_Create2. |
|---|
| 1978 | |
|---|
| 1979 | To perform a transfer with the PCI DMA engine (sub-module), a PCI DMA |
|---|
| 1980 | transfer handle must be created first, then the transfer handle could be |
|---|
| 1981 | used to set block info, start, and get the status. |
|---|
| 1982 | |
|---|
| 1983 | A transfer typically requests to dma a list of contiguous blocks. Each |
|---|
| 1984 | contiguous block is represented by a dma descriptor for hardware. The |
|---|
| 1985 | transfer is then described by a list of linked dma descriptors. When |
|---|
| 1986 | "block info" is set for a block, it is set to the corresponding dma |
|---|
| 1987 | descriptor. |
|---|
| 1988 | |
|---|
| 1989 | A transfer handle could be reused after it is started and finished. It is |
|---|
| 1990 | solely user's responsibility to ensure that each block has the right |
|---|
| 1991 | addresses and swap mode, max burst size. |
|---|
| 1992 | |
|---|
| 1993 | A transfer handle has to be explicitly destroyed when it is no longer |
|---|
| 1994 | needed. Otherwise the max limit of the number of active transfer blocks |
|---|
| 1995 | would be easily reached, that means new transfer creation would fail. |
|---|
| 1996 | |
|---|
| 1997 | Please refer to BDMA_Pci_Handle description and the DMA module overview |
|---|
| 1998 | for more usage info. |
|---|
| 1999 | |
|---|
| 2000 | See Also: |
|---|
| 2001 | BDMA_Pci_Tran_Create2, BDMA_Pci_Tran_SetBlockInfo |
|---|
| 2002 | BDMA_Pci_Tran_StartDma, BDMA_Pci_Tran_StartDmaAndCallBack |
|---|
| 2003 | BDMA_Pci_Tran_GetStatus |
|---|
| 2004 | BDMA_Pci_Tran_Destroy, BDMA_Pci_Tran_Reset |
|---|
| 2005 | BDMA_Pci_Tran_Create2_isr, BDMA_Pci_Tran_SetBlockInfo_isr |
|---|
| 2006 | BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 2007 | BDMA_Pci_Tran_GetStatus_isr |
|---|
| 2008 | BDMA_Pci_Tran_Destroy_isr, BDMA_Pci_Tran_Reset_isr |
|---|
| 2009 | BDMA_Pci_Handle, BDMA |
|---|
| 2010 | ***************************************************************************/ |
|---|
| 2011 | typedef struct BDMA_P_Pci_TranContext *BDMA_Pci_Tran_Handle; |
|---|
| 2012 | |
|---|
| 2013 | /*************************************************************************** |
|---|
| 2014 | Summary: |
|---|
| 2015 | Function pointer type of user DMA interrupt call back function. |
|---|
| 2016 | |
|---|
| 2017 | Description: |
|---|
| 2018 | The call back function is coded by the user, is passed to BDMA when a |
|---|
| 2019 | Tran is started with BDMA_Pci_Tran_StartDmaAndCallBack, and is called |
|---|
| 2020 | by BDMA after the Tran is completed, in interrupt hanlder mode, to |
|---|
| 2021 | process the "dma done info. |
|---|
| 2022 | |
|---|
| 2023 | It should take three parameters. One is the "user data buffer pointer", |
|---|
| 2024 | passed to the transfer starting API function. It is for user to pass |
|---|
| 2025 | user defined data structure to the call back function, in order to |
|---|
| 2026 | process the "done info". The other two are the transfer handle and |
|---|
| 2027 | eStatus, which are provided by the DMA module and are used to specify |
|---|
| 2028 | which transfer just finished and the transfer status. |
|---|
| 2029 | |
|---|
| 2030 | See Also: |
|---|
| 2031 | BDMA_Pci_Tran_StartDmaAndCallBack, BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 2032 | ****************************************************************************/ |
|---|
| 2033 | typedef void (* BDMA_Pci_CallbackFunc)( void * pUserCallBackParam,\ |
|---|
| 2034 | BDMA_Pci_Tran_Handle hTran, \ |
|---|
| 2035 | BDMA_TranStatus eStatus ); |
|---|
| 2036 | |
|---|
| 2037 | /*************************************************************************** |
|---|
| 2038 | Summary: |
|---|
| 2039 | Create a transfer handle. |
|---|
| 2040 | |
|---|
| 2041 | Description: |
|---|
| 2042 | This API function is used to create the transfer handle. |
|---|
| 2043 | |
|---|
| 2044 | BDMA_Pci_Tran_Create2 takes an input parameter ulNumBlocks, to |
|---|
| 2045 | specify the number of contiguous data blocks this transfer is to |
|---|
| 2046 | transfer. It should NOT be bigger than ulMaxNumBlocksPerTran in the |
|---|
| 2047 | BDMA_Pci_Settings passed to BDMA_Pci_Create2. |
|---|
| 2048 | |
|---|
| 2049 | A transfer handle could be reused after it is started and finished, and |
|---|
| 2050 | a transfer handle has to be explicitly destroyed when it is no longer |
|---|
| 2051 | needed. |
|---|
| 2052 | |
|---|
| 2053 | When a block info is set with BDMA_Pci_Tran_SetBlockInfo, it is written |
|---|
| 2054 | into a descriptor in the memory, and the descriptor is later read by HW. |
|---|
| 2055 | Either cached address or non-cached address could be used by BDMA when the |
|---|
| 2056 | descriptor is written. A true value for bCachedDesc indicates cached |
|---|
| 2057 | address should be used. |
|---|
| 2058 | |
|---|
| 2059 | When cached address is used for the descriptor writting, it will be |
|---|
| 2060 | flushed into memory by BDMA_Pci_Tran_StartDmaAndCallBack or |
|---|
| 2061 | BDMA_Pci_Tran_StartDma. |
|---|
| 2062 | |
|---|
| 2063 | Please refer to the DMA module overview and BDMA_Pci_Handle for more |
|---|
| 2064 | info on the usage of the PCI DMA sub-module API functions. |
|---|
| 2065 | |
|---|
| 2066 | Input: |
|---|
| 2067 | hPciDma - Sub-module handle to the PCI DMA engine to perform the DMA |
|---|
| 2068 | transfer. |
|---|
| 2069 | ulNumBlocks - Max number of blocks in this transfer. |
|---|
| 2070 | bCachedDesc - Whether use cached address to modify dma descriptor. |
|---|
| 2071 | |
|---|
| 2072 | Output: |
|---|
| 2073 | phTran - The transfer handle created. |
|---|
| 2074 | |
|---|
| 2075 | Returns: |
|---|
| 2076 | BERR_SUCCESS - The transfer handle is created successfully. |
|---|
| 2077 | BDMA_ERR_SIZE_OUT_RANGE - ulNumBlocks is 0 or bigger than the allowed. |
|---|
| 2078 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2079 | |
|---|
| 2080 | See Also: |
|---|
| 2081 | BDMA_Pci_Tran_SetBlockInfo |
|---|
| 2082 | BDMA_Pci_Tran_StartDma, BDMA_Pci_Tran_StartDmaAndCallBack |
|---|
| 2083 | BDMA_Pci_Tran_GetStatus |
|---|
| 2084 | BDMA_Pci_Tran_Destroy, BDMA_Pci_Tran_Reset |
|---|
| 2085 | BDMA_Pci_Tran_Create2_isr |
|---|
| 2086 | ****************************************************************************/ |
|---|
| 2087 | BERR_Code BDMA_Pci_Tran_Create2( |
|---|
| 2088 | BDMA_Pci_Handle hPciDma, |
|---|
| 2089 | uint32_t ulNumBlocks, |
|---|
| 2090 | bool bCachedDesc, |
|---|
| 2091 | BDMA_Pci_Tran_Handle * phTran ); |
|---|
| 2092 | |
|---|
| 2093 | /*************************************************************************** |
|---|
| 2094 | Summary: |
|---|
| 2095 | Set the block info for one block of a DMA transfer. |
|---|
| 2096 | |
|---|
| 2097 | Description: |
|---|
| 2098 | In order to perform a DMA transfer, user first creates a transfer handle, |
|---|
| 2099 | then uses it to set block info for each block, to start the DMA transfer, |
|---|
| 2100 | and finally to get the transfer status. This API function is used to set |
|---|
| 2101 | block info into HW dma descriptor for one block. |
|---|
| 2102 | |
|---|
| 2103 | ulBlockId is the index of the block, in the block list of the transfer |
|---|
| 2104 | represented by hTran. It starts from 0. |
|---|
| 2105 | |
|---|
| 2106 | The PCI address is in the PCI bus address space. It is a 32 bits unsigned |
|---|
| 2107 | integer number. And the memory address is the memory bus address space. |
|---|
| 2108 | It is a 28 bits number. |
|---|
| 2109 | |
|---|
| 2110 | It is more likely that the memory address is converted from virtual |
|---|
| 2111 | memory mapped address using BMEM_ConvertAddressToOffset and the virtual |
|---|
| 2112 | address is returned by BMEM_AllocAligned or BMEM_Alloc. |
|---|
| 2113 | |
|---|
| 2114 | eTranDirection is to specify whether the transfer of this block is from |
|---|
| 2115 | SDRAM to a PCI device or another way around. |
|---|
| 2116 | |
|---|
| 2117 | Both addresses and block size must be 32-bit aligned. Max block size is |
|---|
| 2118 | 0xfff,ffff (16 MByte), and minimum block size is 0x4. |
|---|
| 2119 | |
|---|
| 2120 | The current state of swap mode is used during the transfer of this block. |
|---|
| 2121 | |
|---|
| 2122 | If the Tran is re-used, and there is no change to this block info ( |
|---|
| 2123 | including the state of read endian ...), there is no need to set info |
|---|
| 2124 | for this block again. |
|---|
| 2125 | |
|---|
| 2126 | Please refer to the DMA module overview and BDMA_Pci_Handle for more info |
|---|
| 2127 | on the usage of the PCI sub-module API functions. |
|---|
| 2128 | |
|---|
| 2129 | Input: |
|---|
| 2130 | hTran - The transfer handle to set block info. |
|---|
| 2131 | ulBlockId - The block index in the block list of this transfer. |
|---|
| 2132 | ulMemBusAddr - Memory address in memory bus address space. |
|---|
| 2133 | ulPciBusAddr - PCI address in PCI bus address space. |
|---|
| 2134 | ulBlockSize - This block size in bytes. |
|---|
| 2135 | eTranDirection - Transfer direction of this block. |
|---|
| 2136 | |
|---|
| 2137 | Output: |
|---|
| 2138 | |
|---|
| 2139 | Returns: |
|---|
| 2140 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 2141 | BDMA_ERR_OVERLAP - Source and destination region overlap. |
|---|
| 2142 | BDMA_ERR_NOT_WORD_ALIGNED - ulSrcBusAddr, ulDstBusAddr, or ulBlockSize |
|---|
| 2143 | is not 32-bit aligned. |
|---|
| 2144 | BDMA_ERR_SIZE_OUT_RANGE - ulBlockSize is bigger than 16 MByte. |
|---|
| 2145 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2146 | |
|---|
| 2147 | See Also: |
|---|
| 2148 | BDMA_Pci_Tran_Create2 |
|---|
| 2149 | BDMA_Pci_Tran_StartDma, BDMA_Pci_Tran_StartDmaAndCallBack |
|---|
| 2150 | BDMA_Pci_SetSwapMode |
|---|
| 2151 | BDMA_Pci_Tran_SetBlockInfo_isr |
|---|
| 2152 | ****************************************************************************/ |
|---|
| 2153 | BERR_Code BDMA_Pci_Tran_SetBlockInfo( |
|---|
| 2154 | BDMA_Pci_Tran_Handle hTran, |
|---|
| 2155 | uint32_t ulBlockId, |
|---|
| 2156 | uint32_t ulMemBusAddr, |
|---|
| 2157 | uint32_t ulPciBusAddr, |
|---|
| 2158 | uint32_t ulBlockSize, |
|---|
| 2159 | BDMA_TranDir eTranDirection ); |
|---|
| 2160 | |
|---|
| 2161 | /*************************************************************************** |
|---|
| 2162 | Summary: |
|---|
| 2163 | Start a DMA transfer. |
|---|
| 2164 | |
|---|
| 2165 | Description: |
|---|
| 2166 | This API function is used to start a DMA transfer. |
|---|
| 2167 | |
|---|
| 2168 | BDMA_Pci_Tran_StartDma takes, as an input parameter, hTran to specify the |
|---|
| 2169 | transfer to start. |
|---|
| 2170 | |
|---|
| 2171 | As starting a transfer with this API function, user needs to implement a |
|---|
| 2172 | status checking and sleeping loop, to wait for the completion of the |
|---|
| 2173 | DMA transfer, and then to process the "done" info. |
|---|
| 2174 | |
|---|
| 2175 | The current state of max burst size is used during the transfer. |
|---|
| 2176 | |
|---|
| 2177 | Before a dma transfer can be started, block info has to be set with |
|---|
| 2178 | BDMA_Pci_Tran_SetBlockInfo for all blocks with block index from 0 to |
|---|
| 2179 | (ulNumActBlocks - 1). ulNumActBlocks should be bigger than 0, and less |
|---|
| 2180 | than or equal to ulNumBlocks passed to BDMA_Pci_Tran_Create2. |
|---|
| 2181 | |
|---|
| 2182 | If cached address is used for the descriptor writting, it will be |
|---|
| 2183 | flushed into memory inside BDMA_Pci_Tran_StartDma. |
|---|
| 2184 | |
|---|
| 2185 | when the dma hardware engine is shared by multiple BDMA instances, the |
|---|
| 2186 | transfer might be queued into software until the hardware is no longer in |
|---|
| 2187 | use by another BDMA instance. User provided lock call back functions are |
|---|
| 2188 | used to ensure atomic access to the hardware dma engine. |
|---|
| 2189 | |
|---|
| 2190 | Please refer to the DMA module overview and BDMA_Pci_Handle for more |
|---|
| 2191 | info on the usage of the PCI DMA sub-module API functions. |
|---|
| 2192 | |
|---|
| 2193 | Input: |
|---|
| 2194 | hTran - The transfer handle to start. |
|---|
| 2195 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 2196 | dma transfered with this start call. |
|---|
| 2197 | |
|---|
| 2198 | Output: |
|---|
| 2199 | |
|---|
| 2200 | Returns: |
|---|
| 2201 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 2202 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2203 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 2204 | BDMA_ERR_ENGINE_BUSY - The engine is busy. |
|---|
| 2205 | |
|---|
| 2206 | See Also: |
|---|
| 2207 | BDMA_Pci_Tran_Create2, BDMA_Pci_Tran_SetBlockInfo |
|---|
| 2208 | BDMA_Pci_Tran_GetStatus |
|---|
| 2209 | BDMA_Pci_SetMaxBurstSize |
|---|
| 2210 | BDMA_Pci_Settings, BDMA_LockCallbackFunc, |
|---|
| 2211 | BDMA_Pci_Tran_StartDmaAndCallBack |
|---|
| 2212 | ****************************************************************************/ |
|---|
| 2213 | BERR_Code BDMA_Pci_Tran_StartDma( |
|---|
| 2214 | BDMA_Pci_Tran_Handle hTran, |
|---|
| 2215 | uint32_t ulNumActBlocks ); |
|---|
| 2216 | |
|---|
| 2217 | /*************************************************************************** |
|---|
| 2218 | Summary: |
|---|
| 2219 | Start a DMA transfer from a specific address. |
|---|
| 2220 | |
|---|
| 2221 | Description: |
|---|
| 2222 | This API function is used to start a DMA transfer from some address.Refer |
|---|
| 2223 | to BDMA_Mem_Tran_StartDma for more details. |
|---|
| 2224 | |
|---|
| 2225 | Input: |
|---|
| 2226 | hTran - The transfer handle to start. |
|---|
| 2227 | ulFirstBlock - specific starting address |
|---|
| 2228 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 2229 | dma transfered with this start call. |
|---|
| 2230 | |
|---|
| 2231 | Output: |
|---|
| 2232 | |
|---|
| 2233 | Returns: |
|---|
| 2234 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 2235 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2236 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 2237 | BDMA_ERR_ENGINE_BUSY - The engine is busy. |
|---|
| 2238 | |
|---|
| 2239 | ****************************************************************************/ |
|---|
| 2240 | BERR_Code BDMA_Pci_Tran_StartDmaSubset( |
|---|
| 2241 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 2242 | uint32_t ulFirstBlock, |
|---|
| 2243 | uint32_t ulNumActBlocks ); |
|---|
| 2244 | /*************************************************************************** |
|---|
| 2245 | Summary: |
|---|
| 2246 | Start a DMA transfer and register a call back function. |
|---|
| 2247 | |
|---|
| 2248 | Description: |
|---|
| 2249 | This API function is used to start a DMA transfer, and to register a call |
|---|
| 2250 | back function to be called when the transfer finishes. This API function |
|---|
| 2251 | can be used only if "true" is set to bSupportCallBack in the struct |
|---|
| 2252 | BDMA_Pci_Settings passed to BDMA_Pci_Create2, otherwise error is returned. |
|---|
| 2253 | |
|---|
| 2254 | It takes, as input parameters, hTran to specify the transfer to start, |
|---|
| 2255 | a call back function pointer, and a user data buffer pointer. Then the |
|---|
| 2256 | call back function will be called by the "DMA done" interrupt handler |
|---|
| 2257 | of the module, when the transfer finishes. |
|---|
| 2258 | |
|---|
| 2259 | The call back function is ideally coded by the user. It should take three |
|---|
| 2260 | parameters. One is the "user data buffer pointer", passed to this API |
|---|
| 2261 | function. It is for user to pass user defined data structure to the call |
|---|
| 2262 | back function, in order to process the "done info". Another two are |
|---|
| 2263 | transfer handle hTran and eStatus, which are provided by the DMA module |
|---|
| 2264 | and are used to specify which transfer just finished and its status. |
|---|
| 2265 | |
|---|
| 2266 | The current state of max burst size is used during the transfer. |
|---|
| 2267 | |
|---|
| 2268 | Before a dma transfer can be started, block info has to be set with |
|---|
| 2269 | BDMA_Pci_Tran_SetBlockInfo for all blocks with block index from 0 to |
|---|
| 2270 | (ulNumActBlocks - 1). ulNumActBlocks should be bigger than 0, and less |
|---|
| 2271 | than or equal to ulNumBlocks passed to BDMA_Pci_Tran_Create2. |
|---|
| 2272 | |
|---|
| 2273 | If cached address is used for the descriptor writting, it will be |
|---|
| 2274 | flushed into memory inside BDMA_Pci_Tran_StartDmaAndCallBack. |
|---|
| 2275 | |
|---|
| 2276 | when the dma hardware engine is shared by multiple BDMA instances, the |
|---|
| 2277 | transfer might be queued into software until the hardware is no longer in |
|---|
| 2278 | use by another BDMA instance. User provided lock call back functions are |
|---|
| 2279 | used to ensure atomic access to the hardware dma engine. |
|---|
| 2280 | |
|---|
| 2281 | Please refer to the DMA module overview and BDMA_Pci_Handle for more |
|---|
| 2282 | info on the usage of the PCI DMA sub-module API functions. |
|---|
| 2283 | |
|---|
| 2284 | Input: |
|---|
| 2285 | hTran - The transfer handle to start. |
|---|
| 2286 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 2287 | dma transfered with this start call. |
|---|
| 2288 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 2289 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 2290 | |
|---|
| 2291 | Output: |
|---|
| 2292 | |
|---|
| 2293 | Returns: |
|---|
| 2294 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 2295 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 2296 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2297 | |
|---|
| 2298 | See Also: |
|---|
| 2299 | BDMA_Pci_Tran_Create2, BDMA_Pci_Tran_SetBlockInfo, |
|---|
| 2300 | BDMA_Pci_Tran_GetStatus, |
|---|
| 2301 | BDMA_Pci_SetMaxBurstSize, |
|---|
| 2302 | BDMA_Pci_Settings, BDMA_LockCallbackFunc, |
|---|
| 2303 | BDMA_Pci_Tran_StartDma, |
|---|
| 2304 | BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 2305 | ****************************************************************************/ |
|---|
| 2306 | BERR_Code BDMA_Pci_Tran_StartDmaAndCallBack( |
|---|
| 2307 | BDMA_Pci_Tran_Handle hTran, |
|---|
| 2308 | uint32_t ulNumActBlocks, |
|---|
| 2309 | BDMA_Pci_CallbackFunc pDoneCallBack_isr, |
|---|
| 2310 | void * pUserCallBackParam ); |
|---|
| 2311 | /*************************************************************************** |
|---|
| 2312 | Summary: |
|---|
| 2313 | Start a DMA transfer and register a call back function. |
|---|
| 2314 | |
|---|
| 2315 | Description: |
|---|
| 2316 | This API function is used to start a DMA transfer |
|---|
| 2317 | |
|---|
| 2318 | Input: |
|---|
| 2319 | hTran - The transfer handle to start. |
|---|
| 2320 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 2321 | dma transfered with this start call. |
|---|
| 2322 | ulFirstBlock - specific starting address |
|---|
| 2323 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 2324 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 2325 | |
|---|
| 2326 | Output: |
|---|
| 2327 | |
|---|
| 2328 | Returns: |
|---|
| 2329 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 2330 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 2331 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2332 | |
|---|
| 2333 | See Also: |
|---|
| 2334 | BDMA_LockCallbackFunc, BDMA_Pci_Settings, |
|---|
| 2335 | BDMA_Pci_Tran_StartDma |
|---|
| 2336 | BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 2337 | BDMA_Pci_Tran_StartDmaSubset |
|---|
| 2338 | ****************************************************************************/ |
|---|
| 2339 | BERR_Code BDMA_Pci_Tran_StartDmaSubsetAndCallBack( |
|---|
| 2340 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 2341 | uint32_t ulFirstBlock, |
|---|
| 2342 | uint32_t ulNumActBlocks, |
|---|
| 2343 | BDMA_Mem_CallbackFunc pCallBackFunc_isr, |
|---|
| 2344 | void * pUserCallBackParam ); |
|---|
| 2345 | |
|---|
| 2346 | /*************************************************************************** |
|---|
| 2347 | Summary: |
|---|
| 2348 | Query the status of a transfer. |
|---|
| 2349 | |
|---|
| 2350 | Description: |
|---|
| 2351 | In order to perform a DMA transfer, user first creates a transfer handle, |
|---|
| 2352 | then uses it to set each block info, to start the DMA transfer, and |
|---|
| 2353 | finally to get the transfer status. This API function is used to get the |
|---|
| 2354 | status of a DMA transfer. |
|---|
| 2355 | |
|---|
| 2356 | Input: |
|---|
| 2357 | hTran - The transfer handle to query status for. |
|---|
| 2358 | |
|---|
| 2359 | Output: |
|---|
| 2360 | peTranStatus - Transfer status returned. |
|---|
| 2361 | |
|---|
| 2362 | Returns: |
|---|
| 2363 | BERR_SUCCESS - Valid status is returned. |
|---|
| 2364 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2365 | |
|---|
| 2366 | See Also: |
|---|
| 2367 | BDMA_Pci_Tran_Create2, BDMA_Pci_Tran_SetBlockInfo |
|---|
| 2368 | BDMA_Pci_Tran_StartDma, BDMA_Pci_Tran_StartDmaAndCallBack |
|---|
| 2369 | BDMA_Pci_Tran_GetStatus_isr |
|---|
| 2370 | ****************************************************************************/ |
|---|
| 2371 | BERR_Code BDMA_Pci_Tran_GetStatus( |
|---|
| 2372 | BDMA_Pci_Tran_Handle hTran, |
|---|
| 2373 | BDMA_TranStatus * peTranStatus ); |
|---|
| 2374 | |
|---|
| 2375 | /*************************************************************************** |
|---|
| 2376 | Summary: |
|---|
| 2377 | Destroy a DMA transfer handle. |
|---|
| 2378 | |
|---|
| 2379 | Description: |
|---|
| 2380 | This API function is used to destroy a no-longer needed DMA transfer |
|---|
| 2381 | handle. It frees the resources occupied by this transfer handle. After |
|---|
| 2382 | a transfer handle is destroyed, it can no-longer be used to set block, |
|---|
| 2383 | to start, or to get transfer status. |
|---|
| 2384 | |
|---|
| 2385 | BDMA_Pci_Tran_Destroy takes, as an input parameter, hTran to specify the |
|---|
| 2386 | transfer handle to destroy. |
|---|
| 2387 | |
|---|
| 2388 | Please refer to the DMA module overview and BDMA_Pci_Handle for more |
|---|
| 2389 | info on the usage of the PCI DMA sub-module API functions. |
|---|
| 2390 | |
|---|
| 2391 | Input: |
|---|
| 2392 | hTran - The transfer handle to destroy. |
|---|
| 2393 | |
|---|
| 2394 | Output: |
|---|
| 2395 | |
|---|
| 2396 | Returns: |
|---|
| 2397 | BERR_SUCCESS - Transfer handle is destroyed. |
|---|
| 2398 | BERR_INVALID_PARAMETER - The input hTran is invalid. |
|---|
| 2399 | |
|---|
| 2400 | See Also: |
|---|
| 2401 | BDMA_Pci_Tran_Create2, BDMA_Pci_Tran_Reset, |
|---|
| 2402 | BDMA_Pci_Tran_GetStatus |
|---|
| 2403 | BDMA_Pci_Tran_Destroy_isr |
|---|
| 2404 | ****************************************************************************/ |
|---|
| 2405 | BERR_Code BDMA_Pci_Tran_Destroy( |
|---|
| 2406 | BDMA_Pci_Tran_Handle hTran ); |
|---|
| 2407 | |
|---|
| 2408 | /*************************************************************************** |
|---|
| 2409 | Summary: |
|---|
| 2410 | Reset a DMA transfer handle. |
|---|
| 2411 | |
|---|
| 2412 | Description: |
|---|
| 2413 | This API function is used to reset DMA transfer handle to its initially |
|---|
| 2414 | created state. |
|---|
| 2415 | |
|---|
| 2416 | For an initially created or reset transfer handle, the module ensures |
|---|
| 2417 | that block info is set for each transfered block, when it is started. |
|---|
| 2418 | Without resetting, user needs to pay extra attention, to ensure that |
|---|
| 2419 | all un-reset block info have correct addresses and configures. |
|---|
| 2420 | |
|---|
| 2421 | BDMA_Pci_Tran_Reset takes, as an input parameter, hTran to specify the |
|---|
| 2422 | transfer handle to reset. |
|---|
| 2423 | |
|---|
| 2424 | After a transfer handle is reset, its status is reset to |
|---|
| 2425 | BDMA_TranStatus_eCreated. |
|---|
| 2426 | |
|---|
| 2427 | Please refer to the DMA module overview and BDMA_Pci_Handle for more |
|---|
| 2428 | info on the usage of the PCI DMA sub-module API functions. |
|---|
| 2429 | |
|---|
| 2430 | Input: |
|---|
| 2431 | hTran - The transfer handle to reset. |
|---|
| 2432 | |
|---|
| 2433 | Output: |
|---|
| 2434 | |
|---|
| 2435 | Returns: |
|---|
| 2436 | BERR_SUCCESS - The transfer handle is reset successfully. |
|---|
| 2437 | BERR_INVALID_PARAMETER - The input hTran is invalid. |
|---|
| 2438 | |
|---|
| 2439 | See Also: |
|---|
| 2440 | BDMA_Pci_Tran_Create2, BDMA_Pci_Tran_Destroy, |
|---|
| 2441 | BDMA_Pci_Tran_GetStatus |
|---|
| 2442 | BDMA_Pci_Tran_Reset_isr |
|---|
| 2443 | ****************************************************************************/ |
|---|
| 2444 | BERR_Code BDMA_Pci_Tran_Reset( |
|---|
| 2445 | BDMA_Pci_Tran_Handle hTran ); |
|---|
| 2446 | |
|---|
| 2447 | /*************************************************************************** |
|---|
| 2448 | Summary: |
|---|
| 2449 | Create a transfer handle. |
|---|
| 2450 | |
|---|
| 2451 | Description: |
|---|
| 2452 | This is the "_isr" version of BDMA_Pci_Tran_Create2. It is used in |
|---|
| 2453 | interrupt handler or critical session. For more description refer to |
|---|
| 2454 | BDMA_Pci_Tran_Create2. |
|---|
| 2455 | |
|---|
| 2456 | Input: |
|---|
| 2457 | hPciDma - Sub-module handle to the PCI DMA engine to perform the DMA |
|---|
| 2458 | transfer. |
|---|
| 2459 | ulNumBlocks - Max number of blocks in this transfer. |
|---|
| 2460 | bCachedDesc - Whether use cached address to modify dma descriptor. |
|---|
| 2461 | |
|---|
| 2462 | Output: |
|---|
| 2463 | phTran - The transfer handle created. |
|---|
| 2464 | |
|---|
| 2465 | Returns: |
|---|
| 2466 | BERR_SUCCESS - The transfer handle is created successfully. |
|---|
| 2467 | BDMA_ERR_SIZE_OUT_RANGE - ulNumBlocks is 0 or bigger than the allowed. |
|---|
| 2468 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2469 | |
|---|
| 2470 | See Also: |
|---|
| 2471 | BDMA_Pci_Tran_SetBlockInfo_isr |
|---|
| 2472 | BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 2473 | BDMA_Pci_Tran_GetStatus_isr |
|---|
| 2474 | BDMA_Pci_Tran_Destroy_isr, BDMA_Pci_Tran_Reset_isr |
|---|
| 2475 | BDMA_Pci_Tran_Create2 |
|---|
| 2476 | ****************************************************************************/ |
|---|
| 2477 | BERR_Code BDMA_Pci_Tran_Create2_isr( |
|---|
| 2478 | BDMA_Pci_Handle hPciDma, |
|---|
| 2479 | uint32_t ulNumBlocks, |
|---|
| 2480 | bool bCachedDesc, |
|---|
| 2481 | BDMA_Pci_Tran_Handle * phTran ); |
|---|
| 2482 | |
|---|
| 2483 | /*************************************************************************** |
|---|
| 2484 | Summary: |
|---|
| 2485 | Set the block info for one block of a DMA transfer. |
|---|
| 2486 | |
|---|
| 2487 | Description: |
|---|
| 2488 | This is the "_isr" version of BDMA_Pci_Tran_SetBlockInfo. It is used in |
|---|
| 2489 | interrupt handler or critical session. For more description refer to |
|---|
| 2490 | BDMA_Pci_Tran_SetBlockInfo. |
|---|
| 2491 | |
|---|
| 2492 | Input: |
|---|
| 2493 | hTran - The transfer handle to set block info. |
|---|
| 2494 | ulBlockId - The block index in the block list of this transfer. |
|---|
| 2495 | ulMemBusAddr - Memory address in memory bus address space. |
|---|
| 2496 | ulPciBusAddr - PCI address in PCI bus address space. |
|---|
| 2497 | ulBlockSize - This block size in bytes. |
|---|
| 2498 | eTranDirection - Transfer direction of this block. |
|---|
| 2499 | |
|---|
| 2500 | Output: |
|---|
| 2501 | |
|---|
| 2502 | Returns: |
|---|
| 2503 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 2504 | BDMA_ERR_OVERLAP - Source and destination region overlap. |
|---|
| 2505 | BDMA_ERR_NOT_WORD_ALIGNED - ulSrcBusAddr, ulDstBusAddr, or ulBlockSize |
|---|
| 2506 | is not 32-bit aligned. |
|---|
| 2507 | BDMA_ERR_SIZE_OUT_RANGE - ulBlockSize is bigger than 16 MByte. |
|---|
| 2508 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2509 | |
|---|
| 2510 | See Also: |
|---|
| 2511 | BDMA_Pci_Tran_Create2_isr |
|---|
| 2512 | BDMA_Pci_Tran_StartDma_isr, BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 2513 | BDMA_Pci_SetSwapMode_isr |
|---|
| 2514 | BDMA_Pci_Tran_SetBlockInfo |
|---|
| 2515 | ****************************************************************************/ |
|---|
| 2516 | BERR_Code BDMA_Pci_Tran_SetBlockInfo_isr( |
|---|
| 2517 | BDMA_Pci_Tran_Handle hTran, |
|---|
| 2518 | uint32_t ulBlockId, |
|---|
| 2519 | uint32_t ulMemBusAddr, |
|---|
| 2520 | uint32_t ulPciBusAddr, |
|---|
| 2521 | uint32_t ulBlockSize, |
|---|
| 2522 | BDMA_TranDir eTranDirection ); |
|---|
| 2523 | |
|---|
| 2524 | /*************************************************************************** |
|---|
| 2525 | Summary: |
|---|
| 2526 | Start a DMA transfer and register a call back function. |
|---|
| 2527 | |
|---|
| 2528 | Description: |
|---|
| 2529 | This is the "_isr" version of BDMA_Pci_Tran_StartDmaAndCallBack. It is used |
|---|
| 2530 | in interrupt handler or critical session. For more description refer to |
|---|
| 2531 | BDMA_Pci_Tran_StartDmaAndCallBack. |
|---|
| 2532 | |
|---|
| 2533 | Input: |
|---|
| 2534 | hTran - The transfer handle to start. |
|---|
| 2535 | ulNumActBlocks - Block with index from 0 to (ulNumActBlocks - 1) will be |
|---|
| 2536 | dma transfered with this start call. |
|---|
| 2537 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 2538 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 2539 | |
|---|
| 2540 | Output: |
|---|
| 2541 | |
|---|
| 2542 | Returns: |
|---|
| 2543 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 2544 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 2545 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2546 | |
|---|
| 2547 | See Also: |
|---|
| 2548 | BDMA_Pci_Tran_Create2_isr, BDMA_Pci_Tran_SetBlockInfo_isr, |
|---|
| 2549 | BDMA_Pci_Tran_GetStatus_isr, |
|---|
| 2550 | BDMA_Pci_Settings, BDMA_LockCallbackFunc, |
|---|
| 2551 | BDMA_Pci_Tran_StartDmaAndCallBack |
|---|
| 2552 | ****************************************************************************/ |
|---|
| 2553 | BERR_Code BDMA_Pci_Tran_StartDmaAndCallBack_isr( |
|---|
| 2554 | BDMA_Pci_Tran_Handle hTran, |
|---|
| 2555 | uint32_t ulNumActBlocks, |
|---|
| 2556 | BDMA_Pci_CallbackFunc pDoneCallBack_isr, |
|---|
| 2557 | void * pUserCallBackParam ); |
|---|
| 2558 | |
|---|
| 2559 | /*************************************************************************** |
|---|
| 2560 | Summary: |
|---|
| 2561 | Query the status of a transfer. |
|---|
| 2562 | |
|---|
| 2563 | Description: |
|---|
| 2564 | This is the "_isr" version of BDMA_Pci_Tran_GetStatus. It is used in |
|---|
| 2565 | interrupt handler or critical session. For more description refer to |
|---|
| 2566 | BDMA_Pci_Tran_GetStatus. |
|---|
| 2567 | |
|---|
| 2568 | Input: |
|---|
| 2569 | hTran - The transfer handle to query status for. |
|---|
| 2570 | |
|---|
| 2571 | Output: |
|---|
| 2572 | peTranStatus - Transfer status returned. |
|---|
| 2573 | |
|---|
| 2574 | Returns: |
|---|
| 2575 | BERR_SUCCESS - Valid status is returned. |
|---|
| 2576 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2577 | |
|---|
| 2578 | See Also: |
|---|
| 2579 | BDMA_Pci_Tran_Create2_isr, BDMA_Pci_Tran_SetBlockInfo_isr |
|---|
| 2580 | BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 2581 | BDMA_Pci_Tran_GetStatus |
|---|
| 2582 | ****************************************************************************/ |
|---|
| 2583 | BERR_Code BDMA_Pci_Tran_GetStatus_isr( |
|---|
| 2584 | BDMA_Pci_Tran_Handle hTran, |
|---|
| 2585 | BDMA_TranStatus * peTranStatus ); |
|---|
| 2586 | |
|---|
| 2587 | /*************************************************************************** |
|---|
| 2588 | Summary: |
|---|
| 2589 | Destroy a DMA transfer handle. |
|---|
| 2590 | |
|---|
| 2591 | Description: |
|---|
| 2592 | This is the "_isr" version of BDMA_Pci_Tran_Destroy. It is used in |
|---|
| 2593 | interrupt handler or critical session. For more description refer to |
|---|
| 2594 | BDMA_Pci_Tran_Destroy. |
|---|
| 2595 | |
|---|
| 2596 | Input: |
|---|
| 2597 | hTran - The transfer handle to destroy. |
|---|
| 2598 | |
|---|
| 2599 | Output: |
|---|
| 2600 | |
|---|
| 2601 | Returns: |
|---|
| 2602 | BERR_SUCCESS - Transfer handle is destroyed. |
|---|
| 2603 | BERR_INVALID_PARAMETER - The input hTran is invalid. |
|---|
| 2604 | |
|---|
| 2605 | See Also: |
|---|
| 2606 | BDMA_Pci_Tran_Create2_isr, BDMA_Pci_Tran_Reset_isr, |
|---|
| 2607 | BDMA_Pci_Tran_GetStatus_isr |
|---|
| 2608 | BDMA_Pci_Tran_Destroy |
|---|
| 2609 | ****************************************************************************/ |
|---|
| 2610 | BERR_Code BDMA_Pci_Tran_Destroy_isr( |
|---|
| 2611 | BDMA_Pci_Tran_Handle hTran ); |
|---|
| 2612 | |
|---|
| 2613 | /*************************************************************************** |
|---|
| 2614 | Summary: |
|---|
| 2615 | Reset a DMA transfer handle. |
|---|
| 2616 | |
|---|
| 2617 | Description: |
|---|
| 2618 | This is the "_isr" version of BDMA_Pci_Tran_Reset. It is used in |
|---|
| 2619 | interrupt handler or critical session. For more description refer to |
|---|
| 2620 | BDMA_Pci_Tran_Reset. |
|---|
| 2621 | |
|---|
| 2622 | Input: |
|---|
| 2623 | hTran - The transfer handle to reset. |
|---|
| 2624 | |
|---|
| 2625 | Output: |
|---|
| 2626 | |
|---|
| 2627 | Returns: |
|---|
| 2628 | BERR_SUCCESS - The transfer handle is reset successfully. |
|---|
| 2629 | BERR_INVALID_PARAMETER - The input hTran is invalid. |
|---|
| 2630 | |
|---|
| 2631 | See Also: |
|---|
| 2632 | BDMA_Pci_Tran_Create2_isr, BDMA_Pci_Tran_Destroy_isr, |
|---|
| 2633 | BDMA_Pci_Tran_GetStatus_isr |
|---|
| 2634 | BDMA_Pci_Tran_Reset |
|---|
| 2635 | ****************************************************************************/ |
|---|
| 2636 | BERR_Code BDMA_Pci_Tran_Reset_isr( |
|---|
| 2637 | BDMA_Pci_Tran_Handle hTran ); |
|---|
| 2638 | |
|---|
| 2639 | |
|---|
| 2640 | /*************************************************************************** |
|---|
| 2641 | * Obsolete Memory Dma API: |
|---|
| 2642 | **************************************************************************/ |
|---|
| 2643 | |
|---|
| 2644 | /*************************************************************************** |
|---|
| 2645 | Summary: |
|---|
| 2646 | Creates a sub-module handle to memory DMA engine. |
|---|
| 2647 | |
|---|
| 2648 | Description: |
|---|
| 2649 | This API function is replaced by BDMA_Mem_Create2 and will be obsolete |
|---|
| 2650 | in the future. New code should use the new one and stop using this API |
|---|
| 2651 | function. |
|---|
| 2652 | |
|---|
| 2653 | Once created, the handle to the unique memory DMA engine is required |
|---|
| 2654 | by memory DMA sub-module functions in order to configure the DMA engine |
|---|
| 2655 | and perform DMA transfer. |
|---|
| 2656 | |
|---|
| 2657 | If the sub-module handle has already been created with the same hDma, |
|---|
| 2658 | error is returned. This function also initializes the sub-module to |
|---|
| 2659 | default configure. |
|---|
| 2660 | |
|---|
| 2661 | Refer to BDMA_Mem_Handle description for detailed usage info. |
|---|
| 2662 | |
|---|
| 2663 | Input: |
|---|
| 2664 | hDma - Handle to the BDMA module. |
|---|
| 2665 | |
|---|
| 2666 | Output: |
|---|
| 2667 | phMemDma - The created memory DMA sub-module handle. If failure |
|---|
| 2668 | occurred phMemDma will holds NULL. |
|---|
| 2669 | |
|---|
| 2670 | Returns: |
|---|
| 2671 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 2672 | BERR_SUCCESS - Successfully created the handle. |
|---|
| 2673 | |
|---|
| 2674 | See Also: |
|---|
| 2675 | BDMA_Mem_Destroy |
|---|
| 2676 | **************************************************************************/ |
|---|
| 2677 | BERR_Code BDMA_Mem_Create( |
|---|
| 2678 | BDMA_Handle hDma, |
|---|
| 2679 | BDMA_Mem_Handle * phMemDma ); |
|---|
| 2680 | |
|---|
| 2681 | /*************************************************************************** |
|---|
| 2682 | Summary: |
|---|
| 2683 | Set the swap mode. |
|---|
| 2684 | |
|---|
| 2685 | Description: |
|---|
| 2686 | This API function is replaced by BDMA_Mem_SetByteSwapMode and will be |
|---|
| 2687 | obsolete in the future. New code should use the new one and stop using |
|---|
| 2688 | this API function. |
|---|
| 2689 | |
|---|
| 2690 | During a DMA data transfer, Memory DMA engines could be programmed to |
|---|
| 2691 | perform translation between little endian and big endian with either |
|---|
| 2692 | byte aligned swap or short aligned swap. This function sets the swap |
|---|
| 2693 | mode. |
|---|
| 2694 | |
|---|
| 2695 | The sub-module maintains a current state of swap mode. Each setting |
|---|
| 2696 | modifies the current state and is applied to the future calls to |
|---|
| 2697 | BDMA_Mem_Tran_SetDmaBlockInfo(_isr), unless it is reset again. This |
|---|
| 2698 | means that in a transfer each block could have different swap mode. |
|---|
| 2699 | |
|---|
| 2700 | Input: |
|---|
| 2701 | hMemDma - Sub-module handle to the memory DMA engine to modify. |
|---|
| 2702 | eSwapMode - Swap mode enum |
|---|
| 2703 | |
|---|
| 2704 | Output: |
|---|
| 2705 | |
|---|
| 2706 | Returns: |
|---|
| 2707 | BERR_SUCCESS - Swap mode is set successfully. |
|---|
| 2708 | BERR_INVALID_PARAMETER - One of the input parameters was invalid. |
|---|
| 2709 | |
|---|
| 2710 | See Also: |
|---|
| 2711 | BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 2712 | ****************************************************************************/ |
|---|
| 2713 | BERR_Code BDMA_Mem_SetSwapMode( |
|---|
| 2714 | BDMA_Mem_Handle hMemDma, |
|---|
| 2715 | BDMA_SwapMode eSwapMode ); |
|---|
| 2716 | |
|---|
| 2717 | /*************************************************************************** |
|---|
| 2718 | Summary: |
|---|
| 2719 | Set encryption / decryption. |
|---|
| 2720 | |
|---|
| 2721 | Description: |
|---|
| 2722 | This API function is replaced by BDMA_Mem_Tran_SetCrypto and will be |
|---|
| 2723 | obsolete in the future. New code should use the new one and stop using |
|---|
| 2724 | this API function. |
|---|
| 2725 | |
|---|
| 2726 | During a DMA data transfer, Memory DMA engines could be configured to |
|---|
| 2727 | perform encryption or decryption. This API function is used to set the |
|---|
| 2728 | crypto. |
|---|
| 2729 | |
|---|
| 2730 | In the case that eCryptMode is BDMA_CryptMode_eNoCrypt, the crypto HW |
|---|
| 2731 | module is disabled and the setting to ulKeySlot has no effect. |
|---|
| 2732 | |
|---|
| 2733 | If eCryptMode has other valid value, the crypto HW is enabled and |
|---|
| 2734 | eCryptMode specifies how the crypto treats the transport packet |
|---|
| 2735 | boundaries (refer to BDMA_CryptMode for detail). |
|---|
| 2736 | |
|---|
| 2737 | Further, when scatter-gather SCRAM operation is enabled by bSgEnable, the |
|---|
| 2738 | dma engine will treat the data stream section of a list of dma blocks as a |
|---|
| 2739 | whole for encrypt or decrypt purpose. The stream section starts from the |
|---|
| 2740 | beginning of the block marked as scatter-gather start point, and ends at |
|---|
| 2741 | the end of the block marked as scatter-gather end point. bSgEnable can not |
|---|
| 2742 | change between the scatter-gather start point and end point. |
|---|
| 2743 | |
|---|
| 2744 | The rest of the crypto configuration, such as what crypto operation |
|---|
| 2745 | (either encryption or decryption) to perform, what crypto algorithm and |
|---|
| 2746 | what key value to use during crypto operation, was programmed into a key |
|---|
| 2747 | slot with the security module. ulKeySlot selects the key slot to use for |
|---|
| 2748 | the crypto. |
|---|
| 2749 | |
|---|
| 2750 | There are 16 key slots in a 7401 chip for the moment. The value (between |
|---|
| 2751 | 0 and 15) of ulKeySlot passed to this function must be the same one used |
|---|
| 2752 | in the security module when the key slot was programmed. |
|---|
| 2753 | |
|---|
| 2754 | The sub-module maintains a current state of crypt mode and key selection. |
|---|
| 2755 | Each setting modifies the current state and is applied to the future |
|---|
| 2756 | calls to BDMA_Mem_Tran_SetDmaBlockInfo(_isr), unless it is reset again. |
|---|
| 2757 | This implies that in a transfer each block could use different crypto key. |
|---|
| 2758 | |
|---|
| 2759 | Application software is responsible to program the selected key slot with |
|---|
| 2760 | the security module. If the key slot is not configured well, the dma result |
|---|
| 2761 | is undetermined. |
|---|
| 2762 | |
|---|
| 2763 | Input: |
|---|
| 2764 | hMemDma - Sub-module handle to the memory DMA engine to modify. |
|---|
| 2765 | BDMA_CryptMode - Crypto mode. If it is BDMA_CryptMode_eNoCrypt, crypto is |
|---|
| 2766 | disabled. Otherwise it specifies how transport packet boundary is treated. |
|---|
| 2767 | ulKeySlot - Key slot (between 0 and 15) selected for the crypto. |
|---|
| 2768 | bSgEnable - Enable scatter-gather SCRAM operation. |
|---|
| 2769 | |
|---|
| 2770 | Output: |
|---|
| 2771 | |
|---|
| 2772 | Returns: |
|---|
| 2773 | BERR_SUCCESS - crypto setting is set successfully. |
|---|
| 2774 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2775 | |
|---|
| 2776 | See Also: |
|---|
| 2777 | BDMA_Mem_Tran_SetSgStartEnd, BDMA_Mem_Tran_SetSgStartEnd_isr, |
|---|
| 2778 | BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 2779 | ****************************************************************************/ |
|---|
| 2780 | BERR_Code BDMA_Mem_SetCrypto( |
|---|
| 2781 | BDMA_Mem_Handle hMemDma, |
|---|
| 2782 | BDMA_CryptMode eCryptMode, |
|---|
| 2783 | uint32_t ulKeySlot, |
|---|
| 2784 | bool bSgEnable); |
|---|
| 2785 | |
|---|
| 2786 | /*************************************************************************** |
|---|
| 2787 | Summary: |
|---|
| 2788 | Set encryption / decryption. |
|---|
| 2789 | |
|---|
| 2790 | Description: |
|---|
| 2791 | This API function is replaced by BDMA_Mem_Tran_SetCrypto and will be |
|---|
| 2792 | obsolete in the future. New code should use the new one and stop using |
|---|
| 2793 | this API function. |
|---|
| 2794 | |
|---|
| 2795 | Input: |
|---|
| 2796 | hMemDma - Sub-module handle to the memory DMA engine to modify. |
|---|
| 2797 | BDMA_CryptMode - Crypto mode. If it is BDMA_CryptMode_eNoCrypt, crypto is |
|---|
| 2798 | disabled. Otherwise it specifies how transport packet boundary is treated. |
|---|
| 2799 | ulKeySlot - Key slot (between 0 and 15) selected for the crypto. |
|---|
| 2800 | |
|---|
| 2801 | Output: |
|---|
| 2802 | |
|---|
| 2803 | Returns: |
|---|
| 2804 | BERR_SUCCESS - crypto setting is set successfully. |
|---|
| 2805 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2806 | |
|---|
| 2807 | See Also: |
|---|
| 2808 | BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 2809 | ****************************************************************************/ |
|---|
| 2810 | BERR_Code BDMA_Mem_SetCrypt( |
|---|
| 2811 | BDMA_Mem_Handle hMemDma, |
|---|
| 2812 | BDMA_CryptMode eCryptMode, |
|---|
| 2813 | uint32_t ulKeySlot ); |
|---|
| 2814 | |
|---|
| 2815 | /*************************************************************************** |
|---|
| 2816 | Summary: |
|---|
| 2817 | Query the max number of blocks allowed in a transfer. |
|---|
| 2818 | |
|---|
| 2819 | Description: |
|---|
| 2820 | This function is obsolete. |
|---|
| 2821 | |
|---|
| 2822 | User can transfer a list of contiguous data blocks in one transfer. This |
|---|
| 2823 | API function is used to query the max number of blocks allowed in one |
|---|
| 2824 | transfer. |
|---|
| 2825 | |
|---|
| 2826 | Input: |
|---|
| 2827 | hMemDma - Sub-module handle to the memory DMA engine to perform DMA |
|---|
| 2828 | transfers. |
|---|
| 2829 | |
|---|
| 2830 | Output: |
|---|
| 2831 | pulMaxNumBlocks - Max number of blocks allowed in one transfer by the |
|---|
| 2832 | memory DMA engine. |
|---|
| 2833 | |
|---|
| 2834 | Returns: |
|---|
| 2835 | BERR_SUCCESS - Got the max number successfully. |
|---|
| 2836 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2837 | |
|---|
| 2838 | See Also: |
|---|
| 2839 | BDMA_Mem_Tran_Create, BDMA_Mem_Tran_Create_isr |
|---|
| 2840 | ****************************************************************************/ |
|---|
| 2841 | BERR_Code BDMA_Mem_Tran_GetMaxNumBlocks( |
|---|
| 2842 | BDMA_Mem_Handle hMemDma, |
|---|
| 2843 | uint32_t * pulMaxNumBlocks ); |
|---|
| 2844 | |
|---|
| 2845 | /*************************************************************************** |
|---|
| 2846 | Summary: |
|---|
| 2847 | Create a transfer handle. |
|---|
| 2848 | |
|---|
| 2849 | Description: |
|---|
| 2850 | This API function is replaced by BDMA_Mem_Tran_Create2 and will be |
|---|
| 2851 | obsolete in the future. New code should use the new one and stop using |
|---|
| 2852 | this API function. |
|---|
| 2853 | |
|---|
| 2854 | In order to perform DMA transfer with memory DMA engine, user needs to |
|---|
| 2855 | first create a transfer handle, then to use it to set each block info, |
|---|
| 2856 | to start the DMA transfer, and finally to get the transfer status. |
|---|
| 2857 | This API function is used to create the transfer handle. |
|---|
| 2858 | |
|---|
| 2859 | BDMA_Mem_Tran_Create takes an input parameter ulNumBlocks, to |
|---|
| 2860 | specify the number of contiguous data blocks this transfer is to |
|---|
| 2861 | transfer. The max number of blocks allowed could be queried with |
|---|
| 2862 | BDMA_Mem_Tran_GetMaxNumBlocks. It is likely close to 128. |
|---|
| 2863 | |
|---|
| 2864 | A transfer handle could be reused after it is started and finished, and a |
|---|
| 2865 | transfer handle has to be explicitly destroyed when it is no longer |
|---|
| 2866 | needed. |
|---|
| 2867 | |
|---|
| 2868 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 2869 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 2870 | |
|---|
| 2871 | Input: |
|---|
| 2872 | hMemDma - Sub-module handle to the memory DMA engine to perform the DMA |
|---|
| 2873 | transfer. |
|---|
| 2874 | ulNumBlocks - Number of blocks in this transfer. |
|---|
| 2875 | |
|---|
| 2876 | Output: |
|---|
| 2877 | phTran - The transfer handle created. |
|---|
| 2878 | |
|---|
| 2879 | Returns: |
|---|
| 2880 | BERR_SUCCESS - The transfer handle is created successfully. |
|---|
| 2881 | BDMA_ERR_SIZE_OUT_RANGE - ulNumBlocks is 0 or bigger than the allowed. |
|---|
| 2882 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2883 | |
|---|
| 2884 | See Also: |
|---|
| 2885 | BDMA_Mem_Tran_GetMaxNumBlocks |
|---|
| 2886 | BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 2887 | BDMA_Mem_Tran_Start, BDMA_Mem_Tran_StartAndCallBack |
|---|
| 2888 | BDMA_Mem_Tran_GetStatus |
|---|
| 2889 | BDMA_Mem_Tran_Destroy, BDMA_Mem_Tran_Reset |
|---|
| 2890 | BDMA_Mem_Tran_Create_isr |
|---|
| 2891 | ****************************************************************************/ |
|---|
| 2892 | BERR_Code BDMA_Mem_Tran_Create( |
|---|
| 2893 | BDMA_Mem_Handle hMemDma, |
|---|
| 2894 | uint32_t ulNumBlocks, |
|---|
| 2895 | BDMA_Mem_Tran_Handle * phTran ); |
|---|
| 2896 | |
|---|
| 2897 | /*************************************************************************** |
|---|
| 2898 | Summary: |
|---|
| 2899 | Start a DMA transfer. |
|---|
| 2900 | |
|---|
| 2901 | Description: |
|---|
| 2902 | This API function is replaced by BDMA_Mem_Tran_StartDma and will be |
|---|
| 2903 | obsolete in the future. New code should use the new one and stop using |
|---|
| 2904 | this API function. |
|---|
| 2905 | |
|---|
| 2906 | In order to perform a DMA transfer, user needs to first create a transfer |
|---|
| 2907 | handle, then to use it to set blocks info, to start the DMA transfer, and |
|---|
| 2908 | finally to get the transfer status. This API function is used to start a |
|---|
| 2909 | DMA transfer. |
|---|
| 2910 | |
|---|
| 2911 | As starting a transfer with this API function, user needs to implement a |
|---|
| 2912 | status checking and sleeping loop, to wait for the completion of the |
|---|
| 2913 | DMA transfer, and then to process the "done" info. |
|---|
| 2914 | |
|---|
| 2915 | BDMA_Mem_Tran_Start takes, as an input parameter, hTran to specify the |
|---|
| 2916 | transfer to start. |
|---|
| 2917 | |
|---|
| 2918 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 2919 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 2920 | |
|---|
| 2921 | Input: |
|---|
| 2922 | hTran - The transfer handle to start. |
|---|
| 2923 | |
|---|
| 2924 | Output: |
|---|
| 2925 | |
|---|
| 2926 | Returns: |
|---|
| 2927 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 2928 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2929 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 2930 | BDMA_ERR_ENGINE_BUSY - The engine is busy. |
|---|
| 2931 | |
|---|
| 2932 | See Also: |
|---|
| 2933 | BDMA_Mem_Tran_Create, BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 2934 | BDMA_Mem_Tran_GetStatus |
|---|
| 2935 | BDMA_Mem_Tran_StartAndCallBack |
|---|
| 2936 | ****************************************************************************/ |
|---|
| 2937 | BERR_Code BDMA_Mem_Tran_Start( |
|---|
| 2938 | BDMA_Mem_Tran_Handle hTran ); |
|---|
| 2939 | |
|---|
| 2940 | /*************************************************************************** |
|---|
| 2941 | Summary: |
|---|
| 2942 | Start a DMA transfer and register a call back function. |
|---|
| 2943 | |
|---|
| 2944 | Description: |
|---|
| 2945 | This API function is replaced by BDMA_Mem_Tran_StartDmaAndCallBack and |
|---|
| 2946 | will be obsolete in the future. New code should use the new one and stop |
|---|
| 2947 | using this API function. |
|---|
| 2948 | |
|---|
| 2949 | In order to perform a DMA transfer, user first creates a transfer handle, |
|---|
| 2950 | then uses it to set blocks info, to start the DMA transfer, and finally |
|---|
| 2951 | to get the transfer status. This API function is used to start a DMA |
|---|
| 2952 | transfer, and to register a call back function to be called when the |
|---|
| 2953 | transfer finishes. |
|---|
| 2954 | |
|---|
| 2955 | It takes, as input parameters, hTran to specify the transfer to start, |
|---|
| 2956 | a call back function pointer, and a user data buffer pointer. Then the |
|---|
| 2957 | call back function will be called by the "DMA done" interrupt handler |
|---|
| 2958 | of the module, when the transfer finishes. |
|---|
| 2959 | |
|---|
| 2960 | The call back function is ideally coded by the user. It should take three |
|---|
| 2961 | parameters. One is the "user data buffer pointer", passed to this API |
|---|
| 2962 | function. It is for user to pass user defined data structure to the call |
|---|
| 2963 | back function, in order to process the "done info". Another two are |
|---|
| 2964 | transfer handle hTran and eStatus, which are provided by the DMA module |
|---|
| 2965 | and are used to specify which transfer just finished and its status. |
|---|
| 2966 | Notice that it is possible to queue several transfers in memory DMA |
|---|
| 2967 | engine. |
|---|
| 2968 | |
|---|
| 2969 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 2970 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 2971 | |
|---|
| 2972 | Input: |
|---|
| 2973 | hTran - The transfer handle to start. |
|---|
| 2974 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 2975 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 2976 | |
|---|
| 2977 | Output: |
|---|
| 2978 | |
|---|
| 2979 | Returns: |
|---|
| 2980 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 2981 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 2982 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 2983 | |
|---|
| 2984 | See Also: |
|---|
| 2985 | BDMA_Mem_Tran_Create, BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 2986 | BDMA_Mem_Tran_GetStatus |
|---|
| 2987 | BDMA_Mem_Tran_Start |
|---|
| 2988 | BDMA_Mem_Tran_StartAndCallBack_isr |
|---|
| 2989 | ****************************************************************************/ |
|---|
| 2990 | BERR_Code BDMA_Mem_Tran_StartAndCallBack( |
|---|
| 2991 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 2992 | BDMA_Mem_CallbackFunc pDoneCallBack_isr, |
|---|
| 2993 | void * pUserCallBackParam ); |
|---|
| 2994 | |
|---|
| 2995 | /*************************************************************************** |
|---|
| 2996 | Summary: |
|---|
| 2997 | Create a transfer handle. |
|---|
| 2998 | |
|---|
| 2999 | Description: |
|---|
| 3000 | This API function is replaced by BDMA_Mem_Tran_Create2_isr and will be |
|---|
| 3001 | obsolete in the future. New code should use the new one and stop using |
|---|
| 3002 | this API function. |
|---|
| 3003 | |
|---|
| 3004 | This is the "_isr" version of BDMA_Mem_Tran_Create. It is used in |
|---|
| 3005 | interrupt handler or critical session. For more description refer to |
|---|
| 3006 | BDMA_Mem_Tran_Create. |
|---|
| 3007 | |
|---|
| 3008 | Input: |
|---|
| 3009 | hMemDma - Sub-module handle to the memory DMA engine to perform the DMA |
|---|
| 3010 | transfer. |
|---|
| 3011 | ulNumBlocks - Number of blocks in this transfer. |
|---|
| 3012 | |
|---|
| 3013 | Output: |
|---|
| 3014 | phTran - The transfer handle created. |
|---|
| 3015 | |
|---|
| 3016 | Returns: |
|---|
| 3017 | BERR_SUCCESS - The transfer handle is created successfully. |
|---|
| 3018 | BDMA_ERR_SIZE_OUT_RANGE - ulNumBlocks is 0 or bigger than the allowed. |
|---|
| 3019 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3020 | |
|---|
| 3021 | See Also: |
|---|
| 3022 | BDMA_Mem_Tran_GetMaxNumBlocks |
|---|
| 3023 | BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 3024 | BDMA_Mem_Tran_StartAndCallBack_isr |
|---|
| 3025 | BDMA_Mem_Tran_GetStatus_isr |
|---|
| 3026 | BDMA_Mem_Tran_Destroy_isr, BDMA_Mem_Tran_Reset_isr |
|---|
| 3027 | BDMA_Mem_Tran_Create |
|---|
| 3028 | ****************************************************************************/ |
|---|
| 3029 | BERR_Code BDMA_Mem_Tran_Create_isr( |
|---|
| 3030 | BDMA_Mem_Handle hMemDma, |
|---|
| 3031 | uint32_t ulNumBlocks, |
|---|
| 3032 | BDMA_Mem_Tran_Handle * phTran ); |
|---|
| 3033 | |
|---|
| 3034 | /*************************************************************************** |
|---|
| 3035 | Summary: |
|---|
| 3036 | Start a DMA transfer and register a call back function. |
|---|
| 3037 | |
|---|
| 3038 | Description: |
|---|
| 3039 | This API function is replaced by BDMA_Mem_Tran_StartDmaAndCallBack_isr and |
|---|
| 3040 | will be obsolete in the future. New code should use the new one and stop |
|---|
| 3041 | using this API function. |
|---|
| 3042 | |
|---|
| 3043 | This is the "_isr" version of BDMA_Mem_Tran_StartAndCallBack. It is used |
|---|
| 3044 | in interrupt handler or critical session. For more description refer to |
|---|
| 3045 | BDMA_Mem_Tran_StartAndCallBack. |
|---|
| 3046 | |
|---|
| 3047 | Input: |
|---|
| 3048 | hTran - The transfer handle to start. |
|---|
| 3049 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 3050 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 3051 | |
|---|
| 3052 | Output: |
|---|
| 3053 | |
|---|
| 3054 | Returns: |
|---|
| 3055 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 3056 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 3057 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3058 | |
|---|
| 3059 | See Also: |
|---|
| 3060 | BDMA_Mem_Tran_Create_isr, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 3061 | BDMA_Mem_Tran_GetStatus_isr |
|---|
| 3062 | BDMA_Mem_Tran_StartAndCallBack |
|---|
| 3063 | ****************************************************************************/ |
|---|
| 3064 | BERR_Code BDMA_Mem_Tran_StartAndCallBack_isr( |
|---|
| 3065 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 3066 | BDMA_Mem_CallbackFunc pDoneCallBack_isr, |
|---|
| 3067 | void * pUserCallBackParam ); |
|---|
| 3068 | |
|---|
| 3069 | /*************************************************************************** |
|---|
| 3070 | Summary: |
|---|
| 3071 | Start a DMA transfer and register a call back function. |
|---|
| 3072 | |
|---|
| 3073 | Description: |
|---|
| 3074 | This function is obsolete. |
|---|
| 3075 | |
|---|
| 3076 | Calling this function is the same as calling BDMA_Mem_Tran_Reset(), |
|---|
| 3077 | BDMA_Mem_Tran_SetDmaBlockInfo(), and BDMA_Mem_Tran_StartAndCallBack() |
|---|
| 3078 | in one call. The callback parameters can be set to null if there is |
|---|
| 3079 | no callback function. |
|---|
| 3080 | |
|---|
| 3081 | Input: |
|---|
| 3082 | hTran - The transfer handle to start. |
|---|
| 3083 | ulBlockId - The block index in the block list of this transfer, it starts |
|---|
| 3084 | from 0. |
|---|
| 3085 | ulDstBusAddr - Destination address in memory bus address space. |
|---|
| 3086 | ulSrcBusAddr - Source address in memory bus address space. |
|---|
| 3087 | ulBlockSize - This block size in bytes. |
|---|
| 3088 | bCryptInit - Whether initialize the encryption / decryption or continue |
|---|
| 3089 | the encryption / decryption from previous block. |
|---|
| 3090 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 3091 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 3092 | |
|---|
| 3093 | Output: |
|---|
| 3094 | |
|---|
| 3095 | Returns: |
|---|
| 3096 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 3097 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 3098 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3099 | |
|---|
| 3100 | See Also: |
|---|
| 3101 | BDMA_Mem_Tran_Create, BDMA_Mem_Tran_SetDmaBlockInfo |
|---|
| 3102 | BDMA_Mem_Tran_GetStatus |
|---|
| 3103 | BDMA_Mem_Tran_Start |
|---|
| 3104 | BDMA_Mem_Tran_StartAndCallBack |
|---|
| 3105 | ****************************************************************************/ |
|---|
| 3106 | BERR_Code BDMA_Mem_Transfer( |
|---|
| 3107 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 3108 | uint32_t ulBlockId, |
|---|
| 3109 | uint32_t ulDstBusAddr, |
|---|
| 3110 | uint32_t ulSrcBusAddr, |
|---|
| 3111 | uint32_t ulBlockSize, |
|---|
| 3112 | bool bCryptInit, |
|---|
| 3113 | BDMA_Mem_CallbackFunc pDoneCallBack_isr, |
|---|
| 3114 | void * pUserCallBackParam ); |
|---|
| 3115 | |
|---|
| 3116 | /*************************************************************************** |
|---|
| 3117 | * Obsolete PCI Dma API: |
|---|
| 3118 | **************************************************************************/ |
|---|
| 3119 | |
|---|
| 3120 | /*************************************************************************** |
|---|
| 3121 | Summary: |
|---|
| 3122 | Creates a sub-module handle to PCI DMA engine. |
|---|
| 3123 | |
|---|
| 3124 | Description: |
|---|
| 3125 | This API function is replaced by BDMA_Pci_Create2 and will be obsolete |
|---|
| 3126 | in the future. New code should use the new one and stop using this API |
|---|
| 3127 | function. |
|---|
| 3128 | |
|---|
| 3129 | Once created, the handle to the unique PCI DMA engine is required |
|---|
| 3130 | by PCI DMA sub-module functions in order to configure the DMA engine |
|---|
| 3131 | and perform DMA transfer. |
|---|
| 3132 | |
|---|
| 3133 | If the sub-module handle has already been created with the same hDma, |
|---|
| 3134 | error is returned. This function also initializes the sub-module to |
|---|
| 3135 | default configure. |
|---|
| 3136 | |
|---|
| 3137 | Refer to BDMA_Pci_Handle description for detailed usage info. |
|---|
| 3138 | |
|---|
| 3139 | Input: |
|---|
| 3140 | hDma - Handle to the BDMA module. |
|---|
| 3141 | |
|---|
| 3142 | Output: |
|---|
| 3143 | phPciDma - The created PCI DMA sub-module handle. If failure |
|---|
| 3144 | occurred phPciDma will holds NULL. |
|---|
| 3145 | |
|---|
| 3146 | Returns: |
|---|
| 3147 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 3148 | BERR_SUCCESS - Successfully created the handle. |
|---|
| 3149 | |
|---|
| 3150 | See Also: |
|---|
| 3151 | BDMA_Pci_Destroy |
|---|
| 3152 | **************************************************************************/ |
|---|
| 3153 | BERR_Code BDMA_Pci_Create( |
|---|
| 3154 | BDMA_Handle hDma, |
|---|
| 3155 | BDMA_Pci_Handle * phPciDma ); |
|---|
| 3156 | |
|---|
| 3157 | /*************************************************************************** |
|---|
| 3158 | Summary: |
|---|
| 3159 | Query the max number of blocks allowed in a transfer. |
|---|
| 3160 | |
|---|
| 3161 | Description: |
|---|
| 3162 | This API function is obsolete. |
|---|
| 3163 | |
|---|
| 3164 | User can transfer a list of contiguous data blocks in one transfer. This |
|---|
| 3165 | API function is used to query the max number of blocks allowed in one |
|---|
| 3166 | transfer. |
|---|
| 3167 | |
|---|
| 3168 | Input: |
|---|
| 3169 | hPciDma - Sub-module handle to the PCI DMA engine to perform DMA |
|---|
| 3170 | transfers. |
|---|
| 3171 | |
|---|
| 3172 | Output: |
|---|
| 3173 | pulMaxNumBlocks - Max number of blocks allowed in one transfer by the |
|---|
| 3174 | PCI DMA engine. |
|---|
| 3175 | |
|---|
| 3176 | Returns: |
|---|
| 3177 | BERR_SUCCESS - Got the max number successfully. |
|---|
| 3178 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3179 | |
|---|
| 3180 | See Also: |
|---|
| 3181 | BDMA_Pci_Tran_Create, BDMA_Pci_Tran_Create_isr |
|---|
| 3182 | ****************************************************************************/ |
|---|
| 3183 | BERR_Code BDMA_Pci_Tran_GetMaxNumBlocks( |
|---|
| 3184 | BDMA_Pci_Handle hPciDma, |
|---|
| 3185 | uint32_t * pulMaxNumBlocks ); |
|---|
| 3186 | |
|---|
| 3187 | /*************************************************************************** |
|---|
| 3188 | Summary: |
|---|
| 3189 | Create a transfer handle. |
|---|
| 3190 | |
|---|
| 3191 | Description: |
|---|
| 3192 | This API function is replaced by BDMA_Pci_Tran_Create2 and will be |
|---|
| 3193 | obsolete in the future. New code should use the new one and stop |
|---|
| 3194 | using this API function. |
|---|
| 3195 | |
|---|
| 3196 | In order to perform DMA transfer with PCI DMA engine, user needs to |
|---|
| 3197 | first create a transfer handle, then to use it to set each block info, |
|---|
| 3198 | to start the DMA transfer, and finally to get the transfer status. |
|---|
| 3199 | This API function is used to create the transfer handle. |
|---|
| 3200 | |
|---|
| 3201 | BDMA_Pci_Tran_Create takes an input parameter ulNumBlocks, to |
|---|
| 3202 | specify the number of contiguous data blocks this transfer is to |
|---|
| 3203 | transfer. The max number of blocks allowed could be queried with |
|---|
| 3204 | BDMA_Pci_Tran_GetMaxNumBlocks. It is likely close to 128. |
|---|
| 3205 | |
|---|
| 3206 | A transfer handle could be reused after it is started and finished, and |
|---|
| 3207 | a transfer handle has to be explicitly destroyed when it is no longer |
|---|
| 3208 | needed. |
|---|
| 3209 | |
|---|
| 3210 | Please refer to the DMA module overview and BDMA_Pci_Handle for more |
|---|
| 3211 | info on the usage of the PCI DMA sub-module API functions. |
|---|
| 3212 | |
|---|
| 3213 | Input: |
|---|
| 3214 | hPciDma - Sub-module handle to the PCI DMA engine to perform the DMA |
|---|
| 3215 | transfer. |
|---|
| 3216 | ulNumBlocks - Number of blocks in this transfer. |
|---|
| 3217 | |
|---|
| 3218 | Output: |
|---|
| 3219 | phTran - The transfer handle created. |
|---|
| 3220 | |
|---|
| 3221 | Returns: |
|---|
| 3222 | BERR_SUCCESS - The transfer handle is created successfully. |
|---|
| 3223 | BDMA_ERR_SIZE_OUT_RANGE - ulNumBlocks is 0 or bigger than the allowed. |
|---|
| 3224 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3225 | |
|---|
| 3226 | See Also: |
|---|
| 3227 | BDMA_Pci_Tran_GetMaxNumBlocks |
|---|
| 3228 | BDMA_Pci_Tran_SetBlockInfo |
|---|
| 3229 | BDMA_Pci_Tran_Start, BDMA_Pci_Tran_StartAndCallBack |
|---|
| 3230 | BDMA_Pci_Tran_GetStatus |
|---|
| 3231 | BDMA_Pci_Tran_Destroy, BDMA_Pci_Tran_Reset |
|---|
| 3232 | BDMA_Pci_Tran_Create_isr |
|---|
| 3233 | ****************************************************************************/ |
|---|
| 3234 | BERR_Code BDMA_Pci_Tran_Create( |
|---|
| 3235 | BDMA_Pci_Handle hPciDma, |
|---|
| 3236 | uint32_t ulNumBlocks, |
|---|
| 3237 | BDMA_Pci_Tran_Handle * phTran ); |
|---|
| 3238 | |
|---|
| 3239 | /*************************************************************************** |
|---|
| 3240 | Summary: |
|---|
| 3241 | Start a DMA transfer. |
|---|
| 3242 | |
|---|
| 3243 | Description: |
|---|
| 3244 | This API function is replaced by BDMA_Pci_Tran_StartDma and will be |
|---|
| 3245 | obsolete in the future. New code should use the new one and stop |
|---|
| 3246 | using this API function. |
|---|
| 3247 | |
|---|
| 3248 | In order to perform a DMA transfer, user needs to first create a transfer |
|---|
| 3249 | handle, then to use it to set each block info, to start the DMA transfer, |
|---|
| 3250 | and finally to get the transfer status. This API function is used to start |
|---|
| 3251 | a DMA transfer. |
|---|
| 3252 | |
|---|
| 3253 | As starting a transfer with this API function, user needs to implement a |
|---|
| 3254 | status checking and sleeping loop, to wait for the completion of the |
|---|
| 3255 | DMA transfer, and then to process the "done" info. |
|---|
| 3256 | |
|---|
| 3257 | BDMA_Pci_Tran_Start takes, as an input parameter, hTran to specify the |
|---|
| 3258 | transfer to start. |
|---|
| 3259 | |
|---|
| 3260 | The current state of max burst size is used during the transfer. |
|---|
| 3261 | |
|---|
| 3262 | Please refer to the DMA module overview and BDMA_Pci_Handle for more |
|---|
| 3263 | info on the usage of the PCI DMA sub-module API functions. |
|---|
| 3264 | |
|---|
| 3265 | Input: |
|---|
| 3266 | hTran - The transfer handle to start. |
|---|
| 3267 | |
|---|
| 3268 | Output: |
|---|
| 3269 | |
|---|
| 3270 | Returns: |
|---|
| 3271 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 3272 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3273 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 3274 | BDMA_ERR_ENGINE_BUSY - The engine is busy. |
|---|
| 3275 | |
|---|
| 3276 | See Also: |
|---|
| 3277 | BDMA_Pci_Tran_Create, BDMA_Pci_Tran_SetBlockInfo |
|---|
| 3278 | BDMA_Pci_Tran_GetStatus |
|---|
| 3279 | BDMA_Pci_SetMaxBurstSize |
|---|
| 3280 | BDMA_Pci_Tran_StartAndCallBack |
|---|
| 3281 | ****************************************************************************/ |
|---|
| 3282 | BERR_Code BDMA_Pci_Tran_Start( |
|---|
| 3283 | BDMA_Pci_Tran_Handle hTran ); |
|---|
| 3284 | |
|---|
| 3285 | /*************************************************************************** |
|---|
| 3286 | Summary: |
|---|
| 3287 | Start a DMA transfer and register a call back function. |
|---|
| 3288 | |
|---|
| 3289 | Description: |
|---|
| 3290 | This API function is replaced by BDMA_Pci_Tran_StartDmaAndCallBack |
|---|
| 3291 | and will be obsolete in the future. New code should use the new one |
|---|
| 3292 | and stop using this API function. |
|---|
| 3293 | |
|---|
| 3294 | In order to perform a DMA transfer, user first creates a transfer handle, |
|---|
| 3295 | then uses it to set block info for each block, to start the DMA transfer, |
|---|
| 3296 | and finally to get the transfer status. This API function is used to start |
|---|
| 3297 | a DMA transfer, and to register a call back function to be called when |
|---|
| 3298 | the transfer finishes. |
|---|
| 3299 | |
|---|
| 3300 | It takes, as input parameters, hTran to specify the transfer to start, |
|---|
| 3301 | a call back function pointer, and a user data buffer pointer. Then the |
|---|
| 3302 | call back function will be called by the "DMA done" interrupt handler |
|---|
| 3303 | of the module, when the transfer finishes. |
|---|
| 3304 | |
|---|
| 3305 | As asynchronous call back is used, it is possible to dynamically link |
|---|
| 3306 | several tran requests in a DMA engine, some linked tran's done call back |
|---|
| 3307 | might be lost. However, the last one is guaranteed, and it also indicates |
|---|
| 3308 | that all trans before this one have also finished. |
|---|
| 3309 | |
|---|
| 3310 | The call back function is ideally coded by the user. It should take three |
|---|
| 3311 | parameters. One is the "user data buffer pointer", passed to this API |
|---|
| 3312 | function. It is for user to pass user defined data structure to the call |
|---|
| 3313 | back function, in order to process the "done info". Another two are |
|---|
| 3314 | transfer handle hTran and eStatus, which are provided by the DMA module |
|---|
| 3315 | and are used to specify which transfer just finished and its status. |
|---|
| 3316 | Notice that as asynchronous call back is used, it is possible to queue |
|---|
| 3317 | several transfers in PCI DMA engine. |
|---|
| 3318 | |
|---|
| 3319 | The current state of max burst size is used during the transfer. |
|---|
| 3320 | |
|---|
| 3321 | Please refer to the DMA module overview and BDMA_Pci_Handle for more |
|---|
| 3322 | info on the usage of the PCI DMA sub-module API functions. |
|---|
| 3323 | |
|---|
| 3324 | Input: |
|---|
| 3325 | hTran - The transfer handle to start. |
|---|
| 3326 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 3327 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 3328 | |
|---|
| 3329 | Output: |
|---|
| 3330 | |
|---|
| 3331 | Returns: |
|---|
| 3332 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 3333 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 3334 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3335 | |
|---|
| 3336 | See Also: |
|---|
| 3337 | BDMA_Pci_Tran_Create, BDMA_Pci_Tran_SetBlockInfo |
|---|
| 3338 | BDMA_Pci_Tran_GetStatus |
|---|
| 3339 | BDMA_Pci_SetMaxBurstSize |
|---|
| 3340 | BDMA_Pci_Tran_Start |
|---|
| 3341 | BDMA_Pci_Tran_StartAndCallBack_isr |
|---|
| 3342 | ****************************************************************************/ |
|---|
| 3343 | BERR_Code BDMA_Pci_Tran_StartAndCallBack( |
|---|
| 3344 | BDMA_Pci_Tran_Handle hTran, |
|---|
| 3345 | BDMA_Pci_CallbackFunc pDoneCallBack_isr, |
|---|
| 3346 | void * pUserCallBackParam ); |
|---|
| 3347 | |
|---|
| 3348 | /*************************************************************************** |
|---|
| 3349 | Summary: |
|---|
| 3350 | Create a transfer handle. |
|---|
| 3351 | |
|---|
| 3352 | Description: |
|---|
| 3353 | This API function is replaced by BDMA_Pci_Tran_Create2_isr and will |
|---|
| 3354 | be obsolete in the future. New code should use the new one and stop |
|---|
| 3355 | using this API function. |
|---|
| 3356 | |
|---|
| 3357 | This is the "_isr" version of BDMA_Pci_Tran_Create. It is used in |
|---|
| 3358 | interrupt handler or critical session. For more description refer to |
|---|
| 3359 | BDMA_Pci_Tran_Create. |
|---|
| 3360 | |
|---|
| 3361 | Input: |
|---|
| 3362 | hPciDma - Sub-module handle to the PCI DMA engine to perform the DMA |
|---|
| 3363 | transfer. |
|---|
| 3364 | ulNumBlocks - Number of blocks in this transfer. |
|---|
| 3365 | |
|---|
| 3366 | Output: |
|---|
| 3367 | phTran - The transfer handle created. |
|---|
| 3368 | |
|---|
| 3369 | Returns: |
|---|
| 3370 | BERR_SUCCESS - The transfer handle is created successfully. |
|---|
| 3371 | BDMA_ERR_SIZE_OUT_RANGE - ulNumBlocks is 0 or bigger than the allowed. |
|---|
| 3372 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3373 | |
|---|
| 3374 | See Also: |
|---|
| 3375 | BDMA_Pci_Tran_GetMaxNumBlocks |
|---|
| 3376 | BDMA_Pci_Tran_SetBlockInfo_isr |
|---|
| 3377 | BDMA_Pci_Tran_StartAndCallBack_isr |
|---|
| 3378 | BDMA_Pci_Tran_GetStatus_isr |
|---|
| 3379 | BDMA_Pci_Tran_Destroy_isr, BDMA_Pci_Tran_Reset_isr |
|---|
| 3380 | BDMA_Pci_Tran_Create |
|---|
| 3381 | ****************************************************************************/ |
|---|
| 3382 | BERR_Code BDMA_Pci_Tran_Create_isr( |
|---|
| 3383 | BDMA_Pci_Handle hPciDma, |
|---|
| 3384 | uint32_t ulNumBlocks, |
|---|
| 3385 | BDMA_Pci_Tran_Handle * phTran ); |
|---|
| 3386 | |
|---|
| 3387 | /*************************************************************************** |
|---|
| 3388 | Summary: |
|---|
| 3389 | Start a DMA transfer and register a call back function. |
|---|
| 3390 | |
|---|
| 3391 | Description: |
|---|
| 3392 | This API function is replaced by BDMA_Pci_Tran_StartDmaAndCallBack_isr |
|---|
| 3393 | and will be obsolete in the future. New code should use the new one |
|---|
| 3394 | and stop using this API function. |
|---|
| 3395 | |
|---|
| 3396 | This is the "_isr" version of BDMA_Pci_Tran_StartAndCallBack. It is used |
|---|
| 3397 | in interrupt handler or critical session. For more description refer to |
|---|
| 3398 | BDMA_Pci_Tran_StartAndCallBack. |
|---|
| 3399 | |
|---|
| 3400 | Input: |
|---|
| 3401 | hTran - The transfer handle to start. |
|---|
| 3402 | pDoneCallBack_isr - Call back function used when the transfer finishes. |
|---|
| 3403 | pUserCallBackParam - User's data passed to the call back function. |
|---|
| 3404 | |
|---|
| 3405 | Output: |
|---|
| 3406 | |
|---|
| 3407 | Returns: |
|---|
| 3408 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 3409 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 3410 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3411 | |
|---|
| 3412 | See Also: |
|---|
| 3413 | BDMA_Pci_Tran_Create_isr, BDMA_Pci_Tran_SetBlockInfo_isr |
|---|
| 3414 | BDMA_Pci_Tran_GetStatus_isr |
|---|
| 3415 | BDMA_Pci_Tran_StartAndCallBack |
|---|
| 3416 | ****************************************************************************/ |
|---|
| 3417 | BERR_Code BDMA_Pci_Tran_StartAndCallBack_isr( |
|---|
| 3418 | BDMA_Pci_Tran_Handle hTran, |
|---|
| 3419 | BDMA_Pci_CallbackFunc pDoneCallBack_isr, |
|---|
| 3420 | void * pUserCallBackParam ); |
|---|
| 3421 | |
|---|
| 3422 | typedef enum BDMA_Sharf |
|---|
| 3423 | { |
|---|
| 3424 | BDMA_Sharf_e0, /* sharf memory dma engine 0 */ |
|---|
| 3425 | BDMA_Sharf_e1, /* sharf memory dma engine 1 */ |
|---|
| 3426 | BDMA_Sharf_eInvalid |
|---|
| 3427 | } |
|---|
| 3428 | BDMA_Sharf; |
|---|
| 3429 | |
|---|
| 3430 | /*************************************************************************** |
|---|
| 3431 | Summary: |
|---|
| 3432 | Creates a sub-module handle to sharf memory DMA engine. |
|---|
| 3433 | |
|---|
| 3434 | Description: |
|---|
| 3435 | Once created, the handle to the unique memory DMA engine is required by |
|---|
| 3436 | sharf memory DMA sub-module functions in order to configure the DMA engine |
|---|
| 3437 | and perform DMA transfer. |
|---|
| 3438 | |
|---|
| 3439 | This function also initializes the sub-module to default configure. |
|---|
| 3440 | |
|---|
| 3441 | Refer to BDMA_Mem_Handle and BDMA_Mem_Create2 description for detailed |
|---|
| 3442 | usage info. |
|---|
| 3443 | |
|---|
| 3444 | Input: |
|---|
| 3445 | hDma - Handle to the BDMA module. |
|---|
| 3446 | eEngine - The enum to identify the HW sharf memory dma engine. |
|---|
| 3447 | |
|---|
| 3448 | Output: |
|---|
| 3449 | phMemDma - The created memory DMA sub-module handle. If failure |
|---|
| 3450 | occurred phMemDma will holds NULL. |
|---|
| 3451 | |
|---|
| 3452 | Returns: |
|---|
| 3453 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 3454 | BERR_SUCCESS - Successfully created the handle. |
|---|
| 3455 | |
|---|
| 3456 | See Also: |
|---|
| 3457 | BDMA_Mem_sharf_Destroy |
|---|
| 3458 | **************************************************************************/ |
|---|
| 3459 | BERR_Code BDMA_Mem_Sharf_Create( |
|---|
| 3460 | BDMA_Handle hDma, |
|---|
| 3461 | BDMA_Sharf eEngine, |
|---|
| 3462 | BDMA_Mem_Settings * pSettings, |
|---|
| 3463 | BDMA_Mem_Handle * phMemDma ); |
|---|
| 3464 | |
|---|
| 3465 | |
|---|
| 3466 | /*************************************************************************** |
|---|
| 3467 | Summary: |
|---|
| 3468 | Destroys the sub-module handle of the memory DMA engine. |
|---|
| 3469 | |
|---|
| 3470 | Description: |
|---|
| 3471 | Once this function is called the sub-module handle can no longer be |
|---|
| 3472 | used. |
|---|
| 3473 | |
|---|
| 3474 | Memory DMA engine sub-module handle should be destroyed before closing |
|---|
| 3475 | the main module handle BDMA_Handle by BDMA_Close. |
|---|
| 3476 | |
|---|
| 3477 | Input: |
|---|
| 3478 | hMemDma - The memory DMA engine sub-module handle to destroy. |
|---|
| 3479 | |
|---|
| 3480 | Output: |
|---|
| 3481 | |
|---|
| 3482 | Returns: |
|---|
| 3483 | BERR_INVALID_PARAMETER - hMemDma is not a valid memory DMA engine |
|---|
| 3484 | sub-module handle. |
|---|
| 3485 | BERR_SUCCESS - Successfully destroyed |
|---|
| 3486 | |
|---|
| 3487 | See Also: |
|---|
| 3488 | BDMA_Mem_Sharf_Create |
|---|
| 3489 | **************************************************************************/ |
|---|
| 3490 | BERR_Code BDMA_Mem_Sharf_Destroy( |
|---|
| 3491 | BDMA_Mem_Handle hMemDma ); |
|---|
| 3492 | |
|---|
| 3493 | /*************************************************************************** |
|---|
| 3494 | Summary: |
|---|
| 3495 | This enumeration represents the possible SCRAM operations performed by |
|---|
| 3496 | sharf dma engines. |
|---|
| 3497 | |
|---|
| 3498 | Description: |
|---|
| 3499 | BDMA_SharfMode is an enumeration which represents the possible SCRAM |
|---|
| 3500 | operations performed by sharf dma engines. |
|---|
| 3501 | |
|---|
| 3502 | See Also: |
|---|
| 3503 | BDMA_Mem_Sharf_Tran_SetCrypto |
|---|
| 3504 | ***************************************************************************/ |
|---|
| 3505 | typedef enum BDMA_SharfMode |
|---|
| 3506 | { |
|---|
| 3507 | BDMA_SharfMode_ePassThrough, |
|---|
| 3508 | BDMA_SharfMode_eSha1, |
|---|
| 3509 | BDMA_SharfMode_eAes128CbcDecrypt, |
|---|
| 3510 | BDMA_SharfMode_eAes128CbcEncrypt, |
|---|
| 3511 | BDMA_SharfMode_eCmac, |
|---|
| 3512 | BDMA_SharfMode_eAes128EcbDecrypt, |
|---|
| 3513 | BDMA_SharfMode_eAes128EcbEncrypt, |
|---|
| 3514 | BDMA_SharfMode_eInvalid |
|---|
| 3515 | } |
|---|
| 3516 | BDMA_SharfMode; |
|---|
| 3517 | |
|---|
| 3518 | |
|---|
| 3519 | /*************************************************************************** |
|---|
| 3520 | Summary: |
|---|
| 3521 | Set sharf scram operation. |
|---|
| 3522 | |
|---|
| 3523 | Description: |
|---|
| 3524 | During a DMA data transfer, sharf memory DMA engines could be configured |
|---|
| 3525 | to perform different kind of SCRAM operations. |
|---|
| 3526 | |
|---|
| 3527 | In the case that eSharfMode is BDMA_SharfMode_ePassThrough, the data will |
|---|
| 3528 | pass through sharf without SCRAM operation. |
|---|
| 3529 | |
|---|
| 3530 | If eSharfMode has other valid value, the specified SCRAM is performed by |
|---|
| 3531 | sharf HW. |
|---|
| 3532 | |
|---|
| 3533 | Further, when scatter-gather mode is enabled by bSgEnable, the dma engine |
|---|
| 3534 | will treat the data stream section of a list of dma blocks as a whole for |
|---|
| 3535 | SCRAM purpose. The stream section starts from the beginning of the block |
|---|
| 3536 | marked as scatter-gather start point, and ends at the end of the block |
|---|
| 3537 | marked as scatter-gather end point. bSgEnable and eSharfMode can not |
|---|
| 3538 | change between the scatter-gather start point and end point. |
|---|
| 3539 | |
|---|
| 3540 | When bUseBspKey is false, sharf uses the key wrapped in the head of the |
|---|
| 3541 | scatter-gather data stream section, for the following data encrypt or |
|---|
| 3542 | decrypt. if bUseBspKey is true, sharf uses the key supplied by Aegis |
|---|
| 3543 | directly for data encrypt and decrypt, regardless of the state of key- |
|---|
| 3544 | present set with BDMA_Mem_Sharf_Tran_SetSgStartEnd. |
|---|
| 3545 | |
|---|
| 3546 | The sub-module maintains a current state of settings by this API function. |
|---|
| 3547 | Each setting modifies the current state and is applied to the future |
|---|
| 3548 | calls to BDMA_Mem_Tran_SetDmaBlockInfo(_isr), unless it is reset again. |
|---|
| 3549 | |
|---|
| 3550 | Input: |
|---|
| 3551 | hTran - The transfer handle to set crypto. |
|---|
| 3552 | BDMA_SharfMode - SCRAM operation mode. |
|---|
| 3553 | bSgEnable - Whether enable scatter-gather SCRAM operation. |
|---|
| 3554 | bUseBspKey - If it is true, sharf uses the key supplied by Aegis directly |
|---|
| 3555 | (regardless of what BDMA_Mem_Sharf_Tran_SetSgStartEnd sets for key-present). |
|---|
| 3556 | bCmp8LstByts - If it is true, sharf will use only the 8 least significant |
|---|
| 3557 | bytes for digest comparing. |
|---|
| 3558 | Output: |
|---|
| 3559 | |
|---|
| 3560 | Returns: |
|---|
| 3561 | BERR_SUCCESS - crypto setting is set successfully. |
|---|
| 3562 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3563 | |
|---|
| 3564 | See Also: |
|---|
| 3565 | BDMA_Mem_Sharf_Tran_SetSgStartEnd, BDMA_Mem_Sharf_Tran_SetSgStartEnd_isr, |
|---|
| 3566 | BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 3567 | ****************************************************************************/ |
|---|
| 3568 | BERR_Code BDMA_Mem_Sharf_Tran_SetCrypto( |
|---|
| 3569 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 3570 | BDMA_SharfMode eSharfMode, |
|---|
| 3571 | bool bSgEnable, |
|---|
| 3572 | bool bUseBspKey, |
|---|
| 3573 | bool bCmp8LstByts); |
|---|
| 3574 | |
|---|
| 3575 | /*************************************************************************** |
|---|
| 3576 | Summary: |
|---|
| 3577 | Set the start point and/or end point of scatter-gather. |
|---|
| 3578 | |
|---|
| 3579 | Description: |
|---|
| 3580 | When SCRAM operation and scatter-gather mode are enabled, the sharf dma |
|---|
| 3581 | engine will treat the data stream section of a list of dma blocks as a |
|---|
| 3582 | whole for SCRAM purpose. The stream section starts from the beginning of |
|---|
| 3583 | the block marked as scatter-gather start point, and ends at the end of |
|---|
| 3584 | the block marked as scatter-gather end point. |
|---|
| 3585 | |
|---|
| 3586 | This API function is used to mark the block with ID ulBlockId as scatter- |
|---|
| 3587 | gather start and/or end point. It can also mark whether crypto key and/or |
|---|
| 3588 | digest/MAC reference value is prepended into the data transferred by dma. |
|---|
| 3589 | |
|---|
| 3590 | Input: |
|---|
| 3591 | hTran - The transfer handle to set block info. |
|---|
| 3592 | ulBlockId - The block index in the block list of this transfer, it starts |
|---|
| 3593 | from 0. |
|---|
| 3594 | bStartSgScram - Whether this block is a scatter-gather start point. |
|---|
| 3595 | bEndSgScram - Whether this block is a scatter-gather end point. |
|---|
| 3596 | bKeyPresent - Whether crypto key is prepended into the data stream. |
|---|
| 3597 | bDigestPresent - Whether digest reference value is prepended into the data |
|---|
| 3598 | stream. |
|---|
| 3599 | Output: |
|---|
| 3600 | |
|---|
| 3601 | Returns: |
|---|
| 3602 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 3603 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3604 | |
|---|
| 3605 | See Also: |
|---|
| 3606 | BDMA_Mem_Sharf_Tran_SetCrypto, BDMA_Mem_Tran_SetDmaBlockInfo, |
|---|
| 3607 | BDMA_Mem_Sharf_Tran_SetSgStartEnd_isr |
|---|
| 3608 | ****************************************************************************/ |
|---|
| 3609 | BERR_Code BDMA_Mem_Sharf_Tran_SetSgStartEnd( |
|---|
| 3610 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 3611 | uint32_t ulBlockId, |
|---|
| 3612 | bool bStartSgScram, |
|---|
| 3613 | bool bEndSgScram, |
|---|
| 3614 | bool bKeyPresent, |
|---|
| 3615 | bool bDigestPresent ); |
|---|
| 3616 | |
|---|
| 3617 | /*************************************************************************** |
|---|
| 3618 | Summary: |
|---|
| 3619 | This enumeration represents the contexts sharf support. |
|---|
| 3620 | |
|---|
| 3621 | Description: |
|---|
| 3622 | BDMA_Context is an enumeration which represents the contexts sharf support. |
|---|
| 3623 | |
|---|
| 3624 | See Also: |
|---|
| 3625 | BDMA_Mem_Sharf_Tran_SetDmaBlockInfo, BDMA_Mem_Sharf_Tran_SetDmaBlockInfo_isr |
|---|
| 3626 | ***************************************************************************/ |
|---|
| 3627 | typedef enum BDMA_Context |
|---|
| 3628 | { |
|---|
| 3629 | BDMA_Context_eSha0, /* context 0 for sha op */ |
|---|
| 3630 | BDMA_Context_eSha1, /* context 1 for sha op */ |
|---|
| 3631 | BDMA_Context_eSha2, /* context 2 for sha op */ |
|---|
| 3632 | BDMA_Context_eAesOrCmac, /* context for AES or CMAC */ |
|---|
| 3633 | BDMA_Context_eInvalid |
|---|
| 3634 | } |
|---|
| 3635 | BDMA_Context; |
|---|
| 3636 | |
|---|
| 3637 | /*************************************************************************** |
|---|
| 3638 | Summary: |
|---|
| 3639 | Set the block info for one block of a DMA transfer. |
|---|
| 3640 | |
|---|
| 3641 | Description: |
|---|
| 3642 | In order to perform a DMA transfer, user first creates a transfer handle, |
|---|
| 3643 | then uses it to set block info for each block, to start the DMA transfer, |
|---|
| 3644 | and finally to get the transfer status. This API function is used to set |
|---|
| 3645 | block info for one block. |
|---|
| 3646 | |
|---|
| 3647 | ulBlockId is the index of the block, in the block list of the transfer |
|---|
| 3648 | represented by hTran. It starts from 0. eContext is the context number |
|---|
| 3649 | this block belongs to. |
|---|
| 3650 | |
|---|
| 3651 | The source and destination address are in memory bus address space. They |
|---|
| 3652 | are 28 bits unsigned integer number in 7038 chip. It is more likely that |
|---|
| 3653 | they are converted from virtual memory mapped address using |
|---|
| 3654 | BMEM_ConvertAddressToOffset and the virtual address is returned by |
|---|
| 3655 | BMEM_AllocAligned or BMEM_Alloc. |
|---|
| 3656 | |
|---|
| 3657 | Both addresses and block size are byte aligned. Max block size is |
|---|
| 3658 | 0xfff,ffff (16 MByte). Source and destination region overlap with |
|---|
| 3659 | (ulSrcBusAddr < ulDstBusAddr < ulSrcBusAddr+ulBlockSize) is not allowed. |
|---|
| 3660 | |
|---|
| 3661 | Encryption and decryption algorithms typically work on memory size of |
|---|
| 3662 | multiple 8 bytes or 16 bytes, and certain residue mode clear termination |
|---|
| 3663 | or OFB, might be used for the remaining bytes in the block. |
|---|
| 3664 | |
|---|
| 3665 | Please notice that when a non-word-aligned source address is used, the |
|---|
| 3666 | read endian determine which bytes to read in a 32 bits word. |
|---|
| 3667 | |
|---|
| 3668 | The current state of read endian, swap mode and encrypt / decrypt setting |
|---|
| 3669 | is used during the transfer of this block. |
|---|
| 3670 | |
|---|
| 3671 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 3672 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 3673 | |
|---|
| 3674 | Input: |
|---|
| 3675 | hTran - The transfer handle to set block info. |
|---|
| 3676 | ulBlockId - The block index in the block list of this transfer, it starts |
|---|
| 3677 | from 0. |
|---|
| 3678 | eContext - The context number this block belongs to. |
|---|
| 3679 | ulDstBusAddr - Destination address in memory bus address space. |
|---|
| 3680 | ulSrcBusAddr - Source address in memory bus address space. |
|---|
| 3681 | ulBlockSize - This block size in bytes. |
|---|
| 3682 | |
|---|
| 3683 | Output: |
|---|
| 3684 | |
|---|
| 3685 | Returns: |
|---|
| 3686 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 3687 | BDMA_ERR_OVERLAP - Source and destination region overlap. |
|---|
| 3688 | BDMA_ERR_SIZE_OUT_RANGE - ulBlockSize is 0 or bigger than 16 MByte. |
|---|
| 3689 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3690 | |
|---|
| 3691 | See Also: |
|---|
| 3692 | BDMA_Mem_Tran_Create2 |
|---|
| 3693 | BDMA_Mem_Tran_Start, BDMA_Mem_Tran_StartAndCallBack |
|---|
| 3694 | BDMA_Mem_SetByteSwapMode, BDMA_Mem_SetCrypt |
|---|
| 3695 | BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 3696 | ****************************************************************************/ |
|---|
| 3697 | BERR_Code BDMA_Mem_Sharf_Tran_SetDmaBlockInfo( |
|---|
| 3698 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 3699 | uint32_t ulBlockId, |
|---|
| 3700 | BDMA_Context eContext, |
|---|
| 3701 | uint32_t ulDstBusAddr, |
|---|
| 3702 | uint32_t ulSrcBusAddr, |
|---|
| 3703 | uint32_t ulBlockSize ); |
|---|
| 3704 | |
|---|
| 3705 | /*************************************************************************** |
|---|
| 3706 | Summary: |
|---|
| 3707 | Set sharf scram operation. |
|---|
| 3708 | |
|---|
| 3709 | Description: |
|---|
| 3710 | This is the "_isr" version of BDMA_Mem_Sharf_Tran_SetCrypto. It is used |
|---|
| 3711 | in interrupt handler or critical session. For more description refer to |
|---|
| 3712 | BDMA_Mem_Sharf_Tran_SetCrypto. |
|---|
| 3713 | |
|---|
| 3714 | Input: |
|---|
| 3715 | hTran - The transfer handle to set crypto. |
|---|
| 3716 | BDMA_SharfMode - SCRAM operation mode. |
|---|
| 3717 | bSgEnable - Whether enable scatter-gather SCRAM operation. |
|---|
| 3718 | bUseBspKey - If it is true, sharf uses the key supplied by Aegis directly |
|---|
| 3719 | (regardless of what BDMA_Mem_Sharf_Tran_SetSgStartEnd sets for key-present). |
|---|
| 3720 | bCmp8LstByts - If it is true, sharf will use only the 8 least significant |
|---|
| 3721 | bytes for digest comparing. |
|---|
| 3722 | Output: |
|---|
| 3723 | |
|---|
| 3724 | Returns: |
|---|
| 3725 | BERR_SUCCESS - crypto setting is set successfully. |
|---|
| 3726 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3727 | |
|---|
| 3728 | See Also: |
|---|
| 3729 | BDMA_Mem_Sharf_Tran_SetCrypto, |
|---|
| 3730 | BDMA_Mem_Sharf_Tran_SetSgStartEnd, BDMA_Mem_Sharf_Tran_SetSgStartEnd_isr, |
|---|
| 3731 | BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 3732 | ****************************************************************************/ |
|---|
| 3733 | BERR_Code BDMA_Mem_Sharf_Tran_SetCrypto_isr( |
|---|
| 3734 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 3735 | BDMA_SharfMode eSharfMode, |
|---|
| 3736 | bool bSgEnable, |
|---|
| 3737 | bool bUseBspKey, |
|---|
| 3738 | bool bCmp8LstByts); |
|---|
| 3739 | |
|---|
| 3740 | /*************************************************************************** |
|---|
| 3741 | Summary: |
|---|
| 3742 | Set the start point and/or end point of scatter-gather. |
|---|
| 3743 | |
|---|
| 3744 | Description: |
|---|
| 3745 | This is the "_isr" version of BDMA_Mem_Sharf_Tran_SetSgStartEnd. It is |
|---|
| 3746 | used in interrupt handler or critical session. For more description refer |
|---|
| 3747 | to BDMA_Mem_Sharf_Tran_SetSgStartEnd. |
|---|
| 3748 | |
|---|
| 3749 | Input: |
|---|
| 3750 | hTran - The transfer handle to set block info. |
|---|
| 3751 | ulBlockId - The block index in the block list of this transfer, it starts |
|---|
| 3752 | from 0. |
|---|
| 3753 | bStartSgScram - Whether this block is a scatter-gather start point. |
|---|
| 3754 | bEndSgScram - Whether this block is a scatter-gather end point. |
|---|
| 3755 | bKeyPresent - Whether crypto key is prepended into the data stream. |
|---|
| 3756 | bDigestPresent - Whether digest reference value is prepended into the data |
|---|
| 3757 | stream. |
|---|
| 3758 | Output: |
|---|
| 3759 | |
|---|
| 3760 | Returns: |
|---|
| 3761 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 3762 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3763 | |
|---|
| 3764 | See Also: |
|---|
| 3765 | BDMA_Mem_Sharf_Tran_SetCrypto, BDMA_Mem_Tran_SetDmaBlockInfo_isr, |
|---|
| 3766 | BDMA_Mem_Sharf_Tran_SetSgStartEnd |
|---|
| 3767 | ****************************************************************************/ |
|---|
| 3768 | BERR_Code BDMA_Mem_Sharf_Tran_SetSgStartEnd_isr( |
|---|
| 3769 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 3770 | uint32_t ulBlockId, |
|---|
| 3771 | bool bStartSgScram, |
|---|
| 3772 | bool bEndSgScram, |
|---|
| 3773 | bool bKeyPresent, |
|---|
| 3774 | bool bDigestPresent ); |
|---|
| 3775 | |
|---|
| 3776 | /*************************************************************************** |
|---|
| 3777 | Summary: |
|---|
| 3778 | Set the block info for one block of a DMA transfer. |
|---|
| 3779 | |
|---|
| 3780 | Description: |
|---|
| 3781 | This is the "_isr" version of BDMA_Mem_Sharf_Tran_SetDmaBlockInfo. It is |
|---|
| 3782 | used in interrupt handler or critical session. For more description refer |
|---|
| 3783 | to BDMA_Mem_Sharf_Tran_SetDmaBlockInfo. |
|---|
| 3784 | |
|---|
| 3785 | Input: |
|---|
| 3786 | hTran - The transfer handle to set block info. |
|---|
| 3787 | ulBlockId - The block index in the block list of this transfer, it starts |
|---|
| 3788 | from 0. |
|---|
| 3789 | eContext - The context number this block belongs to. |
|---|
| 3790 | ulDstBusAddr - Destination address in memory bus address space. |
|---|
| 3791 | ulSrcBusAddr - Source address in memory bus address space. |
|---|
| 3792 | ulBlockSize - This block size in bytes. |
|---|
| 3793 | |
|---|
| 3794 | Output: |
|---|
| 3795 | |
|---|
| 3796 | Returns: |
|---|
| 3797 | BERR_SUCCESS - The block info is set successfully. |
|---|
| 3798 | BDMA_ERR_OVERLAP - Source and destination region overlap. |
|---|
| 3799 | BDMA_ERR_SIZE_OUT_RANGE - ulBlockSize is 0 or bigger than 16 MByte. |
|---|
| 3800 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3801 | |
|---|
| 3802 | See Also: |
|---|
| 3803 | BDMA_Mem_Tran_Create2 |
|---|
| 3804 | BDMA_Mem_Tran_Start, BDMA_Mem_Tran_StartAndCallBack |
|---|
| 3805 | BDMA_Mem_SetByteSwapMode, BDMA_Mem_SetCrypt |
|---|
| 3806 | BDMA_Mem_Tran_SetDmaBlockInfo_isr |
|---|
| 3807 | ****************************************************************************/ |
|---|
| 3808 | BERR_Code BDMA_Mem_Sharf_Tran_SetDmaBlockInfo_isr( |
|---|
| 3809 | BDMA_Mem_Tran_Handle hTran, |
|---|
| 3810 | uint32_t ulBlockId, |
|---|
| 3811 | BDMA_Context eContext, |
|---|
| 3812 | uint32_t ulDstBusAddr, |
|---|
| 3813 | uint32_t ulSrcBusAddr, |
|---|
| 3814 | uint32_t ulBlockSize ); |
|---|
| 3815 | |
|---|
| 3816 | /*************************************************************************** |
|---|
| 3817 | Summary: |
|---|
| 3818 | Start a DMA Sharf transfer. |
|---|
| 3819 | |
|---|
| 3820 | Description: |
|---|
| 3821 | In order to perform a DMA transfer, user needs to first create a transfer |
|---|
| 3822 | handle, then to use it to set blocks info, to start the DMA transfer, and |
|---|
| 3823 | finally to get the transfer status. This API function is used to start a |
|---|
| 3824 | DMA transfer. |
|---|
| 3825 | |
|---|
| 3826 | As starting a transfer with this API function, user needs to implement a |
|---|
| 3827 | status checking and sleeping loop, to wait for the completion of the |
|---|
| 3828 | DMA transfer, and then to process the "done" info. |
|---|
| 3829 | |
|---|
| 3830 | BDMA_Mem_Tran_Start takes, as an input parameter, hTran to specify the |
|---|
| 3831 | transfer to start. |
|---|
| 3832 | |
|---|
| 3833 | Please refer to the DMA module overview and BDMA_Mem_Handle for more |
|---|
| 3834 | info on the usage of the memory DMA sub-module API functions. |
|---|
| 3835 | |
|---|
| 3836 | Input: |
|---|
| 3837 | hTran - The transfer handle to start. |
|---|
| 3838 | |
|---|
| 3839 | Output: |
|---|
| 3840 | |
|---|
| 3841 | Returns: |
|---|
| 3842 | BERR_SUCCESS - Transfer starting request is accepted. |
|---|
| 3843 | BERR_INVALID_PARAMETER - One of the input parameters is invalid. |
|---|
| 3844 | BDMA_ERR_BLOCK_INFO_NOT_SET - A block info has not been set. |
|---|
| 3845 | BDMA_ERR_ENGINE_BUSY - The engine is busy. |
|---|
| 3846 | |
|---|
| 3847 | See Also: |
|---|
| 3848 | BDMA_Mem_Tran_Create, BDMA_Mem_Sharf_Tran_SetDmaBlockInfo |
|---|
| 3849 | BDMA_Mem_Tran_GetStatus |
|---|
| 3850 | BDMA_Mem_Tran_StartAndCallBack |
|---|
| 3851 | ****************************************************************************/ |
|---|
| 3852 | |
|---|
| 3853 | BERR_Code BDMA_Mem_Sharf_Tran_Start( |
|---|
| 3854 | BDMA_Mem_Tran_Handle hTran ); |
|---|
| 3855 | #ifdef __cplusplus |
|---|
| 3856 | } |
|---|
| 3857 | #endif |
|---|
| 3858 | |
|---|
| 3859 | #endif /* #ifndef BDMA_H__ */ |
|---|
| 3860 | |
|---|
| 3861 | /* end of file */ |
|---|