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 / handles.om

142 lines · 2547 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note 64 monotonically consumed slots per open. Tombstones refuse handle reuse until close.
3note Fields live, handle, client, parent, class. Metadata 400 next-root, 401 used.
4fn rmfind t view ulong 4096 cli ulong obj ulong to ulong
5for j ulong 64
6k = mul j 5
7if eq get t k 1
8if eq get t add k 1 obj
9if eq get t add k 2 cli
10ret j
11end
12end
13end
14end
15ret 64
16end
17fn rmseen t view ulong 4096 cli ulong obj ulong to bool
18for j ulong get t 401
19k = mul j 5
20if and eq get t add k 1 obj eq get t add k 2 cli
21ret true
22end
23end
24ret false
25end
26fn rmparent cls ulong parcls ulong to bool
27if or eq cls 62 or eq cls 64 eq cls 112
28ret eq parcls 128
29end
30if or eq cls 50017 eq cls 50785
31ret eq parcls 8320
32end
33if eq cls 128
34ret eq parcls 65
35end
36if or eq cls 8320 or eq cls 37105 eq cls 41068
37ret eq parcls 128
38end
39if or eq cls 36967 eq cls 51567
40ret eq parcls 41068
41end
42if eq cls 52928
43ret eq parcls 51567
44end
45ret false
46end
47fn rminsert t edit ulong 4096 cli ulong par ulong obj ulong cls ulong to ulong
48if eq get t 401 64
49ret 5
50end
51k = mul get t 401 5
52put t k 1
53put t add k 1 obj
54put t add k 2 cli
55put t add k 3 par
56put t add k 4 cls
57put t 401 add get t 401 1
58ret 0
59end
60fn rmaokay t view ulong 4096 a view ulong 8 to ulong
61cli = get a 0
62par = get a 1
63obj = get a 2
64cls = get a 3
65if eq cls 65
66if or ne cli 0 or ne par 0 ne obj 0
67ret 1
68end
69if eq get t 400 4294967295
70ret 5
71end
72if eq get t 401 64
73ret 5
74end
75ret 0
76end
77p = rmfind t cli par
78if eq p 64
79ret 3
80end
81if not rmparent cls get t add mul p 5 4
82ret 3
83end
84if eq obj 0
85ret 1
86end
87if rmseen t cli obj
88ret 4
89end
90if eq get t 401 64
91ret 5
92end
93ret 0
94end
95fn rmchild t view ulong 4096 cli ulong par ulong to bool
96for q ulong 64
97k = mul q 5
98a = eq get t k 2
99b = eq get t add k 2 cli
100c = eq get t add k 1 par
101if and a and b c
102ret true
103end
104end
105ret false
106end
107fn rmfslot t view ulong 4096 cli ulong par ulong obj ulong to ulong
108s = rmfind t cli obj
109if eq s 64
110ret 2
111end
112if ne get t add mul s 5 3 par
113ret 3
114end
115ret add s 64
116end
117fn rmkill t edit ulong 4096 cli ulong s ulong to void
118note Parent slots precede children because insertion is monotonic and handles never recycle.
119put t mul s 5 2
120for j ulong 64
121k = mul j 5
122if and eq get t k 1 eq get t add k 2 cli
123if rmchild t cli get t add k 3
124put t k 2
125end
126end
127end
128for j ulong 64
129if eq get t mul j 5 2
130put t mul j 5 0
131end
132end
133end
134fn rmref t view ulong 4096 cli ulong obj ulong cls ulong par ulong to bool
135s = rmfind t cli obj
136if eq s 64
137ret false
138end
139a = eq get t add mul s 5 4 cls
140b = eq get t add mul s 5 3 par
141ret and a b
142end