interplane.Get Omega
Read in your language

omega-gpu-driver

aien-dev/omega-gpu-driver

Brought by drakestapleton

branch main Branches Tags History

omega-gpu-driver / rm / uvmclient.om

224 lines · 3309 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note HOST_MODEL client UVM adapter. Reuses bounded half-open ranges from uvm/range.om;
3note no PTE publication or real backing. RM capabilities, not handles-as-physical-addresses.
4fn rmusize cmd ulong to ulong
5if eq cmd 805306369
6ret 16
7end
8if eq cmd 37
9ret 40
10end
11if eq cmd 25
12ret 32
13end
14if eq cmd 73
15ret 24
16end
17if eq cmd 33
18ret 9264
19end
20if eq cmd 34
21ret 24
22end
23if eq cmd 26
24ret 20
25end
26if eq cmd 38
27ret 20
28end
29ret 0
30end
31fn rmuoff cmd ulong to ulong
32if eq cmd 805306369
33ret 8
34end
35if eq cmd 37
36ret 36
37end
38if eq cmd 25
39ret 28
40end
41if eq cmd 33
42ret 9260
43end
44ret 16
45end
46fn rmuuid t view ulong 4096 b view uchar 16384 off ulong to bool
47for j ulong 16
48if ne get b add off j rmfx t add 136 j
49ret false
50end
51end
52ret true
53end
54fn rmucreate t edit ulong 4096 b view uchar 16384 to ulong
55va = rmget b 72 8
56n = rmget b 80 8
57if not rmmrange va n
58ret 31
59end
60empty = ulong 64
61for j ulong 64
62k = add 2600 mul j 4
63if eq get t k 0
64empty = j
65else
66lo = get t add k 1
67hi = add lo get t add k 2
68if and lt va hi lt lo add va n
69ret 52
70end
71end
72end
73if eq empty 64
74ret 81
75end
76k = add 2600 mul empty 4
77put t k 1
78put t add k 1 va
79put t add k 2 n
80ret 0
81end
82fn rmumap t edit ulong 4096 b view uchar 16384 to ulong
83va = rmget b 72 8
84n = rmget b 80 8
85if or ne rmget b 88 8 0 ne rmget b 9312 8 1
86ret 31
87end
88if not rmuuid t b 96
89ret 31
90end
91cli = rmget b 9324 4
92slot = rmfind t cli rmget b 9328 4
93if eq slot 64
94ret 51
95end
96if gt n get t add 512 mul slot 4
97ret 31
98end
99found = false
100for j ulong 64
101k = add 2048 mul j 8
102same = eq get t k 1
103same = and same eq get t add k 1 slot
104same = and same eq get t add k 2 2
105if same
106same = eq get t add k 3 va
107same = and same eq get t add k 4 n
108if same
109found = true
110end
111end
112end
113if not found
114ret 54
115end
116for j ulong 64
117k = add 2600 mul j 4
118same = eq get t k 1
119same = and same eq get t add k 1 va
120same = and same eq get t add k 2 n
121if same
122put t k 2
123put t add k 3 add slot 1
124ret 0
125end
126end
127ret 51
128end
129fn rmufree t edit ulong 4096 b view uchar 16384 to ulong
130for j ulong 64
131k = add 2600 mul j 4
132same = ne get t k 0
133same = and same eq get t add k 1 rmget b 72 8
134same = and same eq get t add k 2 rmget b 80 8
135if same
136put t k 0
137ret 0
138end
139end
140ret 51
141end
142fn rmuvact t edit ulong 4096 b edit uchar 16384 cmd ulong to ulong
143if eq cmd 805306369
144if or ne get t 420 0 ne rmget b 72 8 0
145ret 31
146end
147put t 420 1
148ret 0
149end
150if eq cmd 25
151if not rmuuid t b 72
152ret 31
153end
154cli = rmget b 92 4
155slot = rmfind t cli rmget b 96 4
156if eq slot 64
157ret 51
158end
159if ne get t add mul slot 5 4 37105
160ret 54
161end
162put t 420 1
163put t 421 1
164put t 422 add slot 1
165ret 0
166end
167if eq get t 420 0
168ret 54
169end
170if eq cmd 37
171if or ne get t 421 0 not rmuuid t b 72
172ret 31
173end
174if ne rmget b 96 4 4294967295
175ret 31
176end
177put t 421 1
178rmput b 88 4 0
179rmput b 92 4 4294967295
180ret 0
181end
182if eq cmd 38
183if not rmuuid t b 72
184ret 31
185end
186if or eq get t 421 0 ne get t 422 0
187ret 54
188end
189put t 421 0
190ret 0
191end
192if eq cmd 26
193if not rmuuid t b 72
194ret 31
195end
196if eq get t 422 0
197ret 51
198end
199for j ulong 64
200if ne get t add 2600 mul j 4 0
201ret 52
202end
203end
204put t 422 0
205ret 0
206end
207if eq get t 422 0
208ret 54
209end
210if eq cmd 73
211ret rmucreate t b
212end
213if eq cmd 33
214ret rmumap t b
215end
216if eq cmd 34
217ret rmufree t b
218end
219ret 86
220end
221fn rmuvcall t edit ulong 4096 b edit uchar 16384 cmd ulong to void
222r = rmuvact t b cmd
223rmput b add 72 rmuoff cmd 4 r
224end