Changeset 28f4adb in mainline
- Timestamp:
- 2010-11-02T11:13:36Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4687a26c, e06ef614
- Parents:
- 458619f7
- git-author:
- Vojtech Horky <> (2010-11-02 11:13:36)
- git-committer:
- Martin Decky <martin@…> (2010-11-02 11:13:36)
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/arch/hadlbppp.py
r458619f7 r28f4adb 42 42 "Print usage syntax" 43 43 44 print "%s <--bp|--ebp|--adl|--dot|--nop>+ <OUTPUT>" % prname45 print 46 print "--bp Dump original Behavior Protocols (dChecker, BPSlicer)"47 print "--ebp Dump Extended Behavior Protocols (bp2promela)"48 print "--adl Dump Architecture Description Language (modified SOFA ADL/CDL)"49 print "--dot Dump Dot architecture diagram (GraphViz)"50 print "--nop Do not dump anything (just input files syntax check)"51 print 44 print("%s <--bp|--ebp|--adl|--dot|--nop>+ <OUTPUT>" % prname) 45 print() 46 print("--bp Dump original Behavior Protocols (dChecker, BPSlicer)") 47 print("--ebp Dump Extended Behavior Protocols (bp2promela)") 48 print("--adl Dump Architecture Description Language (modified SOFA ADL/CDL)") 49 print("--dot Dump Dot architecture diagram (GraphViz)") 50 print("--nop Do not dump anything (just input files syntax check)") 51 print() 52 52 53 53 def tabs(cnt): … … 163 163 result.append(tokens[i]) 164 164 else: 165 print "%s: Syntax error in tentative statement" % name165 print("%s: Syntax error in tentative statement" % name) 166 166 else: 167 print "%s: Expected '{' for tentative statement" % name167 print("%s: Expected '{' for tentative statement" % name) 168 168 else: 169 169 result.append(tokens[i]) … … 231 231 result.append(tokens[i]) 232 232 else: 233 print "%s: Syntax error in alternative statement" % name233 print("%s: Syntax error in alternative statement" % name) 234 234 else: 235 print "%s: Expected '{' for alternative statement body" % name235 print("%s: Expected '{' for alternative statement body" % name) 236 236 else: 237 print "%s: At least one pattern and one replacement required for alternative statement" % name237 print("%s: At least one pattern and one replacement required for alternative statement" % name) 238 238 else: 239 print "%s: Expected '(' for alternative statement head" % name239 print("%s: Expected '(' for alternative statement head" % name) 240 240 else: 241 241 result.append(tokens[i]) … … 269 269 result.append(tokens[i]) 270 270 else: 271 print "%s: Unexpected end of protocol" % name271 print("%s: Unexpected end of protocol" % name) 272 272 273 273 i += 1 … … 349 349 elif (token == ")"): 350 350 if (indent < base_indent): 351 print "%s: Too many parentheses" % name351 print("%s: Too many parentheses" % name) 352 352 353 353 indent -= 1 … … 358 358 elif (token == "}"): 359 359 if (indent < base_indent): 360 print "%s: Too many parentheses" % name360 print("%s: Too many parentheses" % name) 361 361 362 362 indent -= 1 … … 370 370 371 371 if (indent > base_indent): 372 print "%s: Missing parentheses" % name372 print("%s: Missing parentheses" % name) 373 373 374 374 output = output.strip() … … 405 405 result.extend(inherited_protocols(supiface)) 406 406 else: 407 print "%s: Extends unknown interface '%s'" % (iface['name'], iface['extends'])407 print("%s: Extends unknown interface '%s'" % (iface['name'], iface['extends'])) 408 408 409 409 return result … … 459 459 protocols.append(proto) 460 460 else: 461 print "%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface'])461 print("%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface'])) 462 462 463 463 if (opt_bp): 464 outf = file(outname, "w")464 outf = open(outname, "w") 465 465 outf.write(parse_bp(outname, merge_bp(initialization, finalization, protocols), 0)) 466 466 outf.close() 467 467 468 468 if (opt_ebp): 469 outf = file(outname, "w")469 outf = open(outname, "w") 470 470 outf.write(parse_ebp(frame['name'], outname, merge_bp(initialization, finalization, protocols), 0)) 471 471 outf.close() … … 514 514 515 515 if (opt_bp): 516 outf = file(outname, "w")516 outf = open(outname, "w") 517 517 outf.write("NULL") 518 518 outf.close() 519 519 520 520 if (opt_ebp): 521 outf = file(outname, "w")521 outf = open(outname, "w") 522 522 outf.write("component null {\n\tbehavior {\n\t\tNULL\n\t}\n}") 523 523 outf.close() … … 587 587 insts.append({'var': "%s_%s" % (prefix, inst['var']), 'frame': subframe}) 588 588 else: 589 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])589 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 590 590 591 591 if ('bind' in arch): … … 612 612 613 613 if (arch is None): 614 print "Unable to find system architecture"614 print("Unable to find system architecture") 615 615 return 616 616 … … 634 634 insts.append({'var': inst['var'], 'frame': subframe}) 635 635 else: 636 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])636 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 637 637 638 638 if ('bind' in arch): … … 642 642 if ('delegate' in arch): 643 643 for delegate in arch['delegate']: 644 print "Unable to delegate interface in system architecture"644 print("Unable to delegate interface in system architecture") 645 645 break 646 646 647 647 if ('subsume' in arch): 648 648 for subsume in arch['subsume']: 649 print "Unable to subsume interface in system architecture"649 print("Unable to subsume interface in system architecture") 650 650 break 651 651 … … 654 654 outname = os.path.join(outdir, "%s.archbp" % arch['name']) 655 655 if ((opt_bp) or (opt_ebp)): 656 outf = file(outname, "w")656 outf = open(outname, "w") 657 657 else: 658 658 outf = None … … 709 709 710 710 if (not os.path.isfile(path)): 711 print "%s: Unable to include file %s" % (inname, path)711 print("%s: Unable to include file %s" % (inname, path)) 712 712 return "" 713 713 else: … … 716 716 nested_root = root 717 717 718 inf = file(path, "r")718 inf = open(path, "r") 719 719 720 720 raw = preproc_adl(inf.read(), inarg) … … 733 733 if (POST_INC in context): 734 734 if (token != "]"): 735 print "%s: Expected ]" % inname735 print("%s: Expected ]" % inname) 736 736 737 737 context.remove(POST_INC) … … 774 774 if (NULL in context): 775 775 if (token != ";"): 776 print "%s: Expected ';' in frame '%s'" % (inname, frame)776 print("%s: Expected ';' in frame '%s'" % (inname, frame)) 777 777 else: 778 778 output += "%s\n" % token … … 798 798 799 799 if ('finalization' in frame_properties[frame]): 800 print "%s: Finalization protocol for frame '%s' already defined" % (inname, frame)800 print("%s: Finalization protocol for frame '%s' already defined" % (inname, frame)) 801 801 else: 802 802 frame_properties[frame]['finalization'] = bp … … 832 832 833 833 if ('initialization' in frame_properties[frame]): 834 print "%s: Initialization protocol for frame '%s' already defined" % (inname, frame)834 print("%s: Initialization protocol for frame '%s' already defined" % (inname, frame)) 835 835 else: 836 836 frame_properties[frame]['initialization'] = bp … … 866 866 867 867 if ('protocol' in frame_properties[frame]): 868 print "%s: Protocol for frame '%s' already defined" % (inname, frame)868 print("%s: Protocol for frame '%s' already defined" % (inname, frame)) 869 869 else: 870 870 frame_properties[frame]['protocol'] = bp … … 889 889 if (FIN in context): 890 890 if (token != ";"): 891 print "%s: Expected ';' in frame '%s'" % (inname, frame)891 print("%s: Expected ';' in frame '%s'" % (inname, frame)) 892 892 else: 893 893 output += "%s" % token … … 898 898 if (VAR in context): 899 899 if (not identifier(token)): 900 print "%s: Variable name expected in frame '%s'" % (inname, frame)900 print("%s: Variable name expected in frame '%s'" % (inname, frame)) 901 901 else: 902 902 if (not frame in frame_properties): … … 919 919 else: 920 920 if (not identifier(token)): 921 print "%s: Interface name expected in frame '%s'" % (inname, frame)921 print("%s: Interface name expected in frame '%s'" % (inname, frame)) 922 922 else: 923 923 arg0 = token … … 930 930 if (FIN in context): 931 931 if (token != ";"): 932 print "%s: Expected ';' in frame '%s'" % (inname, frame)932 print("%s: Expected ';' in frame '%s'" % (inname, frame)) 933 933 else: 934 934 output += "%s" % token … … 939 939 if (VAR in context): 940 940 if (not identifier(token)): 941 print "%s: Variable name expected in frame '%s'" % (inname, frame)941 print("%s: Variable name expected in frame '%s'" % (inname, frame)) 942 942 else: 943 943 if (not frame in frame_properties): … … 960 960 else: 961 961 if (not identifier(token)): 962 print "%s: Interface name expected in frame '%s'" % (inname, frame)962 print("%s: Interface name expected in frame '%s'" % (inname, frame)) 963 963 else: 964 964 arg0 = token … … 970 970 if (token == "}"): 971 971 if (indent != 2): 972 print "%s: Wrong number of parentheses in frame '%s'" % (inname, frame)972 print("%s: Wrong number of parentheses in frame '%s'" % (inname, frame)) 973 973 else: 974 974 indent = 0 … … 1010 1010 continue 1011 1011 1012 print "%s: Unknown token '%s' in frame '%s'" % (inname, token, frame)1012 print("%s: Unknown token '%s' in frame '%s'" % (inname, token, frame)) 1013 1013 continue 1014 1014 … … 1027 1027 continue 1028 1028 1029 print "%s: Unknown token '%s' in frame head '%s'" % (inname, token, frame)1029 print("%s: Unknown token '%s' in frame head '%s'" % (inname, token, frame)) 1030 1030 1031 1031 continue 1032 1032 1033 1033 if (not identifier(token)): 1034 print "%s: Expected frame name" % inname1034 print("%s: Expected frame name" % inname) 1035 1035 else: 1036 1036 frame = token … … 1050 1050 if (NULL in context): 1051 1051 if (token != ";"): 1052 print "%s: Expected ';' in interface '%s'" % (inname, interface)1052 print("%s: Expected ';' in interface '%s'" % (inname, interface)) 1053 1053 else: 1054 1054 output += "%s\n" % token … … 1074 1074 1075 1075 if ('protocol' in iface_properties[interface]): 1076 print "%s: Protocol for interface '%s' already defined" % (inname, interface)1076 print("%s: Protocol for interface '%s' already defined" % (inname, interface)) 1077 1077 else: 1078 1078 iface_properties[interface]['protocol'] = bp … … 1094 1094 if (FIN in context): 1095 1095 if (token != ";"): 1096 print "%s: Expected ';' in interface '%s'" % (inname, interface)1096 print("%s: Expected ';' in interface '%s'" % (inname, interface)) 1097 1097 else: 1098 1098 output += "%s" % token … … 1124 1124 if (PAR_LEFT in context): 1125 1125 if (token != "("): 1126 print "%s: Expected '(' in interface '%s'" % (inname, interface)1126 print("%s: Expected '(' in interface '%s'" % (inname, interface)) 1127 1127 else: 1128 1128 output += "%s" % token … … 1133 1133 1134 1134 if (not identifier(token)): 1135 print "%s: Method identifier expected in interface '%s'" % (inname, interface)1135 print("%s: Method identifier expected in interface '%s'" % (inname, interface)) 1136 1136 else: 1137 1137 output += "%s" % token … … 1142 1142 if (token == "}"): 1143 1143 if (indent != 2): 1144 print "%s: Wrong number of parentheses in interface '%s'" % (inname, interface)1144 print("%s: Wrong number of parentheses in interface '%s'" % (inname, interface)) 1145 1145 else: 1146 1146 indent = 0 … … 1163 1163 continue 1164 1164 1165 print "%s: Unknown token '%s' in interface '%s'" % (inname, token, interface)1165 print("%s: Unknown token '%s' in interface '%s'" % (inname, token, interface)) 1166 1166 continue 1167 1167 … … 1183 1183 continue 1184 1184 1185 print "%s: Expected '{' or ';' in interface head '%s'" % (inname, interface)1185 print("%s: Expected '{' or ';' in interface head '%s'" % (inname, interface)) 1186 1186 continue 1187 1187 1188 1188 if (EXTENDS in context): 1189 1189 if (not identifier(token)): 1190 print "%s: Expected inherited interface name in interface head '%s'" % (inname, interface)1190 print("%s: Expected inherited interface name in interface head '%s'" % (inname, interface)) 1191 1191 else: 1192 1192 output += "%s " % token … … 1218 1218 continue 1219 1219 1220 print "%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface)1220 print("%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface)) 1221 1221 continue 1222 1222 1223 1223 if (not identifier(token)): 1224 print "%s: Expected interface name" % inname1224 print("%s: Expected interface name" % inname) 1225 1225 else: 1226 1226 interface = token … … 1240 1240 if (NULL in context): 1241 1241 if (token != ";"): 1242 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1242 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1243 1243 else: 1244 1244 output += "%s\n" % token … … 1254 1254 if (FIN in context): 1255 1255 if (token != ";"): 1256 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1256 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1257 1257 else: 1258 1258 output += "%s" % token … … 1264 1264 if (VAR in context): 1265 1265 if (not descriptor(token)): 1266 print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)1266 print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)) 1267 1267 else: 1268 1268 if (not architecture in arch_properties): … … 1283 1283 if (TO in context): 1284 1284 if (token != "to"): 1285 print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)1285 print("%s: Expected 'to' in architecture '%s'" % (inname, architecture)) 1286 1286 else: 1287 1287 output += "%s " % token … … 1292 1292 1293 1293 if (not identifier(token)): 1294 print "%s: Expected interface name in architecture '%s'" % (inname, architecture)1294 print("%s: Expected interface name in architecture '%s'" % (inname, architecture)) 1295 1295 else: 1296 1296 output += "%s " % token … … 1303 1303 if (FIN in context): 1304 1304 if (token != ";"): 1305 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1305 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1306 1306 else: 1307 1307 output += "%s" % token … … 1313 1313 if (VAR in context): 1314 1314 if (not identifier(token)): 1315 print "%s: Expected interface name in architecture '%s'" % (inname, architecture)1315 print("%s: Expected interface name in architecture '%s'" % (inname, architecture)) 1316 1316 else: 1317 1317 if (not architecture in arch_properties): … … 1332 1332 if (TO in context): 1333 1333 if (token != "to"): 1334 print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)1334 print("%s: Expected 'to' in architecture '%s'" % (inname, architecture)) 1335 1335 else: 1336 1336 output += "%s " % token … … 1341 1341 1342 1342 if (not descriptor(token)): 1343 print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)1343 print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)) 1344 1344 else: 1345 1345 output += "%s " % token … … 1352 1352 if (FIN in context): 1353 1353 if (token != ";"): 1354 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1354 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1355 1355 else: 1356 1356 output += "%s" % token … … 1362 1362 if (VAR in context): 1363 1363 if (not descriptor(token)): 1364 print "%s: Expected second interface descriptor in architecture '%s'" % (inname, architecture)1364 print("%s: Expected second interface descriptor in architecture '%s'" % (inname, architecture)) 1365 1365 else: 1366 1366 if (not architecture in arch_properties): … … 1381 1381 if (TO in context): 1382 1382 if (token != "to"): 1383 print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)1383 print("%s: Expected 'to' in architecture '%s'" % (inname, architecture)) 1384 1384 else: 1385 1385 output += "%s " % token … … 1390 1390 1391 1391 if (not descriptor(token)): 1392 print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)1392 print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)) 1393 1393 else: 1394 1394 output += "%s " % token … … 1401 1401 if (FIN in context): 1402 1402 if (token != ";"): 1403 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1403 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1404 1404 else: 1405 1405 output += "%s" % token … … 1411 1411 if (VAR in context): 1412 1412 if (not identifier(token)): 1413 print "%s: Expected instance name in architecture '%s'" % (inname, architecture)1413 print("%s: Expected instance name in architecture '%s'" % (inname, architecture)) 1414 1414 else: 1415 1415 if (not architecture in arch_properties): … … 1429 1429 1430 1430 if (not identifier(token)): 1431 print "%s: Expected frame/architecture type in architecture '%s'" % (inname, architecture)1431 print("%s: Expected frame/architecture type in architecture '%s'" % (inname, architecture)) 1432 1432 else: 1433 1433 output += "%s " % token … … 1439 1439 if (token == "}"): 1440 1440 if (indent != 1): 1441 print "%s: Wrong number of parentheses in architecture '%s'" % (inname, architecture)1441 print("%s: Wrong number of parentheses in architecture '%s'" % (inname, architecture)) 1442 1442 else: 1443 1443 indent -= 1 … … 1468 1468 continue 1469 1469 1470 print "%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture)1470 print("%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture)) 1471 1471 continue 1472 1472 … … 1487 1487 1488 1488 if (not word(token)): 1489 print "%s: Expected word in architecture head '%s'" % (inname, architecture)1489 print("%s: Expected word in architecture head '%s'" % (inname, architecture)) 1490 1490 else: 1491 1491 output += "%s " % token … … 1494 1494 1495 1495 if (not identifier(token)): 1496 print "%s: Expected architecture name" % inname1496 print("%s: Expected architecture name" % inname) 1497 1497 else: 1498 1498 architecture = token … … 1514 1514 if (SYSTEM in context): 1515 1515 if (token != "architecture"): 1516 print "%s: Expected 'architecture'" % inname1516 print("%s: Expected 'architecture'" % inname) 1517 1517 else: 1518 1518 output += "%s " % token … … 1541 1541 continue 1542 1542 1543 print "%s: Unknown token '%s'" % (inname, token)1543 print("%s: Unknown token '%s'" % (inname, token)) 1544 1544 1545 1545 inf.close() … … 1575 1575 1576 1576 if ((output != "") and (opt_adl)): 1577 outf = file(outname, "w")1577 outf = open(outname, "w") 1578 1578 outf.write(output) 1579 1579 outf.close() … … 1633 1633 merge_dot_frame("%s_%s" % (prefix, inst['var']), inst['var'], subframe, outf, indent + 1) 1634 1634 else: 1635 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])1635 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 1636 1636 1637 1637 if ('bind' in arch): … … 1728 1728 1729 1729 if (arch is None): 1730 print "Unable to find system architecture"1730 print("Unable to find system architecture") 1731 1731 return 1732 1732 1733 1733 if (opt_dot): 1734 1734 outname = os.path.join(outdir, "%s.dot" % arch['name']) 1735 outf = file(outname, "w")1735 outf = open(outname, "w") 1736 1736 1737 1737 outf.write("digraph {\n") … … 1752 1752 merge_dot_frame("%s" % inst['var'], inst['var'], subframe, outf, 1) 1753 1753 else: 1754 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])1754 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 1755 1755 1756 1756 if ('bind' in arch): … … 1784 1784 if ('delegate' in arch): 1785 1785 for delegate in arch['delegate']: 1786 print "Unable to delegate interface in system architecture"1786 print("Unable to delegate interface in system architecture") 1787 1787 break 1788 1788 1789 1789 if ('subsume' in arch): 1790 1790 for subsume in arch['subsume']: 1791 print "Unable to subsume interface in system architecture"1791 print("Unable to subsume interface in system architecture") 1792 1792 break 1793 1793 … … 1826 1826 pass 1827 1827 else: 1828 print "Error: Unknown command line option '%s'" % arg1828 print("Error: Unknown command line option '%s'" % arg) 1829 1829 return 1830 1830 1831 1831 if ((opt_bp) and (opt_ebp)): 1832 print "Error: Cannot dump both original Behavior Protocols and Extended Behavior Protocols"1832 print("Error: Cannot dump both original Behavior Protocols and Extended Behavior Protocols") 1833 1833 return 1834 1834 1835 1835 path = os.path.abspath(sys.argv[-1]) 1836 1836 if (not os.path.isdir(path)): 1837 print "Error: <OUTPUT> is not a directory"1837 print("Error: <OUTPUT> is not a directory") 1838 1838 return 1839 1839 -
kernel/tools/amd64/decpt.py
r458619f7 r28f4adb 7 7 def main(): 8 8 if len(sys.argv) != 2 or not sys.argv[1].startswith('0x'): 9 print "%s 0x..." % sys.argv[0]9 print("%s 0x..." % sys.argv[0]) 10 10 sys.exit(1) 11 11 … … 16 16 ptl1 = (address >> 30) & 0x1ff 17 17 ptl0 = (address >> 39) & 0x1ff 18 print "Ptl0: %3d" % ptl019 print "Ptl1: %3d" % ptl120 print "Ptl2: %3d" % ptl221 print "Ptl3: %3d" % ptl322 print "Offset: 0x%x" % offset18 print("Ptl0: %3d" % ptl0) 19 print("Ptl1: %3d" % ptl1) 20 print("Ptl2: %3d" % ptl2) 21 print("Ptl3: %3d" % ptl3) 22 print("Offset: 0x%x" % offset) 23 23 24 24 if __name__ == '__main__': -
kernel/tools/genmap.py
r458619f7 r28f4adb 86 86 obdump = read_obdump(obmapf) 87 87 88 def sorter(x,y):89 return cmp(x[0],y[0])88 def key_sorter(x): 89 return x[0] 90 90 91 91 for line in kmapf: … … 93 93 res = startfile.match(line) 94 94 95 if ((res) and ( obdump[res.group(1)].has_key(res.group(3)))):95 if ((res) and (res.group(3) in obdump[res.group(1)])): 96 96 offset = int(res.group(2), 16) 97 97 fname = res.group(3) 98 98 symbols = obdump[res.group(1)][fname] 99 symbols.sort( sorter)99 symbols.sort(key = key_sorter) 100 100 for addr, symbol in symbols: 101 101 value = fname + ':' + symbol … … 107 107 def main(): 108 108 if (len(sys.argv) != 4): 109 print "Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0]109 print("Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0]) 110 110 return 1 111 111 112 112 kmapf = open(sys.argv[1], 'r') 113 113 obmapf = open(sys.argv[2], 'r') 114 out = open(sys.argv[3], 'w ')114 out = open(sys.argv[3], 'wb') 115 115 116 116 generate(kmapf, obmapf, out) -
kernel/tools/ia32/decpt.py
r458619f7 r28f4adb 7 7 def main(): 8 8 if len(sys.argv) != 2 or not sys.argv[1].startswith('0x'): 9 print "%s 0x..." % sys.argv[0]9 print("%s 0x..." % sys.argv[0]) 10 10 sys.exit(1) 11 11 … … 14 14 ptl1 = (address >> 12) & 0x3ff 15 15 ptl0 = (address >> 22) & 0x3ff 16 print "Ptl0: %3d" % ptl017 print "Ptl1: %3d" % ptl118 print "Offset: 0x%x" % offset16 print("Ptl0: %3d" % ptl0) 17 print("Ptl1: %3d" % ptl1) 18 print("Offset: 0x%x" % offset) 19 19 20 20 if __name__ == '__main__': -
tools/autotool.py
r458619f7 r28f4adb 75 75 "Read HelenOS build configuration" 76 76 77 inf = file(fname, 'r')77 inf = open(fname, 'r') 78 78 79 79 for line in inf: … … 191 191 check_common(common, "CC") 192 192 193 outf = file(PROBE_SOURCE, 'w')193 outf = open(PROBE_SOURCE, 'w') 194 194 outf.write(PROBE_HEAD) 195 195 … … 212 212 if (not os.path.isfile(PROBE_OUTPUT)): 213 213 sys.stderr.write("failed\n") 214 print output[1]214 print(output[1]) 215 215 print_error(["Error executing \"%s\"." % " ".join(args), 216 216 "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT, … … 221 221 sys.stderr.write("ok\n") 222 222 223 inf = file(PROBE_OUTPUT, 'r')223 inf = open(PROBE_OUTPUT, 'r') 224 224 lines = inf.readlines() 225 225 inf.close() … … 343 343 "Create makefile output" 344 344 345 outmk = file(mkname, 'w')345 outmk = open(mkname, 'w') 346 346 347 347 outmk.write('#########################################\n') … … 357 357 "Create header output" 358 358 359 outhd = file(hdname, 'w')359 outhd = open(hdname, 'w') 360 360 361 361 outhd.write('/***************************************\n') -
tools/checkers/clang.py
r458619f7 r28f4adb 42 42 def usage(prname): 43 43 "Print usage syntax" 44 print prname + " <ROOT>"44 print(prname + " <ROOT>") 45 45 46 46 def clang(root, job): … … 50 50 51 51 if (not os.path.isfile(inname)): 52 print "Unable to open %s" % inname53 print "Did you run \"make precheck\" on the source tree?"52 print("Unable to open %s" % inname) 53 print("Did you run \"make precheck\" on the source tree?") 54 54 return False 55 55 56 inf = file(inname, "r")56 inf = open(inname, "r") 57 57 records = inf.read().splitlines() 58 58 inf.close() … … 64 64 65 65 if (len(arg) < 6): 66 print "Not enought jobfile record arguments"66 print("Not enought jobfile record arguments") 67 67 return False 68 68 … … 76 76 srcfqname = os.path.join(base, srcfname) 77 77 if (not os.path.isfile(srcfqname)): 78 print "Source %s not found" % srcfqname78 print("Source %s not found" % srcfqname) 79 79 return False 80 80 … … 108 108 109 109 if (not os.path.isfile(config)): 110 print "%s not found." % config111 print "Please specify the path to HelenOS build tree root as the first argument."110 print("%s not found." % config) 111 print("Please specify the path to HelenOS build tree root as the first argument.") 112 112 return 113 113 … … 115 115 if (not clang(rootdir, job)): 116 116 print 117 print "Failed job: %s" % job117 print("Failed job: %s" % job) 118 118 return 119 119 120 120 print 121 print "All jobs passed"121 print("All jobs passed") 122 122 123 123 if __name__ == '__main__': -
tools/checkers/jobfile.py
r458619f7 r28f4adb 54 54 nil = True 55 55 else: 56 print "Unexpected '%s'" % record[i]56 print("Unexpected '%s'" % record[i]) 57 57 return False 58 58 -
tools/checkers/stanse.py
r458619f7 r28f4adb 43 43 def usage(prname): 44 44 "Print usage syntax" 45 print prname + " <ROOT>"45 print(prname + " <ROOT>") 46 46 47 47 def stanse(root, job): … … 54 54 55 55 if (not os.path.isfile(inname)): 56 print "Unable to open %s" % inname57 print "Did you run \"make precheck\" on the source tree?"56 print("Unable to open %s" % inname) 57 print("Did you run \"make precheck\" on the source tree?") 58 58 return False 59 59 60 inf = file(inname, "r")60 inf = open(inname, "r") 61 61 records = inf.read().splitlines() 62 62 inf.close() … … 69 69 70 70 if (len(arg) < 6): 71 print "Not enought jobfile record arguments"71 print("Not enought jobfile record arguments") 72 72 return False 73 73 … … 81 81 srcfqname = os.path.join(base, srcfname) 82 82 if (not os.path.isfile(srcfqname)): 83 print "Source %s not found" % srcfqname83 print("Source %s not found" % srcfqname) 84 84 return False 85 85 … … 90 90 output.append([srcfname, tgtfname, base, options]) 91 91 92 outf = file(outname, "w")92 outf = open(outname, "w") 93 93 for record in output: 94 94 outf.write("{%s},{%s},{%s},{%s}\n" % (record[0], record[1], record[2], record[3])) … … 121 121 122 122 if (not os.path.isfile(config)): 123 print "%s not found." % config124 print "Please specify the path to HelenOS build tree root as the first argument."123 print("%s not found." % config) 124 print("Please specify the path to HelenOS build tree root as the first argument.") 125 125 return 126 126 … … 128 128 if (not stanse(rootdir, job)): 129 129 print 130 print "Failed job: %s" % job130 print("Failed job: %s" % job) 131 131 return 132 132 133 133 print 134 print "All jobs passed"134 print("All jobs passed") 135 135 136 136 if __name__ == '__main__': -
tools/checkers/vcc.py
r458619f7 r28f4adb 49 49 def usage(prname): 50 50 "Print usage syntax" 51 print prname + " <ROOT> [VCC_PATH]"51 print(prname + " <ROOT> [VCC_PATH]") 52 52 53 53 def cygpath(upath): … … 72 72 preproc = subprocess.Popen(args, stdout = subprocess.PIPE).communicate()[0] 73 73 74 tmpf = file(tmpfname, "w")74 tmpf = open(tmpfname, "w") 75 75 tmpf.write(specification) 76 76 … … 108 108 109 109 if (not os.path.isfile(inname)): 110 print "Unable to open %s" % inname111 print "Did you run \"make precheck\" on the source tree?"110 print("Unable to open %s" % inname) 111 print("Did you run \"make precheck\" on the source tree?") 112 112 return False 113 113 114 inf = file(inname, "r")114 inf = open(inname, "r") 115 115 records = inf.read().splitlines() 116 116 inf.close() … … 122 122 123 123 if (len(arg) < 6): 124 print "Not enought jobfile record arguments"124 print("Not enought jobfile record arguments") 125 125 return False 126 126 … … 134 134 srcfqname = os.path.join(base, srcfname) 135 135 if (not os.path.isfile(srcfqname)): 136 print "Source %s not found" % srcfqname136 print("Source %s not found" % srcfqname) 137 137 return False 138 138 … … 153 153 154 154 # Run Vcc 155 print " -- %s --" % srcfname155 print(" -- %s --" % srcfname) 156 156 retval = subprocess.Popen([vcc_path, '/pointersize:32', '/newsyntax', cygpath(tmpfqname)]).wait() 157 157 … … 182 182 183 183 if (not os.path.isfile(vcc_path)): 184 print "%s is not a binary." % vcc_path185 print "Please supply the full Cygwin path to Vcc as the second argument."184 print("%s is not a binary." % vcc_path) 185 print("Please supply the full Cygwin path to Vcc as the second argument.") 186 186 return 187 187 … … 189 189 190 190 if (not os.path.isfile(config)): 191 print "%s not found." % config192 print "Please specify the path to HelenOS build tree root as the first argument."191 print("%s not found." % config) 192 print("Please specify the path to HelenOS build tree root as the first argument.") 193 193 return 194 194 195 195 specpath = os.path.join(rootdir, "tools/checkers/vcc.h") 196 196 if (not os.path.isfile(specpath)): 197 print "%s not found." % config197 print("%s not found." % config) 198 198 return 199 199 … … 205 205 if (not vcc(vcc_path, rootdir, job)): 206 206 print 207 print "Failed job: %s" % job207 print("Failed job: %s" % job) 208 208 return 209 209 210 210 print 211 print "All jobs passed"211 print("All jobs passed") 212 212 213 213 if __name__ == '__main__': -
tools/config.py
r458619f7 r28f4adb 48 48 "Read saved values from last configuration run" 49 49 50 inf = file(fname, 'r')50 inf = open(fname, 'r') 51 51 52 52 for line in inf: … … 103 103 condval = res.group(3) 104 104 105 if (not defaults.has_key(condname)):105 if (not condname in defaults): 106 106 varval = '' 107 107 else: … … 131 131 "Parse configuration file" 132 132 133 inf = file(fname, 'r')133 inf = open(fname, 'r') 134 134 135 135 name = '' … … 219 219 continue 220 220 221 if (not defaults.has_key(varname)):221 if (not varname in defaults): 222 222 return False 223 223 … … 232 232 233 233 try: 234 version = subprocess.Popen(['bzr', 'version-info', '--custom', '--template={clean}:{revno}:{revision_id}'], stdout = subprocess.PIPE).communicate()[0]. split(':')234 version = subprocess.Popen(['bzr', 'version-info', '--custom', '--template={clean}:{revno}:{revision_id}'], stdout = subprocess.PIPE).communicate()[0].decode().split(':') 235 235 sys.stderr.write("ok\n") 236 236 except: … … 246 246 revision = None 247 247 248 outmk = file(mkname, 'w')249 outmc = file(mcname, 'w')248 outmk = open(mkname, 'w') 249 outmc = open(mcname, 'w') 250 250 251 251 outmk.write('#########################################\n') … … 263 263 continue 264 264 265 if (not defaults.has_key(varname)):265 if (not varname in defaults): 266 266 default = '' 267 267 else: … … 368 368 # Cancel out all defaults which have to be deduced 369 369 for varname, vartype, name, choices, cond in ask_names: 370 if ((vartype == 'y') and ( defaults.has_key(varname)) and (defaults[varname] == '*')):370 if ((vartype == 'y') and (varname in defaults) and (defaults[varname] == '*')): 371 371 defaults[varname] = None 372 372 … … 385 385 position = cnt 386 386 387 if (not defaults.has_key(varname)):387 if (not varname in defaults): 388 388 default = None 389 389 else: … … 428 428 cnt += 1 429 429 430 if (position >= options):430 if (position != None) and (position >= len(options)): 431 431 position = None 432 432 … … 449 449 450 450 position = None 451 if (not opt2row.has_key(value)):451 if (not value in opt2row): 452 452 raise RuntimeError("Error selecting value: %s" % value) 453 453 454 454 (selname, seltype, name, choices) = opt2row[value] 455 455 456 if (not defaults.has_key(selname)):456 if (not selname in defaults): 457 457 default = None 458 458 else: -
tools/jobfile.py
r458619f7 r28f4adb 38 38 def usage(prname): 39 39 "Print usage syntax" 40 print prname + " <JOBFILE> <SOURCE> <TARGET> <TOOL> <CATEGORY> [OPTIONS ...]"40 print(prname + " <JOBFILE> <SOURCE> <TARGET> <TOOL> <CATEGORY> [OPTIONS ...]") 41 41 42 42 def main(): … … 53 53 options = " ".join(sys.argv[6:]) 54 54 55 jobfile = file(jobfname, "a")55 jobfile = open(jobfname, "a") 56 56 fcntl.lockf(jobfile, fcntl.LOCK_EX) 57 57 jobfile.write("{%s},{%s},{%s},{%s},{%s},{%s}\n" % (srcfname, tgtfname, toolname, category, cwd, options)) -
tools/mkfat.py
r458619f7 r28f4adb 46 46 return size 47 47 48 return (( (size / alignment) + 1) * alignment)48 return ((size // alignment) + 1) * alignment 49 49 50 50 def subtree_size(root, cluster_size, dirent_size): … … 79 79 first = 0 80 80 81 inf = file(path, "r")81 inf = open(path, "rb") 82 82 rd = 0; 83 83 while (rd < size): … … 92 92 prev = empty_cluster 93 93 94 data = inf.read(cluster_size);94 data = bytes(inf.read(cluster_size)); 95 95 outf.seek(data_start + (empty_cluster - reserved_clusters) * cluster_size) 96 96 outf.write(data) … … 120 120 prev = empty_cluster 121 121 122 data = ''122 data = bytes() 123 123 data_len = 0 124 124 while ((i < length) and (data_len < cluster_size)): … … 343 343 def usage(prname): 344 344 "Print usage syntax" 345 print prname + " <EXTRA_BYTES> <PATH> <IMAGE>"345 print(prname + " <EXTRA_BYTES> <PATH> <IMAGE>") 346 346 347 347 def main(): … … 351 351 352 352 if (not sys.argv[1].isdigit()): 353 print "<EXTRA_BYTES> must be a number"353 print("<EXTRA_BYTES> must be a number") 354 354 return 355 355 … … 358 358 path = os.path.abspath(sys.argv[2]) 359 359 if (not os.path.isdir(path)): 360 print "<PATH> must be a directory"360 print("<PATH> must be a directory") 361 361 return 362 362 … … 372 372 # Make sure the filesystem is large enought for FAT16 373 373 size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size + extra_bytes 374 while (size / cluster_size < fat16_clusters):374 while (size // cluster_size < fat16_clusters): 375 375 if (cluster_size > sector_size): 376 cluster_size /=2376 cluster_size = cluster_size // 2 377 377 size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size + extra_bytes 378 378 else: … … 381 381 root_size = align_up(root_entries(path) * dirent_size, cluster_size) 382 382 383 fat_size = align_up(align_up(size, cluster_size) / cluster_size * fatent_size, sector_size)384 385 sectors = (cluster_size + fat_count * fat_size + root_size + size) / sector_size383 fat_size = align_up(align_up(size, cluster_size) // cluster_size * fatent_size, sector_size) 384 385 sectors = (cluster_size + fat_count * fat_size + root_size + size) // sector_size 386 386 root_start = cluster_size + fat_count * fat_size 387 387 data_start = root_start + root_size 388 388 389 outf = file(sys.argv[3], "w")389 outf = open(sys.argv[3], "wb") 390 390 391 391 boot_sector = xstruct.create(BOOT_SECTOR) 392 392 boot_sector.jmp = [0xEB, 0x3C, 0x90] 393 boot_sector.oem = "MSDOS5.0"393 boot_sector.oem = b'MSDOS5.0' 394 394 boot_sector.sector = sector_size 395 boot_sector.cluster = cluster_size / sector_size396 boot_sector.reserved = cluster_size / sector_size395 boot_sector.cluster = cluster_size // sector_size 396 boot_sector.reserved = cluster_size // sector_size 397 397 boot_sector.fats = fat_count 398 boot_sector.rootdir = root_size / dirent_size398 boot_sector.rootdir = root_size // dirent_size 399 399 if (sectors <= 65535): 400 400 boot_sector.sectors = sectors … … 402 402 boot_sector.sectors = 0 403 403 boot_sector.descriptor = 0xF8 404 boot_sector.fat_sectors = fat_size / sector_size404 boot_sector.fat_sectors = fat_size // sector_size 405 405 boot_sector.track_sectors = 63 406 406 boot_sector.heads = 6 … … 414 414 boot_sector.extboot_signature = 0x29 415 415 boot_sector.serial = random.randint(0, 0x7fffffff) 416 boot_sector.label = "HELENOS"417 boot_sector.fstype = "FAT16 "416 boot_sector.label = b'HELENOS' 417 boot_sector.fstype = b'FAT16 ' 418 418 boot_sector.boot_signature = [0x55, 0xAA] 419 419 … … 423 423 424 424 # Reserved sectors 425 for i in range(1, cluster_size / sector_size):425 for i in range(1, cluster_size // sector_size): 426 426 outf.write(empty_sector.pack()) 427 427 428 428 # FAT tables 429 429 for i in range(0, fat_count): 430 for j in range(0, fat_size / sector_size):430 for j in range(0, fat_size // sector_size): 431 431 outf.write(empty_sector.pack()) 432 432 433 433 # Root directory 434 for i in range(0, root_size / sector_size):434 for i in range(0, root_size // sector_size): 435 435 outf.write(empty_sector.pack()) 436 436 437 437 # Data 438 for i in range(0, size / sector_size):438 for i in range(0, size // sector_size): 439 439 outf.write(empty_sector.pack()) 440 440 441 fat = array.array('L', [0] * (fat_size / fatent_size))441 fat = array.array('L', [0] * (fat_size // fatent_size)) 442 442 fat[0] = 0xfff8 443 443 fat[1] = 0xffff … … 449 449 for i in range(0, fat_count): 450 450 outf.seek(cluster_size + i * fat_size) 451 for j in range(0, fat_size / fatent_size):451 for j in range(0, fat_size // fatent_size): 452 452 fat_entry.next = fat[j] 453 453 outf.write(fat_entry.pack()) -
tools/mkhord.py
r458619f7 r28f4adb 52 52 def usage(prname): 53 53 "Print usage syntax" 54 print prname + " <ALIGNMENT> <FS_IMAGE> <HORD_IMAGE>"54 print(prname + " <ALIGNMENT> <FS_IMAGE> <HORD_IMAGE>") 55 55 56 56 def main(): … … 60 60 61 61 if (not sys.argv[1].isdigit()): 62 print "<ALIGNMENT> must be a number"62 print("<ALIGNMENT> must be a number") 63 63 return 64 64 65 65 align = int(sys.argv[1], 0) 66 66 if (align <= 0): 67 print "<ALIGNMENT> must be positive"67 print("<ALIGNMENT> must be positive") 68 68 return 69 69 70 70 fs_image = os.path.abspath(sys.argv[2]) 71 71 if (not os.path.isfile(fs_image)): 72 print "<FS_IMAGE> must be a file"72 print("<FS_IMAGE> must be a file") 73 73 return 74 74 75 inf = file(fs_image, "rb")76 outf = file(sys.argv[3], "wb")75 inf = open(fs_image, "rb") 76 outf = open(sys.argv[3], "wb") 77 77 78 78 header = xstruct.create(HEADER) -
tools/mktmpfs.py
r458619f7 r28f4adb 66 66 def usage(prname): 67 67 "Print usage syntax" 68 print prname + " <PATH> <IMAGE>"68 print(prname + " <PATH> <IMAGE>") 69 69 70 70 def recursion(root, outf): … … 85 85 outf.write(dentry.pack()) 86 86 87 inf = file(canon, "r")87 inf = open(canon, "rb") 88 88 rd = 0; 89 89 while (rd < size): … … 116 116 path = os.path.abspath(sys.argv[1]) 117 117 if (not os.path.isdir(path)): 118 print "<PATH> must be a directory"118 print("<PATH> must be a directory") 119 119 return 120 120 121 outf = file(sys.argv[2], "w")121 outf = open(sys.argv[2], "wb") 122 122 123 123 header = xstruct.create(HEADER) -
tools/mkuimage.py
r458619f7 r28f4adb 72 72 start_addr = (int)(optarg, 0) 73 73 else: 74 print base_name + ": Unrecognized option."74 print(base_name + ": Unrecognized option.") 75 75 print_syntax(cmd_name) 76 76 return 77 77 78 78 if len(args) < 2: 79 print base_name + ": Argument missing."79 print(base_name + ": Argument missing.") 80 80 print_syntax(cmd_name) 81 81 return … … 91 91 92 92 def mkuimage(inf_name, outf_name, image_name, load_addr, start_addr): 93 inf = file(inf_name, 'rb')94 outf = file(outf_name, 'wb')93 inf = open(inf_name, 'rb') 94 outf = open(outf_name, 'wb') 95 95 96 96 header = xstruct.create(UIMAGE_HEADER) … … 140 140 signed_crc = zlib.crc32(byteseq, 0) 141 141 if signed_crc < 0: 142 return (long(signed_crc) + 4294967296L) # 2^32L142 return (long(signed_crc) + (long(2) ** long(32))) # 2^32L 143 143 else: 144 144 return signed_crc … … 147 147 # 148 148 def print_syntax(cmd): 149 print "syntax: " + cmd + " [<options>] <raw_image> <uImage>"149 print("syntax: " + cmd + " [<options>] <raw_image> <uImage>") 150 150 print 151 print "\traw_image\tInput image name (raw binary data)"152 print "\tuImage\t\tOutput uImage name (U-Boot image)"151 print("\traw_image\tInput image name (raw binary data)") 152 print("\tuImage\t\tOutput uImage name (U-Boot image)") 153 153 print 154 print "options:"155 print "\t-name <name>\tImage name (default: 'Noname')"156 print "\t-laddr <name>\tLoad address (default: 0x00000000)"157 print "\t-saddr <name>\tStart address (default: 0x00000000)"154 print("options:") 155 print("\t-name <name>\tImage name (default: 'Noname')") 156 print("\t-laddr <name>\tLoad address (default: 0x00000000)") 157 print("\t-saddr <name>\tStart address (default: 0x00000000)") 158 158 159 159 if __name__ == '__main__': -
tools/pack.py
r458619f7 r28f4adb 43 43 def usage(prname): 44 44 "Print usage syntax" 45 print "%s <OBJCOPY> <FORMAT> <ARCH> <ARCH_PATH> [COMPONENTS ...]" % prname45 print("%s <OBJCOPY> <FORMAT> <ARCH> <ARCH_PATH> [COMPONENTS ...]" % prname) 46 46 47 47 def deflate(data): … … 110 110 symbol = "_binary_%s" % basename.replace(".", "_") 111 111 112 print "%s -> %s" % (component, obj)112 print("%s -> %s" % (component, obj)) 113 113 114 comp_in = file(component, "rb")114 comp_in = open(component, "rb") 115 115 comp_data = comp_in.read() 116 116 comp_in.close() … … 121 121 122 122 try: 123 comp_out = file(basename, "wb")123 comp_out = open(basename, "wb") 124 124 comp_out.write(comp_deflate) 125 125 comp_out.close() … … 151 151 cnt += 1 152 152 153 header = file(os.path.join(arch_path, "include", "%s.h" % COMPONENTS), "w")153 header = open(os.path.join(arch_path, "include", "%s.h" % COMPONENTS), "w") 154 154 155 155 header.write('/***************************************\n') … … 173 173 header.close() 174 174 175 data = file(os.path.join(arch_path, "src", "%s.c" % COMPONENTS), "w")175 data = open(os.path.join(arch_path, "src", "%s.c" % COMPONENTS), "w") 176 176 177 177 data.write('/***************************************\n') … … 187 187 data.close() 188 188 189 link_in = file(os.path.join(arch_path, "%s.in" % LINK), "r")189 link_in = open(os.path.join(arch_path, "%s.in" % LINK), "r") 190 190 template = link_in.read() 191 191 link_in.close() 192 192 193 link_out = file(os.path.join(arch_path, "%s.comp" % LINK), "w")193 link_out = open(os.path.join(arch_path, "%s.comp" % LINK), "w") 194 194 link_out.write(template.replace("[[COMPONENTS]]", "\n".join(link_ctx))) 195 195 link_out.close()
Note:
See TracChangeset
for help on using the changeset viewer.