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_memmgr.h" |
| 41 |
| 42 #define OFFSET( s, e ) (NvU32)(void *)(&(((s*)0)->e)) |
| 43 |
| 44 |
| 45 typedef struct NvRmMemGetStat_in_t |
| 46 { |
| 47 NvU32 package_; |
| 48 NvU32 function_; |
| 49 NvRmMemStat Stat; |
| 50 } NV_ALIGN(4) NvRmMemGetStat_in; |
| 51 |
| 52 typedef struct NvRmMemGetStat_inout_t |
| 53 { |
| 54 NvU32 dummy_; |
| 55 } NV_ALIGN(4) NvRmMemGetStat_inout; |
| 56 |
| 57 typedef struct NvRmMemGetStat_out_t |
| 58 { |
| 59 NvError ret_; |
| 60 NvS32 Result; |
| 61 } NV_ALIGN(4) NvRmMemGetStat_out; |
| 62 |
| 63 typedef struct NvRmMemGetStat_params_t |
| 64 { |
| 65 NvRmMemGetStat_in in; |
| 66 NvRmMemGetStat_inout inout; |
| 67 NvRmMemGetStat_out out; |
| 68 } NvRmMemGetStat_params; |
| 69 |
| 70 typedef struct NvRmMemHandleFromId_in_t |
| 71 { |
| 72 NvU32 package_; |
| 73 NvU32 function_; |
| 74 NvU32 id; |
| 75 } NV_ALIGN(4) NvRmMemHandleFromId_in; |
| 76 |
| 77 typedef struct NvRmMemHandleFromId_inout_t |
| 78 { |
| 79 NvU32 dummy_; |
| 80 } NV_ALIGN(4) NvRmMemHandleFromId_inout; |
| 81 |
| 82 typedef struct NvRmMemHandleFromId_out_t |
| 83 { |
| 84 NvError ret_; |
| 85 NvRmMemHandle hMem; |
| 86 } NV_ALIGN(4) NvRmMemHandleFromId_out; |
| 87 |
| 88 typedef struct NvRmMemHandleFromId_params_t |
| 89 { |
| 90 NvRmMemHandleFromId_in in; |
| 91 NvRmMemHandleFromId_inout inout; |
| 92 NvRmMemHandleFromId_out out; |
| 93 } NvRmMemHandleFromId_params; |
| 94 |
| 95 typedef struct NvRmMemGetId_in_t |
| 96 { |
| 97 NvU32 package_; |
| 98 NvU32 function_; |
| 99 NvRmMemHandle hMem; |
| 100 } NV_ALIGN(4) NvRmMemGetId_in; |
| 101 |
| 102 typedef struct NvRmMemGetId_inout_t |
| 103 { |
| 104 NvU32 dummy_; |
| 105 } NV_ALIGN(4) NvRmMemGetId_inout; |
| 106 |
| 107 typedef struct NvRmMemGetId_out_t |
| 108 { |
| 109 NvU32 ret_; |
| 110 } NV_ALIGN(4) NvRmMemGetId_out; |
| 111 |
| 112 typedef struct NvRmMemGetId_params_t |
| 113 { |
| 114 NvRmMemGetId_in in; |
| 115 NvRmMemGetId_inout inout; |
| 116 NvRmMemGetId_out out; |
| 117 } NvRmMemGetId_params; |
| 118 |
| 119 typedef struct NvRmMemGetHeapType_in_t |
| 120 { |
| 121 NvU32 package_; |
| 122 NvU32 function_; |
| 123 NvRmMemHandle hMem; |
| 124 } NV_ALIGN(4) NvRmMemGetHeapType_in; |
| 125 |
| 126 typedef struct NvRmMemGetHeapType_inout_t |
| 127 { |
| 128 NvU32 dummy_; |
| 129 } NV_ALIGN(4) NvRmMemGetHeapType_inout; |
| 130 |
| 131 typedef struct NvRmMemGetHeapType_out_t |
| 132 { |
| 133 NvRmHeap ret_; |
| 134 NvU32 BasePhysAddr; |
| 135 } NV_ALIGN(4) NvRmMemGetHeapType_out; |
| 136 |
| 137 typedef struct NvRmMemGetHeapType_params_t |
| 138 { |
| 139 NvRmMemGetHeapType_in in; |
| 140 NvRmMemGetHeapType_inout inout; |
| 141 NvRmMemGetHeapType_out out; |
| 142 } NvRmMemGetHeapType_params; |
| 143 |
| 144 typedef struct NvRmMemGetCacheLineSize_in_t |
| 145 { |
| 146 NvU32 package_; |
| 147 NvU32 function_; |
| 148 } NV_ALIGN(4) NvRmMemGetCacheLineSize_in; |
| 149 |
| 150 typedef struct NvRmMemGetCacheLineSize_inout_t |
| 151 { |
| 152 NvU32 dummy_; |
| 153 } NV_ALIGN(4) NvRmMemGetCacheLineSize_inout; |
| 154 |
| 155 typedef struct NvRmMemGetCacheLineSize_out_t |
| 156 { |
| 157 NvU32 ret_; |
| 158 } NV_ALIGN(4) NvRmMemGetCacheLineSize_out; |
| 159 |
| 160 typedef struct NvRmMemGetCacheLineSize_params_t |
| 161 { |
| 162 NvRmMemGetCacheLineSize_in in; |
| 163 NvRmMemGetCacheLineSize_inout inout; |
| 164 NvRmMemGetCacheLineSize_out out; |
| 165 } NvRmMemGetCacheLineSize_params; |
| 166 |
| 167 typedef struct NvRmMemGetAlignment_in_t |
| 168 { |
| 169 NvU32 package_; |
| 170 NvU32 function_; |
| 171 NvRmMemHandle hMem; |
| 172 } NV_ALIGN(4) NvRmMemGetAlignment_in; |
| 173 |
| 174 typedef struct NvRmMemGetAlignment_inout_t |
| 175 { |
| 176 NvU32 dummy_; |
| 177 } NV_ALIGN(4) NvRmMemGetAlignment_inout; |
| 178 |
| 179 typedef struct NvRmMemGetAlignment_out_t |
| 180 { |
| 181 NvU32 ret_; |
| 182 } NV_ALIGN(4) NvRmMemGetAlignment_out; |
| 183 |
| 184 typedef struct NvRmMemGetAlignment_params_t |
| 185 { |
| 186 NvRmMemGetAlignment_in in; |
| 187 NvRmMemGetAlignment_inout inout; |
| 188 NvRmMemGetAlignment_out out; |
| 189 } NvRmMemGetAlignment_params; |
| 190 |
| 191 typedef struct NvRmMemGetSize_in_t |
| 192 { |
| 193 NvU32 package_; |
| 194 NvU32 function_; |
| 195 NvRmMemHandle hMem; |
| 196 } NV_ALIGN(4) NvRmMemGetSize_in; |
| 197 |
| 198 typedef struct NvRmMemGetSize_inout_t |
| 199 { |
| 200 NvU32 dummy_; |
| 201 } NV_ALIGN(4) NvRmMemGetSize_inout; |
| 202 |
| 203 typedef struct NvRmMemGetSize_out_t |
| 204 { |
| 205 NvU32 ret_; |
| 206 } NV_ALIGN(4) NvRmMemGetSize_out; |
| 207 |
| 208 typedef struct NvRmMemGetSize_params_t |
| 209 { |
| 210 NvRmMemGetSize_in in; |
| 211 NvRmMemGetSize_inout inout; |
| 212 NvRmMemGetSize_out out; |
| 213 } NvRmMemGetSize_params; |
| 214 |
| 215 typedef struct NvRmMemMove_in_t |
| 216 { |
| 217 NvU32 package_; |
| 218 NvU32 function_; |
| 219 NvRmMemHandle hDstMem; |
| 220 NvU32 DstOffset; |
| 221 NvRmMemHandle hSrcMem; |
| 222 NvU32 SrcOffset; |
| 223 NvU32 Size; |
| 224 } NV_ALIGN(4) NvRmMemMove_in; |
| 225 |
| 226 typedef struct NvRmMemMove_inout_t |
| 227 { |
| 228 NvU32 dummy_; |
| 229 } NV_ALIGN(4) NvRmMemMove_inout; |
| 230 |
| 231 typedef struct NvRmMemMove_out_t |
| 232 { |
| 233 NvU32 dummy_; |
| 234 } NV_ALIGN(4) NvRmMemMove_out; |
| 235 |
| 236 typedef struct NvRmMemMove_params_t |
| 237 { |
| 238 NvRmMemMove_in in; |
| 239 NvRmMemMove_inout inout; |
| 240 NvRmMemMove_out out; |
| 241 } NvRmMemMove_params; |
| 242 |
| 243 typedef struct NvRmMemUnpinMult_in_t |
| 244 { |
| 245 NvU32 package_; |
| 246 NvU32 function_; |
| 247 NvRmMemHandle * hMems; |
| 248 NvU32 Count; |
| 249 } NV_ALIGN(4) NvRmMemUnpinMult_in; |
| 250 |
| 251 typedef struct NvRmMemUnpinMult_inout_t |
| 252 { |
| 253 NvU32 dummy_; |
| 254 } NV_ALIGN(4) NvRmMemUnpinMult_inout; |
| 255 |
| 256 typedef struct NvRmMemUnpinMult_out_t |
| 257 { |
| 258 NvU32 dummy_; |
| 259 } NV_ALIGN(4) NvRmMemUnpinMult_out; |
| 260 |
| 261 typedef struct NvRmMemUnpinMult_params_t |
| 262 { |
| 263 NvRmMemUnpinMult_in in; |
| 264 NvRmMemUnpinMult_inout inout; |
| 265 NvRmMemUnpinMult_out out; |
| 266 } NvRmMemUnpinMult_params; |
| 267 |
| 268 typedef struct NvRmMemUnpin_in_t |
| 269 { |
| 270 NvU32 package_; |
| 271 NvU32 function_; |
| 272 NvRmMemHandle hMem; |
| 273 } NV_ALIGN(4) NvRmMemUnpin_in; |
| 274 |
| 275 typedef struct NvRmMemUnpin_inout_t |
| 276 { |
| 277 NvU32 dummy_; |
| 278 } NV_ALIGN(4) NvRmMemUnpin_inout; |
| 279 |
| 280 typedef struct NvRmMemUnpin_out_t |
| 281 { |
| 282 NvU32 dummy_; |
| 283 } NV_ALIGN(4) NvRmMemUnpin_out; |
| 284 |
| 285 typedef struct NvRmMemUnpin_params_t |
| 286 { |
| 287 NvRmMemUnpin_in in; |
| 288 NvRmMemUnpin_inout inout; |
| 289 NvRmMemUnpin_out out; |
| 290 } NvRmMemUnpin_params; |
| 291 |
| 292 typedef struct NvRmMemGetAddress_in_t |
| 293 { |
| 294 NvU32 package_; |
| 295 NvU32 function_; |
| 296 NvRmMemHandle hMem; |
| 297 NvU32 Offset; |
| 298 } NV_ALIGN(4) NvRmMemGetAddress_in; |
| 299 |
| 300 typedef struct NvRmMemGetAddress_inout_t |
| 301 { |
| 302 NvU32 dummy_; |
| 303 } NV_ALIGN(4) NvRmMemGetAddress_inout; |
| 304 |
| 305 typedef struct NvRmMemGetAddress_out_t |
| 306 { |
| 307 NvU32 ret_; |
| 308 } NV_ALIGN(4) NvRmMemGetAddress_out; |
| 309 |
| 310 typedef struct NvRmMemGetAddress_params_t |
| 311 { |
| 312 NvRmMemGetAddress_in in; |
| 313 NvRmMemGetAddress_inout inout; |
| 314 NvRmMemGetAddress_out out; |
| 315 } NvRmMemGetAddress_params; |
| 316 |
| 317 typedef struct NvRmMemPinMult_in_t |
| 318 { |
| 319 NvU32 package_; |
| 320 NvU32 function_; |
| 321 NvRmMemHandle * hMems; |
| 322 NvU32 * Addrs; |
| 323 NvU32 Count; |
| 324 } NV_ALIGN(4) NvRmMemPinMult_in; |
| 325 |
| 326 typedef struct NvRmMemPinMult_inout_t |
| 327 { |
| 328 NvU32 dummy_; |
| 329 } NV_ALIGN(4) NvRmMemPinMult_inout; |
| 330 |
| 331 typedef struct NvRmMemPinMult_out_t |
| 332 { |
| 333 NvU32 dummy_; |
| 334 } NV_ALIGN(4) NvRmMemPinMult_out; |
| 335 |
| 336 typedef struct NvRmMemPinMult_params_t |
| 337 { |
| 338 NvRmMemPinMult_in in; |
| 339 NvRmMemPinMult_inout inout; |
| 340 NvRmMemPinMult_out out; |
| 341 } NvRmMemPinMult_params; |
| 342 |
| 343 typedef struct NvRmMemPin_in_t |
| 344 { |
| 345 NvU32 package_; |
| 346 NvU32 function_; |
| 347 NvRmMemHandle hMem; |
| 348 } NV_ALIGN(4) NvRmMemPin_in; |
| 349 |
| 350 typedef struct NvRmMemPin_inout_t |
| 351 { |
| 352 NvU32 dummy_; |
| 353 } NV_ALIGN(4) NvRmMemPin_inout; |
| 354 |
| 355 typedef struct NvRmMemPin_out_t |
| 356 { |
| 357 NvU32 ret_; |
| 358 } NV_ALIGN(4) NvRmMemPin_out; |
| 359 |
| 360 typedef struct NvRmMemPin_params_t |
| 361 { |
| 362 NvRmMemPin_in in; |
| 363 NvRmMemPin_inout inout; |
| 364 NvRmMemPin_out out; |
| 365 } NvRmMemPin_params; |
| 366 |
| 367 typedef struct NvRmMemAlloc_in_t |
| 368 { |
| 369 NvU32 package_; |
| 370 NvU32 function_; |
| 371 NvRmMemHandle hMem; |
| 372 NvRmHeap * Heaps; |
| 373 NvU32 NumHeaps; |
| 374 NvU32 Alignment; |
| 375 NvOsMemAttribute Coherency; |
| 376 } NV_ALIGN(4) NvRmMemAlloc_in; |
| 377 |
| 378 typedef struct NvRmMemAlloc_inout_t |
| 379 { |
| 380 NvU32 dummy_; |
| 381 } NV_ALIGN(4) NvRmMemAlloc_inout; |
| 382 |
| 383 typedef struct NvRmMemAlloc_out_t |
| 384 { |
| 385 NvError ret_; |
| 386 } NV_ALIGN(4) NvRmMemAlloc_out; |
| 387 |
| 388 typedef struct NvRmMemAlloc_params_t |
| 389 { |
| 390 NvRmMemAlloc_in in; |
| 391 NvRmMemAlloc_inout inout; |
| 392 NvRmMemAlloc_out out; |
| 393 } NvRmMemAlloc_params; |
| 394 |
| 395 typedef struct NvRmMemHandleFree_in_t |
| 396 { |
| 397 NvU32 package_; |
| 398 NvU32 function_; |
| 399 NvRmMemHandle hMem; |
| 400 } NV_ALIGN(4) NvRmMemHandleFree_in; |
| 401 |
| 402 typedef struct NvRmMemHandleFree_inout_t |
| 403 { |
| 404 NvU32 dummy_; |
| 405 } NV_ALIGN(4) NvRmMemHandleFree_inout; |
| 406 |
| 407 typedef struct NvRmMemHandleFree_out_t |
| 408 { |
| 409 NvU32 dummy_; |
| 410 } NV_ALIGN(4) NvRmMemHandleFree_out; |
| 411 |
| 412 typedef struct NvRmMemHandleFree_params_t |
| 413 { |
| 414 NvRmMemHandleFree_in in; |
| 415 NvRmMemHandleFree_inout inout; |
| 416 NvRmMemHandleFree_out out; |
| 417 } NvRmMemHandleFree_params; |
| 418 |
| 419 typedef struct NvRmMemHandlePreserveHandle_in_t |
| 420 { |
| 421 NvU32 package_; |
| 422 NvU32 function_; |
| 423 NvRmMemHandle hMem; |
| 424 } NV_ALIGN(4) NvRmMemHandlePreserveHandle_in; |
| 425 |
| 426 typedef struct NvRmMemHandlePreserveHandle_inout_t |
| 427 { |
| 428 NvU32 dummy_; |
| 429 } NV_ALIGN(4) NvRmMemHandlePreserveHandle_inout; |
| 430 |
| 431 typedef struct NvRmMemHandlePreserveHandle_out_t |
| 432 { |
| 433 NvError ret_; |
| 434 NvU32 Key; |
| 435 } NV_ALIGN(4) NvRmMemHandlePreserveHandle_out; |
| 436 |
| 437 typedef struct NvRmMemHandlePreserveHandle_params_t |
| 438 { |
| 439 NvRmMemHandlePreserveHandle_in in; |
| 440 NvRmMemHandlePreserveHandle_inout inout; |
| 441 NvRmMemHandlePreserveHandle_out out; |
| 442 } NvRmMemHandlePreserveHandle_params; |
| 443 |
| 444 typedef struct NvRmMemHandleClaimPreservedHandle_in_t |
| 445 { |
| 446 NvU32 package_; |
| 447 NvU32 function_; |
| 448 NvRmDeviceHandle hDevice; |
| 449 NvU32 Key; |
| 450 } NV_ALIGN(4) NvRmMemHandleClaimPreservedHandle_in; |
| 451 |
| 452 typedef struct NvRmMemHandleClaimPreservedHandle_inout_t |
| 453 { |
| 454 NvU32 dummy_; |
| 455 } NV_ALIGN(4) NvRmMemHandleClaimPreservedHandle_inout; |
| 456 |
| 457 typedef struct NvRmMemHandleClaimPreservedHandle_out_t |
| 458 { |
| 459 NvError ret_; |
| 460 NvRmMemHandle phMem; |
| 461 } NV_ALIGN(4) NvRmMemHandleClaimPreservedHandle_out; |
| 462 |
| 463 typedef struct NvRmMemHandleClaimPreservedHandle_params_t |
| 464 { |
| 465 NvRmMemHandleClaimPreservedHandle_in in; |
| 466 NvRmMemHandleClaimPreservedHandle_inout inout; |
| 467 NvRmMemHandleClaimPreservedHandle_out out; |
| 468 } NvRmMemHandleClaimPreservedHandle_params; |
| 469 |
| 470 typedef struct NvRmMemHandleCreate_in_t |
| 471 { |
| 472 NvU32 package_; |
| 473 NvU32 function_; |
| 474 NvRmDeviceHandle hDevice; |
| 475 NvU32 Size; |
| 476 } NV_ALIGN(4) NvRmMemHandleCreate_in; |
| 477 |
| 478 typedef struct NvRmMemHandleCreate_inout_t |
| 479 { |
| 480 NvU32 dummy_; |
| 481 } NV_ALIGN(4) NvRmMemHandleCreate_inout; |
| 482 |
| 483 typedef struct NvRmMemHandleCreate_out_t |
| 484 { |
| 485 NvError ret_; |
| 486 NvRmMemHandle phMem; |
| 487 } NV_ALIGN(4) NvRmMemHandleCreate_out; |
| 488 |
| 489 typedef struct NvRmMemHandleCreate_params_t |
| 490 { |
| 491 NvRmMemHandleCreate_in in; |
| 492 NvRmMemHandleCreate_inout inout; |
| 493 NvRmMemHandleCreate_out out; |
| 494 } NvRmMemHandleCreate_params; |
| 495 |
| 496 static NvError NvRmMemGetStat_dispatch_( void *InBuffer, NvU32 InSize, void *Out
Buffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 497 { |
| 498 NvError err_ = NvSuccess; |
| 499 NvRmMemGetStat_in *p_in; |
| 500 NvRmMemGetStat_out *p_out; |
| 501 |
| 502 p_in = (NvRmMemGetStat_in *)InBuffer; |
| 503 p_out = (NvRmMemGetStat_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemGetStat_par
ams, out) - OFFSET(NvRmMemGetStat_params, inout)); |
| 504 |
| 505 |
| 506 p_out->ret_ = NvRmMemGetStat( p_in->Stat, &p_out->Result ); |
| 507 |
| 508 return err_; |
| 509 } |
| 510 |
| 511 static NvError NvRmMemHandleFromId_dispatch_( void *InBuffer, NvU32 InSize, void
*OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 512 { |
| 513 NvError err_ = NvSuccess; |
| 514 NvRmMemHandleFromId_in *p_in; |
| 515 NvRmMemHandleFromId_out *p_out; |
| 516 NvRtObjRefHandle ref_hMem = 0; |
| 517 |
| 518 p_in = (NvRmMemHandleFromId_in *)InBuffer; |
| 519 p_out = (NvRmMemHandleFromId_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemHandle
FromId_params, out) - OFFSET(NvRmMemHandleFromId_params, inout)); |
| 520 |
| 521 err_ = NvRtAllocObjRef(Ctx, &ref_hMem); |
| 522 if (err_ != NvSuccess) |
| 523 { |
| 524 goto clean; |
| 525 } |
| 526 |
| 527 p_out->ret_ = NvRmMemHandleFromId( p_in->id, &p_out->hMem ); |
| 528 |
| 529 if ( p_out->ret_ == NvSuccess ) |
| 530 { |
| 531 NvRtStoreObjRef(Ctx, ref_hMem, NvRtObjType_NvRm_NvRmMemHandle, p_out->hM
em); |
| 532 ref_hMem = 0; |
| 533 } |
| 534 clean: |
| 535 if (ref_hMem) NvRtDiscardObjRef(Ctx, ref_hMem); |
| 536 return err_; |
| 537 } |
| 538 |
| 539 static NvError NvRmMemGetId_dispatch_( void *InBuffer, NvU32 InSize, void *OutBu
ffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 540 { |
| 541 NvError err_ = NvSuccess; |
| 542 NvRmMemGetId_in *p_in; |
| 543 NvRmMemGetId_out *p_out; |
| 544 |
| 545 p_in = (NvRmMemGetId_in *)InBuffer; |
| 546 p_out = (NvRmMemGetId_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemGetId_params,
out) - OFFSET(NvRmMemGetId_params, inout)); |
| 547 |
| 548 |
| 549 p_out->ret_ = NvRmMemGetId( p_in->hMem ); |
| 550 |
| 551 return err_; |
| 552 } |
| 553 |
| 554 static NvError NvRmMemGetHeapType_dispatch_( void *InBuffer, NvU32 InSize, void
*OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 555 { |
| 556 NvError err_ = NvSuccess; |
| 557 NvRmMemGetHeapType_in *p_in; |
| 558 NvRmMemGetHeapType_out *p_out; |
| 559 |
| 560 p_in = (NvRmMemGetHeapType_in *)InBuffer; |
| 561 p_out = (NvRmMemGetHeapType_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemGetHeap
Type_params, out) - OFFSET(NvRmMemGetHeapType_params, inout)); |
| 562 |
| 563 |
| 564 p_out->ret_ = NvRmMemGetHeapType( p_in->hMem, &p_out->BasePhysAddr ); |
| 565 |
| 566 return err_; |
| 567 } |
| 568 |
| 569 static NvError NvRmMemGetCacheLineSize_dispatch_( void *InBuffer, NvU32 InSize,
void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 570 { |
| 571 NvError err_ = NvSuccess; |
| 572 NvRmMemGetCacheLineSize_out *p_out; |
| 573 p_out = (NvRmMemGetCacheLineSize_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemGe
tCacheLineSize_params, out) - OFFSET(NvRmMemGetCacheLineSize_params, inout)); |
| 574 |
| 575 |
| 576 p_out->ret_ = NvRmMemGetCacheLineSize( ); |
| 577 |
| 578 return err_; |
| 579 } |
| 580 |
| 581 static NvError NvRmMemGetAlignment_dispatch_( void *InBuffer, NvU32 InSize, void
*OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 582 { |
| 583 NvError err_ = NvSuccess; |
| 584 NvRmMemGetAlignment_in *p_in; |
| 585 NvRmMemGetAlignment_out *p_out; |
| 586 |
| 587 p_in = (NvRmMemGetAlignment_in *)InBuffer; |
| 588 p_out = (NvRmMemGetAlignment_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemGetAli
gnment_params, out) - OFFSET(NvRmMemGetAlignment_params, inout)); |
| 589 |
| 590 |
| 591 p_out->ret_ = NvRmMemGetAlignment( p_in->hMem ); |
| 592 |
| 593 return err_; |
| 594 } |
| 595 |
| 596 static NvError NvRmMemGetSize_dispatch_( void *InBuffer, NvU32 InSize, void *Out
Buffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 597 { |
| 598 NvError err_ = NvSuccess; |
| 599 NvRmMemGetSize_in *p_in; |
| 600 NvRmMemGetSize_out *p_out; |
| 601 |
| 602 p_in = (NvRmMemGetSize_in *)InBuffer; |
| 603 p_out = (NvRmMemGetSize_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemGetSize_par
ams, out) - OFFSET(NvRmMemGetSize_params, inout)); |
| 604 |
| 605 |
| 606 p_out->ret_ = NvRmMemGetSize( p_in->hMem ); |
| 607 |
| 608 return err_; |
| 609 } |
| 610 |
| 611 static NvError NvRmMemMove_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuf
fer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 612 { |
| 613 NvError err_ = NvSuccess; |
| 614 NvRmMemMove_in *p_in; |
| 615 |
| 616 p_in = (NvRmMemMove_in *)InBuffer; |
| 617 |
| 618 |
| 619 NvRmMemMove( p_in->hDstMem, p_in->DstOffset, p_in->hSrcMem, p_in->SrcOffset,
p_in->Size ); |
| 620 |
| 621 return err_; |
| 622 } |
| 623 |
| 624 static NvError NvRmMemUnpinMult_dispatch_( void *InBuffer, NvU32 InSize, void *O
utBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 625 { |
| 626 NvError err_ = NvSuccess; |
| 627 NvRmMemUnpinMult_in *p_in; |
| 628 NvRmMemHandle *hMems = NULL; |
| 629 |
| 630 p_in = (NvRmMemUnpinMult_in *)InBuffer; |
| 631 |
| 632 if( p_in->Count && p_in->hMems ) |
| 633 { |
| 634 hMems = (NvRmMemHandle *)NvOsAlloc( p_in->Count * sizeof( NvRmMemHandle
) ); |
| 635 if( !hMems ) |
| 636 { |
| 637 err_ = NvError_InsufficientMemory; |
| 638 goto clean; |
| 639 } |
| 640 if( p_in->hMems ) |
| 641 { |
| 642 err_ = NvOsCopyIn( hMems, p_in->hMems, p_in->Count * sizeof( NvRmMem
Handle ) ); |
| 643 if( err_ != NvSuccess ) |
| 644 { |
| 645 err_ = NvError_BadParameter; |
| 646 goto clean; |
| 647 } |
| 648 } |
| 649 } |
| 650 |
| 651 NvRmMemUnpinMult( hMems, p_in->Count ); |
| 652 |
| 653 clean: |
| 654 NvOsFree( hMems ); |
| 655 return err_; |
| 656 } |
| 657 |
| 658 static NvError NvRmMemUnpin_dispatch_( void *InBuffer, NvU32 InSize, void *OutBu
ffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 659 { |
| 660 NvError err_ = NvSuccess; |
| 661 NvRmMemUnpin_in *p_in; |
| 662 |
| 663 p_in = (NvRmMemUnpin_in *)InBuffer; |
| 664 |
| 665 |
| 666 NvRmMemUnpin( p_in->hMem ); |
| 667 |
| 668 return err_; |
| 669 } |
| 670 |
| 671 static NvError NvRmMemGetAddress_dispatch_( void *InBuffer, NvU32 InSize, void *
OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 672 { |
| 673 NvError err_ = NvSuccess; |
| 674 NvRmMemGetAddress_in *p_in; |
| 675 NvRmMemGetAddress_out *p_out; |
| 676 |
| 677 p_in = (NvRmMemGetAddress_in *)InBuffer; |
| 678 p_out = (NvRmMemGetAddress_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemGetAddre
ss_params, out) - OFFSET(NvRmMemGetAddress_params, inout)); |
| 679 |
| 680 |
| 681 p_out->ret_ = NvRmMemGetAddress( p_in->hMem, p_in->Offset ); |
| 682 |
| 683 return err_; |
| 684 } |
| 685 |
| 686 static NvError NvRmMemPinMult_dispatch_( void *InBuffer, NvU32 InSize, void *Out
Buffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 687 { |
| 688 NvError err_ = NvSuccess; |
| 689 NvRmMemPinMult_in *p_in; |
| 690 NvRmMemHandle *hMems = NULL; |
| 691 NvU32 *Addrs = NULL; |
| 692 |
| 693 p_in = (NvRmMemPinMult_in *)InBuffer; |
| 694 |
| 695 if( p_in->Count && p_in->hMems ) |
| 696 { |
| 697 hMems = (NvRmMemHandle *)NvOsAlloc( p_in->Count * sizeof( NvRmMemHandle
) ); |
| 698 if( !hMems ) |
| 699 { |
| 700 err_ = NvError_InsufficientMemory; |
| 701 goto clean; |
| 702 } |
| 703 if( p_in->hMems ) |
| 704 { |
| 705 err_ = NvOsCopyIn( hMems, p_in->hMems, p_in->Count * sizeof( NvRmMem
Handle ) ); |
| 706 if( err_ != NvSuccess ) |
| 707 { |
| 708 err_ = NvError_BadParameter; |
| 709 goto clean; |
| 710 } |
| 711 } |
| 712 } |
| 713 if( p_in->Count && p_in->Addrs ) |
| 714 { |
| 715 Addrs = (NvU32 *)NvOsAlloc( p_in->Count * sizeof( NvU32 ) ); |
| 716 if( !Addrs ) |
| 717 { |
| 718 err_ = NvError_InsufficientMemory; |
| 719 goto clean; |
| 720 } |
| 721 } |
| 722 |
| 723 NvRmMemPinMult( hMems, Addrs, p_in->Count ); |
| 724 |
| 725 if(p_in->Addrs && Addrs) |
| 726 { |
| 727 err_ = NvOsCopyOut( p_in->Addrs, Addrs, p_in->Count * sizeof( NvU32 ) )
; |
| 728 if( err_ != NvSuccess ) |
| 729 { |
| 730 err_ = NvError_BadParameter; |
| 731 } |
| 732 } |
| 733 clean: |
| 734 NvOsFree( hMems ); |
| 735 NvOsFree( Addrs ); |
| 736 return err_; |
| 737 } |
| 738 |
| 739 static NvError NvRmMemPin_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuff
er, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 740 { |
| 741 NvError err_ = NvSuccess; |
| 742 NvRmMemPin_in *p_in; |
| 743 NvRmMemPin_out *p_out; |
| 744 |
| 745 p_in = (NvRmMemPin_in *)InBuffer; |
| 746 p_out = (NvRmMemPin_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemPin_params, out
) - OFFSET(NvRmMemPin_params, inout)); |
| 747 |
| 748 |
| 749 p_out->ret_ = NvRmMemPin( p_in->hMem ); |
| 750 |
| 751 return err_; |
| 752 } |
| 753 |
| 754 static NvError NvRmMemAlloc_dispatch_( void *InBuffer, NvU32 InSize, void *OutBu
ffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 755 { |
| 756 NvError err_ = NvSuccess; |
| 757 NvRmMemAlloc_in *p_in; |
| 758 NvRmMemAlloc_out *p_out; |
| 759 NvRmHeap *Heaps = NULL; |
| 760 |
| 761 p_in = (NvRmMemAlloc_in *)InBuffer; |
| 762 p_out = (NvRmMemAlloc_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemAlloc_params,
out) - OFFSET(NvRmMemAlloc_params, inout)); |
| 763 |
| 764 if( p_in->NumHeaps && p_in->Heaps ) |
| 765 { |
| 766 Heaps = (NvRmHeap *)NvOsAlloc( p_in->NumHeaps * sizeof( NvRmHeap ) ); |
| 767 if( !Heaps ) |
| 768 { |
| 769 err_ = NvError_InsufficientMemory; |
| 770 goto clean; |
| 771 } |
| 772 if( p_in->Heaps ) |
| 773 { |
| 774 err_ = NvOsCopyIn( Heaps, p_in->Heaps, p_in->NumHeaps * sizeof( NvRm
Heap ) ); |
| 775 if( err_ != NvSuccess ) |
| 776 { |
| 777 err_ = NvError_BadParameter; |
| 778 goto clean; |
| 779 } |
| 780 } |
| 781 } |
| 782 |
| 783 p_out->ret_ = NvRmMemAlloc( p_in->hMem, Heaps, p_in->NumHeaps, p_in->Alignme
nt, p_in->Coherency ); |
| 784 |
| 785 clean: |
| 786 NvOsFree( Heaps ); |
| 787 return err_; |
| 788 } |
| 789 |
| 790 static NvError NvRmMemHandleFree_dispatch_( void *InBuffer, NvU32 InSize, void *
OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 791 { |
| 792 NvError err_ = NvSuccess; |
| 793 NvRmMemHandleFree_in *p_in; |
| 794 |
| 795 p_in = (NvRmMemHandleFree_in *)InBuffer; |
| 796 |
| 797 if (p_in->hMem != NULL) NvRtFreeObjRef(Ctx, NvRtObjType_NvRm_NvRmMemHandle,
p_in->hMem); |
| 798 |
| 799 NvRmMemHandleFree( p_in->hMem ); |
| 800 |
| 801 return err_; |
| 802 } |
| 803 |
| 804 static NvError NvRmMemHandlePreserveHandle_dispatch_( void *InBuffer, NvU32 InSi
ze, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 805 { |
| 806 NvError err_ = NvSuccess; |
| 807 NvRmMemHandlePreserveHandle_in *p_in; |
| 808 NvRmMemHandlePreserveHandle_out *p_out; |
| 809 |
| 810 p_in = (NvRmMemHandlePreserveHandle_in *)InBuffer; |
| 811 p_out = (NvRmMemHandlePreserveHandle_out *)((NvU8 *)OutBuffer + OFFSET(NvRmM
emHandlePreserveHandle_params, out) - OFFSET(NvRmMemHandlePreserveHandle_params,
inout)); |
| 812 |
| 813 |
| 814 p_out->ret_ = NvRmMemHandlePreserveHandle( p_in->hMem, &p_out->Key ); |
| 815 |
| 816 return err_; |
| 817 } |
| 818 |
| 819 static NvError NvRmMemHandleClaimPreservedHandle_dispatch_( void *InBuffer, NvU3
2 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 820 { |
| 821 NvError err_ = NvSuccess; |
| 822 NvRmMemHandleClaimPreservedHandle_in *p_in; |
| 823 NvRmMemHandleClaimPreservedHandle_out *p_out; |
| 824 NvRtObjRefHandle ref_phMem = 0; |
| 825 |
| 826 p_in = (NvRmMemHandleClaimPreservedHandle_in *)InBuffer; |
| 827 p_out = (NvRmMemHandleClaimPreservedHandle_out *)((NvU8 *)OutBuffer + OFFSET
(NvRmMemHandleClaimPreservedHandle_params, out) - OFFSET(NvRmMemHandleClaimPrese
rvedHandle_params, inout)); |
| 828 |
| 829 err_ = NvRtAllocObjRef(Ctx, &ref_phMem); |
| 830 if (err_ != NvSuccess) |
| 831 { |
| 832 goto clean; |
| 833 } |
| 834 |
| 835 p_out->ret_ = NvRmMemHandleClaimPreservedHandle( p_in->hDevice, p_in->Key, &
p_out->phMem ); |
| 836 |
| 837 if ( p_out->ret_ == NvSuccess ) |
| 838 { |
| 839 NvRtStoreObjRef(Ctx, ref_phMem, NvRtObjType_NvRm_NvRmMemHandle, p_out->p
hMem); |
| 840 ref_phMem = 0; |
| 841 } |
| 842 clean: |
| 843 if (ref_phMem) NvRtDiscardObjRef(Ctx, ref_phMem); |
| 844 return err_; |
| 845 } |
| 846 |
| 847 static NvError NvRmMemHandleCreate_dispatch_( void *InBuffer, NvU32 InSize, void
*OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 848 { |
| 849 NvError err_ = NvSuccess; |
| 850 NvRmMemHandleCreate_in *p_in; |
| 851 NvRmMemHandleCreate_out *p_out; |
| 852 NvRtObjRefHandle ref_phMem = 0; |
| 853 |
| 854 p_in = (NvRmMemHandleCreate_in *)InBuffer; |
| 855 p_out = (NvRmMemHandleCreate_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMemHandle
Create_params, out) - OFFSET(NvRmMemHandleCreate_params, inout)); |
| 856 |
| 857 err_ = NvRtAllocObjRef(Ctx, &ref_phMem); |
| 858 if (err_ != NvSuccess) |
| 859 { |
| 860 goto clean; |
| 861 } |
| 862 |
| 863 p_out->ret_ = NvRmMemHandleCreate( p_in->hDevice, &p_out->phMem, p_in->Size
); |
| 864 |
| 865 if ( p_out->ret_ == NvSuccess ) |
| 866 { |
| 867 NvRtStoreObjRef(Ctx, ref_phMem, NvRtObjType_NvRm_NvRmMemHandle, p_out->p
hMem); |
| 868 ref_phMem = 0; |
| 869 } |
| 870 clean: |
| 871 if (ref_phMem) NvRtDiscardObjRef(Ctx, ref_phMem); |
| 872 return err_; |
| 873 } |
| 874 |
| 875 NvError nvrm_memmgr_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void
*OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ); |
| 876 NvError nvrm_memmgr_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void
*OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 877 { |
| 878 NvError err_ = NvSuccess; |
| 879 |
| 880 switch( function ) { |
| 881 case 17: |
| 882 err_ = NvRmMemGetStat_dispatch_( InBuffer, InSize, OutBuffer, OutSize, C
tx ); |
| 883 break; |
| 884 case 16: |
| 885 err_ = NvRmMemHandleFromId_dispatch_( InBuffer, InSize, OutBuffer, OutSi
ze, Ctx ); |
| 886 break; |
| 887 case 15: |
| 888 err_ = NvRmMemGetId_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 889 break; |
| 890 case 14: |
| 891 err_ = NvRmMemGetHeapType_dispatch_( InBuffer, InSize, OutBuffer, OutSiz
e, Ctx ); |
| 892 break; |
| 893 case 13: |
| 894 err_ = NvRmMemGetCacheLineSize_dispatch_( InBuffer, InSize, OutBuffer, O
utSize, Ctx ); |
| 895 break; |
| 896 case 12: |
| 897 err_ = NvRmMemGetAlignment_dispatch_( InBuffer, InSize, OutBuffer, OutSi
ze, Ctx ); |
| 898 break; |
| 899 case 11: |
| 900 err_ = NvRmMemGetSize_dispatch_( InBuffer, InSize, OutBuffer, OutSize, C
tx ); |
| 901 break; |
| 902 case 10: |
| 903 err_ = NvRmMemMove_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 904 break; |
| 905 case 9: |
| 906 err_ = NvRmMemUnpinMult_dispatch_( InBuffer, InSize, OutBuffer, OutSize,
Ctx ); |
| 907 break; |
| 908 case 8: |
| 909 err_ = NvRmMemUnpin_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 910 break; |
| 911 case 7: |
| 912 err_ = NvRmMemGetAddress_dispatch_( InBuffer, InSize, OutBuffer, OutSize
, Ctx ); |
| 913 break; |
| 914 case 6: |
| 915 err_ = NvRmMemPinMult_dispatch_( InBuffer, InSize, OutBuffer, OutSize, C
tx ); |
| 916 break; |
| 917 case 5: |
| 918 err_ = NvRmMemPin_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx )
; |
| 919 break; |
| 920 case 4: |
| 921 err_ = NvRmMemAlloc_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 922 break; |
| 923 case 3: |
| 924 err_ = NvRmMemHandleFree_dispatch_( InBuffer, InSize, OutBuffer, OutSize
, Ctx ); |
| 925 break; |
| 926 case 2: |
| 927 err_ = NvRmMemHandlePreserveHandle_dispatch_( InBuffer, InSize, OutBuffe
r, OutSize, Ctx ); |
| 928 break; |
| 929 case 1: |
| 930 err_ = NvRmMemHandleClaimPreservedHandle_dispatch_( InBuffer, InSize, Ou
tBuffer, OutSize, Ctx ); |
| 931 break; |
| 932 case 0: |
| 933 err_ = NvRmMemHandleCreate_dispatch_( InBuffer, InSize, OutBuffer, OutSi
ze, Ctx ); |
| 934 break; |
| 935 default: |
| 936 err_ = NvError_BadParameter; |
| 937 break; |
| 938 } |
| 939 |
| 940 return err_; |
| 941 } |
OLD | NEW |