Changes in / [7ae3d6f:b445803] in mainline
- Files:
-
- 12 deleted
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.common
r7ae3d6f rb445803 106 106 $(USPACE_PATH)/srv/net/tl/tcp/tcp \ 107 107 $(USPACE_PATH)/srv/net/net/net \ 108 $(USPACE_PATH)/srv/devman/devman 108 $(USPACE_PATH)/srv/devman/devman \ 109 $(USPACE_PATH)/srv/drivers/root/root 109 110 110 111 RD_DRVS = \ -
boot/arch/amd64/Makefile.inc
r7ae3d6f rb445803 34 34 RD_SRVS_NON_ESSENTIAL += \ 35 35 $(USPACE_PATH)/srv/bd/ata_bd/ata_bd \ 36 $(USPACE_PATH)/srv/hw/bus/pci/pci \ 36 37 $(USPACE_PATH)/srv/hid/char_mouse/char_ms 37 38 -
contrib/arch/hadlbppp.py
r7ae3d6f rb445803 42 42 "Print usage syntax" 43 43 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 ()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" % name)165 print "%s: Syntax error in tentative statement" % name 166 166 else: 167 print ("%s: Expected '{' for tentative statement" % name)167 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" % name)233 print "%s: Syntax error in alternative statement" % name 234 234 else: 235 print ("%s: Expected '{' for alternative statement body" % name)235 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" % name)237 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" % name)239 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" % name)271 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" % name)351 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" % name)360 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" % name)372 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 = open(outname, "w")464 outf = file(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 = open(outname, "w")469 outf = file(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 = open(outname, "w")516 outf = file(outname, "w") 517 517 outf.write("NULL") 518 518 outf.close() 519 519 520 520 if (opt_ebp): 521 outf = open(outname, "w")521 outf = file(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 = open(outname, "w")656 outf = file(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 = open(path, "r")718 inf = file(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 ]" % inname)735 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" % inname)1034 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" % inname)1224 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" % inname)1496 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'" % inname)1516 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 = open(outname, "w")1577 outf = file(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 = open(outname, "w")1735 outf = file(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'" % arg)1828 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
r7ae3d6f rb445803 37 37 38 38 #include <typedefs.h> 39 #include <arch/istate.h> 39 #include <verify.h> 40 #include <trace.h> 40 41 41 42 #define IVT_ITEMS 0 … … 44 45 #define VECTOR_TLB_SHOOTDOWN_IPI 0 45 46 47 /* 48 * On real hardware this stores the registers which 49 * 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 interrupted 61 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 46 91 #endif 47 92 -
kernel/arch/amd64/include/interrupt.h
r7ae3d6f rb445803 37 37 38 38 #include <typedefs.h> 39 #include <arch/istate.h>40 39 #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 73 123 extern void (* disable_irqs_function)(uint16_t); 74 124 extern void (* enable_irqs_function)(uint16_t); -
kernel/arch/amd64/src/asm.S
r7ae3d6f rb445803 95 95 memcpy_from_uspace_failover_address: 96 96 memcpy_to_uspace_failover_address: 97 xor l %eax, %eax /* return 0, failure */97 xorq %rax, %rax /* return 0, failure */ 98 98 ret 99 99 … … 143 143 144 144 set_efer_flag: 145 mov l $0xc0000080, %ecx145 movq $0xc0000080, %rcx 146 146 rdmsr 147 147 btsl %edi, %eax … … 150 150 151 151 read_efer_flag: 152 mov l $0xc0000080, %ecx152 movq $0xc0000080, %rcx 153 153 rdmsr 154 154 ret … … 243 243 * Stop stack traces here if we came from userspace. 244 244 */ 245 xor l %edx, %edx245 xorq %rdx, %rdx 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-bit391 * register and the instruction is shorter.392 */393 xorl %edx, %edx394 xorl %esi, %esi395 xorl %edi, %edi396 xorq %r8, %r8397 xorq %r9, %r9398 xorq %r10, %r10399 400 388 sysretq 401 389 … … 425 413 movq %rdi, %rsi 426 414 movq $(PA2KA(0xb8000)), %rdi /* base of EGA text mode memory */ 427 xor l %eax, %eax415 xorq %rax, %rax 428 416 429 417 /* Read bits 8 - 15 of the cursor address */ … … 505 493 movq $(PA2KA(0xb80a0)), %rsi 506 494 movq $(PA2KA(0xb8000)), %rdi 507 mov l $480, %ecx495 movq $480, %rcx 508 496 rep movsq 509 497 510 498 /* Clear the 24th row */ 511 xor l %eax, %eax512 mov l $20, %ecx499 xorq %rax, %rax 500 movq $20, %rcx 513 501 rep stosq 514 502 -
kernel/arch/amd64/src/boot/boot.S
r7ae3d6f rb445803 516 516 movq $(PA2KA(0xb80a0)), %rsi 517 517 movq $(PA2KA(0xb8000)), %rdi 518 mov l $480, %ecx518 movq $480, %rcx 519 519 rep movsq 520 520 521 521 /* Clear the 24th row */ 522 xor l %eax, %eax523 mov l $20, %ecx522 xorq %rax, %rax 523 movq $20, %rcx 524 524 rep stosq 525 525 -
kernel/arch/amd64/src/context.S
r7ae3d6f rb445803 45 45 CONTEXT_SAVE_ARCH_CORE %rdi %rdx 46 46 47 xor l %eax, %eax # context_save returns 148 inc l %eax47 xorq %rax, %rax # context_save returns 1 48 incq %rax 49 49 ret 50 50 … … 60 60 movq %rdx, (%rsp) 61 61 62 xor l %eax, %eax # context_restore returns 062 xorq %rax, %rax # context_restore returns 0 63 63 ret -
kernel/arch/arm32/include/exception.h
r7ae3d6f rb445803 39 39 40 40 #include <typedefs.h> 41 #include <arch/istate.h> 41 #include <arch/regutils.h> 42 #include <trace.h> 42 43 43 44 /** If defined, forces using of high exception vectors. */ … … 84 85 extern uintptr_t exc_stack; 85 86 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 structure 113 * @param retaddr new value of istate's PC member 114 * 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 86 139 extern void install_exception_handlers(void); 87 140 extern void exception_init(void); -
kernel/arch/ia32/include/interrupt.h
r7ae3d6f rb445803 37 37 38 38 #include <typedefs.h> 39 #include <arch/istate.h>40 39 #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 the 76 * istate structure for both regular interrupts and exceptions as well 77 * 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 73 125 extern void (* disable_irqs_function)(uint16_t); 74 126 extern void (* enable_irqs_function)(uint16_t); -
kernel/arch/ia64/include/interrupt.h
r7ae3d6f rb445803 37 37 38 38 #include <typedefs.h> 39 #include <arch/istate.h> 39 #include <arch/register.h> 40 #include <trace.h> 40 41 41 42 /** ia64 has 256 INRs. */ … … 73 74 #define EOI 0 /**< The actual value doesn't matter. */ 74 75 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_instruction 125 * 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 75 136 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 } 76 161 77 162 extern void general_exception(uint64_t, istate_t *); -
kernel/arch/ia64/include/register.h
r7ae3d6f rb445803 142 142 #ifndef __ASM__ 143 143 144 #ifdef KERNEL145 144 #include <typedefs.h> 146 #else147 #include <sys/types.h>148 #endif149 145 150 146 /** Processor Status Register. */ -
kernel/arch/mips32/include/cp0.h
r7ae3d6f rb445803 36 36 #define KERN_mips32_CP0_H_ 37 37 38 #ifdef KERNEL39 38 #include <typedefs.h> 40 #else41 #include <sys/types.h>42 #endif43 39 44 40 #define cp0_status_ie_enabled_bit (1 << 0) -
kernel/arch/mips32/include/exception.h
r7ae3d6f rb445803 37 37 38 38 #include <typedefs.h> 39 #include <arch/istate.h> 39 #include <arch/cp0.h> 40 #include <trace.h> 40 41 41 42 #define EXC_Int 0 … … 58 59 #define EXC_VCED 31 59 60 61 typedef struct istate { 62 /* 63 * The first seven registers are arranged so that the istate structure 64 * 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 60 129 extern void exception(istate_t *istate); 61 130 extern void tlb_refill_entry(void); -
kernel/arch/sparc64/include/interrupt.h
r7ae3d6f rb445803 38 38 39 39 #include <typedefs.h> 40 #include <arch/istate.h> 40 #include <arch/regdef.h> 41 #include <trace.h> 41 42 42 43 #define IVT_ITEMS 15 … … 50 51 }; 51 52 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 52 82 #endif 53 83 -
kernel/generic/src/ipc/kbox.c
r7ae3d6f rb445803 107 107 /* Terminate debugging session (if any). */ 108 108 LOG("Terminate debugging session."); 109 mutex_lock(&TASK->udebug.lock);109 irq_spinlock_lock(&TASK->lock, true); 110 110 udebug_task_cleanup(TASK); 111 mutex_unlock(&TASK->udebug.lock);111 irq_spinlock_unlock(&TASK->lock, true); 112 112 } else { 113 113 LOG("Was not debugger."); -
kernel/tools/amd64/decpt.py
r7ae3d6f rb445803 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" % ptl0)19 print ("Ptl1: %3d" % ptl1)20 print ("Ptl2: %3d" % ptl2)21 print ("Ptl3: %3d" % ptl3)22 print ("Offset: 0x%x" % offset)18 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
r7ae3d6f rb445803 86 86 obdump = read_obdump(obmapf) 87 87 88 def key_sorter(x):89 return x[0]88 def sorter(x,y): 89 return cmp(x[0],y[0]) 90 90 91 91 for line in kmapf: … … 93 93 res = startfile.match(line) 94 94 95 if ((res) and ( res.group(3) in obdump[res.group(1)])):95 if ((res) and (obdump[res.group(1)].has_key(res.group(3)))): 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( key = key_sorter)99 symbols.sort(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 b')114 out = open(sys.argv[3], 'w') 115 115 116 116 generate(kmapf, obmapf, out) -
kernel/tools/ia32/decpt.py
r7ae3d6f rb445803 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" % ptl0)17 print ("Ptl1: %3d" % ptl1)18 print ("Offset: 0x%x" % offset)16 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
r7ae3d6f rb445803 75 75 "Read HelenOS build configuration" 76 76 77 inf = open(fname, 'r')77 inf = file(fname, 'r') 78 78 79 79 for line in inf: … … 191 191 check_common(common, "CC") 192 192 193 outf = open(PROBE_SOURCE, 'w')193 outf = file(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 = open(PROBE_OUTPUT, 'r')223 inf = file(PROBE_OUTPUT, 'r') 224 224 lines = inf.readlines() 225 225 inf.close() … … 343 343 "Create makefile output" 344 344 345 outmk = open(mkname, 'w')345 outmk = file(mkname, 'w') 346 346 347 347 outmk.write('#########################################\n') … … 357 357 "Create header output" 358 358 359 outhd = open(hdname, 'w')359 outhd = file(hdname, 'w') 360 360 361 361 outhd.write('/***************************************\n') -
tools/checkers/clang.py
r7ae3d6f rb445803 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" % inname)53 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 = open(inname, "r")56 inf = file(inname, "r") 57 57 records = inf.read().splitlines() 58 58 inf.close() … … 64 64 65 65 if (len(arg) < 6): 66 print ("Not enought jobfile record arguments")66 print "Not enought jobfile record arguments" 67 67 return False 68 68 … … 76 76 srcfqname = os.path.join(base, srcfname) 77 77 if (not os.path.isfile(srcfqname)): 78 print ("Source %s not found" % srcfqname)78 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." % config)111 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" % job)117 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
r7ae3d6f rb445803 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
r7ae3d6f rb445803 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" % inname)57 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 = open(inname, "r")60 inf = file(inname, "r") 61 61 records = inf.read().splitlines() 62 62 inf.close() … … 69 69 70 70 if (len(arg) < 6): 71 print ("Not enought jobfile record arguments")71 print "Not enought jobfile record arguments" 72 72 return False 73 73 … … 81 81 srcfqname = os.path.join(base, srcfname) 82 82 if (not os.path.isfile(srcfqname)): 83 print ("Source %s not found" % srcfqname)83 print "Source %s not found" % srcfqname 84 84 return False 85 85 … … 90 90 output.append([srcfname, tgtfname, base, options]) 91 91 92 outf = open(outname, "w")92 outf = file(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." % config)124 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" % job)130 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
r7ae3d6f rb445803 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 = open(tmpfname, "w")74 tmpf = file(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" % inname)111 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 = open(inname, "r")114 inf = file(inname, "r") 115 115 records = inf.read().splitlines() 116 116 inf.close() … … 122 122 123 123 if (len(arg) < 6): 124 print ("Not enought jobfile record arguments")124 print "Not enought jobfile record arguments" 125 125 return False 126 126 … … 134 134 srcfqname = os.path.join(base, srcfname) 135 135 if (not os.path.isfile(srcfqname)): 136 print ("Source %s not found" % srcfqname)136 print "Source %s not found" % srcfqname 137 137 return False 138 138 … … 153 153 154 154 # Run Vcc 155 print (" -- %s --" % srcfname)155 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_path)185 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." % config)192 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." % config)197 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" % job)207 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
r7ae3d6f rb445803 48 48 "Read saved values from last configuration run" 49 49 50 inf = open(fname, 'r')50 inf = file(fname, 'r') 51 51 52 52 for line in inf: … … 103 103 condval = res.group(3) 104 104 105 if (not condname in defaults):105 if (not defaults.has_key(condname)): 106 106 varval = '' 107 107 else: … … 131 131 "Parse configuration file" 132 132 133 inf = open(fname, 'r')133 inf = file(fname, 'r') 134 134 135 135 name = '' … … 219 219 continue 220 220 221 if (not varname in defaults):221 if (not defaults.has_key(varname)): 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]. decode().split(':')234 version = subprocess.Popen(['bzr', 'version-info', '--custom', '--template={clean}:{revno}:{revision_id}'], stdout = subprocess.PIPE).communicate()[0].split(':') 235 235 sys.stderr.write("ok\n") 236 236 except: … … 246 246 revision = None 247 247 248 outmk = open(mkname, 'w')249 outmc = open(mcname, 'w')248 outmk = file(mkname, 'w') 249 outmc = file(mcname, 'w') 250 250 251 251 outmk.write('#########################################\n') … … 263 263 continue 264 264 265 if (not varname in defaults):265 if (not defaults.has_key(varname)): 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 ( varname in defaults) and (defaults[varname] == '*')):370 if ((vartype == 'y') and (defaults.has_key(varname)) and (defaults[varname] == '*')): 371 371 defaults[varname] = None 372 372 … … 385 385 position = cnt 386 386 387 if (not varname in defaults):387 if (not defaults.has_key(varname)): 388 388 default = None 389 389 else: … … 428 428 cnt += 1 429 429 430 if (position != None) and (position >= len(options)):430 if (position >= options): 431 431 position = None 432 432 … … 449 449 450 450 position = None 451 if (not value in opt2row):451 if (not opt2row.has_key(value)): 452 452 raise RuntimeError("Error selecting value: %s" % value) 453 453 454 454 (selname, seltype, name, choices) = opt2row[value] 455 455 456 if (not selname in defaults):456 if (not defaults.has_key(selname)): 457 457 default = None 458 458 else: -
tools/jobfile.py
r7ae3d6f rb445803 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 = open(jobfname, "a")55 jobfile = file(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
r7ae3d6f rb445803 46 46 return size 47 47 48 return (( size // alignment) + 1) * alignment48 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 = open(path, "rb")81 inf = file(path, "r") 82 82 rd = 0; 83 83 while (rd < size): … … 92 92 prev = empty_cluster 93 93 94 data = bytes(inf.read(cluster_size));94 data = 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 = bytes()122 data = '' 123 123 data_len = 0 124 124 while ((i < length) and (data_len < cluster_size)): … … 343 343 def usage(prname): 344 344 "Print usage syntax" 345 print (prname + " <EXTRA_BYTES> <PATH> <IMAGE>")345 print prname + " <EXTRA_BYTES> <PATH> <IMAGE>" 346 346 347 347 def main(): … … 351 351 352 352 if (not sys.argv[1].isdigit()): 353 print ("<EXTRA_BYTES> must be a number")353 print "<EXTRA_BYTES> must be a number" 354 354 return 355 355 … … 358 358 path = os.path.abspath(sys.argv[2]) 359 359 if (not os.path.isdir(path)): 360 print ("<PATH> must be a directory")360 print "<PATH> must be a directory" 361 361 return 362 362 … … 372 372 # Make sure the filesystem is large enought for FAT16 373 373 size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size + extra_bytes 374 while (size / /cluster_size < fat16_clusters):374 while (size / cluster_size < fat16_clusters): 375 375 if (cluster_size > sector_size): 376 cluster_size = cluster_size //2376 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 = open(sys.argv[3], "wb")389 outf = file(sys.argv[3], "w") 390 390 391 391 boot_sector = xstruct.create(BOOT_SECTOR) 392 392 boot_sector.jmp = [0xEB, 0x3C, 0x90] 393 boot_sector.oem = b'MSDOS5.0'393 boot_sector.oem = "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 = b'HELENOS'417 boot_sector.fstype = b'FAT16 '416 boot_sector.label = "HELENOS" 417 boot_sector.fstype = "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
r7ae3d6f rb445803 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 = open(fs_image, "rb")76 outf = open(sys.argv[3], "wb")75 inf = file(fs_image, "rb") 76 outf = file(sys.argv[3], "wb") 77 77 78 78 header = xstruct.create(HEADER) -
tools/mktmpfs.py
r7ae3d6f rb445803 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 = open(canon, "rb")87 inf = file(canon, "r") 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 = open(sys.argv[2], "wb")121 outf = file(sys.argv[2], "w") 122 122 123 123 header = xstruct.create(HEADER) -
tools/mkuimage.py
r7ae3d6f rb445803 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 = open(inf_name, 'rb')94 outf = open(outf_name, 'wb')93 inf = file(inf_name, 'rb') 94 outf = file(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) + (long(2) ** long(32))) # 2^32L142 return (long(signed_crc) + 4294967296L) # 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
r7ae3d6f rb445803 43 43 def usage(prname): 44 44 "Print usage syntax" 45 print ("%s <OBJCOPY> <FORMAT> <ARCH> <ARCH_PATH> [COMPONENTS ...]" % prname)45 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 = open(component, "rb")115 comp_data = comp_in.read() 114 comp_in = file(component, "rb") 115 comp_data = comp_in.read(); 116 116 comp_in.close() 117 117 … … 121 121 122 122 try: 123 comp_out = open(basename, "wb")123 comp_out = file(basename, "wb") 124 124 comp_out.write(comp_deflate) 125 125 comp_out.close() … … 151 151 cnt += 1 152 152 153 header = open(os.path.join(arch_path, "include", "%s.h" % COMPONENTS), "w")153 header = file(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 = open(os.path.join(arch_path, "src", "%s.c" % COMPONENTS), "w")175 data = file(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 = open(os.path.join(arch_path, "%s.in" % LINK), "r")189 link_in = file(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 = open(os.path.join(arch_path, "%s.comp" % LINK), "w")193 link_out = file(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
r7ae3d6f rb445803 123 123 static void delete_ns8250_dev_data(ns8250_dev_data_t *data) 124 124 { 125 if ( data != NULL)125 if (NULL != data) 126 126 free(data); 127 127 } … … 251 251 static void ns8250_dev_cleanup(device_t *dev) 252 252 { 253 if ( dev->driver_data != NULL) {253 if (NULL != dev->driver_data) { 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 ( data == NULL)334 if (NULL == data) 335 335 return ENOMEM; 336 336 dev->driver_data = data; … … 436 436 /* Enable interrupt globally. */ 437 437 res = interrupt_enable(data->irq); 438 if ( res != EOK)438 if (EOK != res) 439 439 return res; 440 440 … … 480 480 uint8_t div_low, div_high; 481 481 482 if ( baud_rate < 50 || MAX_BAUD_RATE % baud_rate != 0) {482 if (50 > baud_rate || 0 != MAX_BAUD_RATE % baud_rate) { 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 ns8250_port_get_com_props(ioport8_t *port, unsigned int *parity, 536 static void 537 ns8250_port_get_com_props(ioport8_t *port, unsigned int *parity, 537 538 unsigned int *word_length, unsigned int *stop_bits) 538 539 { … … 571 572 * is invalid. 572 573 */ 573 static int ns8250_port_set_com_props(ioport8_t *port, unsigned int parity, 574 static int 575 ns8250_port_set_com_props(ioport8_t *port, unsigned int parity, 574 576 unsigned int word_length, unsigned int stop_bits) 575 577 { … … 689 691 * @param dev The serial port device. 690 692 */ 691 static inline void ns8250_interrupt_handler(device_t *dev, ipc_callid_t iid,692 693 static inline void 694 ns8250_interrupt_handler(device_t *dev, ipc_callid_t iid, ipc_call_t *icall) 693 695 { 694 696 ns8250_read_from_device(dev); … … 724 726 * @param dev The serial port device. 725 727 */ 726 static int ns8250_add_device(device_t *dev) 728 static int ns8250_add_device(device_t *dev) 727 729 { 728 730 printf(NAME ": ns8250_add_device %s (handle = %d)\n", … … 730 732 731 733 int res = ns8250_dev_initialize(dev); 732 if ( res != EOK)734 if (EOK != res) 733 735 return res; 734 736 … … 748 750 749 751 /* Register interrupt handler. */ 750 if ( ns8250_register_interrupt_handler(dev) != EOK) {752 if (EOK != ns8250_register_interrupt_handler(dev)) { 751 753 printf(NAME ": failed to register interrupt handler.\n"); 752 754 ns8250_dev_cleanup(dev); … … 756 758 /* Enable interrupt. */ 757 759 res = ns8250_interrupt_enable(dev); 758 if ( res != EOK) {760 if (EOK != res) { 759 761 printf(NAME ": failed to enable the interrupt. Error code = " 760 762 "%d.\n", res); … … 857 859 * @param stop_bits The number of stop bits to be used. 858 860 */ 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) 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) 861 864 { 862 865 printf(NAME ": ns8250_set_props: baud rate %d, parity 0x%x, word " … … 871 874 ns8250_port_interrupts_disable(port); 872 875 ret = ns8250_port_set_baud_rate(port, baud_rate); 873 if ( ret == EOK)876 if (EOK == ret) 874 877 ret = ns8250_port_set_com_props(port, parity, word_length, stop_bits); 875 878 ns8250_port_interrupts_enable(port); … … 884 887 * Configure the parameters of the serial communication. 885 888 */ 886 static void ns8250_default_handler(device_t *dev, ipc_callid_t callid,887 889 static void 890 ns8250_default_handler(device_t *dev, ipc_callid_t callid, ipc_call_t *call) 888 891 { 889 892 ipcarg_t method = IPC_GET_METHOD(*call); -
uspace/drv/pciintel/pci.c
r7ae3d6f rb445803 65 65 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; 66 66 67 if ( dev_data == NULL)67 if (NULL == dev_data) 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 ( bus_data != NULL) {111 if (NULL != bus_data) { 112 112 memset(bus_data, 0, sizeof(pci_bus_data_t)); 113 113 fibril_mutex_initialize(&bus_data->conf_mutex); 114 114 } 115 116 115 return bus_data; 117 116 } … … 124 123 static void pci_conf_read(device_t *dev, int reg, uint8_t *buf, size_t len) 125 124 { 126 assert( dev->parent != NULL);125 assert(NULL != dev->parent); 127 126 128 127 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; … … 154 153 static void pci_conf_write(device_t *dev, int reg, uint8_t *buf, size_t len) 155 154 { 156 assert( dev->parent != NULL);155 assert(NULL != dev->parent); 157 156 158 157 pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data; … … 225 224 226 225 match_id = create_match_id(); 227 if ( match_id != NULL) {226 if (NULL != match_id) { 228 227 asprintf(&match_id_str, "pci/ven=%04x&dev=%04x", 229 228 dev_data->vendor_id, dev_data->device_id); … … 231 230 match_id->score = 90; 232 231 add_match_id(&dev->match_ids, match_id); 233 } 234 232 } 235 233 /* TODO add more ids (with subsys ids, using class id etc.) */ 236 234 } … … 244 242 size_t count = hw_res_list->count; 245 243 246 assert( hw_resources != NULL);244 assert(NULL != hw_resources); 247 245 assert(count < PCI_MAX_HW_RES); 248 246 … … 277 275 bool io; 278 276 /* 64-bit wide address */ 279 bool addrw64;277 bool w64; 280 278 281 279 /* Size of the io or memory range specified by the BAR */ … … 289 287 io = (bool) (val & 1); 290 288 if (io) { 291 addrw64 = false;289 w64 = false; 292 290 } else { 293 291 switch ((val >> 1) & 3) { 294 292 case 0: 295 addrw64 = false;293 w64 = false; 296 294 break; 297 295 case 2: 298 addrw64 = true;296 w64 = true; 299 297 break; 300 298 default: … … 314 312 range_size = pci_bar_mask_to_size(mask); 315 313 316 if ( addrw64) {314 if (w64) { 317 315 range_addr = ((uint64_t)pci_conf_read_32(dev, addr + 4) << 32) | 318 316 (val & 0xfffffff0); … … 321 319 } 322 320 323 if ( range_addr != 0) {321 if (0 != range_addr) { 324 322 printf(NAME ": device %s : ", dev->name); 325 323 printf("address = %x", range_addr); … … 329 327 pci_add_range(dev, range_addr, range_size, io); 330 328 331 if ( addrw64)329 if (w64) 332 330 return addr + 8; 333 331 … … 356 354 { 357 355 uint8_t irq = pci_conf_read_8(dev, PCI_BRIDGE_INT_LINE); 358 if ( irq != 0xff)356 if (0xff != irq) 359 357 pci_add_interrupt(dev, irq); 360 358 } … … 417 415 create_pci_match_ids(dev); 418 416 419 if ( child_device_register(dev, parent) != EOK) {417 if (EOK != child_device_register(dev, parent)) { 420 418 pci_clean_resource_list(dev); 421 419 clean_match_ids(&dev->match_ids); … … 426 424 427 425 if (header_type == PCI_HEADER_TYPE_BRIDGE || 428 header_type == PCI_HEADER_TYPE_CARDBUS ) {426 header_type == PCI_HEADER_TYPE_CARDBUS ) { 429 427 child_bus = pci_conf_read_8(dev, 430 428 PCI_BRIDGE_SEC_BUS_NUM); 431 429 printf(NAME ": device is pci-to-pci bridge, " 432 430 "secondary bus number = %d.\n", bus_num); 433 if 431 if(child_bus > bus_num) 434 432 pci_bus_scan(parent, child_bus); 435 433 } … … 455 453 456 454 pci_bus_data_t *bus_data = create_pci_bus_data(); 457 if ( bus_data == NULL) {455 if (NULL == bus_data) { 458 456 printf(NAME ": pci_add_device allocation failed.\n"); 459 457 return ENOMEM; … … 515 513 } 516 514 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 addresses571 * 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 the579 * 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 592 515 int main(int argc, char *argv[]) 593 516 { -
uspace/drv/pciintel/pci.h
r7ae3d6f rb445803 69 69 extern void pci_bus_scan(device_t *, int); 70 70 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 *); 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 } 75 79 76 extern bool pci_alloc_resource_list(device_t *); 77 extern void pci_clean_resource_list(device_t *); 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 } 78 87 79 extern void pci_read_bars(device_t *); 80 extern size_t pci_bar_mask_to_size(uint32_t); 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 } 81 146 82 147 #endif -
uspace/lib/c/arch/abs32le/include/fibril.h
r7ae3d6f rb445803 44 44 (ctx)->pc = (uintptr_t) (_pc); \ 45 45 (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \ 46 (ctx)->fp = 0; \47 46 (ctx)->tls = ((uintptr_t) (ptls)) + sizeof(tcb_t); \ 48 47 } while (0) … … 54 53 typedef struct { 55 54 uintptr_t sp; 56 uintptr_t fp;57 55 uintptr_t pc; 58 56 uintptr_t tls; 59 57 } 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 }66 58 67 59 #endif -
uspace/lib/c/arch/abs32le/include/istate.h
r7ae3d6f rb445803 36 36 #define LIBC_abs32le__ISTATE_H_ 37 37 38 #include <arch/istate.h> 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 } 39 60 40 61 #endif -
uspace/lib/c/arch/amd64/include/fibril.h
r7ae3d6f rb445803 56 56 */ 57 57 typedef struct { 58 uint64_t sp; 59 uint64_t pc; 58 uint64_t sp; 59 uint64_t pc; 60 61 uint64_t rbx; 62 uint64_t rbp; 60 63 61 uint64_t rbx; 62 uint64_t rbp; 64 uint64_t r12; 65 uint64_t r13; 66 uint64_t r14; 67 uint64_t r15; 63 68 64 uint64_t r12; 65 uint64_t r13; 66 uint64_t r14; 67 uint64_t r15; 68 69 uint64_t tls; 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 }76 71 77 72 #endif -
uspace/lib/c/arch/amd64/include/istate.h
r7ae3d6f rb445803 36 36 #define LIBC_amd64_ISTATE_H_ 37 37 38 #include <arch/istate.h> 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 } 39 71 40 72 #endif -
uspace/lib/c/arch/amd64/src/entry.s
r7ae3d6f rb445803 42 42 # 43 43 pushq $0 44 mov q%rsp, %rbp44 mov %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
r7ae3d6f rb445803 49 49 movq %rax, OFFSET_TLS(%rdi) 50 50 51 xor l %eax, %eax # context_save returns 152 inc l %eax51 xorq %rax,%rax # context_save returns 1 52 incq %rax 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 l $1, %eax # SYS_TLS_SET69 movq $1, %rax # SYS_TLS_SET 70 70 syscall 71 71 72 xor l %eax, %eax # context_restore returns 072 xorq %rax,%rax # context_restore returns 0 73 73 ret -
uspace/lib/c/arch/arm32/include/fibril.h
r7ae3d6f rb445803 86 86 } context_t; 87 87 88 static inline uintptr_t context_get_fp(context_t *ctx)89 {90 return ctx->fp;91 }92 93 88 94 89 #endif -
uspace/lib/c/arch/arm32/include/istate.h
r7ae3d6f rb445803 36 36 #define LIBC_arm32__ISTATE_H_ 37 37 38 #include <arch/istate.h> 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 } 39 75 40 76 #endif -
uspace/lib/c/arch/ia32/include/fibril.h
r7ae3d6f rb445803 67 67 } context_t; 68 68 69 static inline uintptr_t context_get_fp(context_t *ctx)70 {71 return ctx->ebp;72 }73 74 69 #endif 75 70 -
uspace/lib/c/arch/ia32/include/istate.h
r7ae3d6f rb445803 36 36 #define LIBC_ia32__ISTATE_H_ 37 37 38 #include <arch/istate.h> 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 } 39 71 40 72 #endif -
uspace/lib/c/arch/ia64/include/fibril.h
r7ae3d6f rb445803 130 130 } context_t; 131 131 132 static inline uintptr_t context_get_fp(context_t *ctx)133 {134 return 0; /* FIXME */135 }136 137 132 #endif 138 133 -
uspace/lib/c/arch/ia64/include/istate.h
r7ae3d6f rb445803 36 36 #define LIBC_ia64_ISTATE_H_ 37 37 38 #include <arch/istate.h> 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 } 39 59 40 60 #endif -
uspace/lib/c/arch/mips32/include/fibril.h
r7ae3d6f rb445803 85 85 } context_t; 86 86 87 static inline uintptr_t context_get_fp(context_t *ctx)88 {89 return ctx->sp;90 }91 92 87 #endif 93 88 -
uspace/lib/c/arch/mips32/include/istate.h
r7ae3d6f rb445803 36 36 #define LIBC_mips32__ISTATE_H_ 37 37 38 #include <arch/istate.h> 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 } 39 84 40 85 #endif -
uspace/lib/c/arch/ppc32/include/fibril.h
r7ae3d6f rb445803 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 85 80 #endif 86 81 -
uspace/lib/c/arch/sparc64/include/fibril.h
r7ae3d6f rb445803 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 84 79 #endif 85 80 -
uspace/lib/c/arch/sparc64/include/istate.h
r7ae3d6f rb445803 36 36 #define LIBC_sparc64_ISTATE_H_ 37 37 38 #include <arch/istate.h> 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 } 39 59 40 60 #endif -
uspace/lib/c/generic/fibril.c
r7ae3d6f rb445803 275 275 fibril->func = func; 276 276 fibril->arg = arg; 277 278 fibril->waits_for = NULL;279 277 280 278 context_save(&fibril->ctx); -
uspace/lib/c/generic/fibril_synch.c
r7ae3d6f rb445803 42 42 #include <errno.h> 43 43 #include <assert.h> 44 #include <stacktrace.h>45 #include <stdlib.h>46 44 47 45 static void optimize_execution_power(void) … … 58 56 } 59 57 60 static bool check_for_deadlock(fibril_owner_info_t *oi)61 {62 while (oi && oi->owned_by) {63 if (oi->owned_by == (fibril_t *) fibril_get_id())64 return true;65 oi = oi->owned_by->waits_for;66 }67 68 return false;69 }70 71 static void print_deadlock(fibril_owner_info_t *oi)72 {73 fibril_t *f = (fibril_t *) fibril_get_id();74 75 printf("Deadlock detected.\n");76 stacktrace_print();77 78 printf("Fibril %p waits for primitive %p.\n", f, oi);79 80 while (oi && oi->owned_by) {81 printf("Primitive %p is owned by fibril %p.\n",82 oi, oi->owned_by);83 if (oi->owned_by == f)84 break;85 stacktrace_print_fp_pc(context_get_fp(&oi->owned_by->ctx),86 oi->owned_by->ctx.pc);87 printf("Fibril %p waits for primitive %p.\n",88 oi->owned_by, oi->owned_by->waits_for);89 oi = oi->owned_by->waits_for;90 }91 92 abort();93 }94 95 58 void fibril_mutex_initialize(fibril_mutex_t *fm) 96 59 { 97 fm->oi.owned_by = NULL;98 60 fm->counter = 1; 99 61 list_initialize(&fm->waiters); … … 102 64 void fibril_mutex_lock(fibril_mutex_t *fm) 103 65 { 104 fibril_t *f = (fibril_t *) fibril_get_id();105 106 66 futex_down(&async_futex); 107 67 if (fm->counter-- <= 0) { … … 113 73 link_initialize(&wdata.wu_event.link); 114 74 list_append(&wdata.wu_event.link, &fm->waiters); 115 116 if (check_for_deadlock(&fm->oi))117 print_deadlock(&fm->oi);118 f->waits_for = &fm->oi;119 120 75 fibril_switch(FIBRIL_TO_MANAGER); 121 76 } else { 122 fm->oi.owned_by = f;123 77 futex_up(&async_futex); 124 78 } … … 132 86 if (fm->counter > 0) { 133 87 fm->counter--; 134 fm->oi.owned_by = (fibril_t *) fibril_get_id();135 88 locked = true; 136 89 } … … 146 99 link_t *tmp; 147 100 awaiter_t *wdp; 148 fibril_t *f;149 101 150 102 assert(!list_empty(&fm->waiters)); … … 153 105 wdp->active = true; 154 106 wdp->wu_event.inlist = false; 155 156 f = (fibril_t *) wdp->fid;157 fm->oi.owned_by = f;158 f->waits_for = NULL;159 160 107 list_remove(&wdp->wu_event.link); 161 108 fibril_add_ready(wdp->fid); 162 109 optimize_execution_power(); 163 } else {164 fm->oi.owned_by = NULL;165 110 } 166 111 } … … 175 120 void fibril_rwlock_initialize(fibril_rwlock_t *frw) 176 121 { 177 frw->oi.owned_by = NULL;178 122 frw->writers = 0; 179 123 frw->readers = 0; -
uspace/lib/c/include/fibril.h
r7ae3d6f rb445803 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 56 50 typedef enum { 57 51 FIBRIL_PREEMPT, … … 74 68 int retval; 75 69 int flags; 76 77 fibril_owner_info_t *waits_for;78 70 } fibril_t; 79 71 -
uspace/lib/c/include/fibril_synch.h
r7ae3d6f rb445803 43 43 44 44 typedef struct { 45 fibril_owner_info_t oi; /* Keep this the first thing. */46 45 int counter; 47 46 link_t waiters; … … 50 49 #define FIBRIL_MUTEX_INITIALIZER(name) \ 51 50 { \ 52 .oi = { \53 .owned_by = NULL \54 }, \55 51 .counter = 1, \ 56 52 .waiters = { \ … … 64 60 65 61 typedef struct { 66 fibril_owner_info_t oi; /* Keep this the first thing. */67 62 unsigned writers; 68 63 unsigned readers; … … 72 67 #define FIBRIL_RWLOCK_INITIALIZER(name) \ 73 68 { \ 74 .oi = { \75 .owned_by = NULL \76 }, \77 69 .readers = 0, \ 78 70 .writers = 0, \ -
uspace/srv/devman/devman.c
r7ae3d6f rb445803 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 }92 78 93 79 /** Allocate and initialize a new driver structure. … … 562 548 } 563 549 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 }605 550 606 551 /** Create devmap path and name for the device. */ … … 740 685 } 741 686 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 811 687 /** Create and set device's full path in device tree. 812 688 * … … 949 825 return NULL; 950 826 } 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 998 827 999 828 /** Create unique device name within the class. … … 1092 921 } 1093 922 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 1099 923 void init_class_list(class_list_t *class_list) 1100 924 { … … 1106 930 1107 931 1108 /* Devmap devices */932 /* devmap devices */ 1109 933 1110 934 node_t *find_devmap_tree_device(dev_tree_t *tree, dev_handle_t devmap_handle) … … 1143 967 } 1144 968 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 1162 969 /** @} 1163 970 */ -
uspace/srv/devman/devman.h
r7ae3d6f rb445803 283 283 /* Drivers */ 284 284 285 extern void init_driver_list(driver_list_t *); 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 286 299 extern driver_t *create_driver(void); 287 300 extern bool get_driver_info(const char *, const char *, driver_t *); … … 298 311 extern driver_t *find_driver(driver_list_t *, const char *); 299 312 extern void set_driver_phone(driver_t *, ipcarg_t); 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 *); 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 305 357 306 358 /* Device nodes */ 307 359 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); 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 313 427 extern node_t *find_dev_node_by_path(dev_tree_t *, char *); 314 428 extern node_t *find_node_child(node_t *, const char *); 429 315 430 316 431 /* Device tree */ … … 320 435 extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *); 321 436 437 322 438 /* Device classes */ 323 439 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 *); 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 327 484 extern char *create_dev_name_for_class(dev_class_t *, const char *); 328 485 extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *, … … 333 490 extern dev_class_t *get_dev_class(class_list_t *, char *); 334 491 extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *); 335 extern void add_dev_class_no_lock(class_list_t *, dev_class_t *); 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 336 499 337 500 /* Devmap devices */ … … 340 503 extern node_t *find_devmap_class_device(class_list_t *, dev_handle_t); 341 504 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 *); 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 } 344 522 345 523 #endif -
uspace/srv/devman/main.c
r7ae3d6f rb445803 66 66 static driver_t *devman_driver_register(void) 67 67 { 68 printf(NAME ": devman_driver_register \n"); 69 68 70 ipc_call_t icall; 69 ipc_callid_t iid ;71 ipc_callid_t iid = async_get_call(&icall); 70 72 driver_t *driver = NULL; 71 72 printf(NAME ": devman_driver_register \n"); 73 74 iid = async_get_call(&icall); 73 75 74 if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) { 76 75 ipc_answer_0(iid, EREFUSED); … … 86 85 return NULL; 87 86 } 88 89 87 printf(NAME ": the %s driver is trying to register by the service.\n", 90 88 drv_name); … … 93 91 driver = find_driver(&drivers_list, drv_name); 94 92 95 if ( driver == NULL) {93 if (NULL == driver) { 96 94 printf(NAME ": no driver named %s was found.\n", drv_name); 97 95 free(drv_name); … … 148 146 } 149 147 150 if ( match_id == NULL) {148 if (NULL == match_id) { 151 149 printf(NAME ": ERROR: devman_receive_match_id - failed to " 152 150 "allocate match id.\n"); … … 162 160 rc = async_data_write_accept((void **) &match_id_str, true, 0, 0, 0, 0); 163 161 match_id->id = match_id_str; 164 if ( rc != EOK) {162 if (EOK != rc) { 165 163 delete_match_id(match_id); 166 164 printf(NAME ": devman_receive_match_id - failed to receive " … … 183 181 * @return Zero on success, negative error code otherwise. 184 182 */ 185 static int devman_receive_match_ids(ipcarg_t match_count,186 183 static int 184 devman_receive_match_ids(ipcarg_t match_count, match_id_list_t *match_ids) 187 185 { 188 186 int ret = EOK; … … 207 205 208 206 fibril_rwlock_write_lock(&tree->rwlock); 209 node_t *parent = find_dev_node_no_lock(&device_tree, parent_handle);210 211 if ( parent == NULL) {207 node_t *parent = find_dev_node_no_lock(&device_tree, parent_handle); 208 209 if (NULL == parent) { 212 210 fibril_rwlock_write_unlock(&tree->rwlock); 213 211 ipc_answer_0(callid, ENOENT); 214 212 return; 215 } 213 } 216 214 217 215 char *dev_name = NULL; 218 216 int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0); 219 if ( rc != EOK) {217 if (EOK != rc) { 220 218 fibril_rwlock_write_unlock(&tree->rwlock); 221 219 ipc_answer_0(callid, rc); … … 229 227 ipc_answer_0(callid, ENOMEM); 230 228 return; 231 } 232 229 } 233 230 fibril_rwlock_write_unlock(&tree->rwlock); 234 231 … … 248 245 /* Create devmap path and name for the device. */ 249 246 char *devmap_pathname = NULL; 250 251 247 asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE, 252 248 cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name); 253 if ( devmap_pathname == NULL)249 if (NULL == devmap_pathname) 254 250 return; 255 251 … … 283 279 284 280 node_t *dev = find_dev_node(&device_tree, handle); 285 if ( dev == NULL) {281 if (NULL == dev) { 286 282 ipc_answer_0(callid, ENOENT); 287 283 return; … … 322 318 323 319 driver_t *driver = devman_driver_register(); 324 if ( driver == NULL)320 if (NULL == driver) 325 321 return; 326 322 … … 377 373 free(pathname); 378 374 379 if ( dev == NULL) {375 if (NULL == dev) { 380 376 ipc_answer_0(iid, ENOENT); 381 377 return; … … 408 404 ipc_answer_0(callid, ENOENT); 409 405 } 410 } 411 } 412 413 static void devman_forward(ipc_callid_t iid, ipc_call_t *icall,414 406 } 407 } 408 409 static void 410 devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent) 415 411 { 416 412 device_handle_t handle = IPC_GET_ARG2(*icall); 417 413 418 414 node_t *dev = find_dev_node(&device_tree, handle); 419 if ( dev == NULL) {415 if (NULL == dev) { 420 416 printf(NAME ": devman_forward error - no device with handle %x " 421 417 "was found.\n", handle); … … 427 423 428 424 if (drv_to_parent) { 429 if ( dev->parent != NULL)425 if (NULL != dev->parent) 430 426 driver = dev->parent->drv; 431 } else if ( dev->state == DEVICE_USABLE) {427 } else if (DEVICE_USABLE == dev->state) { 432 428 driver = dev->drv; 433 assert( driver != NULL);434 } 435 436 if ( driver == NULL) {429 assert(NULL != driver); 430 } 431 432 if (NULL == driver) { 437 433 printf(NAME ": devman_forward error - the device is not in " 438 434 "usable state.\n", handle); … … 454 450 return; 455 451 } 456 457 452 printf(NAME ": devman_forward: forward connection to device %s to " 458 453 "driver %s.\n", dev->pathname, driver->name); … … 465 460 { 466 461 dev_handle_t devmap_handle = IPC_GET_METHOD(*icall); 467 node_t *dev; 468 469 dev = find_devmap_tree_device(&device_tree, devmap_handle); 470 if (dev == NULL) 462 463 node_t *dev = find_devmap_tree_device(&device_tree, devmap_handle); 464 if (NULL == dev) 471 465 dev = find_devmap_class_device(&class_list, devmap_handle); 472 466 473 if ( dev == NULL || dev->drv == NULL) {467 if (NULL == dev || NULL == dev->drv) { 474 468 ipc_answer_0(iid, ENOENT); 475 469 return; 476 470 } 477 471 478 if ( dev->state != DEVICE_USABLE|| dev->drv->phone <= 0) {472 if (DEVICE_USABLE != dev->state || dev->drv->phone <= 0) { 479 473 ipc_answer_0(iid, EINVAL); 480 474 return; … … 499 493 * passes device handle to the driver as an ipc method.) 500 494 */ 501 if (IPC_ GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO)495 if (IPC_M_CONNECT_ME_TO != IPC_GET_METHOD(*icall)) 502 496 devman_connection_devmapper(iid, icall); 503 497 … … 537 531 /* Initialize list of available drivers. */ 538 532 init_driver_list(&drivers_list); 539 if ( lookup_available_drivers(&drivers_list,540 DRIVER_DEFAULT_STORE) == 0) {533 if (0 == lookup_available_drivers(&drivers_list, 534 DRIVER_DEFAULT_STORE)) { 541 535 printf(NAME " no drivers found."); 542 536 return false; 543 537 } 544 545 538 printf(NAME ": devman_init - list of drivers has been initialized.\n"); 546 539 -
uspace/srv/devman/match.c
r7ae3d6f rb445803 55 55 match_id_t *tmp_ma_id; 56 56 57 if ( str_cmp(drv_id->id, dev_id->id) == 0) {57 if (0 == str_cmp(drv_id->id, dev_id->id)) { 58 58 /* 59 59 * We found a match. … … 67 67 * list of match ids. 68 68 */ 69 if (drv_ link->next != drv_head) {69 if (drv_head != drv_link->next) { 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_ link->next != dev_head) {81 if (dev_head != dev_link->next) { 82 82 tmp_ma_id = list_get_instance(dev_link->next, 83 83 match_id_t, link); … … 99 99 } 100 100 101 } while (drv_ link->next != drv_head && dev_link->next != dev_head);101 } while (drv_head != drv_link->next && dev_head != dev_link->next); 102 102 103 103 return 0; -
uspace/srv/devman/util.c
r7ae3d6f rb445803 61 61 char *get_path_elem_end(char *path) 62 62 { 63 while ( *path != '\0' && *path != '/')63 while (0 != *path && '/' != *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 113 68 /** @} 114 69 */ -
uspace/srv/devman/util.h
r7ae3d6f rb445803 41 41 extern char *get_path_elem_end(char *); 42 42 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); 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 } 48 86 49 87 #endif
Note:
See TracChangeset
for help on using the changeset viewer.