OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2009 NVIDIA Corporation. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: |
| 7 * |
| 8 * Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. |
| 10 * |
| 11 * Redistributions in binary form must reproduce the above copyright notice, |
| 12 * this list of conditions and the following disclaimer in the documentation |
| 13 * and/or other materials provided with the distribution. |
| 14 * |
| 15 * Neither the name of the NVIDIA Corporation nor the names of its contributors |
| 16 * may be used to endorse or promote products derived from this software |
| 17 * without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 * POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 */ |
| 32 |
| 33 #define NV_IDL_IS_DISPATCH |
| 34 |
| 35 #include "nvcommon.h" |
| 36 #include "nvos.h" |
| 37 #include "nvassert.h" |
| 38 #include "nvreftrack.h" |
| 39 #include "nvidlcmd.h" |
| 40 #include "nvrm_dma.h" |
| 41 |
| 42 #define OFFSET( s, e ) (NvU32)(void *)(&(((s*)0)->e)) |
| 43 |
| 44 |
| 45 typedef struct NvRmDmaIsDmaTransferCompletes_in_t |
| 46 { |
| 47 NvU32 package_; |
| 48 NvU32 function_; |
| 49 NvRmDmaHandle hDma; |
| 50 NvBool IsFirstHalfBuffer; |
| 51 } NV_ALIGN(4) NvRmDmaIsDmaTransferCompletes_in; |
| 52 |
| 53 typedef struct NvRmDmaIsDmaTransferCompletes_inout_t |
| 54 { |
| 55 NvU32 dummy_; |
| 56 } NV_ALIGN(4) NvRmDmaIsDmaTransferCompletes_inout; |
| 57 |
| 58 typedef struct NvRmDmaIsDmaTransferCompletes_out_t |
| 59 { |
| 60 NvBool ret_; |
| 61 } NV_ALIGN(4) NvRmDmaIsDmaTransferCompletes_out; |
| 62 |
| 63 typedef struct NvRmDmaIsDmaTransferCompletes_params_t |
| 64 { |
| 65 NvRmDmaIsDmaTransferCompletes_in in; |
| 66 NvRmDmaIsDmaTransferCompletes_inout inout; |
| 67 NvRmDmaIsDmaTransferCompletes_out out; |
| 68 } NvRmDmaIsDmaTransferCompletes_params; |
| 69 |
| 70 typedef struct NvRmDmaGetTransferredCount_in_t |
| 71 { |
| 72 NvU32 package_; |
| 73 NvU32 function_; |
| 74 NvRmDmaHandle hDma; |
| 75 NvBool IsTransferStop; |
| 76 } NV_ALIGN(4) NvRmDmaGetTransferredCount_in; |
| 77 |
| 78 typedef struct NvRmDmaGetTransferredCount_inout_t |
| 79 { |
| 80 NvU32 dummy_; |
| 81 } NV_ALIGN(4) NvRmDmaGetTransferredCount_inout; |
| 82 |
| 83 typedef struct NvRmDmaGetTransferredCount_out_t |
| 84 { |
| 85 NvError ret_; |
| 86 NvU32 pTransferCount; |
| 87 } NV_ALIGN(4) NvRmDmaGetTransferredCount_out; |
| 88 |
| 89 typedef struct NvRmDmaGetTransferredCount_params_t |
| 90 { |
| 91 NvRmDmaGetTransferredCount_in in; |
| 92 NvRmDmaGetTransferredCount_inout inout; |
| 93 NvRmDmaGetTransferredCount_out out; |
| 94 } NvRmDmaGetTransferredCount_params; |
| 95 |
| 96 typedef struct NvRmDmaAbort_in_t |
| 97 { |
| 98 NvU32 package_; |
| 99 NvU32 function_; |
| 100 NvRmDmaHandle hDma; |
| 101 } NV_ALIGN(4) NvRmDmaAbort_in; |
| 102 |
| 103 typedef struct NvRmDmaAbort_inout_t |
| 104 { |
| 105 NvU32 dummy_; |
| 106 } NV_ALIGN(4) NvRmDmaAbort_inout; |
| 107 |
| 108 typedef struct NvRmDmaAbort_out_t |
| 109 { |
| 110 NvU32 dummy_; |
| 111 } NV_ALIGN(4) NvRmDmaAbort_out; |
| 112 |
| 113 typedef struct NvRmDmaAbort_params_t |
| 114 { |
| 115 NvRmDmaAbort_in in; |
| 116 NvRmDmaAbort_inout inout; |
| 117 NvRmDmaAbort_out out; |
| 118 } NvRmDmaAbort_params; |
| 119 |
| 120 typedef struct NvRmDmaStartDmaTransfer_in_t |
| 121 { |
| 122 NvU32 package_; |
| 123 NvU32 function_; |
| 124 NvRmDmaHandle hDma; |
| 125 NvRmDmaClientBuffer pClientBuffer; |
| 126 NvRmDmaDirection DmaDirection; |
| 127 NvU32 WaitTimeoutInMilliSecond; |
| 128 NvOsSemaphoreHandle AsynchSemaphoreId; |
| 129 } NV_ALIGN(4) NvRmDmaStartDmaTransfer_in; |
| 130 |
| 131 typedef struct NvRmDmaStartDmaTransfer_inout_t |
| 132 { |
| 133 NvU32 dummy_; |
| 134 } NV_ALIGN(4) NvRmDmaStartDmaTransfer_inout; |
| 135 |
| 136 typedef struct NvRmDmaStartDmaTransfer_out_t |
| 137 { |
| 138 NvError ret_; |
| 139 } NV_ALIGN(4) NvRmDmaStartDmaTransfer_out; |
| 140 |
| 141 typedef struct NvRmDmaStartDmaTransfer_params_t |
| 142 { |
| 143 NvRmDmaStartDmaTransfer_in in; |
| 144 NvRmDmaStartDmaTransfer_inout inout; |
| 145 NvRmDmaStartDmaTransfer_out out; |
| 146 } NvRmDmaStartDmaTransfer_params; |
| 147 |
| 148 typedef struct NvRmDmaFree_in_t |
| 149 { |
| 150 NvU32 package_; |
| 151 NvU32 function_; |
| 152 NvRmDmaHandle hDma; |
| 153 } NV_ALIGN(4) NvRmDmaFree_in; |
| 154 |
| 155 typedef struct NvRmDmaFree_inout_t |
| 156 { |
| 157 NvU32 dummy_; |
| 158 } NV_ALIGN(4) NvRmDmaFree_inout; |
| 159 |
| 160 typedef struct NvRmDmaFree_out_t |
| 161 { |
| 162 NvU32 dummy_; |
| 163 } NV_ALIGN(4) NvRmDmaFree_out; |
| 164 |
| 165 typedef struct NvRmDmaFree_params_t |
| 166 { |
| 167 NvRmDmaFree_in in; |
| 168 NvRmDmaFree_inout inout; |
| 169 NvRmDmaFree_out out; |
| 170 } NvRmDmaFree_params; |
| 171 |
| 172 typedef struct NvRmDmaAllocate_in_t |
| 173 { |
| 174 NvU32 package_; |
| 175 NvU32 function_; |
| 176 NvRmDeviceHandle hRmDevice; |
| 177 NvBool Enable32bitSwap; |
| 178 NvRmDmaPriority Priority; |
| 179 NvRmDmaModuleID DmaRequestorModuleId; |
| 180 NvU32 DmaRequestorInstanceId; |
| 181 } NV_ALIGN(4) NvRmDmaAllocate_in; |
| 182 |
| 183 typedef struct NvRmDmaAllocate_inout_t |
| 184 { |
| 185 NvU32 dummy_; |
| 186 } NV_ALIGN(4) NvRmDmaAllocate_inout; |
| 187 |
| 188 typedef struct NvRmDmaAllocate_out_t |
| 189 { |
| 190 NvError ret_; |
| 191 NvRmDmaHandle phDma; |
| 192 } NV_ALIGN(4) NvRmDmaAllocate_out; |
| 193 |
| 194 typedef struct NvRmDmaAllocate_params_t |
| 195 { |
| 196 NvRmDmaAllocate_in in; |
| 197 NvRmDmaAllocate_inout inout; |
| 198 NvRmDmaAllocate_out out; |
| 199 } NvRmDmaAllocate_params; |
| 200 |
| 201 typedef struct NvRmDmaGetCapabilities_in_t |
| 202 { |
| 203 NvU32 package_; |
| 204 NvU32 function_; |
| 205 NvRmDeviceHandle hDevice; |
| 206 NvRmDmaCapabilities pRmDmaCaps; |
| 207 } NV_ALIGN(4) NvRmDmaGetCapabilities_in; |
| 208 |
| 209 typedef struct NvRmDmaGetCapabilities_inout_t |
| 210 { |
| 211 NvU32 dummy_; |
| 212 } NV_ALIGN(4) NvRmDmaGetCapabilities_inout; |
| 213 |
| 214 typedef struct NvRmDmaGetCapabilities_out_t |
| 215 { |
| 216 NvError ret_; |
| 217 } NV_ALIGN(4) NvRmDmaGetCapabilities_out; |
| 218 |
| 219 typedef struct NvRmDmaGetCapabilities_params_t |
| 220 { |
| 221 NvRmDmaGetCapabilities_in in; |
| 222 NvRmDmaGetCapabilities_inout inout; |
| 223 NvRmDmaGetCapabilities_out out; |
| 224 } NvRmDmaGetCapabilities_params; |
| 225 |
| 226 static NvError NvRmDmaIsDmaTransferCompletes_dispatch_( void *InBuffer, NvU32 In
Size, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 227 { |
| 228 NvError err_ = NvSuccess; |
| 229 NvRmDmaIsDmaTransferCompletes_in *p_in; |
| 230 NvRmDmaIsDmaTransferCompletes_out *p_out; |
| 231 |
| 232 p_in = (NvRmDmaIsDmaTransferCompletes_in *)InBuffer; |
| 233 p_out = (NvRmDmaIsDmaTransferCompletes_out *)((NvU8 *)OutBuffer + OFFSET(NvR
mDmaIsDmaTransferCompletes_params, out) - OFFSET(NvRmDmaIsDmaTransferCompletes_p
arams, inout)); |
| 234 |
| 235 |
| 236 p_out->ret_ = NvRmDmaIsDmaTransferCompletes( p_in->hDma, p_in->IsFirstHalfBu
ffer ); |
| 237 |
| 238 return err_; |
| 239 } |
| 240 |
| 241 static NvError NvRmDmaGetTransferredCount_dispatch_( void *InBuffer, NvU32 InSiz
e, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 242 { |
| 243 NvError err_ = NvSuccess; |
| 244 NvRmDmaGetTransferredCount_in *p_in; |
| 245 NvRmDmaGetTransferredCount_out *p_out; |
| 246 |
| 247 p_in = (NvRmDmaGetTransferredCount_in *)InBuffer; |
| 248 p_out = (NvRmDmaGetTransferredCount_out *)((NvU8 *)OutBuffer + OFFSET(NvRmDm
aGetTransferredCount_params, out) - OFFSET(NvRmDmaGetTransferredCount_params, in
out)); |
| 249 |
| 250 |
| 251 p_out->ret_ = NvRmDmaGetTransferredCount( p_in->hDma, &p_out->pTransferCount
, p_in->IsTransferStop ); |
| 252 |
| 253 return err_; |
| 254 } |
| 255 |
| 256 static NvError NvRmDmaAbort_dispatch_( void *InBuffer, NvU32 InSize, void *OutBu
ffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 257 { |
| 258 NvError err_ = NvSuccess; |
| 259 NvRmDmaAbort_in *p_in; |
| 260 |
| 261 p_in = (NvRmDmaAbort_in *)InBuffer; |
| 262 |
| 263 |
| 264 NvRmDmaAbort( p_in->hDma ); |
| 265 |
| 266 return err_; |
| 267 } |
| 268 |
| 269 static NvError NvRmDmaStartDmaTransfer_dispatch_( void *InBuffer, NvU32 InSize,
void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 270 { |
| 271 NvError err_ = NvSuccess; |
| 272 NvRmDmaStartDmaTransfer_in *p_in; |
| 273 NvRmDmaStartDmaTransfer_out *p_out; |
| 274 NvOsSemaphoreHandle AsynchSemaphoreId = NULL; |
| 275 |
| 276 p_in = (NvRmDmaStartDmaTransfer_in *)InBuffer; |
| 277 p_out = (NvRmDmaStartDmaTransfer_out *)((NvU8 *)OutBuffer + OFFSET(NvRmDmaSt
artDmaTransfer_params, out) - OFFSET(NvRmDmaStartDmaTransfer_params, inout)); |
| 278 |
| 279 if( p_in->AsynchSemaphoreId ) |
| 280 { |
| 281 err_ = NvOsSemaphoreUnmarshal( p_in->AsynchSemaphoreId, &AsynchSemaphore
Id ); |
| 282 if( err_ != NvSuccess ) |
| 283 { |
| 284 err_ = NvError_BadParameter; |
| 285 goto clean; |
| 286 } |
| 287 } |
| 288 |
| 289 p_out->ret_ = NvRmDmaStartDmaTransfer( p_in->hDma, &p_in->pClientBuffer, p_i
n->DmaDirection, p_in->WaitTimeoutInMilliSecond, AsynchSemaphoreId ); |
| 290 |
| 291 clean: |
| 292 NvOsSemaphoreDestroy( AsynchSemaphoreId ); |
| 293 return err_; |
| 294 } |
| 295 |
| 296 static NvError NvRmDmaFree_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuf
fer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 297 { |
| 298 NvError err_ = NvSuccess; |
| 299 NvRmDmaFree_in *p_in; |
| 300 |
| 301 p_in = (NvRmDmaFree_in *)InBuffer; |
| 302 |
| 303 |
| 304 NvRmDmaFree( p_in->hDma ); |
| 305 |
| 306 return err_; |
| 307 } |
| 308 |
| 309 static NvError NvRmDmaAllocate_dispatch_( void *InBuffer, NvU32 InSize, void *Ou
tBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 310 { |
| 311 NvError err_ = NvSuccess; |
| 312 NvRmDmaAllocate_in *p_in; |
| 313 NvRmDmaAllocate_out *p_out; |
| 314 |
| 315 p_in = (NvRmDmaAllocate_in *)InBuffer; |
| 316 p_out = (NvRmDmaAllocate_out *)((NvU8 *)OutBuffer + OFFSET(NvRmDmaAllocate_p
arams, out) - OFFSET(NvRmDmaAllocate_params, inout)); |
| 317 |
| 318 |
| 319 p_out->ret_ = NvRmDmaAllocate( p_in->hRmDevice, &p_out->phDma, p_in->Enable3
2bitSwap, p_in->Priority, p_in->DmaRequestorModuleId, p_in->DmaRequestorInstance
Id ); |
| 320 |
| 321 return err_; |
| 322 } |
| 323 |
| 324 static NvError NvRmDmaGetCapabilities_dispatch_( void *InBuffer, NvU32 InSize, v
oid *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 325 { |
| 326 NvError err_ = NvSuccess; |
| 327 NvRmDmaGetCapabilities_in *p_in; |
| 328 NvRmDmaGetCapabilities_out *p_out; |
| 329 |
| 330 p_in = (NvRmDmaGetCapabilities_in *)InBuffer; |
| 331 p_out = (NvRmDmaGetCapabilities_out *)((NvU8 *)OutBuffer + OFFSET(NvRmDmaGet
Capabilities_params, out) - OFFSET(NvRmDmaGetCapabilities_params, inout)); |
| 332 |
| 333 |
| 334 p_out->ret_ = NvRmDmaGetCapabilities( p_in->hDevice, &p_in->pRmDmaCaps ); |
| 335 |
| 336 return err_; |
| 337 } |
| 338 |
| 339 NvError nvrm_dma_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void *O
utBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ); |
| 340 NvError nvrm_dma_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void *O
utBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 341 { |
| 342 NvError err_ = NvSuccess; |
| 343 |
| 344 switch( function ) { |
| 345 case 6: |
| 346 err_ = NvRmDmaIsDmaTransferCompletes_dispatch_( InBuffer, InSize, OutBuf
fer, OutSize, Ctx ); |
| 347 break; |
| 348 case 5: |
| 349 err_ = NvRmDmaGetTransferredCount_dispatch_( InBuffer, InSize, OutBuffer
, OutSize, Ctx ); |
| 350 break; |
| 351 case 4: |
| 352 err_ = NvRmDmaAbort_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 353 break; |
| 354 case 3: |
| 355 err_ = NvRmDmaStartDmaTransfer_dispatch_( InBuffer, InSize, OutBuffer, O
utSize, Ctx ); |
| 356 break; |
| 357 case 2: |
| 358 err_ = NvRmDmaFree_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 359 break; |
| 360 case 1: |
| 361 err_ = NvRmDmaAllocate_dispatch_( InBuffer, InSize, OutBuffer, OutSize,
Ctx ); |
| 362 break; |
| 363 case 0: |
| 364 err_ = NvRmDmaGetCapabilities_dispatch_( InBuffer, InSize, OutBuffer, Ou
tSize, Ctx ); |
| 365 break; |
| 366 default: |
| 367 err_ = NvError_BadParameter; |
| 368 break; |
| 369 } |
| 370 |
| 371 return err_; |
| 372 } |
OLD | NEW |