• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1nv_classes = [
2  'cl902d',
3  'cl9039',
4  'cl906f',
5  'cl9097',
6  'cl90b5',
7  'cl90c0',
8  'cla040',
9  'cla0b5',
10  'cla097',
11  'cla140',
12  'cla297',
13  'clb097',
14  'clb0c0',
15  'clb197',
16  'clb1c0',
17  'clc097',
18  'clc1b5',
19  'cla0c0',
20  'clc0c0',
21  'clc397',
22  'clc3c0',
23  'clc597',
24  'clc5c0',
25  'clc697',
26  'clc6c0',
27  'clc797',
28  'clc7c0',
29]
30
31hwref_gens = [
32  'maxwell/gm107',
33  'pascal/gp100',
34  'hopper/gh100',
35  'turing/tu102',
36]
37
38cl_generated = []
39foreach cl : nv_classes
40  cl_generated += custom_target(
41    cl + '.h',
42    input : ['class_parser.py', 'nvidia/classes/'+cl+'.h'],
43    output : ['nv_push_'+cl+'.h', 'nv_push_'+cl+'.c'],
44    command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@',
45               '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@'],
46  )
47endforeach
48
49_libnvidia_headers = static_library(
50  'nvidia_headers_c',
51  ['nv_push.c', cl_generated],
52  include_directories : ['.', 'nvidia/classes', inc_include, inc_src],
53  c_args : [no_override_init_args],
54  gnu_symbol_visibility : 'hidden',
55)
56
57idep_nvidia_headers = declare_dependency(
58  include_directories : include_directories('.', 'nvidia/classes'),
59  sources : cl_generated,
60  link_with : _libnvidia_headers,
61)
62
63executable(
64  'nv_push_dump',
65  'nv_push_dump.c',
66  dependencies : [ idep_mesautil, idep_nvidia_headers ],
67  build_by_default : with_tools.contains('nouveau'),
68  install : with_tools.contains('nouveau'),
69)
70
71# Only generate Rust bindings for NVK
72if with_nouveau_vk
73  cl_rs_generated = []
74  foreach cl : nv_classes
75    cl_rs_generated += custom_target(
76      'nvh_classes_' + cl + '.rs',
77      input : ['class_parser.py', 'nvidia/classes/'+cl+'.h'],
78      output : ['nvh_classes_'+cl+'.rs'],
79      command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@',
80                 '--out-rs', '@OUTPUT0@'],
81    )
82
83    cl_rs_generated += custom_target(
84      'nvh_' + cl + '_mthd.rs',
85      input : ['class_parser.py', 'nvidia/classes/'+cl+'.h'],
86      output : ['nvh_classes_'+cl+'_mthd.rs'],
87      command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@',
88                 '--out-rs-mthd', '@OUTPUT0@'],
89    )
90
91    if cl.endswith('c0') and fs.is_file('nvidia/classes/'+cl+'qmd.h')
92      cl_rs_generated += custom_target(
93        'nvh_classes_' + cl + '_qmd.rs',
94        input : ['struct_parser.py', 'nvidia/classes/'+cl+'qmd.h'],
95        output : ['nvh_classes_'+cl+'_qmd.rs'],
96        command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@',
97                   '--out-rs', '@OUTPUT0@']
98      )
99    endif
100
101    if cl.endswith('97')
102      cl_rs_generated += custom_target(
103        'nvh_classes_' + cl + '_tex.rs',
104        input : ['struct_parser.py', 'nvidia/classes/'+cl+'tex.h'],
105        output : ['nvh_classes_'+cl+'_tex.rs'],
106        command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@',
107                   '--out-rs', '@OUTPUT0@']
108      )
109    endif
110
111    if fs.is_file(f'nvidia/classes/@cl@sph.h')
112      cl_rs_generated += custom_target(
113        input : ['struct_parser.py', f'nvidia/classes/@cl@sph.h'],
114        output : [f'nvh_classes_@cl@_sph.rs'],
115        command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@',
116                   '--out-rs', '@OUTPUT0@']
117      )
118    endif
119  endforeach
120
121  foreach family_gen : hwref_gens
122    family = fs.parent(family_gen)
123    gen = fs.name(family_gen)
124    cl_rs_generated += rust.bindgen(
125      input : ['nvidia/hwref/'+family+'/'+gen+'/dev_mmu.h'],
126      output : 'nvh_hwref_'+gen+'_mmu.rs',
127      args : ['--allowlist-var', 'NV_MMU_.*'],
128    )
129  endforeach
130
131  _nvidia_headers_lib_rs = custom_target(
132    'lib.rs',
133    input : ['lib_rs_gen.py'],
134    output : ['lib.rs'],
135    command : [prog_python, '@INPUT0@', '--out-rs', '@OUTPUT0@',
136               cl_rs_generated]
137  )
138
139  _nvidia_headers_rs = static_library(
140    'nvidia_headers',
141    _nvidia_headers_lib_rs,
142    gnu_symbol_visibility : 'hidden',
143    rust_abi : 'rust',
144  )
145
146  idep_nvidia_headers_rs = declare_dependency(
147    link_with : _nvidia_headers_rs,
148  )
149
150  _libnv_push_rs = static_library(
151    'nv_push_rs',
152    files('nv_push_rs/lib.rs'),
153    gnu_symbol_visibility: 'hidden',
154    rust_abi: 'rust',
155    dependencies: [idep_nvidia_headers_rs],
156  )
157
158  idep_nv_push_rs = declare_dependency(
159    link_with : _libnv_push_rs,
160  )
161endif
162