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_init.h" |
| 41 |
| 42 #define OFFSET( s, e ) (NvU32)(void *)(&(((s*)0)->e)) |
| 43 |
| 44 |
| 45 typedef struct NvRmClose_in_t |
| 46 { |
| 47 NvU32 package_; |
| 48 NvU32 function_; |
| 49 NvRmDeviceHandle hDevice; |
| 50 } NV_ALIGN(4) NvRmClose_in; |
| 51 |
| 52 typedef struct NvRmClose_inout_t |
| 53 { |
| 54 NvU32 dummy_; |
| 55 } NV_ALIGN(4) NvRmClose_inout; |
| 56 |
| 57 typedef struct NvRmClose_out_t |
| 58 { |
| 59 NvU32 dummy_; |
| 60 } NV_ALIGN(4) NvRmClose_out; |
| 61 |
| 62 typedef struct NvRmClose_params_t |
| 63 { |
| 64 NvRmClose_in in; |
| 65 NvRmClose_inout inout; |
| 66 NvRmClose_out out; |
| 67 } NvRmClose_params; |
| 68 |
| 69 typedef struct NvRmOpenNew_in_t |
| 70 { |
| 71 NvU32 package_; |
| 72 NvU32 function_; |
| 73 } NV_ALIGN(4) NvRmOpenNew_in; |
| 74 |
| 75 typedef struct NvRmOpenNew_inout_t |
| 76 { |
| 77 NvU32 dummy_; |
| 78 } NV_ALIGN(4) NvRmOpenNew_inout; |
| 79 |
| 80 typedef struct NvRmOpenNew_out_t |
| 81 { |
| 82 NvError ret_; |
| 83 NvRmDeviceHandle pHandle; |
| 84 } NV_ALIGN(4) NvRmOpenNew_out; |
| 85 |
| 86 typedef struct NvRmOpenNew_params_t |
| 87 { |
| 88 NvRmOpenNew_in in; |
| 89 NvRmOpenNew_inout inout; |
| 90 NvRmOpenNew_out out; |
| 91 } NvRmOpenNew_params; |
| 92 |
| 93 typedef struct NvRmInit_in_t |
| 94 { |
| 95 NvU32 package_; |
| 96 NvU32 function_; |
| 97 } NV_ALIGN(4) NvRmInit_in; |
| 98 |
| 99 typedef struct NvRmInit_inout_t |
| 100 { |
| 101 NvU32 dummy_; |
| 102 } NV_ALIGN(4) NvRmInit_inout; |
| 103 |
| 104 typedef struct NvRmInit_out_t |
| 105 { |
| 106 NvRmDeviceHandle pHandle; |
| 107 } NV_ALIGN(4) NvRmInit_out; |
| 108 |
| 109 typedef struct NvRmInit_params_t |
| 110 { |
| 111 NvRmInit_in in; |
| 112 NvRmInit_inout inout; |
| 113 NvRmInit_out out; |
| 114 } NvRmInit_params; |
| 115 |
| 116 typedef struct NvRmOpen_in_t |
| 117 { |
| 118 NvU32 package_; |
| 119 NvU32 function_; |
| 120 NvU32 DeviceId; |
| 121 } NV_ALIGN(4) NvRmOpen_in; |
| 122 |
| 123 typedef struct NvRmOpen_inout_t |
| 124 { |
| 125 NvU32 dummy_; |
| 126 } NV_ALIGN(4) NvRmOpen_inout; |
| 127 |
| 128 typedef struct NvRmOpen_out_t |
| 129 { |
| 130 NvError ret_; |
| 131 NvRmDeviceHandle pHandle; |
| 132 } NV_ALIGN(4) NvRmOpen_out; |
| 133 |
| 134 typedef struct NvRmOpen_params_t |
| 135 { |
| 136 NvRmOpen_in in; |
| 137 NvRmOpen_inout inout; |
| 138 NvRmOpen_out out; |
| 139 } NvRmOpen_params; |
| 140 |
| 141 static NvError NvRmClose_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffe
r, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 142 { |
| 143 NvError err_ = NvSuccess; |
| 144 NvRmClose_in *p_in; |
| 145 |
| 146 p_in = (NvRmClose_in *)InBuffer; |
| 147 |
| 148 |
| 149 NvRmClose( p_in->hDevice ); |
| 150 |
| 151 return err_; |
| 152 } |
| 153 |
| 154 static NvError NvRmOpenNew_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuf
fer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 155 { |
| 156 NvError err_ = NvSuccess; |
| 157 NvRmOpenNew_in *p_in; |
| 158 NvRmOpenNew_out *p_out; |
| 159 |
| 160 p_in = (NvRmOpenNew_in *)InBuffer; |
| 161 p_out = (NvRmOpenNew_out *)((NvU8 *)OutBuffer + OFFSET(NvRmOpenNew_params, o
ut) - OFFSET(NvRmOpenNew_params, inout)); |
| 162 |
| 163 |
| 164 p_out->ret_ = NvRmOpenNew( &p_out->pHandle ); |
| 165 |
| 166 return err_; |
| 167 } |
| 168 |
| 169 static NvError NvRmInit_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer
, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 170 { |
| 171 NvError err_ = NvSuccess; |
| 172 NvRmInit_in *p_in; |
| 173 NvRmInit_out *p_out; |
| 174 |
| 175 p_in = (NvRmInit_in *)InBuffer; |
| 176 p_out = (NvRmInit_out *)((NvU8 *)OutBuffer + OFFSET(NvRmInit_params, out) -
OFFSET(NvRmInit_params, inout)); |
| 177 |
| 178 |
| 179 NvRmInit( &p_out->pHandle ); |
| 180 |
| 181 return err_; |
| 182 } |
| 183 |
| 184 static NvError NvRmOpen_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer
, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 185 { |
| 186 NvError err_ = NvSuccess; |
| 187 NvRmOpen_in *p_in; |
| 188 NvRmOpen_out *p_out; |
| 189 |
| 190 p_in = (NvRmOpen_in *)InBuffer; |
| 191 p_out = (NvRmOpen_out *)((NvU8 *)OutBuffer + OFFSET(NvRmOpen_params, out) -
OFFSET(NvRmOpen_params, inout)); |
| 192 |
| 193 |
| 194 p_out->ret_ = NvRmOpen( &p_out->pHandle, p_in->DeviceId ); |
| 195 |
| 196 return err_; |
| 197 } |
| 198 |
| 199 NvError nvrm_init_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void *
OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ); |
| 200 NvError nvrm_init_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void *
OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 201 { |
| 202 NvError err_ = NvSuccess; |
| 203 |
| 204 switch( function ) { |
| 205 case 3: |
| 206 err_ = NvRmClose_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx ); |
| 207 break; |
| 208 case 2: |
| 209 err_ = NvRmOpenNew_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 210 break; |
| 211 case 1: |
| 212 err_ = NvRmInit_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx ); |
| 213 break; |
| 214 case 0: |
| 215 err_ = NvRmOpen_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx ); |
| 216 break; |
| 217 default: |
| 218 err_ = NvError_BadParameter; |
| 219 break; |
| 220 } |
| 221 |
| 222 return err_; |
| 223 } |
OLD | NEW |