Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: arch/arm/mach-tegra/nv/nvrm/dispatch/nvrm_module_dispatch.c

Issue 3256004: [ARM] tegra: add nvos/nvrm/nvmap drivers (Closed) Base URL: ssh://git@gitrw.chromium.org/kernel.git
Patch Set: remove ap15 headers Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_module.h"
41
42 #define OFFSET( s, e ) (NvU32)(void *)(&(((s*)0)->e))
43
44
45 typedef struct NvRegw08_in_t
46 {
47 NvU32 package_;
48 NvU32 function_;
49 NvRmDeviceHandle rm;
50 NvRmModuleID aperture;
51 NvU32 offset;
52 NvU8 data;
53 } NV_ALIGN(4) NvRegw08_in;
54
55 typedef struct NvRegw08_inout_t
56 {
57 NvU32 dummy_;
58 } NV_ALIGN(4) NvRegw08_inout;
59
60 typedef struct NvRegw08_out_t
61 {
62 NvU32 dummy_;
63 } NV_ALIGN(4) NvRegw08_out;
64
65 typedef struct NvRegw08_params_t
66 {
67 NvRegw08_in in;
68 NvRegw08_inout inout;
69 NvRegw08_out out;
70 } NvRegw08_params;
71
72 typedef struct NvRegr08_in_t
73 {
74 NvU32 package_;
75 NvU32 function_;
76 NvRmDeviceHandle hDeviceHandle;
77 NvRmModuleID aperture;
78 NvU32 offset;
79 } NV_ALIGN(4) NvRegr08_in;
80
81 typedef struct NvRegr08_inout_t
82 {
83 NvU32 dummy_;
84 } NV_ALIGN(4) NvRegr08_inout;
85
86 typedef struct NvRegr08_out_t
87 {
88 NvU8 ret_;
89 } NV_ALIGN(4) NvRegr08_out;
90
91 typedef struct NvRegr08_params_t
92 {
93 NvRegr08_in in;
94 NvRegr08_inout inout;
95 NvRegr08_out out;
96 } NvRegr08_params;
97
98 typedef struct NvRegrb_in_t
99 {
100 NvU32 package_;
101 NvU32 function_;
102 NvRmDeviceHandle hRmDeviceHandle;
103 NvRmModuleID aperture;
104 NvU32 num;
105 NvU32 offset;
106 NvU32 * values;
107 } NV_ALIGN(4) NvRegrb_in;
108
109 typedef struct NvRegrb_inout_t
110 {
111 NvU32 dummy_;
112 } NV_ALIGN(4) NvRegrb_inout;
113
114 typedef struct NvRegrb_out_t
115 {
116 NvU32 dummy_;
117 } NV_ALIGN(4) NvRegrb_out;
118
119 typedef struct NvRegrb_params_t
120 {
121 NvRegrb_in in;
122 NvRegrb_inout inout;
123 NvRegrb_out out;
124 } NvRegrb_params;
125
126 typedef struct NvRegwb_in_t
127 {
128 NvU32 package_;
129 NvU32 function_;
130 NvRmDeviceHandle hRmDeviceHandle;
131 NvRmModuleID aperture;
132 NvU32 num;
133 NvU32 offset;
134 NvU32 * values;
135 } NV_ALIGN(4) NvRegwb_in;
136
137 typedef struct NvRegwb_inout_t
138 {
139 NvU32 dummy_;
140 } NV_ALIGN(4) NvRegwb_inout;
141
142 typedef struct NvRegwb_out_t
143 {
144 NvU32 dummy_;
145 } NV_ALIGN(4) NvRegwb_out;
146
147 typedef struct NvRegwb_params_t
148 {
149 NvRegwb_in in;
150 NvRegwb_inout inout;
151 NvRegwb_out out;
152 } NvRegwb_params;
153
154 typedef struct NvRegwm_in_t
155 {
156 NvU32 package_;
157 NvU32 function_;
158 NvRmDeviceHandle hRmDeviceHandle;
159 NvRmModuleID aperture;
160 NvU32 num;
161 NvU32 * offsets;
162 NvU32 * values;
163 } NV_ALIGN(4) NvRegwm_in;
164
165 typedef struct NvRegwm_inout_t
166 {
167 NvU32 dummy_;
168 } NV_ALIGN(4) NvRegwm_inout;
169
170 typedef struct NvRegwm_out_t
171 {
172 NvU32 dummy_;
173 } NV_ALIGN(4) NvRegwm_out;
174
175 typedef struct NvRegwm_params_t
176 {
177 NvRegwm_in in;
178 NvRegwm_inout inout;
179 NvRegwm_out out;
180 } NvRegwm_params;
181
182 typedef struct NvRegrm_in_t
183 {
184 NvU32 package_;
185 NvU32 function_;
186 NvRmDeviceHandle hRmDeviceHandle;
187 NvRmModuleID aperture;
188 NvU32 num;
189 NvU32 * offsets;
190 NvU32 * values;
191 } NV_ALIGN(4) NvRegrm_in;
192
193 typedef struct NvRegrm_inout_t
194 {
195 NvU32 dummy_;
196 } NV_ALIGN(4) NvRegrm_inout;
197
198 typedef struct NvRegrm_out_t
199 {
200 NvU32 dummy_;
201 } NV_ALIGN(4) NvRegrm_out;
202
203 typedef struct NvRegrm_params_t
204 {
205 NvRegrm_in in;
206 NvRegrm_inout inout;
207 NvRegrm_out out;
208 } NvRegrm_params;
209
210 typedef struct NvRegw_in_t
211 {
212 NvU32 package_;
213 NvU32 function_;
214 NvRmDeviceHandle hDeviceHandle;
215 NvRmModuleID aperture;
216 NvU32 offset;
217 NvU32 data;
218 } NV_ALIGN(4) NvRegw_in;
219
220 typedef struct NvRegw_inout_t
221 {
222 NvU32 dummy_;
223 } NV_ALIGN(4) NvRegw_inout;
224
225 typedef struct NvRegw_out_t
226 {
227 NvU32 dummy_;
228 } NV_ALIGN(4) NvRegw_out;
229
230 typedef struct NvRegw_params_t
231 {
232 NvRegw_in in;
233 NvRegw_inout inout;
234 NvRegw_out out;
235 } NvRegw_params;
236
237 typedef struct NvRegr_in_t
238 {
239 NvU32 package_;
240 NvU32 function_;
241 NvRmDeviceHandle hDeviceHandle;
242 NvRmModuleID aperture;
243 NvU32 offset;
244 } NV_ALIGN(4) NvRegr_in;
245
246 typedef struct NvRegr_inout_t
247 {
248 NvU32 dummy_;
249 } NV_ALIGN(4) NvRegr_inout;
250
251 typedef struct NvRegr_out_t
252 {
253 NvU32 ret_;
254 } NV_ALIGN(4) NvRegr_out;
255
256 typedef struct NvRegr_params_t
257 {
258 NvRegr_in in;
259 NvRegr_inout inout;
260 NvRegr_out out;
261 } NvRegr_params;
262
263 typedef struct NvRmGetRandomBytes_in_t
264 {
265 NvU32 package_;
266 NvU32 function_;
267 NvRmDeviceHandle hRmDeviceHandle;
268 NvU32 NumBytes;
269 void* pBytes;
270 } NV_ALIGN(4) NvRmGetRandomBytes_in;
271
272 typedef struct NvRmGetRandomBytes_inout_t
273 {
274 NvU32 dummy_;
275 } NV_ALIGN(4) NvRmGetRandomBytes_inout;
276
277 typedef struct NvRmGetRandomBytes_out_t
278 {
279 NvError ret_;
280 } NV_ALIGN(4) NvRmGetRandomBytes_out;
281
282 typedef struct NvRmGetRandomBytes_params_t
283 {
284 NvRmGetRandomBytes_in in;
285 NvRmGetRandomBytes_inout inout;
286 NvRmGetRandomBytes_out out;
287 } NvRmGetRandomBytes_params;
288
289 typedef struct NvRmQueryChipUniqueId_in_t
290 {
291 NvU32 package_;
292 NvU32 function_;
293 NvRmDeviceHandle hDevHandle;
294 NvU32 IdSize;
295 void* pId;
296 } NV_ALIGN(4) NvRmQueryChipUniqueId_in;
297
298 typedef struct NvRmQueryChipUniqueId_inout_t
299 {
300 NvU32 dummy_;
301 } NV_ALIGN(4) NvRmQueryChipUniqueId_inout;
302
303 typedef struct NvRmQueryChipUniqueId_out_t
304 {
305 NvError ret_;
306 } NV_ALIGN(4) NvRmQueryChipUniqueId_out;
307
308 typedef struct NvRmQueryChipUniqueId_params_t
309 {
310 NvRmQueryChipUniqueId_in in;
311 NvRmQueryChipUniqueId_inout inout;
312 NvRmQueryChipUniqueId_out out;
313 } NvRmQueryChipUniqueId_params;
314
315 typedef struct NvRmModuleGetCapabilities_in_t
316 {
317 NvU32 package_;
318 NvU32 function_;
319 NvRmDeviceHandle hDeviceHandle;
320 NvRmModuleID Module;
321 NvRmModuleCapability * pCaps;
322 NvU32 NumCaps;
323 } NV_ALIGN(4) NvRmModuleGetCapabilities_in;
324
325 typedef struct NvRmModuleGetCapabilities_inout_t
326 {
327 NvU32 dummy_;
328 } NV_ALIGN(4) NvRmModuleGetCapabilities_inout;
329
330 typedef struct NvRmModuleGetCapabilities_out_t
331 {
332 NvError ret_;
333 void* Capability;
334 } NV_ALIGN(4) NvRmModuleGetCapabilities_out;
335
336 typedef struct NvRmModuleGetCapabilities_params_t
337 {
338 NvRmModuleGetCapabilities_in in;
339 NvRmModuleGetCapabilities_inout inout;
340 NvRmModuleGetCapabilities_out out;
341 } NvRmModuleGetCapabilities_params;
342
343 typedef struct NvRmModuleResetWithHold_in_t
344 {
345 NvU32 package_;
346 NvU32 function_;
347 NvRmDeviceHandle hRmDeviceHandle;
348 NvRmModuleID Module;
349 NvBool bHold;
350 } NV_ALIGN(4) NvRmModuleResetWithHold_in;
351
352 typedef struct NvRmModuleResetWithHold_inout_t
353 {
354 NvU32 dummy_;
355 } NV_ALIGN(4) NvRmModuleResetWithHold_inout;
356
357 typedef struct NvRmModuleResetWithHold_out_t
358 {
359 NvU32 dummy_;
360 } NV_ALIGN(4) NvRmModuleResetWithHold_out;
361
362 typedef struct NvRmModuleResetWithHold_params_t
363 {
364 NvRmModuleResetWithHold_in in;
365 NvRmModuleResetWithHold_inout inout;
366 NvRmModuleResetWithHold_out out;
367 } NvRmModuleResetWithHold_params;
368
369 typedef struct NvRmModuleReset_in_t
370 {
371 NvU32 package_;
372 NvU32 function_;
373 NvRmDeviceHandle hRmDeviceHandle;
374 NvRmModuleID Module;
375 } NV_ALIGN(4) NvRmModuleReset_in;
376
377 typedef struct NvRmModuleReset_inout_t
378 {
379 NvU32 dummy_;
380 } NV_ALIGN(4) NvRmModuleReset_inout;
381
382 typedef struct NvRmModuleReset_out_t
383 {
384 NvU32 dummy_;
385 } NV_ALIGN(4) NvRmModuleReset_out;
386
387 typedef struct NvRmModuleReset_params_t
388 {
389 NvRmModuleReset_in in;
390 NvRmModuleReset_inout inout;
391 NvRmModuleReset_out out;
392 } NvRmModuleReset_params;
393
394 typedef struct NvRmModuleGetNumInstances_in_t
395 {
396 NvU32 package_;
397 NvU32 function_;
398 NvRmDeviceHandle hRmDeviceHandle;
399 NvRmModuleID Module;
400 } NV_ALIGN(4) NvRmModuleGetNumInstances_in;
401
402 typedef struct NvRmModuleGetNumInstances_inout_t
403 {
404 NvU32 dummy_;
405 } NV_ALIGN(4) NvRmModuleGetNumInstances_inout;
406
407 typedef struct NvRmModuleGetNumInstances_out_t
408 {
409 NvU32 ret_;
410 } NV_ALIGN(4) NvRmModuleGetNumInstances_out;
411
412 typedef struct NvRmModuleGetNumInstances_params_t
413 {
414 NvRmModuleGetNumInstances_in in;
415 NvRmModuleGetNumInstances_inout inout;
416 NvRmModuleGetNumInstances_out out;
417 } NvRmModuleGetNumInstances_params;
418
419 typedef struct NvRmModuleGetBaseAddress_in_t
420 {
421 NvU32 package_;
422 NvU32 function_;
423 NvRmDeviceHandle hRmDeviceHandle;
424 NvRmModuleID Module;
425 } NV_ALIGN(4) NvRmModuleGetBaseAddress_in;
426
427 typedef struct NvRmModuleGetBaseAddress_inout_t
428 {
429 NvU32 dummy_;
430 } NV_ALIGN(4) NvRmModuleGetBaseAddress_inout;
431
432 typedef struct NvRmModuleGetBaseAddress_out_t
433 {
434 NvRmPhysAddr pBaseAddress;
435 NvU32 pSize;
436 } NV_ALIGN(4) NvRmModuleGetBaseAddress_out;
437
438 typedef struct NvRmModuleGetBaseAddress_params_t
439 {
440 NvRmModuleGetBaseAddress_in in;
441 NvRmModuleGetBaseAddress_inout inout;
442 NvRmModuleGetBaseAddress_out out;
443 } NvRmModuleGetBaseAddress_params;
444
445 typedef struct NvRmModuleGetModuleInfo_in_t
446 {
447 NvU32 package_;
448 NvU32 function_;
449 NvRmDeviceHandle hDevice;
450 NvRmModuleID module;
451 NvRmModuleInfo * pModuleInfo;
452 } NV_ALIGN(4) NvRmModuleGetModuleInfo_in;
453
454 typedef struct NvRmModuleGetModuleInfo_inout_t
455 {
456 NvU32 pNum;
457 } NV_ALIGN(4) NvRmModuleGetModuleInfo_inout;
458
459 typedef struct NvRmModuleGetModuleInfo_out_t
460 {
461 NvError ret_;
462 } NV_ALIGN(4) NvRmModuleGetModuleInfo_out;
463
464 typedef struct NvRmModuleGetModuleInfo_params_t
465 {
466 NvRmModuleGetModuleInfo_in in;
467 NvRmModuleGetModuleInfo_inout inout;
468 NvRmModuleGetModuleInfo_out out;
469 } NvRmModuleGetModuleInfo_params;
470
471 static NvError NvRegw08_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer , NvU32 OutSize, NvDispatchCtx* Ctx )
472 {
473 NvError err_ = NvSuccess;
474 NvRegw08_in *p_in;
475
476 p_in = (NvRegw08_in *)InBuffer;
477
478
479 NvRegw08( p_in->rm, p_in->aperture, p_in->offset, p_in->data );
480
481 return err_;
482 }
483
484 static NvError NvRegr08_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer , NvU32 OutSize, NvDispatchCtx* Ctx )
485 {
486 NvError err_ = NvSuccess;
487 NvRegr08_in *p_in;
488 NvRegr08_out *p_out;
489
490 p_in = (NvRegr08_in *)InBuffer;
491 p_out = (NvRegr08_out *)((NvU8 *)OutBuffer + OFFSET(NvRegr08_params, out) - OFFSET(NvRegr08_params, inout));
492
493
494 p_out->ret_ = NvRegr08( p_in->hDeviceHandle, p_in->aperture, p_in->offset );
495
496 return err_;
497 }
498
499 static NvError NvRegrb_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
500 {
501 NvError err_ = NvSuccess;
502 NvRegrb_in *p_in;
503 NvU32 *values = NULL;
504
505 p_in = (NvRegrb_in *)InBuffer;
506
507 if( p_in->num && p_in->values )
508 {
509 values = (NvU32 *)NvOsAlloc( p_in->num * sizeof( NvU32 ) );
510 if( !values )
511 {
512 err_ = NvError_InsufficientMemory;
513 goto clean;
514 }
515 }
516
517 NvRegrb( p_in->hRmDeviceHandle, p_in->aperture, p_in->num, p_in->offset, val ues );
518
519 if(p_in->values && values)
520 {
521 err_ = NvOsCopyOut( p_in->values, values, p_in->num * sizeof( NvU32 ) ) ;
522 if( err_ != NvSuccess )
523 {
524 err_ = NvError_BadParameter;
525 }
526 }
527 clean:
528 NvOsFree( values );
529 return err_;
530 }
531
532 static NvError NvRegwb_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
533 {
534 NvError err_ = NvSuccess;
535 NvRegwb_in *p_in;
536 NvU32 *values = NULL;
537
538 p_in = (NvRegwb_in *)InBuffer;
539
540 if( p_in->num && p_in->values )
541 {
542 values = (NvU32 *)NvOsAlloc( p_in->num * sizeof( NvU32 ) );
543 if( !values )
544 {
545 err_ = NvError_InsufficientMemory;
546 goto clean;
547 }
548 if( p_in->values )
549 {
550 err_ = NvOsCopyIn( values, p_in->values, p_in->num * sizeof( NvU32 ) );
551 if( err_ != NvSuccess )
552 {
553 err_ = NvError_BadParameter;
554 goto clean;
555 }
556 }
557 }
558
559 NvRegwb( p_in->hRmDeviceHandle, p_in->aperture, p_in->num, p_in->offset, val ues );
560
561 clean:
562 NvOsFree( values );
563 return err_;
564 }
565
566 static NvError NvRegwm_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
567 {
568 NvError err_ = NvSuccess;
569 NvRegwm_in *p_in;
570 NvU32 *offsets = NULL;
571 NvU32 *values = NULL;
572
573 p_in = (NvRegwm_in *)InBuffer;
574
575 if( p_in->num && p_in->offsets )
576 {
577 offsets = (NvU32 *)NvOsAlloc( p_in->num * sizeof( NvU32 ) );
578 if( !offsets )
579 {
580 err_ = NvError_InsufficientMemory;
581 goto clean;
582 }
583 if( p_in->offsets )
584 {
585 err_ = NvOsCopyIn( offsets, p_in->offsets, p_in->num * sizeof( NvU32 ) );
586 if( err_ != NvSuccess )
587 {
588 err_ = NvError_BadParameter;
589 goto clean;
590 }
591 }
592 }
593 if( p_in->num && p_in->values )
594 {
595 values = (NvU32 *)NvOsAlloc( p_in->num * sizeof( NvU32 ) );
596 if( !values )
597 {
598 err_ = NvError_InsufficientMemory;
599 goto clean;
600 }
601 if( p_in->values )
602 {
603 err_ = NvOsCopyIn( values, p_in->values, p_in->num * sizeof( NvU32 ) );
604 if( err_ != NvSuccess )
605 {
606 err_ = NvError_BadParameter;
607 goto clean;
608 }
609 }
610 }
611
612 NvRegwm( p_in->hRmDeviceHandle, p_in->aperture, p_in->num, offsets, values ) ;
613
614 clean:
615 NvOsFree( offsets );
616 NvOsFree( values );
617 return err_;
618 }
619
620 static NvError NvRegrm_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
621 {
622 NvError err_ = NvSuccess;
623 NvRegrm_in *p_in;
624 NvU32 *offsets = NULL;
625 NvU32 *values = NULL;
626
627 p_in = (NvRegrm_in *)InBuffer;
628
629 if( p_in->num && p_in->offsets )
630 {
631 offsets = (NvU32 *)NvOsAlloc( p_in->num * sizeof( NvU32 ) );
632 if( !offsets )
633 {
634 err_ = NvError_InsufficientMemory;
635 goto clean;
636 }
637 if( p_in->offsets )
638 {
639 err_ = NvOsCopyIn( offsets, p_in->offsets, p_in->num * sizeof( NvU32 ) );
640 if( err_ != NvSuccess )
641 {
642 err_ = NvError_BadParameter;
643 goto clean;
644 }
645 }
646 }
647 if( p_in->num && p_in->values )
648 {
649 values = (NvU32 *)NvOsAlloc( p_in->num * sizeof( NvU32 ) );
650 if( !values )
651 {
652 err_ = NvError_InsufficientMemory;
653 goto clean;
654 }
655 }
656
657 NvRegrm( p_in->hRmDeviceHandle, p_in->aperture, p_in->num, offsets, values ) ;
658
659 if(p_in->values && values)
660 {
661 err_ = NvOsCopyOut( p_in->values, values, p_in->num * sizeof( NvU32 ) ) ;
662 if( err_ != NvSuccess )
663 {
664 err_ = NvError_BadParameter;
665 }
666 }
667 clean:
668 NvOsFree( offsets );
669 NvOsFree( values );
670 return err_;
671 }
672
673 static NvError NvRegw_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
674 {
675 NvError err_ = NvSuccess;
676 NvRegw_in *p_in;
677
678 p_in = (NvRegw_in *)InBuffer;
679
680
681 NvRegw( p_in->hDeviceHandle, p_in->aperture, p_in->offset, p_in->data );
682
683 return err_;
684 }
685
686 static NvError NvRegr_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
687 {
688 NvError err_ = NvSuccess;
689 NvRegr_in *p_in;
690 NvRegr_out *p_out;
691
692 p_in = (NvRegr_in *)InBuffer;
693 p_out = (NvRegr_out *)((NvU8 *)OutBuffer + OFFSET(NvRegr_params, out) - OFFS ET(NvRegr_params, inout));
694
695
696 p_out->ret_ = NvRegr( p_in->hDeviceHandle, p_in->aperture, p_in->offset );
697
698 return err_;
699 }
700
701 static NvError NvRmGetRandomBytes_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
702 {
703 NvError err_ = NvSuccess;
704 NvRmGetRandomBytes_in *p_in;
705 NvRmGetRandomBytes_out *p_out;
706 void* pBytes = NULL;
707
708 p_in = (NvRmGetRandomBytes_in *)InBuffer;
709 p_out = (NvRmGetRandomBytes_out *)((NvU8 *)OutBuffer + OFFSET(NvRmGetRandomB ytes_params, out) - OFFSET(NvRmGetRandomBytes_params, inout));
710
711 if( p_in->NumBytes && p_in->pBytes )
712 {
713 pBytes = (void* )NvOsAlloc( p_in->NumBytes );
714 if( !pBytes )
715 {
716 err_ = NvError_InsufficientMemory;
717 goto clean;
718 }
719 }
720
721 p_out->ret_ = NvRmGetRandomBytes( p_in->hRmDeviceHandle, p_in->NumBytes, pBy tes );
722
723 if(p_in->pBytes && pBytes)
724 {
725 err_ = NvOsCopyOut( p_in->pBytes, pBytes, p_in->NumBytes );
726 if( err_ != NvSuccess )
727 {
728 err_ = NvError_BadParameter;
729 }
730 }
731 clean:
732 NvOsFree( pBytes );
733 return err_;
734 }
735
736 static NvError NvRmQueryChipUniqueId_dispatch_( void *InBuffer, NvU32 InSize, vo id *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
737 {
738 NvError err_ = NvSuccess;
739 NvRmQueryChipUniqueId_in *p_in;
740 NvRmQueryChipUniqueId_out *p_out;
741 void* pId = NULL;
742
743 p_in = (NvRmQueryChipUniqueId_in *)InBuffer;
744 p_out = (NvRmQueryChipUniqueId_out *)((NvU8 *)OutBuffer + OFFSET(NvRmQueryCh ipUniqueId_params, out) - OFFSET(NvRmQueryChipUniqueId_params, inout));
745
746 if( p_in->IdSize && p_in->pId )
747 {
748 pId = (void* )NvOsAlloc( p_in->IdSize );
749 if( !pId )
750 {
751 err_ = NvError_InsufficientMemory;
752 goto clean;
753 }
754 }
755
756 p_out->ret_ = NvRmQueryChipUniqueId( p_in->hDevHandle, p_in->IdSize, pId );
757
758 if(p_in->pId && pId)
759 {
760 err_ = NvOsCopyOut( p_in->pId, pId, p_in->IdSize );
761 if( err_ != NvSuccess )
762 {
763 err_ = NvError_BadParameter;
764 }
765 }
766 clean:
767 NvOsFree( pId );
768 return err_;
769 }
770
771 static NvError NvRmModuleGetCapabilities_dispatch_( void *InBuffer, NvU32 InSize , void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
772 {
773 NvError err_ = NvSuccess;
774 NvRmModuleGetCapabilities_in *p_in;
775 NvRmModuleGetCapabilities_out *p_out;
776 NvRmModuleCapability *pCaps = NULL;
777
778 p_in = (NvRmModuleGetCapabilities_in *)InBuffer;
779 p_out = (NvRmModuleGetCapabilities_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMod uleGetCapabilities_params, out) - OFFSET(NvRmModuleGetCapabilities_params, inout ));
780
781 if( p_in->NumCaps && p_in->pCaps )
782 {
783 pCaps = (NvRmModuleCapability *)NvOsAlloc( p_in->NumCaps * sizeof( NvRm ModuleCapability ) );
784 if( !pCaps )
785 {
786 err_ = NvError_InsufficientMemory;
787 goto clean;
788 }
789 if( p_in->pCaps )
790 {
791 err_ = NvOsCopyIn( pCaps, p_in->pCaps, p_in->NumCaps * sizeof( NvRmM oduleCapability ) );
792 if( err_ != NvSuccess )
793 {
794 err_ = NvError_BadParameter;
795 goto clean;
796 }
797 }
798 }
799
800 p_out->ret_ = NvRmModuleGetCapabilities( p_in->hDeviceHandle, p_in->Module, pCaps, p_in->NumCaps, &p_out->Capability );
801
802 clean:
803 NvOsFree( pCaps );
804 return err_;
805 }
806
807 static NvError NvRmModuleResetWithHold_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
808 {
809 NvError err_ = NvSuccess;
810 NvRmModuleResetWithHold_in *p_in;
811
812 p_in = (NvRmModuleResetWithHold_in *)InBuffer;
813
814
815 NvRmModuleResetWithHold( p_in->hRmDeviceHandle, p_in->Module, p_in->bHold );
816
817 return err_;
818 }
819
820 static NvError NvRmModuleReset_dispatch_( void *InBuffer, NvU32 InSize, void *Ou tBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
821 {
822 NvError err_ = NvSuccess;
823 NvRmModuleReset_in *p_in;
824
825 p_in = (NvRmModuleReset_in *)InBuffer;
826
827
828 NvRmModuleReset( p_in->hRmDeviceHandle, p_in->Module );
829
830 return err_;
831 }
832
833 static NvError NvRmModuleGetNumInstances_dispatch_( void *InBuffer, NvU32 InSize , void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
834 {
835 NvError err_ = NvSuccess;
836 NvRmModuleGetNumInstances_in *p_in;
837 NvRmModuleGetNumInstances_out *p_out;
838
839 p_in = (NvRmModuleGetNumInstances_in *)InBuffer;
840 p_out = (NvRmModuleGetNumInstances_out *)((NvU8 *)OutBuffer + OFFSET(NvRmMod uleGetNumInstances_params, out) - OFFSET(NvRmModuleGetNumInstances_params, inout ));
841
842
843 p_out->ret_ = NvRmModuleGetNumInstances( p_in->hRmDeviceHandle, p_in->Module );
844
845 return err_;
846 }
847
848 static NvError NvRmModuleGetBaseAddress_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
849 {
850 NvError err_ = NvSuccess;
851 NvRmModuleGetBaseAddress_in *p_in;
852 NvRmModuleGetBaseAddress_out *p_out;
853
854 p_in = (NvRmModuleGetBaseAddress_in *)InBuffer;
855 p_out = (NvRmModuleGetBaseAddress_out *)((NvU8 *)OutBuffer + OFFSET(NvRmModu leGetBaseAddress_params, out) - OFFSET(NvRmModuleGetBaseAddress_params, inout));
856
857
858 NvRmModuleGetBaseAddress( p_in->hRmDeviceHandle, p_in->Module, &p_out->pBase Address, &p_out->pSize );
859
860 return err_;
861 }
862
863 static NvError NvRmModuleGetModuleInfo_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
864 {
865 NvError err_ = NvSuccess;
866 NvRmModuleGetModuleInfo_in *p_in;
867 NvRmModuleGetModuleInfo_inout *p_inout;
868 NvRmModuleGetModuleInfo_out *p_out;
869 NvRmModuleGetModuleInfo_inout inout;
870 NvRmModuleInfo *pModuleInfo = NULL;
871
872 p_in = (NvRmModuleGetModuleInfo_in *)InBuffer;
873 p_inout = (NvRmModuleGetModuleInfo_inout *)((NvU8 *)InBuffer + OFFSET(NvRmMo duleGetModuleInfo_params, inout));
874 p_out = (NvRmModuleGetModuleInfo_out *)((NvU8 *)OutBuffer + OFFSET(NvRmModul eGetModuleInfo_params, out) - OFFSET(NvRmModuleGetModuleInfo_params, inout));
875
876 (void)inout;
877 inout.pNum = p_inout->pNum;
878 if( p_inout->pNum && p_in->pModuleInfo )
879 {
880 pModuleInfo = (NvRmModuleInfo *)NvOsAlloc( p_inout->pNum * sizeof( NvRm ModuleInfo ) );
881 if( !pModuleInfo )
882 {
883 err_ = NvError_InsufficientMemory;
884 goto clean;
885 }
886 }
887
888 p_out->ret_ = NvRmModuleGetModuleInfo( p_in->hDevice, p_in->module, &inout.p Num, pModuleInfo );
889
890
891 p_inout = (NvRmModuleGetModuleInfo_inout *)OutBuffer;
892 p_inout->pNum = inout.pNum;
893 if(p_in->pModuleInfo && pModuleInfo)
894 {
895 err_ = NvOsCopyOut( p_in->pModuleInfo, pModuleInfo, p_inout->pNum * size of( NvRmModuleInfo ) );
896 if( err_ != NvSuccess )
897 {
898 err_ = NvError_BadParameter;
899 }
900 }
901 clean:
902 NvOsFree( pModuleInfo );
903 return err_;
904 }
905
906 NvError nvrm_module_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx );
907 NvError nvrm_module_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
908 {
909 NvError err_ = NvSuccess;
910
911 switch( function ) {
912 case 15:
913 err_ = NvRegw08_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
914 break;
915 case 14:
916 err_ = NvRegr08_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
917 break;
918 case 13:
919 err_ = NvRegrb_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
920 break;
921 case 12:
922 err_ = NvRegwb_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
923 break;
924 case 11:
925 err_ = NvRegwm_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
926 break;
927 case 10:
928 err_ = NvRegrm_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
929 break;
930 case 9:
931 err_ = NvRegw_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
932 break;
933 case 8:
934 err_ = NvRegr_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
935 break;
936 case 7:
937 err_ = NvRmGetRandomBytes_dispatch_( InBuffer, InSize, OutBuffer, OutSiz e, Ctx );
938 break;
939 case 6:
940 err_ = NvRmQueryChipUniqueId_dispatch_( InBuffer, InSize, OutBuffer, Out Size, Ctx );
941 break;
942 case 5:
943 err_ = NvRmModuleGetCapabilities_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
944 break;
945 case 4:
946 err_ = NvRmModuleResetWithHold_dispatch_( InBuffer, InSize, OutBuffer, O utSize, Ctx );
947 break;
948 case 3:
949 err_ = NvRmModuleReset_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
950 break;
951 case 2:
952 err_ = NvRmModuleGetNumInstances_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
953 break;
954 case 1:
955 err_ = NvRmModuleGetBaseAddress_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
956 break;
957 case 0:
958 err_ = NvRmModuleGetModuleInfo_dispatch_( InBuffer, InSize, OutBuffer, O utSize, Ctx );
959 break;
960 default:
961 err_ = NvError_BadParameter;
962 break;
963 }
964
965 return err_;
966 }
OLDNEW
« no previous file with comments | « arch/arm/mach-tegra/nv/nvrm/dispatch/nvrm_memmgr_dispatch.c ('k') | arch/arm/mach-tegra/nv/nvrm/dispatch/nvrm_owr_dispatch.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698