Use node type for shared memory query
[barrelfish] / usr / skb / programs / decodingNetQueries.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
13 printRange((SrcId,SrcMin,SrcMax)) :-
14     printf("%a [0x%16R..0x%16R]",
15         [ SrcId,SrcMin,SrcMax ]
16     ).
17
18 printSrcDestRanges(SrcRange,DestRange) :-
19     printRange(SrcRange),
20     write(" -> "),
21     printRange(DestRange),
22     writeln("").
23
24 printSharedRanges(Range1,SharedRange,Range2) :-
25     printRange(Range1),
26     write(" -> "),
27     printRange(SharedRange),
28     write(" <- "),
29     printRange(Range2),
30     writeln("").
31
32 findTargetRanges(NodeId) :-
33     SrcName = name(NodeId,_),
34     findall((SrcRange,DestRange),findRanges(SrcName,_,SrcRange,DestRange),List),
35     (foreach((Src,Dest),List) do printSrcDestRanges(Src,Dest)).
36
37
38 findOriginRanges(NodeId) :-
39     DestName = name(NodeId,_),
40     findall((SrcRange,DestRange),findRanges(_,DestName,SrcRange,DestRange),List),
41     (foreach((Src,Dest),List) do printSrcDestRanges(Src,Dest)).
42
43 findDeviceFrame(NodeId,DeviceId) :-
44     SrcName = name(NodeId,_),
45     DestName = name(DeviceId,_),
46     findRanges(SrcName,DestName,SrcRange,DestRange),
47     printSrcDestRanges(SrcRange,DestRange).
48
49 findInterruptLine(NodeId,DeviceId) :-
50     SrcName = name(DeviceId,_),
51     DestName = name(NodeId,_),
52     findRanges(SrcName,DestName,SrcRange,DestRange),
53     printSrcDestRanges(SrcRange,DestRange).
54
55 findSharedMemoryFrame(NodeId,DeviceId) :-
56     NodeName = name(NodeId,_),
57     DevName = name(DeviceId,_),
58     SharedName = name(SharedId,_),
59     net(SharedId,node(memory,_,_,_)),
60     findRanges(NodeName,SharedName,NodeRange,SharedRange),
61     findRanges(DevName,SharedName,DeviceRange,SharedRange),
62     printSharedRanges(NodeRange,SharedRange,DeviceRange).