interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / driver / tests / pm_gate.om

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