omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / tests / pm_gate.om
| 1 | note tests/pm_gate.om: the runtime-PM gate of gspboot (gsp/mmio.om). On arm64 a BAR read of a |
| 2 | note device in D3 is an external abort, so gspboot must refuse with EPM (-9) before its first access. |
| 3 | note usage: pm_gate SUSPENDED_FILE ACTIVE_FILE NEAR_FILE (host files holding "suspended\n", "active\n" |
| 4 | note and "activa\n", same length as active but one byte off). |
| 5 | note exit 0 PASS; 1..7 name the case that failed. Mode 1 is only pointed at host files here: gspbar is |
| 6 | note never mapped, so a gate that let the start through would trap on its first mapget (exit != 0). |
| 7 | global pa uchar 128 |
| 8 | global pb uchar 128 |
| 9 | global pc uchar 128 |
| 10 | fn setgin to void |
| 11 | for i ulong 7 |
| 12 | put gin i 0 |
| 13 | end |
| 14 | put gin 0 4 |
| 15 | for k ulong 4 |
| 16 | put gpkt k uchar 1 |
| 17 | end |
| 18 | end |
| 19 | fn usepath which int n long to void |
| 20 | for i ulong ulong n |
| 21 | if eq which 0 |
| 22 | put gpmp i get pa i |
| 23 | end |
| 24 | if eq which 1 |
| 25 | put gpmp i get pb i |
| 26 | end |
| 27 | if eq which 2 |
| 28 | put gpmp i get pc i |
| 29 | end |
| 30 | end |
| 31 | put gpmn 0 ulong n |
| 32 | end |
| 33 | fn main to int |
| 34 | if ne argcnt 4 |
| 35 | ret 9 |
| 36 | end |
| 37 | na = argread 1 pa 0 128 |
| 38 | nb = argread 2 pb 0 128 |
| 39 | nc = argread 3 pc 0 128 |
| 40 | if or or le na 0 le nb 0 le nc 0 |
| 41 | ret 9 |
| 42 | end |
| 43 | note case 1, planted fault: simulated device suspended; refused, zero accesses, zero violations |
| 44 | put gspmode 0 0 |
| 45 | siminit |
| 46 | put spm 0 1 |
| 47 | setgin |
| 48 | if ne gspboot EPM |
| 49 | ret 1 |
| 50 | end |
| 51 | if or ne sg SNLOG 0 ne sg SVIOL 0 |
| 52 | ret 2 |
| 53 | end |
| 54 | note case 2, positive control: the same start with the device active is not refused and touches it |
| 55 | siminit |
| 56 | put spm 0 0 |
| 57 | setgin |
| 58 | if eq gspboot EPM |
| 59 | ret 3 |
| 60 | end |
| 61 | if eq sg SNLOG 0 |
| 62 | ret 4 |
| 63 | end |
| 64 | note case 3: mode 1 reads runtime_status from a file that says suspended; refused before any mapget |
| 65 | put gspmode 0 1 |
| 66 | usepath 0 na |
| 67 | if ne gspboot EPM |
| 68 | ret 5 |
| 69 | end |
| 70 | note case 4: the same reader accepts exactly "active\n" |
| 71 | usepath 1 nb |
| 72 | if not gsppm |
| 73 | ret 6 |
| 74 | end |
| 75 | note case 5: one byte off is refused |
| 76 | usepath 2 nc |
| 77 | if gsppm |
| 78 | ret 7 |
| 79 | end |
| 80 | put gspmode 0 0 |
| 81 | ret 0 |
| 82 | end |