omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / uvm / notify.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note UVM-owned MODEL notification, not a physical IRQ or TLB completion lease. |
| 3 | note Uses omega-mv#1045 eventfd only. No OmcVfioIrq registration or device open. |
| 4 | abstract unirq ulong |
| 5 | global unfd int 1 |
| 6 | global unlive ulong 1 |
| 7 | global unwakes ulong 1 |
| 8 | global unbytes uchar 8 |
| 9 | fn unvalid cap unirq to bool |
| 10 | ret and eq open cap 1 eq get unlive 0 1 |
| 11 | end |
| 12 | fn unirqmk to unirq |
| 13 | if ne get unlive 0 0 |
| 14 | ret seal unirq ulong 0 |
| 15 | end |
| 16 | r = eventfd uint 0 |
| 17 | if lt r 0 |
| 18 | ret seal unirq ulong 0 |
| 19 | end |
| 20 | put unfd 0 int r |
| 21 | put unlive 0 1 |
| 22 | ret seal unirq ulong 1 |
| 23 | end |
| 24 | fn unpost cap unirq to long |
| 25 | if not unvalid cap |
| 26 | ret -9 |
| 27 | end |
| 28 | r = fbpush |
| 29 | if ne r UVOK |
| 30 | ret long r |
| 31 | end |
| 32 | for j ulong 8 |
| 33 | put unbytes j 0 |
| 34 | end |
| 35 | put unbytes 0 1 |
| 36 | wr = write get unfd 0 unbytes 0 8 |
| 37 | if ne wr 8 |
| 38 | note Entry remains owned by the ring; never undo a possibly delivered notification. |
| 39 | ret -5 |
| 40 | end |
| 41 | ret 0 |
| 42 | end |
| 43 | fn unpump cap unirq timeout long to long |
| 44 | if not unvalid cap |
| 45 | ret -9 |
| 46 | end |
| 47 | r = waitio get unfd 0 1 timeout |
| 48 | if eq r 0 |
| 49 | ret 0 |
| 50 | end |
| 51 | if lt r 0 |
| 52 | ret r |
| 53 | end |
| 54 | r = read get unfd 0 unbytes 0 8 |
| 55 | if ne r 8 |
| 56 | ret -5 |
| 57 | end |
| 58 | count = ulong 0 |
| 59 | for j ulong 8 |
| 60 | count = or count shl ulong get unbytes j mul j 8 |
| 61 | end |
| 62 | put unwakes 0 add get unwakes 0 count |
| 63 | r2 = fbbatch |
| 64 | if ne r2 UVOK |
| 65 | ret long r2 |
| 66 | end |
| 67 | ret 1 |
| 68 | end |
| 69 | fn unclose cap unirq to long |
| 70 | if not unvalid cap |
| 71 | ret -9 |
| 72 | end |
| 73 | put unlive 0 2 |
| 74 | ret fclose get unfd 0 |
| 75 | end |