omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / gsp / irqsim.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Explicit host-only GSP IRQ/queue peer. No map handles, VFIO, device fds or physical firmware. |
| 3 | note Model choices: finite queue; one edge may arrive during receive or the post-drain status read; |
| 4 | note service can fail at an ordinal or deliver a lockdown notification. Not firmware emulation. |
| 5 | note Constants intentionally independent of irq.om so a wrong handler mask does not move this peer. |
| 6 | global israw uint 1 |
| 7 | global ismask uint 1 |
| 8 | global isdest uint 1 |
| 9 | global iscnt ulong 1 |
| 10 | global isdone ulong 1 |
| 11 | global isedge ulong 1 |
| 12 | global isfail ulong 1 |
| 13 | global islock ulong 1 |
| 14 | global istail ulong 1 |
| 15 | global ispm ulong 1 |
| 16 | global isacks ulong 1 |
| 17 | global isreads ulong 1 |
| 18 | global ismasks ulong 1 |
| 19 | global isviol ulong 1 |
| 20 | global islocked ulong 1 |
| 21 | fn isaccess to void |
| 22 | if or ne get ispm 0 0 ne get islocked 0 0 |
| 23 | put isviol 0 add get isviol 0 1 |
| 24 | end |
| 25 | end |
| 26 | fn iqpm to bool |
| 27 | ret eq get ispm 0 0 |
| 28 | end |
| 29 | fn iqread to uint |
| 30 | isaccess |
| 31 | put isreads 0 add get isreads 0 1 |
| 32 | if and ne get istail 0 0 eq get isreads 0 2 |
| 33 | put istail 0 0 |
| 34 | put israw 0 or get israw 0 64 |
| 35 | put iscnt 0 add get iscnt 0 1 |
| 36 | end |
| 37 | ret and and get israw 0 get ismask 0 get isdest 0 |
| 38 | end |
| 39 | fn iqclear v uint to void |
| 40 | isaccess |
| 41 | if ne v 64 |
| 42 | put isviol 0 add get isviol 0 1 |
| 43 | end |
| 44 | put isacks 0 add get isacks 0 1 |
| 45 | put israw 0 and get israw 0 not v |
| 46 | end |
| 47 | fn iqready to bool |
| 48 | isaccess |
| 49 | if eq get isacks 0 0 |
| 50 | put isviol 0 add get isviol 0 1 |
| 51 | end |
| 52 | ret lt get isdone 0 get iscnt 0 |
| 53 | end |
| 54 | fn iqrecv to long |
| 55 | isaccess |
| 56 | if eq get isacks 0 0 |
| 57 | put isviol 0 add get isviol 0 1 |
| 58 | end |
| 59 | n = add get isdone 0 1 |
| 60 | if eq get isfail 0 n |
| 61 | ret -1 |
| 62 | end |
| 63 | if gt n get iscnt 0 |
| 64 | ret -1 |
| 65 | end |
| 66 | put isdone 0 n |
| 67 | if and ne get isedge 0 0 eq get isedge 0 n |
| 68 | put isedge 0 0 |
| 69 | put israw 0 or get israw 0 64 |
| 70 | put iscnt 0 add get iscnt 0 1 |
| 71 | end |
| 72 | if eq get islock 0 n |
| 73 | put islocked 0 1 |
| 74 | ret 2 |
| 75 | end |
| 76 | ret 1 |
| 77 | end |
| 78 | fn iqmask to void |
| 79 | isaccess |
| 80 | put ismasks 0 add get ismasks 0 1 |
| 81 | put ismask 0 0 |
| 82 | end |