Move Prolog predicates to usr/skb/programs
authorDaniel Schwyn <schwyda@student.ethz.ch>
Wed, 31 May 2017 14:25:29 +0000 (16:25 +0200)
committerDaniel Schwyn <schwyda@student.ethz.ch>
Tue, 13 Jun 2017 12:22:26 +0000 (14:22 +0200)
Signed-off-by: Daniel Schwyn <schwyda@student.ethz.ch>

usr/skb/programs/decodingNet.pl [moved from tools/sockeye2/decodingNet.pl with 65% similarity]
usr/skb/programs/decodingNetQueries.pl [new file with mode: 0644]
usr/skb/programs/decodingNet_naive.pl [moved from tools/sockeye2/decodingNet_naive.pl with 100% similarity]

similarity index 65%
rename from tools/sockeye2/decodingNet.pl
rename to usr/skb/programs/decodingNet.pl
index 23da5bb..835a920 100644 (file)
@@ -8,8 +8,15 @@
 % Attn: Systems Group.
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+:- module(decodingNet).
+:- export net/2.
+:- export resolve/2.
+:- export findRanges/4.
+
 :- lib(ic).
 
+:- dynamic net/2.
+
 %% Address range in block
 blockRange(block(Base,Limit),Range) :-
     Range = Base..Limit.
@@ -49,6 +56,7 @@ translateMap(node(_,Translate,_),Addr,Name) :-
     listMapsToName(Translate,Addr,Name).
 
 translateOverlay(node(Accept,Translate,Overlay),Addr,Name) :-
+    not(Overlay = '@none'),
     blockListRanges(Accept,ARanges),
     neg(Addr :: ARanges),
     mapListRanges(Translate,TRanges),
@@ -102,52 +110,4 @@ findRanges(SrcName,DestName,SrcRange,DestRange) :-
     get_min(DestAddr,DestMin),get_max(DestAddr,DestMax),
     SrcRange = (SrcId, SrcMin, SrcMax),
     DestRange = (DestId, DestMin, DestMax).
-
-printRange((SrcId,SrcMin,SrcMax)) :-
-    printf("%a [0x%x..0x%x]",
-        [ SrcId,SrcMin,SrcMax ]
-    ).
-
-printSrcDestRanges(SrcRange,DestRange) :-
-    printRange(SrcRange),
-    write(" -> "),
-    printRange(DestRange),
-    writeln("").
-
-printSharedRanges(Range1,SharedRange,Range2) :-
-    printRange(Range1),
-    write(" -> "),
-    printRange(SharedRange),
-    write(" <- "),
-    printRange(Range2),
-    writeln("").
-
-findTargetRanges(NodeId) :-
-    SrcName = name(NodeId,_),
-    findall((SrcRange,DestRange),findRanges(SrcName,_,SrcRange,DestRange),List),
-    (foreach((Src,Dest),List) do printSrcDestRanges(Src,Dest)).
-
-
-findOriginRanges(NodeId) :-
-    DestName = name(NodeId,_),
-    findall((SrcRange,DestRange),findRanges(_,DestName,SrcRange,DestRange),List),
-    (foreach((Src,Dest),List) do printSrcDestRanges(Src,Dest)).
-
-findDeviceFrame(NodeId,DeviceId) :-
-    SrcName = name(NodeId,_),
-    DestName = name(DeviceId,_),
-    findRanges(SrcName,DestName,SrcRange,DestRange),
-    printSrcDestRanges(SrcRange,DestRange).
-
-findInterruptLine(NodeId,DeviceId) :-
-    SrcName = name(DeviceId,_),
-    DestName = name(NodeId,_),
-    findRanges(SrcName,DestName,SrcRange,DestRange),
-    printSrcDestRanges(SrcRange,DestRange).
-
-findSharedMemoryFrame(NodeId,DeviceId) :-
-    NodeName = name(NodeId,_),
-    DevName = name(DeviceId,_),
-    findRanges(NodeName,_,NodeRange,SharedRange),
-    findRanges(DevName,_,DeviceRange,SharedRange),
-    printSharedRanges(NodeRange,SharedRange,DeviceRange).    
\ No newline at end of file
+  
\ No newline at end of file
diff --git a/usr/skb/programs/decodingNetQueries.pl b/usr/skb/programs/decodingNetQueries.pl
new file mode 100644 (file)
index 0000000..2a41f02
--- /dev/null
@@ -0,0 +1,60 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Copyright (c) 2017, ETH Zurich.
+% All rights reserved.
+%
+% This file is distributed under the terms in the attached LICENSE file.
+% If you do not find this file, copies can be found by writing to:
+% ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich.
+% Attn: Systems Group.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+:- use_module(decodingNet).
+
+printRange((SrcId,SrcMin,SrcMax)) :-
+    printf("%a [0x%16R..0x%16R]",
+        [ SrcId,SrcMin,SrcMax ]
+    ).
+
+printSrcDestRanges(SrcRange,DestRange) :-
+    printRange(SrcRange),
+    write(" -> "),
+    printRange(DestRange),
+    writeln("").
+
+printSharedRanges(Range1,SharedRange,Range2) :-
+    printRange(Range1),
+    write(" -> "),
+    printRange(SharedRange),
+    write(" <- "),
+    printRange(Range2),
+    writeln("").
+
+findTargetRanges(NodeId) :-
+    SrcName = name(NodeId,_),
+    findall((SrcRange,DestRange),findRanges(SrcName,_,SrcRange,DestRange),List),
+    (foreach((Src,Dest),List) do printSrcDestRanges(Src,Dest)).
+
+
+findOriginRanges(NodeId) :-
+    DestName = name(NodeId,_),
+    findall((SrcRange,DestRange),findRanges(_,DestName,SrcRange,DestRange),List),
+    (foreach((Src,Dest),List) do printSrcDestRanges(Src,Dest)).
+
+findDeviceFrame(NodeId,DeviceId) :-
+    SrcName = name(NodeId,_),
+    DestName = name(DeviceId,_),
+    findRanges(SrcName,DestName,SrcRange,DestRange),
+    printSrcDestRanges(SrcRange,DestRange).
+
+findInterruptLine(NodeId,DeviceId) :-
+    SrcName = name(DeviceId,_),
+    DestName = name(NodeId,_),
+    findRanges(SrcName,DestName,SrcRange,DestRange),
+    printSrcDestRanges(SrcRange,DestRange).
+
+findSharedMemoryFrame(NodeId,DeviceId) :-
+    NodeName = name(NodeId,_),
+    DevName = name(DeviceId,_),
+    findRanges(NodeName,_,NodeRange,SharedRange),
+    findRanges(DevName,_,DeviceRange,SharedRange),
+    printSharedRanges(NodeRange,SharedRange,DeviceRange).  
\ No newline at end of file