Changeset 60898b6 in mainline
- Timestamp:
- 2010-11-05T16:17:48Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 08042bd
- Parents:
- a63ff7d (diff), a66e2993 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 8 added
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.common
ra63ff7d r60898b6 106 106 $(USPACE_PATH)/srv/net/tl/tcp/tcp \ 107 107 $(USPACE_PATH)/srv/net/net/net \ 108 $(USPACE_PATH)/srv/devman/devman \ 109 $(USPACE_PATH)/srv/drivers/root/root 108 $(USPACE_PATH)/srv/devman/devman 110 109 111 110 RD_DRVS = \ -
boot/arch/amd64/Makefile.inc
ra63ff7d r60898b6 34 34 RD_SRVS_NON_ESSENTIAL += \ 35 35 $(USPACE_PATH)/srv/bd/ata_bd/ata_bd \ 36 $(USPACE_PATH)/srv/hw/bus/pci/pci \37 36 $(USPACE_PATH)/srv/hid/char_mouse/char_ms 38 37 -
contrib/arch/hadlbppp.py
ra63ff7d r60898b6 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/arch/abs32le/include/interrupt.h
ra63ff7d r60898b6 37 37 38 38 #include <typedefs.h> 39 #include <verify.h> 40 #include <trace.h> 39 #include <arch/istate.h> 41 40 42 41 #define IVT_ITEMS 0 … … 45 44 #define VECTOR_TLB_SHOOTDOWN_IPI 0 46 45 47 /*48 * On real hardware this stores the registers which49 * need to be preserved during interupts.50 */51 typedef struct istate {52 uintptr_t ip;53 uintptr_t fp;54 uint32_t stack[];55 } istate_t;56 57 NO_TRACE static inline int istate_from_uspace(istate_t *istate)58 REQUIRES_EXTENT_MUTABLE(istate)59 {60 /* On real hardware this checks whether the interrupted61 context originated from user space. */62 63 return !(istate->ip & 0x80000000);64 }65 66 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,67 uintptr_t retaddr)68 WRITES(&istate->ip)69 {70 /* On real hardware this sets the instruction pointer. */71 72 istate->ip = retaddr;73 }74 75 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)76 REQUIRES_EXTENT_MUTABLE(istate)77 {78 /* On real hardware this returns the instruction pointer. */79 80 return istate->ip;81 }82 83 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)84 REQUIRES_EXTENT_MUTABLE(istate)85 {86 /* On real hardware this returns the frame pointer. */87 88 return istate->fp;89 }90 91 46 #endif 92 47 -
kernel/arch/amd64/include/interrupt.h
ra63ff7d r60898b6 37 37 38 38 #include <typedefs.h> 39 #include <arch/istate.h> 39 40 #include <arch/pm.h> 40 #include <trace.h>41 41 42 42 #define IVT_ITEMS IDT_ITEMS … … 71 71 #define VECTOR_DEBUG_IPI (IVT_FREEBASE + 2) 72 72 73 /** This is passed to interrupt handlers */74 typedef struct istate {75 uint64_t rax;76 uint64_t rbx;77 uint64_t rcx;78 uint64_t rdx;79 uint64_t rsi;80 uint64_t rdi;81 uint64_t rbp;82 uint64_t r8;83 uint64_t r9;84 uint64_t r10;85 uint64_t r11;86 uint64_t r12;87 uint64_t r13;88 uint64_t r14;89 uint64_t r15;90 uint64_t alignment; /* align rbp_frame on multiple of 16 */91 uint64_t rbp_frame; /* imitation of frame pointer linkage */92 uint64_t rip_frame; /* imitation of return address linkage */93 uint64_t error_word; /* real or fake error word */94 uint64_t rip;95 uint64_t cs;96 uint64_t rflags;97 uint64_t rsp; /* only if istate_t is from uspace */98 uint64_t ss; /* only if istate_t is from uspace */99 } istate_t;100 101 /** Return true if exception happened while in userspace */102 NO_TRACE static inline int istate_from_uspace(istate_t *istate)103 {104 return !(istate->rip & 0x8000000000000000);105 }106 107 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,108 uintptr_t retaddr)109 {110 istate->rip = retaddr;111 }112 113 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)114 {115 return istate->rip;116 }117 118 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)119 {120 return istate->rbp;121 }122 123 73 extern void (* disable_irqs_function)(uint16_t); 124 74 extern void (* enable_irqs_function)(uint16_t); -
kernel/arch/amd64/src/asm.S
ra63ff7d r60898b6 95 95 memcpy_from_uspace_failover_address: 96 96 memcpy_to_uspace_failover_address: 97 xor q %rax, %rax /* return 0, failure */97 xorl %eax, %eax /* return 0, failure */ 98 98 ret 99 99 … … 143 143 144 144 set_efer_flag: 145 mov q $0xc0000080, %rcx145 movl $0xc0000080, %ecx 146 146 rdmsr 147 147 btsl %edi, %eax … … 150 150 151 151 read_efer_flag: 152 mov q $0xc0000080, %rcx152 movl $0xc0000080, %ecx 153 153 rdmsr 154 154 ret … … 243 243 * Stop stack traces here if we came from userspace. 244 244 */ 245 xor q %rdx, %rdx245 xorl %edx, %edx 246 246 cmpq $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp) 247 247 cmovnzq %rdx, %rbp … … 386 386 movq ISTATE_OFFSET_RSP(%rsp), %rsp 387 387 388 /* 389 * Clear the rest of the scratch registers to prevent information leak. 390 * The 32-bit XOR on the low GPRs actually clears the entire 64-bit 391 * register and the instruction is shorter. 392 */ 393 xorl %edx, %edx 394 xorl %esi, %esi 395 xorl %edi, %edi 396 xorq %r8, %r8 397 xorq %r9, %r9 398 xorq %r10, %r10 399 388 400 sysretq 389 401 … … 413 425 movq %rdi, %rsi 414 426 movq $(PA2KA(0xb8000)), %rdi /* base of EGA text mode memory */ 415 xor q %rax, %rax427 xorl %eax, %eax 416 428 417 429 /* Read bits 8 - 15 of the cursor address */ … … 493 505 movq $(PA2KA(0xb80a0)), %rsi 494 506 movq $(PA2KA(0xb8000)), %rdi 495 mov q $480, %rcx507 movl $480, %ecx 496 508 rep movsq 497 509 498 510 /* Clear the 24th row */ 499 xor q %rax, %rax500 mov q $20, %rcx511 xorl %eax, %eax 512 movl $20, %ecx 501 513 rep stosq 502 514 -
kernel/arch/amd64/src/boot/boot.S
ra63ff7d r60898b6 516 516 movq $(PA2KA(0xb80a0)), %rsi 517 517 movq $(PA2KA(0xb8000)), %rdi 518 mov q $480, %rcx518 movl $480, %ecx 519 519 rep movsq 520 520 521 521 /* Clear the 24th row */ 522 xor q %rax, %rax523 mov q $20, %rcx522 xorl %eax, %eax 523 movl $20, %ecx 524 524 rep stosq 525 525 -
kernel/arch/amd64/src/context.S
ra63ff7d r60898b6 45 45 CONTEXT_SAVE_ARCH_CORE %rdi %rdx 46 46 47 xor q %rax, %rax # context_save returns 148 inc q %rax47 xorl %eax, %eax # context_save returns 1 48 incl %eax 49 49 ret 50 50 … … 60 60 movq %rdx, (%rsp) 61 61 62 xor q %rax, %rax # context_restore returns 062 xorl %eax, %eax # context_restore returns 0 63 63 ret -
kernel/arch/arm32/include/exception.h
ra63ff7d r60898b6 39 39 40 40 #include <typedefs.h> 41 #include <arch/regutils.h> 42 #include <trace.h> 41 #include <arch/istate.h> 43 42 44 43 /** If defined, forces using of high exception vectors. */ … … 85 84 extern uintptr_t exc_stack; 86 85 87 /** Struct representing CPU state saved when an exception occurs. */88 typedef struct istate {89 uint32_t spsr;90 uint32_t sp;91 uint32_t lr;92 93 uint32_t r0;94 uint32_t r1;95 uint32_t r2;96 uint32_t r3;97 uint32_t r4;98 uint32_t r5;99 uint32_t r6;100 uint32_t r7;101 uint32_t r8;102 uint32_t r9;103 uint32_t r10;104 uint32_t fp;105 uint32_t r12;106 107 uint32_t pc;108 } istate_t;109 110 /** Set Program Counter member of given istate structure.111 *112 * @param istate istate structure113 * @param retaddr new value of istate's PC member114 *115 */116 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,117 uintptr_t retaddr)118 {119 istate->pc = retaddr;120 }121 122 /** Return true if exception happened while in userspace. */123 NO_TRACE static inline int istate_from_uspace(istate_t *istate)124 {125 return (istate->spsr & STATUS_REG_MODE_MASK) == USER_MODE;126 }127 128 /** Return Program Counter member of given istate structure. */129 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)130 {131 return istate->pc;132 }133 134 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)135 {136 return istate->fp;137 }138 139 86 extern void install_exception_handlers(void); 140 87 extern void exception_init(void); -
kernel/arch/ia32/include/interrupt.h
ra63ff7d r60898b6 37 37 38 38 #include <typedefs.h> 39 #include <arch/istate.h> 39 40 #include <arch/pm.h> 40 #include <trace.h>41 41 42 42 #define IVT_ITEMS IDT_ITEMS … … 71 71 #define VECTOR_DEBUG_IPI (IVT_FREEBASE + 2) 72 72 73 typedef struct istate {74 /*75 * The strange order of the GPRs is given by the requirement to use the76 * istate structure for both regular interrupts and exceptions as well77 * as for syscall handlers which use this order as an optimization.78 */79 uint32_t edx;80 uint32_t ecx;81 uint32_t ebx;82 uint32_t esi;83 uint32_t edi;84 uint32_t ebp;85 uint32_t eax;86 87 uint32_t ebp_frame; /* imitation of frame pointer linkage */88 uint32_t eip_frame; /* imitation of return address linkage */89 90 uint32_t gs;91 uint32_t fs;92 uint32_t es;93 uint32_t ds;94 95 uint32_t error_word; /* real or fake error word */96 uint32_t eip;97 uint32_t cs;98 uint32_t eflags;99 uint32_t esp; /* only if istate_t is from uspace */100 uint32_t ss; /* only if istate_t is from uspace */101 } istate_t;102 103 /** Return true if exception happened while in userspace */104 NO_TRACE static inline int istate_from_uspace(istate_t *istate)105 {106 return !(istate->eip & 0x80000000);107 }108 109 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,110 uintptr_t retaddr)111 {112 istate->eip = retaddr;113 }114 115 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)116 {117 return istate->eip;118 }119 120 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)121 {122 return istate->ebp;123 }124 125 73 extern void (* disable_irqs_function)(uint16_t); 126 74 extern void (* enable_irqs_function)(uint16_t); -
kernel/arch/ia64/include/interrupt.h
ra63ff7d r60898b6 37 37 38 38 #include <typedefs.h> 39 #include <arch/register.h> 40 #include <trace.h> 39 #include <arch/istate.h> 41 40 42 41 /** ia64 has 256 INRs. */ … … 74 73 #define EOI 0 /**< The actual value doesn't matter. */ 75 74 76 typedef struct istate {77 uint128_t f2;78 uint128_t f3;79 uint128_t f4;80 uint128_t f5;81 uint128_t f6;82 uint128_t f7;83 uint128_t f8;84 uint128_t f9;85 uint128_t f10;86 uint128_t f11;87 uint128_t f12;88 uint128_t f13;89 uint128_t f14;90 uint128_t f15;91 uint128_t f16;92 uint128_t f17;93 uint128_t f18;94 uint128_t f19;95 uint128_t f20;96 uint128_t f21;97 uint128_t f22;98 uint128_t f23;99 uint128_t f24;100 uint128_t f25;101 uint128_t f26;102 uint128_t f27;103 uint128_t f28;104 uint128_t f29;105 uint128_t f30;106 uint128_t f31;107 108 uintptr_t ar_bsp;109 uintptr_t ar_bspstore;110 uintptr_t ar_bspstore_new;111 uint64_t ar_rnat;112 uint64_t ar_ifs;113 uint64_t ar_pfs;114 uint64_t ar_rsc;115 uintptr_t cr_ifa;116 cr_isr_t cr_isr;117 uintptr_t cr_iipa;118 psr_t cr_ipsr;119 uintptr_t cr_iip;120 uint64_t pr;121 uintptr_t sp;122 123 /*124 * The following variables are defined only for break_instruction125 * handler.126 */127 uint64_t in0;128 uint64_t in1;129 uint64_t in2;130 uint64_t in3;131 uint64_t in4;132 uint64_t in5;133 uint64_t in6;134 } istate_t;135 136 75 extern void *ivt; 137 138 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,139 uintptr_t retaddr)140 {141 istate->cr_iip = retaddr;142 istate->cr_ipsr.ri = 0; /* return to instruction slot #0 */143 }144 145 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)146 {147 return istate->cr_iip;148 }149 150 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)151 {152 /* FIXME */153 154 return 0;155 }156 157 NO_TRACE static inline int istate_from_uspace(istate_t *istate)158 {159 return (istate->cr_iip) < 0xe000000000000000ULL;160 }161 76 162 77 extern void general_exception(uint64_t, istate_t *); -
kernel/arch/ia64/include/register.h
ra63ff7d r60898b6 142 142 #ifndef __ASM__ 143 143 144 #ifdef KERNEL 144 145 #include <typedefs.h> 146 #else 147 #include <sys/types.h> 148 #endif 145 149 146 150 /** Processor Status Register. */ -
kernel/arch/mips32/include/cp0.h
ra63ff7d r60898b6 36 36 #define KERN_mips32_CP0_H_ 37 37 38 #ifdef KERNEL 38 39 #include <typedefs.h> 40 #else 41 #include <sys/types.h> 42 #endif 39 43 40 44 #define cp0_status_ie_enabled_bit (1 << 0) -
kernel/arch/mips32/include/exception.h
ra63ff7d r60898b6 37 37 38 38 #include <typedefs.h> 39 #include <arch/cp0.h> 40 #include <trace.h> 39 #include <arch/istate.h> 41 40 42 41 #define EXC_Int 0 … … 59 58 #define EXC_VCED 31 60 59 61 typedef struct istate {62 /*63 * The first seven registers are arranged so that the istate structure64 * can be used both for exception handlers and for the syscall handler.65 */66 uint32_t a0; /* arg1 */67 uint32_t a1; /* arg2 */68 uint32_t a2; /* arg3 */69 uint32_t a3; /* arg4 */70 uint32_t t0; /* arg5 */71 uint32_t t1; /* arg6 */72 uint32_t v0; /* arg7 */73 uint32_t v1;74 uint32_t at;75 uint32_t t2;76 uint32_t t3;77 uint32_t t4;78 uint32_t t5;79 uint32_t t6;80 uint32_t t7;81 uint32_t s0;82 uint32_t s1;83 uint32_t s2;84 uint32_t s3;85 uint32_t s4;86 uint32_t s5;87 uint32_t s6;88 uint32_t s7;89 uint32_t t8;90 uint32_t t9;91 uint32_t kt0;92 uint32_t kt1; /* We use it as thread-local pointer */93 uint32_t gp;94 uint32_t sp;95 uint32_t s8;96 uint32_t ra;97 98 uint32_t lo;99 uint32_t hi;100 101 uint32_t status; /* cp0_status */102 uint32_t epc; /* cp0_epc */103 104 uint32_t alignment; /* to make sizeof(istate_t) a multiple of 8 */105 } istate_t;106 107 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,108 uintptr_t retaddr)109 {110 istate->epc = retaddr;111 }112 113 /** Return true if exception happened while in userspace */114 NO_TRACE static inline int istate_from_uspace(istate_t *istate)115 {116 return istate->status & cp0_status_um_bit;117 }118 119 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)120 {121 return istate->epc;122 }123 124 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)125 {126 return istate->sp;127 }128 129 60 extern void exception(istate_t *istate); 130 61 extern void tlb_refill_entry(void); -
kernel/arch/sparc64/include/interrupt.h
ra63ff7d r60898b6 38 38 39 39 #include <typedefs.h> 40 #include <arch/regdef.h> 41 #include <trace.h> 40 #include <arch/istate.h> 42 41 43 42 #define IVT_ITEMS 15 … … 51 50 }; 52 51 53 typedef struct istate {54 uint64_t tnpc;55 uint64_t tpc;56 uint64_t tstate;57 } istate_t;58 59 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,60 uintptr_t retaddr)61 {62 istate->tpc = retaddr;63 }64 65 NO_TRACE static inline int istate_from_uspace(istate_t *istate)66 {67 return !(istate->tstate & TSTATE_PRIV_BIT);68 }69 70 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)71 {72 return istate->tpc;73 }74 75 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)76 {77 /* TODO */78 79 return 0;80 }81 82 52 #endif 83 53 -
kernel/generic/src/ipc/kbox.c
ra63ff7d r60898b6 107 107 /* Terminate debugging session (if any). */ 108 108 LOG("Terminate debugging session."); 109 irq_spinlock_lock(&TASK->lock, true);109 mutex_lock(&TASK->udebug.lock); 110 110 udebug_task_cleanup(TASK); 111 irq_spinlock_unlock(&TASK->lock, true);111 mutex_unlock(&TASK->udebug.lock); 112 112 } else { 113 113 LOG("Was not debugger."); -
kernel/tools/amd64/decpt.py
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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 enough 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
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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 enough 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
ra63ff7d r60898b6 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 enough 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
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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 … … 370 370 reserved_clusters = 2 371 371 372 # Make sure the filesystem is large enough tfor FAT16372 # Make sure the filesystem is large enough 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
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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
ra63ff7d r60898b6 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")115 comp_data = comp_in.read() ;114 comp_in = open(component, "rb") 115 comp_data = comp_in.read() 116 116 comp_in.close() 117 117 … … 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() -
uspace/drv/ns8250/ns8250.c
ra63ff7d r60898b6 123 123 static void delete_ns8250_dev_data(ns8250_dev_data_t *data) 124 124 { 125 if ( NULL != data)125 if (data != NULL) 126 126 free(data); 127 127 } … … 251 251 static void ns8250_dev_cleanup(device_t *dev) 252 252 { 253 if ( NULL != dev->driver_data) {253 if (dev->driver_data != NULL) { 254 254 delete_ns8250_dev_data((ns8250_dev_data_t*) dev->driver_data); 255 255 dev->driver_data = NULL; … … 332 332 /* Allocate driver data for the device. */ 333 333 ns8250_dev_data_t *data = create_ns8250_dev_data(); 334 if ( NULL == data)334 if (data == NULL) 335 335 return ENOMEM; 336 336 dev->driver_data = data; … … 436 436 /* Enable interrupt globally. */ 437 437 res = interrupt_enable(data->irq); 438 if ( EOK != res)438 if (res != EOK) 439 439 return res; 440 440 … … 480 480 uint8_t div_low, div_high; 481 481 482 if ( 50 > baud_rate || 0 != MAX_BAUD_RATE % baud_rate) {482 if (baud_rate < 50 || MAX_BAUD_RATE % baud_rate != 0) { 483 483 printf(NAME ": error - somebody tried to set invalid baud rate " 484 484 "%d\n", baud_rate); … … 534 534 * @param stop_bits The number of stop bits used (one or two). 535 535 */ 536 static void 537 ns8250_port_get_com_props(ioport8_t *port, unsigned int *parity, 536 static void ns8250_port_get_com_props(ioport8_t *port, unsigned int *parity, 538 537 unsigned int *word_length, unsigned int *stop_bits) 539 538 { … … 572 571 * is invalid. 573 572 */ 574 static int 575 ns8250_port_set_com_props(ioport8_t *port, unsigned int parity, 573 static int ns8250_port_set_com_props(ioport8_t *port, unsigned int parity, 576 574 unsigned int word_length, unsigned int stop_bits) 577 575 { … … 691 689 * @param dev The serial port device. 692 690 */ 693 static inline void 694 ns8250_interrupt_handler(device_t *dev, ipc_callid_t iid,ipc_call_t *icall)691 static inline void ns8250_interrupt_handler(device_t *dev, ipc_callid_t iid, 692 ipc_call_t *icall) 695 693 { 696 694 ns8250_read_from_device(dev); … … 726 724 * @param dev The serial port device. 727 725 */ 728 static int ns8250_add_device(device_t *dev) 726 static int ns8250_add_device(device_t *dev) 729 727 { 730 728 printf(NAME ": ns8250_add_device %s (handle = %d)\n", … … 732 730 733 731 int res = ns8250_dev_initialize(dev); 734 if ( EOK != res)732 if (res != EOK) 735 733 return res; 736 734 … … 750 748 751 749 /* Register interrupt handler. */ 752 if ( EOK != ns8250_register_interrupt_handler(dev)) {750 if (ns8250_register_interrupt_handler(dev) != EOK) { 753 751 printf(NAME ": failed to register interrupt handler.\n"); 754 752 ns8250_dev_cleanup(dev); … … 758 756 /* Enable interrupt. */ 759 757 res = ns8250_interrupt_enable(dev); 760 if ( EOK != res) {758 if (res != EOK) { 761 759 printf(NAME ": failed to enable the interrupt. Error code = " 762 760 "%d.\n", res); … … 859 857 * @param stop_bits The number of stop bits to be used. 860 858 */ 861 static int 862 ns8250_set_props(device_t *dev, unsigned int baud_rate, unsigned int parity, 863 unsigned int word_length, unsigned int stop_bits) 859 static int ns8250_set_props(device_t *dev, unsigned int baud_rate, 860 unsigned int parity, unsigned int word_length, unsigned int stop_bits) 864 861 { 865 862 printf(NAME ": ns8250_set_props: baud rate %d, parity 0x%x, word " … … 874 871 ns8250_port_interrupts_disable(port); 875 872 ret = ns8250_port_set_baud_rate(port, baud_rate); 876 if ( EOK == ret)873 if (ret == EOK) 877 874 ret = ns8250_port_set_com_props(port, parity, word_length, stop_bits); 878 875 ns8250_port_interrupts_enable(port); … … 887 884 * Configure the parameters of the serial communication. 888 885 */ 889 static void 890 ns8250_default_handler(device_t *dev, ipc_callid_t callid,ipc_call_t *call)886 static void ns8250_default_handler(device_t *dev, ipc_callid_t callid, 887 ipc_call_t *call) 891 888 { 892 889 ipcarg_t method = IPC_GET_METHOD(*call); -
uspace/drv/pciintel/pci.c
ra63ff7d r60898b6 65 65 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; 66 66 67 if ( NULL == dev_data)67 if (dev_data == NULL) 68 68 return NULL; 69 69 return &dev_data->hw_resources; … … 109 109 110 110 bus_data = (pci_bus_data_t *) malloc(sizeof(pci_bus_data_t)); 111 if ( NULL != bus_data) {111 if (bus_data != NULL) { 112 112 memset(bus_data, 0, sizeof(pci_bus_data_t)); 113 113 fibril_mutex_initialize(&bus_data->conf_mutex); 114 114 } 115 115 116 return bus_data; 116 117 } … … 123 124 static void pci_conf_read(device_t *dev, int reg, uint8_t *buf, size_t len) 124 125 { 125 assert( NULL != dev->parent);126 assert(dev->parent != NULL); 126 127 127 128 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; … … 153 154 static void pci_conf_write(device_t *dev, int reg, uint8_t *buf, size_t len) 154 155 { 155 assert( NULL != dev->parent);156 assert(dev->parent != NULL); 156 157 157 158 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; … … 224 225 225 226 match_id = create_match_id(); 226 if ( NULL != match_id) {227 if (match_id != NULL) { 227 228 asprintf(&match_id_str, "pci/ven=%04x&dev=%04x", 228 229 dev_data->vendor_id, dev_data->device_id); … … 230 231 match_id->score = 90; 231 232 add_match_id(&dev->match_ids, match_id); 232 } 233 } 234 233 235 /* TODO add more ids (with subsys ids, using class id etc.) */ 234 236 } … … 242 244 size_t count = hw_res_list->count; 243 245 244 assert( NULL != hw_resources);246 assert(hw_resources != NULL); 245 247 assert(count < PCI_MAX_HW_RES); 246 248 … … 275 277 bool io; 276 278 /* 64-bit wide address */ 277 bool w64;279 bool addrw64; 278 280 279 281 /* Size of the io or memory range specified by the BAR */ … … 287 289 io = (bool) (val & 1); 288 290 if (io) { 289 w64 = false;291 addrw64 = false; 290 292 } else { 291 293 switch ((val >> 1) & 3) { 292 294 case 0: 293 w64 = false;295 addrw64 = false; 294 296 break; 295 297 case 2: 296 w64 = true;298 addrw64 = true; 297 299 break; 298 300 default: … … 312 314 range_size = pci_bar_mask_to_size(mask); 313 315 314 if ( w64) {316 if (addrw64) { 315 317 range_addr = ((uint64_t)pci_conf_read_32(dev, addr + 4) << 32) | 316 318 (val & 0xfffffff0); … … 319 321 } 320 322 321 if ( 0 != range_addr) {323 if (range_addr != 0) { 322 324 printf(NAME ": device %s : ", dev->name); 323 325 printf("address = %x", range_addr); … … 327 329 pci_add_range(dev, range_addr, range_size, io); 328 330 329 if ( w64)331 if (addrw64) 330 332 return addr + 8; 331 333 … … 354 356 { 355 357 uint8_t irq = pci_conf_read_8(dev, PCI_BRIDGE_INT_LINE); 356 if ( 0xff != irq)358 if (irq != 0xff) 357 359 pci_add_interrupt(dev, irq); 358 360 } … … 415 417 create_pci_match_ids(dev); 416 418 417 if ( EOK != child_device_register(dev, parent)) {419 if (child_device_register(dev, parent) != EOK) { 418 420 pci_clean_resource_list(dev); 419 421 clean_match_ids(&dev->match_ids); … … 424 426 425 427 if (header_type == PCI_HEADER_TYPE_BRIDGE || 426 header_type == PCI_HEADER_TYPE_CARDBUS 428 header_type == PCI_HEADER_TYPE_CARDBUS) { 427 429 child_bus = pci_conf_read_8(dev, 428 430 PCI_BRIDGE_SEC_BUS_NUM); 429 431 printf(NAME ": device is pci-to-pci bridge, " 430 432 "secondary bus number = %d.\n", bus_num); 431 if (child_bus > bus_num)433 if (child_bus > bus_num) 432 434 pci_bus_scan(parent, child_bus); 433 435 } … … 453 455 454 456 pci_bus_data_t *bus_data = create_pci_bus_data(); 455 if ( NULL == bus_data) {457 if (bus_data == NULL) { 456 458 printf(NAME ": pci_add_device allocation failed.\n"); 457 459 return ENOMEM; … … 513 515 } 514 516 517 pci_dev_data_t *create_pci_dev_data(void) 518 { 519 pci_dev_data_t *res = (pci_dev_data_t *) malloc(sizeof(pci_dev_data_t)); 520 521 if (res != NULL) 522 memset(res, 0, sizeof(pci_dev_data_t)); 523 return res; 524 } 525 526 void init_pci_dev_data(pci_dev_data_t *dev_data, int bus, int dev, int fn) 527 { 528 dev_data->bus = bus; 529 dev_data->dev = dev; 530 dev_data->fn = fn; 531 } 532 533 void delete_pci_dev_data(pci_dev_data_t *dev_data) 534 { 535 if (dev_data != NULL) { 536 clean_hw_resource_list(&dev_data->hw_resources); 537 free(dev_data); 538 } 539 } 540 541 void create_pci_dev_name(device_t *dev) 542 { 543 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; 544 char *name = NULL; 545 546 asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev, 547 dev_data->fn); 548 dev->name = name; 549 } 550 551 bool pci_alloc_resource_list(device_t *dev) 552 { 553 pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data; 554 555 dev_data->hw_resources.resources = 556 (hw_resource_t *) malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t)); 557 return dev_data->hw_resources.resources != NULL; 558 } 559 560 void pci_clean_resource_list(device_t *dev) 561 { 562 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; 563 564 if (dev_data->hw_resources.resources != NULL) { 565 free(dev_data->hw_resources.resources); 566 dev_data->hw_resources.resources = NULL; 567 } 568 } 569 570 /** Read the base address registers (BARs) of the device and adds the addresses 571 * to its hw resource list. 572 * 573 * @param dev the pci device. 574 */ 575 void pci_read_bars(device_t *dev) 576 { 577 /* 578 * Position of the BAR in the PCI configuration address space of the 579 * device. 580 */ 581 int addr = PCI_BASE_ADDR_0; 582 583 while (addr <= PCI_BASE_ADDR_5) 584 addr = pci_read_bar(dev, addr); 585 } 586 587 size_t pci_bar_mask_to_size(uint32_t mask) 588 { 589 return ((mask & 0xfffffff0) ^ 0xffffffff) + 1; 590 } 591 515 592 int main(int argc, char *argv[]) 516 593 { -
uspace/drv/pciintel/pci.h
ra63ff7d r60898b6 69 69 extern void pci_bus_scan(device_t *, int); 70 70 71 static inline pci_dev_data_t *create_pci_dev_data(void) 72 { 73 pci_dev_data_t *res = (pci_dev_data_t *) malloc(sizeof(pci_dev_data_t)); 74 75 if (NULL != res) 76 memset(res, 0, sizeof(pci_dev_data_t)); 77 return res; 78 } 71 extern pci_dev_data_t *create_pci_dev_data(void); 72 extern void init_pci_dev_data(pci_dev_data_t *, int, int, int); 73 extern void delete_pci_dev_data(pci_dev_data_t *); 74 extern void create_pci_dev_name(device_t *); 79 75 80 static inline void 81 init_pci_dev_data(pci_dev_data_t *d, int bus, int dev, int fn) 82 { 83 d->bus = bus; 84 d->dev = dev; 85 d->fn = fn; 86 } 76 extern bool pci_alloc_resource_list(device_t *); 77 extern void pci_clean_resource_list(device_t *); 87 78 88 static inline void delete_pci_dev_data(pci_dev_data_t *d) 89 { 90 if (NULL != d) { 91 clean_hw_resource_list(&d->hw_resources); 92 free(d); 93 } 94 } 95 96 static inline void create_pci_dev_name(device_t *dev) 97 { 98 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; 99 char *name = NULL; 100 101 asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev, 102 dev_data->fn); 103 dev->name = name; 104 } 105 106 static inline bool pci_alloc_resource_list(device_t *dev) 107 { 108 pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data; 109 110 dev_data->hw_resources.resources = 111 (hw_resource_t *) malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t)); 112 return dev_data->hw_resources.resources != NULL; 113 } 114 115 static inline void pci_clean_resource_list(device_t *dev) 116 { 117 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; 118 119 if (NULL != dev_data->hw_resources.resources) { 120 free(dev_data->hw_resources.resources); 121 dev_data->hw_resources.resources = NULL; 122 } 123 } 124 125 /** Read the base address registers (BARs) of the device and adds the addresses 126 * to its hw resource list. 127 * 128 * @param dev the pci device. 129 */ 130 static inline void pci_read_bars(device_t *dev) 131 { 132 /* 133 * Position of the BAR in the PCI configuration address space of the 134 * device. 135 */ 136 int addr = PCI_BASE_ADDR_0; 137 138 while (addr <= PCI_BASE_ADDR_5) 139 addr = pci_read_bar(dev, addr); 140 } 141 142 static inline size_t pci_bar_mask_to_size(uint32_t mask) 143 { 144 return ((mask & 0xfffffff0) ^ 0xffffffff) + 1; 145 } 79 extern void pci_read_bars(device_t *); 80 extern size_t pci_bar_mask_to_size(uint32_t); 146 81 147 82 #endif -
uspace/lib/c/arch/abs32le/include/fibril.h
ra63ff7d r60898b6 44 44 (ctx)->pc = (uintptr_t) (_pc); \ 45 45 (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \ 46 (ctx)->fp = 0; \ 46 47 (ctx)->tls = ((uintptr_t) (ptls)) + sizeof(tcb_t); \ 47 48 } while (0) … … 53 54 typedef struct { 54 55 uintptr_t sp; 56 uintptr_t fp; 55 57 uintptr_t pc; 56 58 uintptr_t tls; 57 59 } context_t; 60 61 static inline uintptr_t context_get_fp(context_t *ctx) 62 { 63 /* On real hardware, this function returns the frame pointer. */ 64 return ctx->fp; 65 } 58 66 59 67 #endif -
uspace/lib/c/arch/abs32le/include/istate.h
ra63ff7d r60898b6 36 36 #define LIBC_abs32le__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * On real hardware this stores the registers which 43 * need to be preserved during interupts. 44 */ 45 typedef struct istate { 46 uintptr_t ip; 47 uintptr_t fp; 48 uint32_t stack[]; 49 } istate_t; 50 51 static inline uintptr_t istate_get_pc(istate_t *istate) 52 { 53 return istate->ip; 54 } 55 56 static inline uintptr_t istate_get_fp(istate_t *istate) 57 { 58 return istate->fp; 59 } 38 #include <arch/istate.h> 60 39 61 40 #endif -
uspace/lib/c/arch/amd64/include/fibril.h
ra63ff7d r60898b6 56 56 */ 57 57 typedef struct { 58 uint64_t sp; 59 uint64_t pc; 60 61 uint64_t rbx; 62 uint64_t rbp; 58 uint64_t sp; 59 uint64_t pc; 63 60 64 uint64_t r12; 65 uint64_t r13; 66 uint64_t r14; 67 uint64_t r15; 61 uint64_t rbx; 62 uint64_t rbp; 68 63 69 uint64_t tls; 64 uint64_t r12; 65 uint64_t r13; 66 uint64_t r14; 67 uint64_t r15; 68 69 uint64_t tls; 70 70 } context_t; 71 72 static inline uintptr_t context_get_fp(context_t *ctx) 73 { 74 return ctx->rbp; 75 } 71 76 72 77 #endif -
uspace/lib/c/arch/amd64/include/istate.h
ra63ff7d r60898b6 36 36 #define LIBC_amd64_ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint64_t rax; 46 uint64_t rcx; 47 uint64_t rdx; 48 uint64_t rsi; 49 uint64_t rdi; 50 uint64_t r8; 51 uint64_t r9; 52 uint64_t r10; 53 uint64_t r11; 54 uint64_t rbp; 55 uint64_t error_word; 56 uint64_t rip; 57 uint64_t cs; 58 uint64_t rflags; 59 uint64_t stack[]; /* Additional data on stack */ 60 } istate_t; 61 62 static inline uintptr_t istate_get_pc(istate_t *istate) 63 { 64 return istate->rip; 65 } 66 67 static inline uintptr_t istate_get_fp(istate_t *istate) 68 { 69 return istate->rbp; 70 } 38 #include <arch/istate.h> 71 39 72 40 #endif -
uspace/lib/c/arch/amd64/src/entry.s
ra63ff7d r60898b6 42 42 # 43 43 pushq $0 44 mov %rsp, %rbp44 movq %rsp, %rbp 45 45 46 46 # %rdi was deliberately chosen as the first argument is also in %rdi -
uspace/lib/c/arch/amd64/src/fibril.S
ra63ff7d r60898b6 49 49 movq %rax, OFFSET_TLS(%rdi) 50 50 51 xor q %rax,%rax # context_save returns 152 inc q %rax51 xorl %eax, %eax # context_save returns 1 52 incl %eax 53 53 ret 54 54 … … 67 67 # Set thread local storage 68 68 movq OFFSET_TLS(%rdi), %rdi # Set arg1 to TLS addr 69 mov q $1, %rax # SYS_TLS_SET69 movl $1, %eax # SYS_TLS_SET 70 70 syscall 71 71 72 xor q %rax,%rax # context_restore returns 072 xorl %eax, %eax # context_restore returns 0 73 73 ret -
uspace/lib/c/arch/arm32/include/fibril.h
ra63ff7d r60898b6 86 86 } context_t; 87 87 88 static inline uintptr_t context_get_fp(context_t *ctx) 89 { 90 return ctx->fp; 91 } 92 88 93 89 94 #endif -
uspace/lib/c/arch/arm32/include/istate.h
ra63ff7d r60898b6 36 36 #define LIBC_arm32__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t spsr; 46 uint32_t sp; 47 uint32_t lr; 48 49 uint32_t r0; 50 uint32_t r1; 51 uint32_t r2; 52 uint32_t r3; 53 uint32_t r4; 54 uint32_t r5; 55 uint32_t r6; 56 uint32_t r7; 57 uint32_t r8; 58 uint32_t r9; 59 uint32_t r10; 60 uint32_t fp; 61 uint32_t r12; 62 63 uint32_t pc; 64 } istate_t; 65 66 static inline uintptr_t istate_get_pc(istate_t *istate) 67 { 68 return istate->pc; 69 } 70 71 static inline uintptr_t istate_get_fp(istate_t *istate) 72 { 73 return istate->fp; 74 } 38 #include <arch/istate.h> 75 39 76 40 #endif -
uspace/lib/c/arch/ia32/include/fibril.h
ra63ff7d r60898b6 67 67 } context_t; 68 68 69 static inline uintptr_t context_get_fp(context_t *ctx) 70 { 71 return ctx->ebp; 72 } 73 69 74 #endif 70 75 -
uspace/lib/c/arch/ia32/include/istate.h
ra63ff7d r60898b6 36 36 #define LIBC_ia32__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t eax; 46 uint32_t ecx; 47 uint32_t edx; 48 uint32_t ebp; 49 50 uint32_t gs; 51 uint32_t fs; 52 uint32_t es; 53 uint32_t ds; 54 55 uint32_t error_word; 56 uint32_t eip; 57 uint32_t cs; 58 uint32_t eflags; 59 uint32_t stack[]; 60 } istate_t; 61 62 static inline uintptr_t istate_get_pc(istate_t *istate) 63 { 64 return istate->eip; 65 } 66 67 static inline uintptr_t istate_get_fp(istate_t *istate) 68 { 69 return istate->ebp; 70 } 38 #include <arch/istate.h> 71 39 72 40 #endif -
uspace/lib/c/arch/ia64/include/fibril.h
ra63ff7d r60898b6 130 130 } context_t; 131 131 132 static inline uintptr_t context_get_fp(context_t *ctx) 133 { 134 return 0; /* FIXME */ 135 } 136 132 137 #endif 133 138 -
uspace/lib/c/arch/ia64/include/istate.h
ra63ff7d r60898b6 36 36 #define LIBC_ia64_ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 /* TODO */ 46 } istate_t; 47 48 static inline uintptr_t istate_get_pc(istate_t *istate) 49 { 50 /* TODO */ 51 return 0; 52 } 53 54 static inline uintptr_t istate_get_fp(istate_t *istate) 55 { 56 /* TODO */ 57 return 0; 58 } 38 #include <arch/istate.h> 59 39 60 40 #endif -
uspace/lib/c/arch/mips32/include/fibril.h
ra63ff7d r60898b6 85 85 } context_t; 86 86 87 static inline uintptr_t context_get_fp(context_t *ctx) 88 { 89 return ctx->sp; 90 } 91 87 92 #endif 88 93 -
uspace/lib/c/arch/mips32/include/istate.h
ra63ff7d r60898b6 36 36 #define LIBC_mips32__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t at; 46 uint32_t v0; 47 uint32_t v1; 48 uint32_t a0; 49 uint32_t a1; 50 uint32_t a2; 51 uint32_t a3; 52 uint32_t t0; 53 uint32_t t1; 54 uint32_t t2; 55 uint32_t t3; 56 uint32_t t4; 57 uint32_t t5; 58 uint32_t t6; 59 uint32_t t7; 60 uint32_t t8; 61 uint32_t t9; 62 uint32_t gp; 63 uint32_t sp; 64 uint32_t ra; 65 66 uint32_t lo; 67 uint32_t hi; 68 69 uint32_t status; /* cp0_status */ 70 uint32_t epc; /* cp0_epc */ 71 uint32_t k1; /* We use it as thread-local pointer */ 72 } istate_t; 73 74 static inline uintptr_t istate_get_pc(istate_t *istate) 75 { 76 return istate->epc; 77 } 78 79 static inline uintptr_t istate_get_fp(istate_t *istate) 80 { 81 /* TODO */ 82 return 0; 83 } 38 #include <arch/istate.h> 84 39 85 40 #endif -
uspace/lib/c/arch/ppc32/include/fibril.h
ra63ff7d r60898b6 78 78 } __attribute__ ((packed)) context_t; 79 79 80 static inline uintptr_t context_get_fp(context_t *ctx) 81 { 82 return ctx->sp; 83 } 84 80 85 #endif 81 86 -
uspace/lib/c/arch/sparc64/include/fibril.h
ra63ff7d r60898b6 77 77 } context_t; 78 78 79 static inline uintptr_t context_get_fp(context_t *ctx) 80 { 81 return ctx->sp + STACK_BIAS; 82 } 83 79 84 #endif 80 85 -
uspace/lib/c/arch/sparc64/include/istate.h
ra63ff7d r60898b6 36 36 #define LIBC_sparc64_ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 /* TODO */ 46 } istate_t; 47 48 static inline uintptr_t istate_get_pc(istate_t *istate) 49 { 50 /* TODO */ 51 return 0; 52 } 53 54 static inline uintptr_t istate_get_fp(istate_t *istate) 55 { 56 /* TODO */ 57 return 0; 58 } 38 #include <arch/istate.h> 59 39 60 40 #endif -
uspace/lib/c/generic/fibril.c
ra63ff7d r60898b6 275 275 fibril->func = func; 276 276 fibril->arg = arg; 277 278 fibril->waits_for = NULL; 277 279 278 280 context_save(&fibril->ctx); -
uspace/lib/c/generic/fibril_synch.c
ra63ff7d r60898b6 42 42 #include <errno.h> 43 43 #include <assert.h> 44 #include <stacktrace.h> 45 #include <stdlib.h> 44 46 45 47 static void optimize_execution_power(void) … … 56 58 } 57 59 60 static void print_deadlock(fibril_owner_info_t *oi) 61 { 62 fibril_t *f = (fibril_t *) fibril_get_id(); 63 64 printf("Deadlock detected.\n"); 65 stacktrace_print(); 66 67 printf("Fibril %p waits for primitive %p.\n", f, oi); 68 69 while (oi && oi->owned_by) { 70 printf("Primitive %p is owned by fibril %p.\n", 71 oi, oi->owned_by); 72 if (oi->owned_by == f) 73 break; 74 stacktrace_print_fp_pc(context_get_fp(&oi->owned_by->ctx), 75 oi->owned_by->ctx.pc); 76 printf("Fibril %p waits for primitive %p.\n", 77 oi->owned_by, oi->owned_by->waits_for); 78 oi = oi->owned_by->waits_for; 79 } 80 } 81 82 83 static void check_for_deadlock(fibril_owner_info_t *oi) 84 { 85 while (oi && oi->owned_by) { 86 if (oi->owned_by == (fibril_t *) fibril_get_id()) { 87 print_deadlock(oi); 88 abort(); 89 } 90 oi = oi->owned_by->waits_for; 91 } 92 } 93 94 58 95 void fibril_mutex_initialize(fibril_mutex_t *fm) 59 96 { 97 fm->oi.owned_by = NULL; 60 98 fm->counter = 1; 61 99 list_initialize(&fm->waiters); … … 64 102 void fibril_mutex_lock(fibril_mutex_t *fm) 65 103 { 104 fibril_t *f = (fibril_t *) fibril_get_id(); 105 66 106 futex_down(&async_futex); 67 107 if (fm->counter-- <= 0) { … … 73 113 link_initialize(&wdata.wu_event.link); 74 114 list_append(&wdata.wu_event.link, &fm->waiters); 115 check_for_deadlock(&fm->oi); 116 f->waits_for = &fm->oi; 75 117 fibril_switch(FIBRIL_TO_MANAGER); 76 118 } else { 119 fm->oi.owned_by = f; 77 120 futex_up(&async_futex); 78 121 } … … 86 129 if (fm->counter > 0) { 87 130 fm->counter--; 131 fm->oi.owned_by = (fibril_t *) fibril_get_id(); 88 132 locked = true; 89 133 } … … 99 143 link_t *tmp; 100 144 awaiter_t *wdp; 145 fibril_t *f; 101 146 102 147 assert(!list_empty(&fm->waiters)); … … 105 150 wdp->active = true; 106 151 wdp->wu_event.inlist = false; 152 153 f = (fibril_t *) wdp->fid; 154 fm->oi.owned_by = f; 155 f->waits_for = NULL; 156 107 157 list_remove(&wdp->wu_event.link); 108 158 fibril_add_ready(wdp->fid); 109 159 optimize_execution_power(); 160 } else { 161 fm->oi.owned_by = NULL; 110 162 } 111 163 } … … 120 172 void fibril_rwlock_initialize(fibril_rwlock_t *frw) 121 173 { 174 frw->oi.owned_by = NULL; 122 175 frw->writers = 0; 123 176 frw->readers = 0; … … 138 191 f->flags &= ~FIBRIL_WRITER; 139 192 list_append(&wdata.wu_event.link, &frw->waiters); 193 check_for_deadlock(&frw->oi); 194 f->waits_for = &frw->oi; 140 195 fibril_switch(FIBRIL_TO_MANAGER); 141 196 } else { … … 147 202 void fibril_rwlock_write_lock(fibril_rwlock_t *frw) 148 203 { 204 fibril_t *f = (fibril_t *) fibril_get_id(); 205 149 206 futex_down(&async_futex); 150 207 if (frw->writers || frw->readers) { 151 fibril_t *f = (fibril_t *) fibril_get_id();152 208 awaiter_t wdata; 153 209 … … 158 214 f->flags |= FIBRIL_WRITER; 159 215 list_append(&wdata.wu_event.link, &frw->waiters); 216 check_for_deadlock(&frw->oi); 217 f->waits_for = &frw->oi; 160 218 fibril_switch(FIBRIL_TO_MANAGER); 161 219 } else { 220 frw->oi.owned_by = f; 162 221 frw->writers++; 163 222 futex_up(&async_futex); … … 177 236 178 237 assert(!frw->readers && !frw->writers); 238 239 frw->oi.owned_by = NULL; 179 240 180 241 while (!list_empty(&frw->waiters)) { … … 185 246 wdp = list_get_instance(tmp, awaiter_t, wu_event.link); 186 247 f = (fibril_t *) wdp->fid; 248 249 f->waits_for = NULL; 187 250 188 251 if (f->flags & FIBRIL_WRITER) { … … 194 257 fibril_add_ready(wdp->fid); 195 258 frw->writers++; 259 frw->oi.owned_by = f; 196 260 optimize_execution_power(); 197 261 break; -
uspace/lib/c/include/fibril.h
ra63ff7d r60898b6 48 48 #define FIBRIL_WRITER 2 49 49 50 struct fibril; 51 52 typedef struct { 53 struct fibril *owned_by; 54 } fibril_owner_info_t; 55 50 56 typedef enum { 51 57 FIBRIL_PREEMPT, … … 68 74 int retval; 69 75 int flags; 76 77 fibril_owner_info_t *waits_for; 70 78 } fibril_t; 71 79 -
uspace/lib/c/include/fibril_synch.h
ra63ff7d r60898b6 43 43 44 44 typedef struct { 45 fibril_owner_info_t oi; /* Keep this the first thing. */ 45 46 int counter; 46 47 link_t waiters; … … 49 50 #define FIBRIL_MUTEX_INITIALIZER(name) \ 50 51 { \ 52 .oi = { \ 53 .owned_by = NULL \ 54 }, \ 51 55 .counter = 1, \ 52 56 .waiters = { \ … … 60 64 61 65 typedef struct { 66 fibril_owner_info_t oi; /* Keep this the first thing. */ 62 67 unsigned writers; 63 68 unsigned readers; … … 67 72 #define FIBRIL_RWLOCK_INITIALIZER(name) \ 68 73 { \ 74 .oi = { \ 75 .owned_by = NULL \ 76 }, \ 69 77 .readers = 0, \ 70 78 .writers = 0, \ -
uspace/srv/devman/devman.c
ra63ff7d r60898b6 76 76 .remove_callback = devices_remove_callback 77 77 }; 78 79 /** 80 * Initialize the list of device driver's. 81 * 82 * @param drv_list the list of device driver's. 83 * 84 */ 85 void init_driver_list(driver_list_t *drv_list) 86 { 87 assert(drv_list != NULL); 88 89 list_initialize(&drv_list->drivers); 90 fibril_mutex_initialize(&drv_list->drivers_mutex); 91 } 78 92 79 93 /** Allocate and initialize a new driver structure. … … 548 562 } 549 563 564 /** Initialize device driver structure. 565 * 566 * @param drv The device driver structure. 567 */ 568 void init_driver(driver_t *drv) 569 { 570 assert(drv != NULL); 571 572 memset(drv, 0, sizeof(driver_t)); 573 list_initialize(&drv->match_ids.ids); 574 list_initialize(&drv->devices); 575 fibril_mutex_initialize(&drv->driver_mutex); 576 } 577 578 /** Device driver structure clean-up. 579 * 580 * @param drv The device driver structure. 581 */ 582 void clean_driver(driver_t *drv) 583 { 584 assert(drv != NULL); 585 586 free_not_null(drv->name); 587 free_not_null(drv->binary_path); 588 589 clean_match_ids(&drv->match_ids); 590 591 init_driver(drv); 592 } 593 594 /** Delete device driver structure. 595 * 596 * @param drv The device driver structure. 597 */ 598 void delete_driver(driver_t *drv) 599 { 600 assert(drv != NULL); 601 602 clean_driver(drv); 603 free(drv); 604 } 550 605 551 606 /** Create devmap path and name for the device. */ … … 685 740 } 686 741 742 /* Device nodes */ 743 744 /** Create a new device node. 745 * 746 * @return A device node structure. 747 */ 748 node_t *create_dev_node(void) 749 { 750 node_t *res = malloc(sizeof(node_t)); 751 752 if (res != NULL) { 753 memset(res, 0, sizeof(node_t)); 754 list_initialize(&res->children); 755 list_initialize(&res->match_ids.ids); 756 list_initialize(&res->classes); 757 } 758 759 return res; 760 } 761 762 /** Delete a device node. 763 * 764 * @param node The device node structure. 765 */ 766 void delete_dev_node(node_t *node) 767 { 768 assert(list_empty(&node->children)); 769 assert(node->parent == NULL); 770 assert(node->drv == NULL); 771 772 clean_match_ids(&node->match_ids); 773 free_not_null(node->name); 774 free_not_null(node->pathname); 775 free(node); 776 } 777 778 /** Find the device node structure of the device witch has the specified handle. 779 * 780 * Device tree's rwlock should be held at least for reading. 781 * 782 * @param tree The device tree where we look for the device node. 783 * @param handle The handle of the device. 784 * @return The device node. 785 */ 786 node_t *find_dev_node_no_lock(dev_tree_t *tree, device_handle_t handle) 787 { 788 unsigned long key = handle; 789 link_t *link = hash_table_find(&tree->devman_devices, &key); 790 return hash_table_get_instance(link, node_t, devman_link); 791 } 792 793 /** Find the device node structure of the device witch has the specified handle. 794 * 795 * @param tree The device tree where we look for the device node. 796 * @param handle The handle of the device. 797 * @return The device node. 798 */ 799 node_t *find_dev_node(dev_tree_t *tree, device_handle_t handle) 800 { 801 node_t *node = NULL; 802 803 fibril_rwlock_read_lock(&tree->rwlock); 804 node = find_dev_node_no_lock(tree, handle); 805 fibril_rwlock_read_unlock(&tree->rwlock); 806 807 return node; 808 } 809 810 687 811 /** Create and set device's full path in device tree. 688 812 * … … 825 949 return NULL; 826 950 } 951 952 /* Device classes */ 953 954 /** Create device class. 955 * 956 * @return Device class. 957 */ 958 dev_class_t *create_dev_class(void) 959 { 960 dev_class_t *cl; 961 962 cl = (dev_class_t *) malloc(sizeof(dev_class_t)); 963 if (cl != NULL) { 964 memset(cl, 0, sizeof(dev_class_t)); 965 list_initialize(&cl->devices); 966 fibril_mutex_initialize(&cl->mutex); 967 } 968 969 return cl; 970 } 971 972 /** Create device class info. 973 * 974 * @return Device class info. 975 */ 976 dev_class_info_t *create_dev_class_info(void) 977 { 978 dev_class_info_t *info; 979 980 info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t)); 981 if (info != NULL) 982 memset(info, 0, sizeof(dev_class_info_t)); 983 984 return info; 985 } 986 987 size_t get_new_class_dev_idx(dev_class_t *cl) 988 { 989 size_t dev_idx; 990 991 fibril_mutex_lock(&cl->mutex); 992 dev_idx = ++cl->curr_dev_idx; 993 fibril_mutex_unlock(&cl->mutex); 994 995 return dev_idx; 996 } 997 827 998 828 999 /** Create unique device name within the class. … … 921 1092 } 922 1093 1094 void add_dev_class_no_lock(class_list_t *class_list, dev_class_t *cl) 1095 { 1096 list_append(&cl->link, &class_list->classes); 1097 } 1098 923 1099 void init_class_list(class_list_t *class_list) 924 1100 { … … 930 1106 931 1107 932 /* devmap devices */1108 /* Devmap devices */ 933 1109 934 1110 node_t *find_devmap_tree_device(dev_tree_t *tree, dev_handle_t devmap_handle) … … 967 1143 } 968 1144 1145 void class_add_devmap_device(class_list_t *class_list, dev_class_info_t *cli) 1146 { 1147 unsigned long key = (unsigned long) cli->devmap_handle; 1148 1149 fibril_rwlock_write_lock(&class_list->rwlock); 1150 hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link); 1151 fibril_rwlock_write_unlock(&class_list->rwlock); 1152 } 1153 1154 void tree_add_devmap_device(dev_tree_t *tree, node_t *node) 1155 { 1156 unsigned long key = (unsigned long) node->devmap_handle; 1157 fibril_rwlock_write_lock(&tree->rwlock); 1158 hash_table_insert(&tree->devmap_devices, &key, &node->devmap_link); 1159 fibril_rwlock_write_unlock(&tree->rwlock); 1160 } 1161 969 1162 /** @} 970 1163 */ -
uspace/srv/devman/devman.h
ra63ff7d r60898b6 283 283 /* Drivers */ 284 284 285 /** 286 * Initialize the list of device driver's. 287 * 288 * @param drv_list the list of device driver's. 289 * 290 */ 291 static inline void init_driver_list(driver_list_t *drv_list) 292 { 293 assert(drv_list != NULL); 294 295 list_initialize(&drv_list->drivers); 296 fibril_mutex_initialize(&drv_list->drivers_mutex); 297 } 298 285 extern void init_driver_list(driver_list_t *); 299 286 extern driver_t *create_driver(void); 300 287 extern bool get_driver_info(const char *, const char *, driver_t *); … … 311 298 extern driver_t *find_driver(driver_list_t *, const char *); 312 299 extern void set_driver_phone(driver_t *, ipcarg_t); 313 void initialize_running_driver(driver_t *, dev_tree_t *); 314 315 /** Initialize device driver structure. 316 * 317 * @param drv The device driver structure. 318 */ 319 static inline void init_driver(driver_t *drv) 320 { 321 assert(drv != NULL); 322 323 memset(drv, 0, sizeof(driver_t)); 324 list_initialize(&drv->match_ids.ids); 325 list_initialize(&drv->devices); 326 fibril_mutex_initialize(&drv->driver_mutex); 327 } 328 329 /** Device driver structure clean-up. 330 * 331 * @param drv The device driver structure. 332 */ 333 static inline void clean_driver(driver_t *drv) 334 { 335 assert(drv != NULL); 336 337 free_not_null(drv->name); 338 free_not_null(drv->binary_path); 339 340 clean_match_ids(&drv->match_ids); 341 342 init_driver(drv); 343 } 344 345 /** Delete device driver structure. 346 * 347 * @param drv The device driver structure. 348 */ 349 static inline void delete_driver(driver_t *drv) 350 { 351 assert(drv != NULL); 352 353 clean_driver(drv); 354 free(drv); 355 } 356 300 extern void initialize_running_driver(driver_t *, dev_tree_t *); 301 302 extern void init_driver(driver_t *); 303 extern void clean_driver(driver_t *); 304 extern void delete_driver(driver_t *); 357 305 358 306 /* Device nodes */ 359 307 360 /** Create a new device node. 361 * 362 * @return A device node structure. 363 */ 364 static inline node_t *create_dev_node(void) 365 { 366 node_t *res = malloc(sizeof(node_t)); 367 368 if (res != NULL) { 369 memset(res, 0, sizeof(node_t)); 370 list_initialize(&res->children); 371 list_initialize(&res->match_ids.ids); 372 list_initialize(&res->classes); 373 } 374 375 return res; 376 } 377 378 /** Delete a device node. 379 * 380 * @param node The device node structure. 381 */ 382 static inline void delete_dev_node(node_t *node) 383 { 384 assert(list_empty(&node->children)); 385 assert(node->parent == NULL); 386 assert(node->drv == NULL); 387 388 clean_match_ids(&node->match_ids); 389 free_not_null(node->name); 390 free_not_null(node->pathname); 391 free(node); 392 } 393 394 /** Find the device node structure of the device witch has the specified handle. 395 * 396 * Device tree's rwlock should be held at least for reading. 397 * 398 * @param tree The device tree where we look for the device node. 399 * @param handle The handle of the device. 400 * @return The device node. 401 */ 402 static inline node_t *find_dev_node_no_lock(dev_tree_t *tree, 403 device_handle_t handle) 404 { 405 unsigned long key = handle; 406 link_t *link = hash_table_find(&tree->devman_devices, &key); 407 return hash_table_get_instance(link, node_t, devman_link); 408 } 409 410 /** Find the device node structure of the device witch has the specified handle. 411 * 412 * @param tree The device tree where we look for the device node. 413 * @param handle The handle of the device. 414 * @return The device node. 415 */ 416 static inline node_t *find_dev_node(dev_tree_t *tree, device_handle_t handle) 417 { 418 node_t *node = NULL; 419 420 fibril_rwlock_read_lock(&tree->rwlock); 421 node = find_dev_node_no_lock(tree, handle); 422 fibril_rwlock_read_unlock(&tree->rwlock); 423 424 return node; 425 } 426 308 extern node_t *create_dev_node(void); 309 extern void delete_dev_node(node_t *node); 310 extern node_t *find_dev_node_no_lock(dev_tree_t *tree, 311 device_handle_t handle); 312 extern node_t *find_dev_node(dev_tree_t *tree, device_handle_t handle); 427 313 extern node_t *find_dev_node_by_path(dev_tree_t *, char *); 428 314 extern node_t *find_node_child(node_t *, const char *); 429 430 315 431 316 /* Device tree */ … … 435 320 extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *); 436 321 437 438 322 /* Device classes */ 439 323 440 /** Create device class. 441 * 442 * @return Device class. 443 */ 444 static inline dev_class_t *create_dev_class(void) 445 { 446 dev_class_t *cl; 447 448 cl = (dev_class_t *) malloc(sizeof(dev_class_t)); 449 if (cl != NULL) { 450 memset(cl, 0, sizeof(dev_class_t)); 451 list_initialize(&cl->devices); 452 fibril_mutex_initialize(&cl->mutex); 453 } 454 455 return cl; 456 } 457 458 /** Create device class info. 459 * 460 * @return Device class info. 461 */ 462 static inline dev_class_info_t *create_dev_class_info(void) 463 { 464 dev_class_info_t *info; 465 466 info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t)); 467 if (info != NULL) 468 memset(info, 0, sizeof(dev_class_info_t)); 469 470 return info; 471 } 472 473 static inline size_t get_new_class_dev_idx(dev_class_t *cl) 474 { 475 size_t dev_idx; 476 477 fibril_mutex_lock(&cl->mutex); 478 dev_idx = ++cl->curr_dev_idx; 479 fibril_mutex_unlock(&cl->mutex); 480 481 return dev_idx; 482 } 483 324 extern dev_class_t *create_dev_class(void); 325 extern dev_class_info_t *create_dev_class_info(void); 326 extern size_t get_new_class_dev_idx(dev_class_t *); 484 327 extern char *create_dev_name_for_class(dev_class_t *, const char *); 485 328 extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *, … … 490 333 extern dev_class_t *get_dev_class(class_list_t *, char *); 491 334 extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *); 492 493 static inline void add_dev_class_no_lock(class_list_t *class_list, 494 dev_class_t *cl) 495 { 496 list_append(&cl->link, &class_list->classes); 497 } 498 335 extern void add_dev_class_no_lock(class_list_t *, dev_class_t *); 499 336 500 337 /* Devmap devices */ … … 503 340 extern node_t *find_devmap_class_device(class_list_t *, dev_handle_t); 504 341 505 static inline void class_add_devmap_device(class_list_t *class_list, 506 dev_class_info_t *cli) 507 { 508 unsigned long key = (unsigned long) cli->devmap_handle; 509 510 fibril_rwlock_write_lock(&class_list->rwlock); 511 hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link); 512 fibril_rwlock_write_unlock(&class_list->rwlock); 513 } 514 515 static inline void tree_add_devmap_device(dev_tree_t *tree, node_t *node) 516 { 517 unsigned long key = (unsigned long) node->devmap_handle; 518 fibril_rwlock_write_lock(&tree->rwlock); 519 hash_table_insert(&tree->devmap_devices, &key, &node->devmap_link); 520 fibril_rwlock_write_unlock(&tree->rwlock); 521 } 342 extern void class_add_devmap_device(class_list_t *, dev_class_info_t *); 343 extern void tree_add_devmap_device(dev_tree_t *, node_t *); 522 344 523 345 #endif -
uspace/srv/devman/main.c
ra63ff7d r60898b6 66 66 static driver_t *devman_driver_register(void) 67 67 { 68 ipc_call_t icall; 69 ipc_callid_t iid; 70 driver_t *driver = NULL; 71 68 72 printf(NAME ": devman_driver_register \n"); 69 73 70 ipc_call_t icall; 71 ipc_callid_t iid = async_get_call(&icall); 72 driver_t *driver = NULL; 73 74 iid = async_get_call(&icall); 74 75 if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) { 75 76 ipc_answer_0(iid, EREFUSED); … … 85 86 return NULL; 86 87 } 88 87 89 printf(NAME ": the %s driver is trying to register by the service.\n", 88 90 drv_name); … … 91 93 driver = find_driver(&drivers_list, drv_name); 92 94 93 if ( NULL == driver) {95 if (driver == NULL) { 94 96 printf(NAME ": no driver named %s was found.\n", drv_name); 95 97 free(drv_name); … … 146 148 } 147 149 148 if ( NULL == match_id) {150 if (match_id == NULL) { 149 151 printf(NAME ": ERROR: devman_receive_match_id - failed to " 150 152 "allocate match id.\n"); … … 160 162 rc = async_data_write_accept((void **) &match_id_str, true, 0, 0, 0, 0); 161 163 match_id->id = match_id_str; 162 if ( EOK != rc) {164 if (rc != EOK) { 163 165 delete_match_id(match_id); 164 166 printf(NAME ": devman_receive_match_id - failed to receive " … … 181 183 * @return Zero on success, negative error code otherwise. 182 184 */ 183 static int 184 devman_receive_match_ids(ipcarg_t match_count,match_id_list_t *match_ids)185 static int devman_receive_match_ids(ipcarg_t match_count, 186 match_id_list_t *match_ids) 185 187 { 186 188 int ret = EOK; … … 205 207 206 208 fibril_rwlock_write_lock(&tree->rwlock); 207 node_t *parent = 208 209 if ( NULL == parent) {209 node_t *parent = find_dev_node_no_lock(&device_tree, parent_handle); 210 211 if (parent == NULL) { 210 212 fibril_rwlock_write_unlock(&tree->rwlock); 211 213 ipc_answer_0(callid, ENOENT); 212 214 return; 213 } 215 } 214 216 215 217 char *dev_name = NULL; 216 218 int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0); 217 if ( EOK != rc) {219 if (rc != EOK) { 218 220 fibril_rwlock_write_unlock(&tree->rwlock); 219 221 ipc_answer_0(callid, rc); … … 227 229 ipc_answer_0(callid, ENOMEM); 228 230 return; 229 } 231 } 232 230 233 fibril_rwlock_write_unlock(&tree->rwlock); 231 234 … … 245 248 /* Create devmap path and name for the device. */ 246 249 char *devmap_pathname = NULL; 250 247 251 asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE, 248 252 cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name); 249 if ( NULL == devmap_pathname)253 if (devmap_pathname == NULL) 250 254 return; 251 255 … … 279 283 280 284 node_t *dev = find_dev_node(&device_tree, handle); 281 if ( NULL == dev) {285 if (dev == NULL) { 282 286 ipc_answer_0(callid, ENOENT); 283 287 return; … … 318 322 319 323 driver_t *driver = devman_driver_register(); 320 if ( NULL == driver)324 if (driver == NULL) 321 325 return; 322 326 … … 373 377 free(pathname); 374 378 375 if ( NULL == dev) {379 if (dev == NULL) { 376 380 ipc_answer_0(iid, ENOENT); 377 381 return; … … 404 408 ipc_answer_0(callid, ENOENT); 405 409 } 406 } 407 } 408 409 static void 410 devman_forward(ipc_callid_t iid, ipc_call_t *icall,bool drv_to_parent)410 } 411 } 412 413 static void devman_forward(ipc_callid_t iid, ipc_call_t *icall, 414 bool drv_to_parent) 411 415 { 412 416 device_handle_t handle = IPC_GET_ARG2(*icall); 413 417 414 418 node_t *dev = find_dev_node(&device_tree, handle); 415 if ( NULL == dev) {419 if (dev == NULL) { 416 420 printf(NAME ": devman_forward error - no device with handle %x " 417 421 "was found.\n", handle); … … 423 427 424 428 if (drv_to_parent) { 425 if ( NULL != dev->parent)429 if (dev->parent != NULL) 426 430 driver = dev->parent->drv; 427 } else if ( DEVICE_USABLE == dev->state) {431 } else if (dev->state == DEVICE_USABLE) { 428 432 driver = dev->drv; 429 assert( NULL != driver);430 } 431 432 if ( NULL == driver) {433 assert(driver != NULL); 434 } 435 436 if (driver == NULL) { 433 437 printf(NAME ": devman_forward error - the device is not in " 434 438 "usable state.\n", handle); … … 450 454 return; 451 455 } 456 452 457 printf(NAME ": devman_forward: forward connection to device %s to " 453 458 "driver %s.\n", dev->pathname, driver->name); … … 460 465 { 461 466 dev_handle_t devmap_handle = IPC_GET_METHOD(*icall); 462 463 node_t *dev = find_devmap_tree_device(&device_tree, devmap_handle); 464 if (NULL == dev) 467 node_t *dev; 468 469 dev = find_devmap_tree_device(&device_tree, devmap_handle); 470 if (dev == NULL) 465 471 dev = find_devmap_class_device(&class_list, devmap_handle); 466 472 467 if ( NULL == dev || NULL == dev->drv) {473 if (dev == NULL || dev->drv == NULL) { 468 474 ipc_answer_0(iid, ENOENT); 469 475 return; 470 476 } 471 477 472 if ( DEVICE_USABLE != dev->state|| dev->drv->phone <= 0) {478 if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) { 473 479 ipc_answer_0(iid, EINVAL); 474 480 return; … … 493 499 * passes device handle to the driver as an ipc method.) 494 500 */ 495 if (IPC_ M_CONNECT_ME_TO != IPC_GET_METHOD(*icall))501 if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO) 496 502 devman_connection_devmapper(iid, icall); 497 503 … … 531 537 /* Initialize list of available drivers. */ 532 538 init_driver_list(&drivers_list); 533 if ( 0 ==lookup_available_drivers(&drivers_list,534 DRIVER_DEFAULT_STORE) ) {539 if (lookup_available_drivers(&drivers_list, 540 DRIVER_DEFAULT_STORE) == 0) { 535 541 printf(NAME " no drivers found."); 536 542 return false; 537 543 } 544 538 545 printf(NAME ": devman_init - list of drivers has been initialized.\n"); 539 546 -
uspace/srv/devman/match.c
ra63ff7d r60898b6 55 55 match_id_t *tmp_ma_id; 56 56 57 if ( 0 == str_cmp(drv_id->id, dev_id->id)) {57 if (str_cmp(drv_id->id, dev_id->id) == 0) { 58 58 /* 59 59 * We found a match. … … 67 67 * list of match ids. 68 68 */ 69 if (drv_ head != drv_link->next) {69 if (drv_link->next != drv_head) { 70 70 tmp_ma_id = list_get_instance(drv_link->next, 71 71 match_id_t, link); … … 79 79 * list of match ids. 80 80 */ 81 if (dev_ head != dev_link->next) {81 if (dev_link->next != dev_head) { 82 82 tmp_ma_id = list_get_instance(dev_link->next, 83 83 match_id_t, link); … … 99 99 } 100 100 101 } while (drv_ head != drv_link->next && dev_head != dev_link->next);101 } while (drv_link->next != drv_head && dev_link->next != dev_head); 102 102 103 103 return 0; -
uspace/srv/devman/util.c
ra63ff7d r60898b6 61 61 char *get_path_elem_end(char *path) 62 62 { 63 while ( 0 != *path && '/' != *path)63 while (*path != '\0' && *path != '/') 64 64 path++; 65 65 return path; 66 66 } 67 67 68 bool skip_spaces(char **buf) 69 { 70 while (isspace(**buf)) 71 (*buf)++; 72 return *buf != 0; 73 } 74 75 size_t get_nonspace_len(const char *str) 76 { 77 size_t len = 0; 78 79 while(*str != '\0' && !isspace(*str)) { 80 len++; 81 str++; 82 } 83 84 return len; 85 } 86 87 void free_not_null(const void *ptr) 88 { 89 if (ptr != NULL) 90 free(ptr); 91 } 92 93 char *clone_string(const char *s) 94 { 95 size_t size = str_size(s) + 1; 96 char *str; 97 98 str = (char *) malloc(size); 99 if (str != NULL) 100 str_cpy(str, size, s); 101 return str; 102 } 103 104 void replace_char(char *str, char orig, char repl) 105 { 106 while (*str) { 107 if (*str == orig) 108 *str = repl; 109 str++; 110 } 111 } 112 68 113 /** @} 69 114 */ -
uspace/srv/devman/util.h
ra63ff7d r60898b6 41 41 extern char *get_path_elem_end(char *); 42 42 43 static inline bool skip_spaces(char **buf) 44 { 45 while (isspace(**buf)) 46 (*buf)++; 47 return *buf != 0; 48 } 49 50 static inline size_t get_nonspace_len(const char *str) 51 { 52 size_t len = 0; 53 54 while(*str != 0 && !isspace(*str)) { 55 len++; 56 str++; 57 } 58 return len; 59 } 60 61 static inline void free_not_null(const void *ptr) 62 { 63 if (NULL != ptr) 64 free(ptr); 65 } 66 67 static inline char *clone_string(const char *s) 68 { 69 size_t size = str_size(s) + 1; 70 char *str; 71 72 str = (char *) malloc(size); 73 if (NULL != str) 74 str_cpy(str, size, s); 75 return str; 76 } 77 78 static inline void replace_char(char *str, char orig, char repl) 79 { 80 while (*str) { 81 if (orig == *str) 82 *str = repl; 83 str++; 84 } 85 } 43 extern bool skip_spaces(char **); 44 extern size_t get_nonspace_len(const char *); 45 extern void free_not_null(const void *); 46 extern char *clone_string(const char *); 47 extern void replace_char(char *, char, char); 86 48 87 49 #endif
Note:
See TracChangeset
for help on using the changeset viewer.