| 1 |
nv_classes = [ |
| 2 |
'cl85b5', |
| 3 |
'cl902d', |
| 4 |
'cl9039', |
| 5 |
'cl906f', |
| 6 |
'cl9097', |
| 7 |
'cl90b5', |
| 8 |
'cl90c0', |
| 9 |
'cl91c0', |
| 10 |
'cl9297', |
| 11 |
'cla040', |
| 12 |
'cla0b5', |
| 13 |
'cla06f', |
| 14 |
'cla097', |
| 15 |
'cla140', |
| 16 |
'cla16f', |
| 17 |
'cla1c0', |
| 18 |
'cla197', |
| 19 |
'cla26f', |
| 20 |
'cla297', |
| 21 |
'clb06f', |
| 22 |
'clb097', |
| 23 |
'clb0b5', |
| 24 |
'clb0c0', |
| 25 |
'clb197', |
| 26 |
'clb1c0', |
| 27 |
'clc06f', |
| 28 |
'clc097', |
| 29 |
'clc197', |
| 30 |
'clc1b5', |
| 31 |
'clc1c0', |
| 32 |
'cla0c0', |
| 33 |
'clc0b5', |
| 34 |
'clc0c0', |
| 35 |
'clc36f', |
| 36 |
'clc397', |
| 37 |
'clc3b5', |
| 38 |
'clc3c0', |
| 39 |
'clc46f', |
| 40 |
'clc56f', |
| 41 |
'clc597', |
| 42 |
'clc5b0', |
| 43 |
'clc5b5', |
| 44 |
'clc5c0', |
| 45 |
'clc697', |
| 46 |
'clc6b5', |
| 47 |
'clc6c0', |
| 48 |
'clc797', |
| 49 |
'clc7b0', |
| 50 |
'clc7b5', |
| 51 |
'clc7c0', |
| 52 |
'clc86f', |
| 53 |
'clc8b5', |
| 54 |
'clc96f', |
| 55 |
'clc997', |
| 56 |
'clc9b0', |
| 57 |
'clc9b5', |
| 58 |
'clc9c0', |
| 59 |
'clca6f', |
| 60 |
'clcab5', |
| 61 |
'clcb97', |
| 62 |
'clcbc0', |
| 63 |
'clcd97', |
| 64 |
'clcdc0', |
| 65 |
'clcec0', |
| 66 |
'clce97', |
| 67 |
] |
| 68 |
|
| 69 |
hwref_gens = [ |
| 70 |
'maxwell/gm107', |
| 71 |
'pascal/gp100', |
| 72 |
'hopper/gh100', |
| 73 |
'turing/tu102', |
| 74 |
] |
| 75 |
|
| 76 |
flat_nv_classes = '' |
| 77 |
|
| 78 |
cl_generated = [] |
| 79 |
foreach cl : nv_classes |
| 80 |
prev_cl_h = [] |
| 81 |
prev_cl_args = [] |
| 82 |
foreach prev_cl : nv_classes |
| 83 |
if prev_cl == cl |
| 84 |
break |
| 85 |
endif |
| 86 |
|
| 87 |
if prev_cl.substring(-2) == cl.substring(-2) |
| 88 |
prev_cl_h = 'nvidia/classes/'+prev_cl+'.h' |
| 89 |
prev_cl_args = ['--prev-in-h', '@INPUT2@'] |
| 90 |
endif |
| 91 |
endforeach |
| 92 |
|
| 93 |
flat_nv_classes = flat_nv_classes + cl + ' ' |
| 94 |
cl_generated += custom_target( |
| 95 |
cl + '.h', |
| 96 |
input : ['class_parser.py', 'nvidia/classes/'+cl+'.h', prev_cl_h, 'util.py'], |
| 97 |
output : ['nv_push_'+cl+'.h', 'nv_push_'+cl+'.c'], |
| 98 |
command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', prev_cl_args, |
| 99 |
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@'], |
| 100 |
) |
| 101 |
endforeach |
| 102 |
|
| 103 |
nv_push_class_dump_h = custom_target( |
| 104 |
'nv_push_class_dump.h', |
| 105 |
input : ['nv_push_class_dump_h.py', 'nvidia/classes/'+cl+'.h', 'util.py'], |
| 106 |
output : ['nv_push_class_dump.h'], |
| 107 |
command : [prog_python, '@INPUT0@', '--classes', flat_nv_classes, '--out-h', '@OUTPUT0@'], |
| 108 |
) |
| 109 |
|
| 110 |
libnvidia_headers = static_library( |
| 111 |
'nvidia_headers_c', |
| 112 |
['nv_push.c', cl_generated, nv_push_class_dump_h], |
| 113 |
include_directories : ['.', 'nvidia/classes', inc_include, inc_src], |
| 114 |
c_args : [no_override_init_args], |
| 115 |
gnu_symbol_visibility : 'hidden', |
| 116 |
) |
| 117 |
|
| 118 |
idep_nvidia_headers = declare_dependency( |
| 119 |
include_directories : include_directories('.', 'nvidia/classes'), |
| 120 |
sources : cl_generated, |
| 121 |
link_with : libnvidia_headers, |
| 122 |
) |
| 123 |
|
| 124 |
executable( |
| 125 |
'nv_push_dump', |
| 126 |
'nv_push_dump.c', |
| 127 |
dependencies : [ idep_mesautil, idep_nvidia_headers ], |
| 128 |
build_by_default : with_tools.contains('nouveau'), |
| 129 |
install : with_tools.contains('nouveau'), |
| 130 |
) |
| 131 |
|
| 132 |
nouveau_util_py = files('util.py') |
| 133 |
nouveau_util_py_path = meson.current_source_dir() |
| 134 |
|
| 135 |
# Only generate Rust bindings for NVK |
| 136 |
if with_nouveau_vk |
| 137 |
cl_rs_generated = [] |
| 138 |
foreach cl : nv_classes |
| 139 |
cl_rs_generated += custom_target( |
| 140 |
'nvh_classes_' + cl + '.rs', |
| 141 |
input : ['class_parser.py', 'nvidia/classes/'+cl+'.h', 'util.py'], |
| 142 |
output : ['nvh_classes_'+cl+'.rs'], |
| 143 |
command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', |
| 144 |
'--out-rs', '@OUTPUT0@'], |
| 145 |
) |
| 146 |
|
| 147 |
prev_cl_h = [] |
| 148 |
prev_cl_args = [] |
| 149 |
foreach prev_cl : nv_classes |
| 150 |
if prev_cl == cl |
| 151 |
break |
| 152 |
endif |
| 153 |
|
| 154 |
if prev_cl.substring(-2) == cl.substring(-2) |
| 155 |
prev_cl_h = 'nvidia/classes/'+prev_cl+'.h' |
| 156 |
prev_cl_args = ['--prev-in-h', '@INPUT2@'] |
| 157 |
endif |
| 158 |
endforeach |
| 159 |
|
| 160 |
cl_rs_generated += custom_target( |
| 161 |
'nvh_' + cl + '_mthd.rs', |
| 162 |
input : ['class_parser.py', 'nvidia/classes/'+cl+'.h', prev_cl_h, 'util.py'], |
| 163 |
output : ['nvh_classes_'+cl+'_mthd.rs'], |
| 164 |
command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', |
| 165 |
prev_cl_args, '--out-rs-mthd', '@OUTPUT0@'], |
| 166 |
) |
| 167 |
|
| 168 |
if cl.endswith('c0') and fs.is_file('nvidia/classes/'+cl+'qmd.h') |
| 169 |
cl_rs_generated += custom_target( |
| 170 |
'nvh_classes_' + cl + '_qmd.rs', |
| 171 |
input : ['struct_parser.py', 'nvidia/classes/'+cl+'qmd.h', 'util.py'], |
| 172 |
output : ['nvh_classes_'+cl+'_qmd.rs'], |
| 173 |
command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', |
| 174 |
'--out-rs', '@OUTPUT0@'] |
| 175 |
) |
| 176 |
endif |
| 177 |
|
| 178 |
if cl.endswith('97') |
| 179 |
cl_rs_generated += custom_target( |
| 180 |
'nvh_classes_' + cl + '_tex.rs', |
| 181 |
input : ['struct_parser.py', 'nvidia/classes/'+cl+'tex.h', 'util.py'], |
| 182 |
output : ['nvh_classes_'+cl+'_tex.rs'], |
| 183 |
command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', |
| 184 |
'--out-rs', '@OUTPUT0@'] |
| 185 |
) |
| 186 |
endif |
| 187 |
|
| 188 |
if fs.is_file(f'nvidia/classes/@[email protected]') |
| 189 |
cl_rs_generated += custom_target( |
| 190 |
input : ['struct_parser.py', f'nvidia/classes/@[email protected]', 'util.py'], |
| 191 |
output : [f'nvh_classes_@cl@_sph.rs'], |
| 192 |
command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', |
| 193 |
'--out-rs', '@OUTPUT0@'] |
| 194 |
) |
| 195 |
endif |
| 196 |
endforeach |
| 197 |
|
| 198 |
foreach family_gen : hwref_gens |
| 199 |
family = fs.parent(family_gen) |
| 200 |
gen = fs.name(family_gen) |
| 201 |
cl_rs_generated += rust.bindgen( |
| 202 |
input : ['nvidia/hwref/'+family+'/'+gen+'/dev_mmu.h'], |
| 203 |
output : 'nvh_hwref_'+gen+'_mmu.rs', |
| 204 |
args : ['--allowlist-var', 'NV_MMU_.*'], |
| 205 |
) |
| 206 |
endforeach |
| 207 |
|
| 208 |
_nvidia_headers_lib_rs = custom_target( |
| 209 |
'lib.rs', |
| 210 |
input : ['lib_rs_gen.py', 'util.py'], |
| 211 |
output : ['lib.rs'], |
| 212 |
command : [prog_python, '@INPUT0@', '--out-rs', '@OUTPUT0@', |
| 213 |
cl_rs_generated] |
| 214 |
) |
| 215 |
|
| 216 |
_nvidia_headers_rs = static_library( |
| 217 |
'nvidia_headers', |
| 218 |
_nvidia_headers_lib_rs, |
| 219 |
gnu_symbol_visibility : 'hidden', |
| 220 |
rust_abi : 'rust', |
| 221 |
) |
| 222 |
|
| 223 |
idep_nvidia_headers_rs = declare_dependency( |
| 224 |
link_with : _nvidia_headers_rs, |
| 225 |
) |
| 226 |
|
| 227 |
_libnv_push_rs = static_library( |
| 228 |
'nv_push_rs', |
| 229 |
files('nv_push_rs/lib.rs'), |
| 230 |
gnu_symbol_visibility: 'hidden', |
| 231 |
rust_abi: 'rust', |
| 232 |
rust_args : rust_global_args, |
| 233 |
dependencies: [idep_nvidia_headers_rs], |
| 234 |
) |
| 235 |
|
| 236 |
idep_nv_push_rs = declare_dependency( |
| 237 |
link_with : _libnv_push_rs, |
| 238 |
) |
| 239 |
endif |