c6a2f53e86e5404cb7077ba55398f6f704f03728
[barrelfish] / usr / skb / programs / decodingNetSKB.pl
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 % Copyright (c) 2017, ETH Zurich.
3 % All rights reserved.
4 %
5 % This file is distributed under the terms in the attached LICENSE file.
6 % If you do not find this file, copies can be found by writing to:
7 % ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich.
8 % Attn: Systems Group.
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10
11 :- use_module(decodingNet).
12 :- use_module(decodingNetQueries).
13 :- local loadnet/1.
14
15 %%%%%%%%%%%%%%
16 %% Printing %%
17 %%%%%%%%%%%%%%
18 printNodeid(nodeId(Name, Namespace)) :-
19     reverse([Name|Namespace], IdList),
20     join_string(IdList,".",String),
21     write(String).
22
23 printRegion((Id,Addr,Size)) :-
24     End is Addr + Size - 1,
25     printNodeid(Id),
26     printf(" [0x%16R..0x%16R]",
27         [ Addr,End ]
28     ).
29
30 printSrcDestRegions((SrcRegion,DestRegion)) :-
31     printRegion(SrcRegion),
32     write(" -> "),
33     printRegion(DestRegion),
34     writeln("").
35
36 printSharedRegions((Region1,Region2,SharedRegion)) :-
37     printRegion(Region1),
38     write(" -> "),
39     printRegion(SharedRegion),
40     write(" <- "),
41     printRegion(Region2),
42     writeln("").
43
44
45 %%%%%%%%%%%%%%%%%%%%%%%
46 %% Helper predicates %%
47 %%%%%%%%%%%%%%%%%%%%%%%
48 loadnet(Name) :- 
49     concat_string(["sockeyefacts/",Name],File),
50     decodingNet:loadnet(File).
51
52 all(Pred) :- findall(_,Pred,_).
53
54
55 %%%%%%%%%%%%%
56 %% Queries %%
57 %%%%%%%%%%%%%
58 findTargetRegion(NodeId) :-
59     findTargetRegion(NodeId,Result),
60     printSrcDestRegions(Result).
61
62 findOriginRegion(NodeId) :-
63     findOriginRegion(NodeId,Result),
64     printSrcDestRegions(Result).
65
66 findDeviceRegion(NodeId,DeviceId) :-
67     findDeviceRegion(NodeId,DeviceId,Result),
68     printSrcDestRegions(Result).
69
70 findMemoryRegion(NodeId,MemoryId) :-
71     findMemoryRegion(NodeId,MemoryId,Result),
72     printSrcDestRegions(Result).
73
74 findSharedMemoryRegion(NodeId,DeviceId) :-
75     findSharedMemoryRegion(NodeId,DeviceId,Result),
76     printSharedRegions(Result).
77
78 findDeviceId(NodeId,Addr) :-
79     findDeviceId(NodeId,Addr,Result),
80     writeln(Result).
81
82 findInterruptLine(NodeId,DeviceId) :-
83     findInterruptLine(NodeId,DeviceId,Result),
84     printSrcDestRegions(Result).