omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / gsp / irqqueue.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Ordered GSP RX adapter over transport.om; stage immutable validated RPC, handle, then publish. |
| 3 | note No direct drvstep-to-iqrecv binding: service result2 is sequencer progress, NOT lockdown. |
| 4 | note Lockdown event source: NVIDIA580.173.02 rpc_global_enums.h GSP_LOCKDOWN_NOTICE0x101c; |
| 5 | note g_rpc-structures.h rpc_gsp_lockdown_notice_v17_00 is one NvBool byte. |
| 6 | note WolframLanguageEvaluator {5*8,FromDigits["101c",16],8*40} -> {40,4124,320}. |
| 7 | global qrstate ulong 1 |
| 8 | global qrtoken ulong 1 |
| 9 | global qrlock ulong 1 |
| 10 | global qruse ulong 1 |
| 11 | fn qrfail r long to long |
| 12 | qtlose |
| 13 | put qrstate 0 3 |
| 14 | ret r |
| 15 | end |
| 16 | fn qrready to long |
| 17 | if ne get qrlock 0 0 |
| 18 | ret -14 |
| 19 | end |
| 20 | if ne get qrstate 0 0 |
| 21 | ret -6 |
| 22 | end |
| 23 | r = qtsnap |
| 24 | if ne r 0 |
| 25 | ret qrfail r |
| 26 | end |
| 27 | put qrtoken 0 get qttok 0 |
| 28 | r = qtstage get qrtoken 0 |
| 29 | if lt r 0 |
| 30 | ret qrfail r |
| 31 | end |
| 32 | if eq r 1 |
| 33 | put qrstate 0 1 |
| 34 | end |
| 35 | ret r |
| 36 | end |
| 37 | fn qrrecv to long |
| 38 | if or ne get qrstate 0 1 ne get qrlock 0 0 |
| 39 | ret -6 |
| 40 | end |
| 41 | if eq get rqfun 0 4124 |
| 42 | if or ne get rqlen 0 1 ne get rqout 80 1 |
| 43 | ret qrfail -13 |
| 44 | end |
| 45 | note Sticky lockdown: no consumer publication or further register effects after recognizing it. |
| 46 | put qrlock 0 1 |
| 47 | put qrstate 0 2 |
| 48 | ret 2 |
| 49 | end |
| 50 | put qthold 0 1 |
| 51 | r = drvstep ne get qruse 0 0 |
| 52 | put qthold 0 0 |
| 53 | if lt r 0 |
| 54 | ret qrfail r |
| 55 | end |
| 56 | if eq r 0 |
| 57 | ret qrfail -13 |
| 58 | end |
| 59 | r = qthandled get qrtoken 0 |
| 60 | if ne r 0 |
| 61 | ret qrfail r |
| 62 | end |
| 63 | r = qtfinish get qrtoken 0 |
| 64 | if ne r 1 |
| 65 | ret qrfail r |
| 66 | end |
| 67 | put qrstate 0 0 |
| 68 | ret 1 |
| 69 | end |
| 70 | note Explicit model-only UVM command queue, NOT a GSP RPC function-number assignment. |
| 71 | note Five u64 LE fields: op(1 replay,2 invalidate), sequence, VA, PA, flags; bounded8 records. |
| 72 | note iqcommand records transport acceptance only, never MMU/TLB effect completion. |
| 73 | global iqcmode ulong 1 |
| 74 | global iqcstate ulong 1 |
| 75 | global iqcseq ulong 1 |
| 76 | global iqcprod ulong 1 |
| 77 | global iqccons ulong 1 |
| 78 | global iqcmd uchar 320 |
| 79 | fn iqcword off ulong v ulong to void |
| 80 | for i ulong 8 |
| 81 | put iqcmd add off i uchar and shr v mul i 8 255 |
| 82 | end |
| 83 | end |
| 84 | fn iqcommand op ulong seq ulong va ulong pa ulong flags ulong to long |
| 85 | if ne get iqcmode 0 1 |
| 86 | ret -95 |
| 87 | end |
| 88 | if or ne get iqcstate 0 1 or eq seq 0 le seq get iqcseq 0 |
| 89 | ret -4 |
| 90 | end |
| 91 | if not or eq op 1 eq op 2 |
| 92 | ret -1 |
| 93 | end |
| 94 | if ge sub get iqcprod 0 get iqccons 0 8 |
| 95 | ret -2 |
| 96 | end |
| 97 | if eq add get iqcprod 0 1 0 |
| 98 | ret -4 |
| 99 | end |
| 100 | o = mul rem get iqcprod 0 8 40 |
| 101 | iqcword o op |
| 102 | iqcword add o 8 seq |
| 103 | iqcword add o 16 va |
| 104 | iqcword add o 24 pa |
| 105 | iqcword add o 32 flags |
| 106 | note Serialized model release/publication; physical ordered queue/DMA effects are not admitted here. |
| 107 | put iqcprod 0 add get iqcprod 0 1 |
| 108 | put iqcseq 0 seq |
| 109 | ret 0 |
| 110 | end |