Changes in / [60898b6:a63ff7d] in mainline


Ignore:
Files:
8 deleted
61 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r60898b6 ra63ff7d  
    106106        $(USPACE_PATH)/srv/net/tl/tcp/tcp \
    107107        $(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
    109110       
    110111RD_DRVS = \
  • boot/arch/amd64/Makefile.inc

    r60898b6 ra63ff7d  
    3434RD_SRVS_NON_ESSENTIAL += \
    3535        $(USPACE_PATH)/srv/bd/ata_bd/ata_bd \
     36        $(USPACE_PATH)/srv/hw/bus/pci/pci \
    3637        $(USPACE_PATH)/srv/hid/char_mouse/char_ms
    3738
  • contrib/arch/hadlbppp.py

    r60898b6 ra63ff7d  
    4242        "Print usage syntax"
    4343       
    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
    5252
    5353def tabs(cnt):
     
    163163                                                result.append(tokens[i])
    164164                                else:
    165                                         print("%s: Syntax error in tentative statement" % name)
     165                                        print "%s: Syntax error in tentative statement" % name
    166166                        else:
    167                                 print("%s: Expected '{' for tentative statement" % name)
     167                                print "%s: Expected '{' for tentative statement" % name
    168168                else:
    169169                        result.append(tokens[i])
     
    231231                                                                result.append(tokens[i])
    232232                                                else:
    233                                                         print("%s: Syntax error in alternative statement" % name)
     233                                                        print "%s: Syntax error in alternative statement" % name
    234234                                        else:
    235                                                 print("%s: Expected '{' for alternative statement body" % name)
     235                                                print "%s: Expected '{' for alternative statement body" % name
    236236                                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
    238238                        else:
    239                                 print("%s: Expected '(' for alternative statement head" % name)
     239                                print "%s: Expected '(' for alternative statement head" % name
    240240                else:
    241241                        result.append(tokens[i])
     
    269269                                        result.append(tokens[i])
    270270                        else:
    271                                 print("%s: Unexpected end of protocol" % name)
     271                                print "%s: Unexpected end of protocol" % name
    272272               
    273273                i += 1
     
    349349                elif (token == ")"):
    350350                        if (indent < base_indent):
    351                                 print("%s: Too many parentheses" % name)
     351                                print "%s: Too many parentheses" % name
    352352                       
    353353                        indent -= 1
     
    358358                elif (token == "}"):
    359359                        if (indent < base_indent):
    360                                 print("%s: Too many parentheses" % name)
     360                                print "%s: Too many parentheses" % name
    361361                       
    362362                        indent -= 1
     
    370370       
    371371        if (indent > base_indent):
    372                 print("%s: Missing parentheses" % name)
     372                print "%s: Missing parentheses" % name
    373373       
    374374        output = output.strip()
     
    405405                        result.extend(inherited_protocols(supiface))
    406406                else:
    407                         print("%s: Extends unknown interface '%s'" % (iface['name'], iface['extends']))
     407                        print "%s: Extends unknown interface '%s'" % (iface['name'], iface['extends'])
    408408       
    409409        return result
     
    459459                                                protocols.append(proto)
    460460                        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'])
    462462       
    463463        if (opt_bp):
    464                 outf = open(outname, "w")
     464                outf = file(outname, "w")
    465465                outf.write(parse_bp(outname, merge_bp(initialization, finalization, protocols), 0))
    466466                outf.close()
    467467       
    468468        if (opt_ebp):
    469                 outf = open(outname, "w")
     469                outf = file(outname, "w")
    470470                outf.write(parse_ebp(frame['name'], outname, merge_bp(initialization, finalization, protocols), 0))
    471471                outf.close()
     
    514514       
    515515        if (opt_bp):
    516                 outf = open(outname, "w")
     516                outf = file(outname, "w")
    517517                outf.write("NULL")
    518518                outf.close()
    519519       
    520520        if (opt_ebp):
    521                 outf = open(outname, "w")
     521                outf = file(outname, "w")
    522522                outf.write("component null {\n\tbehavior {\n\t\tNULL\n\t}\n}")
    523523                outf.close()
     
    587587                                        insts.append({'var': "%s_%s" % (prefix, inst['var']), 'frame': subframe})
    588588                                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'])
    590590       
    591591        if ('bind' in arch):
     
    612612       
    613613        if (arch is None):
    614                 print("Unable to find system architecture")
     614                print "Unable to find system architecture"
    615615                return
    616616       
     
    634634                                        insts.append({'var': inst['var'], 'frame': subframe})
    635635                                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'])
    637637       
    638638        if ('bind' in arch):
     
    642642        if ('delegate' in arch):
    643643                for delegate in arch['delegate']:
    644                         print("Unable to delegate interface in system architecture")
     644                        print "Unable to delegate interface in system architecture"
    645645                        break
    646646       
    647647        if ('subsume' in arch):
    648648                for subsume in arch['subsume']:
    649                         print("Unable to subsume interface in system architecture")
     649                        print "Unable to subsume interface in system architecture"
    650650                        break
    651651       
     
    654654        outname = os.path.join(outdir, "%s.archbp" % arch['name'])
    655655        if ((opt_bp) or (opt_ebp)):
    656                 outf = open(outname, "w")
     656                outf = file(outname, "w")
    657657        else:
    658658                outf = None
     
    709709               
    710710                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)
    712712                        return ""
    713713        else:
     
    716716                nested_root = root
    717717       
    718         inf = open(path, "r")
     718        inf = file(path, "r")
    719719       
    720720        raw = preproc_adl(inf.read(), inarg)
     
    733733                if (POST_INC in context):
    734734                        if (token != "]"):
    735                                 print("%s: Expected ]" % inname)
     735                                print "%s: Expected ]" % inname
    736736                       
    737737                        context.remove(POST_INC)
     
    774774                        if (NULL in context):
    775775                                if (token != ";"):
    776                                         print("%s: Expected ';' in frame '%s'" % (inname, frame))
     776                                        print "%s: Expected ';' in frame '%s'" % (inname, frame)
    777777                                else:
    778778                                        output += "%s\n" % token
     
    798798                                               
    799799                                                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)
    801801                                                else:
    802802                                                        frame_properties[frame]['finalization'] = bp
     
    832832                                               
    833833                                                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)
    835835                                                else:
    836836                                                        frame_properties[frame]['initialization'] = bp
     
    866866                                               
    867867                                                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)
    869869                                                else:
    870870                                                        frame_properties[frame]['protocol'] = bp
     
    889889                                        if (FIN in context):
    890890                                                if (token != ";"):
    891                                                         print("%s: Expected ';' in frame '%s'" % (inname, frame))
     891                                                        print "%s: Expected ';' in frame '%s'" % (inname, frame)
    892892                                                else:
    893893                                                        output += "%s" % token
     
    898898                                        if (VAR in context):
    899899                                                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)
    901901                                                else:
    902902                                                        if (not frame in frame_properties):
     
    919919                                        else:
    920920                                                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)
    922922                                                else:
    923923                                                        arg0 = token
     
    930930                                        if (FIN in context):
    931931                                                if (token != ";"):
    932                                                         print("%s: Expected ';' in frame '%s'" % (inname, frame))
     932                                                        print "%s: Expected ';' in frame '%s'" % (inname, frame)
    933933                                                else:
    934934                                                        output += "%s" % token
     
    939939                                        if (VAR in context):
    940940                                                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)
    942942                                                else:
    943943                                                        if (not frame in frame_properties):
     
    960960                                        else:
    961961                                                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)
    963963                                                else:
    964964                                                        arg0 = token
     
    970970                                if (token == "}"):
    971971                                        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)
    973973                                        else:
    974974                                                indent = 0
     
    10101010                                        continue
    10111011                               
    1012                                 print("%s: Unknown token '%s' in frame '%s'" % (inname, token, frame))
     1012                                print "%s: Unknown token '%s' in frame '%s'" % (inname, token, frame)
    10131013                                continue
    10141014                       
     
    10271027                                        continue
    10281028                               
    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)
    10301030                               
    10311031                                continue
    10321032                       
    10331033                        if (not identifier(token)):
    1034                                 print("%s: Expected frame name" % inname)
     1034                                print "%s: Expected frame name" % inname
    10351035                        else:
    10361036                                frame = token
     
    10501050                        if (NULL in context):
    10511051                                if (token != ";"):
    1052                                         print("%s: Expected ';' in interface '%s'" % (inname, interface))
     1052                                        print "%s: Expected ';' in interface '%s'" % (inname, interface)
    10531053                                else:
    10541054                                        output += "%s\n" % token
     
    10741074                                               
    10751075                                                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)
    10771077                                                else:
    10781078                                                        iface_properties[interface]['protocol'] = bp
     
    10941094                                        if (FIN in context):
    10951095                                                if (token != ";"):
    1096                                                         print("%s: Expected ';' in interface '%s'" % (inname, interface))
     1096                                                        print "%s: Expected ';' in interface '%s'" % (inname, interface)
    10971097                                                else:
    10981098                                                        output += "%s" % token
     
    11241124                                        if (PAR_LEFT in context):
    11251125                                                if (token != "("):
    1126                                                         print("%s: Expected '(' in interface '%s'" % (inname, interface))
     1126                                                        print "%s: Expected '(' in interface '%s'" % (inname, interface)
    11271127                                                else:
    11281128                                                        output += "%s" % token
     
    11331133                                       
    11341134                                        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)
    11361136                                        else:
    11371137                                                output += "%s" % token
     
    11421142                                if (token == "}"):
    11431143                                        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)
    11451145                                        else:
    11461146                                                indent = 0
     
    11631163                                        continue
    11641164                               
    1165                                 print("%s: Unknown token '%s' in interface '%s'" % (inname, token, interface))
     1165                                print "%s: Unknown token '%s' in interface '%s'" % (inname, token, interface)
    11661166                                continue
    11671167                       
     
    11831183                                                continue
    11841184                                               
    1185                                         print("%s: Expected '{' or ';' in interface head '%s'" % (inname, interface))
     1185                                        print "%s: Expected '{' or ';' in interface head '%s'" % (inname, interface)
    11861186                                        continue
    11871187                               
    11881188                                if (EXTENDS in context):
    11891189                                        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)
    11911191                                        else:
    11921192                                                output += "%s " % token
     
    12181218                                        continue
    12191219                               
    1220                                 print("%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface))
     1220                                print "%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface)
    12211221                                continue
    12221222                       
    12231223                        if (not identifier(token)):
    1224                                 print("%s: Expected interface name" % inname)
     1224                                print "%s: Expected interface name" % inname
    12251225                        else:
    12261226                                interface = token
     
    12401240                        if (NULL in context):
    12411241                                if (token != ";"):
    1242                                         print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
     1242                                        print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
    12431243                                else:
    12441244                                        output += "%s\n" % token
     
    12541254                                        if (FIN in context):
    12551255                                                if (token != ";"):
    1256                                                         print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
     1256                                                        print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
    12571257                                                else:
    12581258                                                        output += "%s" % token
     
    12641264                                        if (VAR in context):
    12651265                                                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)
    12671267                                                else:
    12681268                                                        if (not architecture in arch_properties):
     
    12831283                                        if (TO in context):
    12841284                                                if (token != "to"):
    1285                                                         print("%s: Expected 'to' in architecture '%s'" % (inname, architecture))
     1285                                                        print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)
    12861286                                                else:
    12871287                                                        output += "%s " % token
     
    12921292                                       
    12931293                                        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)
    12951295                                        else:
    12961296                                                output += "%s " % token
     
    13031303                                        if (FIN in context):
    13041304                                                if (token != ";"):
    1305                                                         print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
     1305                                                        print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
    13061306                                                else:
    13071307                                                        output += "%s" % token
     
    13131313                                        if (VAR in context):
    13141314                                                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)
    13161316                                                else:
    13171317                                                        if (not architecture in arch_properties):
     
    13321332                                        if (TO in context):
    13331333                                                if (token != "to"):
    1334                                                         print("%s: Expected 'to' in architecture '%s'" % (inname, architecture))
     1334                                                        print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)
    13351335                                                else:
    13361336                                                        output += "%s " % token
     
    13411341                                       
    13421342                                        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)
    13441344                                        else:
    13451345                                                output += "%s " % token
     
    13521352                                        if (FIN in context):
    13531353                                                if (token != ";"):
    1354                                                         print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
     1354                                                        print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
    13551355                                                else:
    13561356                                                        output += "%s" % token
     
    13621362                                        if (VAR in context):
    13631363                                                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)
    13651365                                                else:
    13661366                                                        if (not architecture in arch_properties):
     
    13811381                                        if (TO in context):
    13821382                                                if (token != "to"):
    1383                                                         print("%s: Expected 'to' in architecture '%s'" % (inname, architecture))
     1383                                                        print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)
    13841384                                                else:
    13851385                                                        output += "%s " % token
     
    13901390                                       
    13911391                                        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)
    13931393                                        else:
    13941394                                                output += "%s " % token
     
    14011401                                        if (FIN in context):
    14021402                                                if (token != ";"):
    1403                                                         print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
     1403                                                        print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
    14041404                                                else:
    14051405                                                        output += "%s" % token
     
    14111411                                        if (VAR in context):
    14121412                                                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)
    14141414                                                else:
    14151415                                                        if (not architecture in arch_properties):
     
    14291429                                       
    14301430                                        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)
    14321432                                        else:
    14331433                                                output += "%s " % token
     
    14391439                                if (token == "}"):
    14401440                                        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)
    14421442                                        else:
    14431443                                                indent -= 1
     
    14681468                                        continue
    14691469                               
    1470                                 print("%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture))
     1470                                print "%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture)
    14711471                                continue
    14721472                       
     
    14871487                               
    14881488                                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)
    14901490                                else:
    14911491                                        output += "%s " % token
     
    14941494                       
    14951495                        if (not identifier(token)):
    1496                                 print("%s: Expected architecture name" % inname)
     1496                                print "%s: Expected architecture name" % inname
    14971497                        else:
    14981498                                architecture = token
     
    15141514                if (SYSTEM in context):
    15151515                        if (token != "architecture"):
    1516                                 print("%s: Expected 'architecture'" % inname)
     1516                                print "%s: Expected 'architecture'" % inname
    15171517                        else:
    15181518                                output += "%s " % token
     
    15411541                        continue
    15421542               
    1543                 print("%s: Unknown token '%s'" % (inname, token))
     1543                print "%s: Unknown token '%s'" % (inname, token)
    15441544       
    15451545        inf.close()
     
    15751575       
    15761576        if ((output != "") and (opt_adl)):
    1577                 outf = open(outname, "w")
     1577                outf = file(outname, "w")
    15781578                outf.write(output)
    15791579                outf.close()
     
    16331633                                        merge_dot_frame("%s_%s" % (prefix, inst['var']), inst['var'], subframe, outf, indent + 1)
    16341634                                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'])
    16361636       
    16371637        if ('bind' in arch):
     
    17281728       
    17291729        if (arch is None):
    1730                 print("Unable to find system architecture")
     1730                print "Unable to find system architecture"
    17311731                return
    17321732       
    17331733        if (opt_dot):
    17341734                outname = os.path.join(outdir, "%s.dot" % arch['name'])
    1735                 outf = open(outname, "w")
     1735                outf = file(outname, "w")
    17361736               
    17371737                outf.write("digraph {\n")
     
    17521752                                                merge_dot_frame("%s" % inst['var'], inst['var'], subframe, outf, 1)
    17531753                                        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'])
    17551755               
    17561756                if ('bind' in arch):
     
    17841784                if ('delegate' in arch):
    17851785                        for delegate in arch['delegate']:
    1786                                 print("Unable to delegate interface in system architecture")
     1786                                print "Unable to delegate interface in system architecture"
    17871787                                break
    17881788               
    17891789                if ('subsume' in arch):
    17901790                        for subsume in arch['subsume']:
    1791                                 print("Unable to subsume interface in system architecture")
     1791                                print "Unable to subsume interface in system architecture"
    17921792                                break
    17931793               
     
    18261826                        pass
    18271827                else:
    1828                         print("Error: Unknown command line option '%s'" % arg)
     1828                        print "Error: Unknown command line option '%s'" % arg
    18291829                        return
    18301830       
    18311831        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"
    18331833                return
    18341834       
    18351835        path = os.path.abspath(sys.argv[-1])
    18361836        if (not os.path.isdir(path)):
    1837                 print("Error: <OUTPUT> is not a directory")
     1837                print "Error: <OUTPUT> is not a directory"
    18381838                return
    18391839       
  • kernel/arch/abs32le/include/interrupt.h

    r60898b6 ra63ff7d  
    3737
    3838#include <typedefs.h>
    39 #include <arch/istate.h>
     39#include <verify.h>
     40#include <trace.h>
    4041
    4142#define IVT_ITEMS  0
     
    4445#define VECTOR_TLB_SHOOTDOWN_IPI  0
    4546
     47/*
     48 * On real hardware this stores the registers which
     49 * need to be preserved during interupts.
     50 */
     51typedef struct istate {
     52        uintptr_t ip;
     53        uintptr_t fp;
     54        uint32_t stack[];
     55} istate_t;
     56
     57NO_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
     66NO_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
     75NO_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
     83NO_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
    4691#endif
    4792
  • kernel/arch/amd64/include/interrupt.h

    r60898b6 ra63ff7d  
    3737
    3838#include <typedefs.h>
    39 #include <arch/istate.h>
    4039#include <arch/pm.h>
     40#include <trace.h>
    4141
    4242#define IVT_ITEMS  IDT_ITEMS
     
    7171#define VECTOR_DEBUG_IPI          (IVT_FREEBASE + 2)
    7272
     73/** This is passed to interrupt handlers */
     74typedef 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 */
     102NO_TRACE static inline int istate_from_uspace(istate_t *istate)
     103{
     104        return !(istate->rip & 0x8000000000000000);
     105}
     106
     107NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
     108    uintptr_t retaddr)
     109{
     110        istate->rip = retaddr;
     111}
     112
     113NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
     114{
     115        return istate->rip;
     116}
     117
     118NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
     119{
     120        return istate->rbp;
     121}
     122
    73123extern void (* disable_irqs_function)(uint16_t);
    74124extern void (* enable_irqs_function)(uint16_t);
  • kernel/arch/amd64/src/asm.S

    r60898b6 ra63ff7d  
    9595memcpy_from_uspace_failover_address:
    9696memcpy_to_uspace_failover_address:
    97         xorl %eax, %eax         /* return 0, failure */
     97        xorq %rax, %rax         /* return 0, failure */
    9898        ret
    9999
     
    143143
    144144set_efer_flag:
    145         movl $0xc0000080, %ecx
     145        movq $0xc0000080, %rcx
    146146        rdmsr
    147147        btsl %edi, %eax
     
    150150
    151151read_efer_flag:
    152         movl $0xc0000080, %ecx
     152        movq $0xc0000080, %rcx
    153153        rdmsr
    154154        ret
     
    243243         * Stop stack traces here if we came from userspace.
    244244         */
    245         xorl %edx, %edx
     245        xorq %rdx, %rdx
    246246        cmpq $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp)
    247247        cmovnzq %rdx, %rbp
     
    386386        movq ISTATE_OFFSET_RSP(%rsp), %rsp
    387387
    388         /*
    389          * Clear the rest of the scratch registers to prevent information leak.
    390          * The 32-bit XOR on the low GPRs actually clears the entire 64-bit
    391          * register and the instruction is shorter.
    392          */
    393         xorl %edx, %edx
    394         xorl %esi, %esi
    395         xorl %edi, %edi
    396         xorq %r8, %r8
    397         xorq %r9, %r9
    398         xorq %r10, %r10
    399 
    400388        sysretq
    401389
     
    425413        movq %rdi, %rsi
    426414        movq $(PA2KA(0xb8000)), %rdi  /* base of EGA text mode memory */
    427         xorl %eax, %eax
     415        xorq %rax, %rax
    428416       
    429417        /* Read bits 8 - 15 of the cursor address */
     
    505493                movq $(PA2KA(0xb80a0)), %rsi
    506494                movq $(PA2KA(0xb8000)), %rdi
    507                 movl $480, %ecx
     495                movq $480, %rcx
    508496                rep movsq
    509497               
    510498                /* Clear the 24th row */
    511                 xorl %eax, %eax
    512                 movl $20, %ecx
     499                xorq %rax, %rax
     500                movq $20, %rcx
    513501                rep stosq
    514502               
  • kernel/arch/amd64/src/boot/boot.S

    r60898b6 ra63ff7d  
    516516                movq $(PA2KA(0xb80a0)), %rsi
    517517                movq $(PA2KA(0xb8000)), %rdi
    518                 movl $480, %ecx
     518                movq $480, %rcx
    519519                rep movsq
    520520               
    521521                /* Clear the 24th row */
    522                 xorl %eax, %eax
    523                 movl $20, %ecx
     522                xorq %rax, %rax
     523                movq $20, %rcx
    524524                rep stosq
    525525               
  • kernel/arch/amd64/src/context.S

    r60898b6 ra63ff7d  
    4545        CONTEXT_SAVE_ARCH_CORE %rdi %rdx
    4646       
    47         xorl %eax, %eax       # context_save returns 1
    48         incl %eax
     47        xorq %rax, %rax       # context_save returns 1
     48        incq %rax
    4949        ret
    5050
     
    6060        movq %rdx, (%rsp)
    6161       
    62         xorl %eax, %eax       # context_restore returns 0
     62        xorq %rax, %rax       # context_restore returns 0
    6363        ret
  • kernel/arch/arm32/include/exception.h

    r60898b6 ra63ff7d  
    3939
    4040#include <typedefs.h>
    41 #include <arch/istate.h>
     41#include <arch/regutils.h>
     42#include <trace.h>
    4243
    4344/** If defined, forces using of high exception vectors. */
     
    8485extern uintptr_t exc_stack;
    8586
     87/** Struct representing CPU state saved when an exception occurs. */
     88typedef 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 */
     116NO_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. */
     123NO_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. */
     129NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
     130{
     131        return istate->pc;
     132}
     133
     134NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
     135{
     136        return istate->fp;
     137}
     138
    86139extern void install_exception_handlers(void);
    87140extern void exception_init(void);
  • kernel/arch/ia32/include/interrupt.h

    r60898b6 ra63ff7d  
    3737
    3838#include <typedefs.h>
    39 #include <arch/istate.h>
    4039#include <arch/pm.h>
     40#include <trace.h>
    4141
    4242#define IVT_ITEMS  IDT_ITEMS
     
    7171#define VECTOR_DEBUG_IPI          (IVT_FREEBASE + 2)
    7272
     73typedef 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 */
     104NO_TRACE static inline int istate_from_uspace(istate_t *istate)
     105{
     106        return !(istate->eip & 0x80000000);
     107}
     108
     109NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
     110    uintptr_t retaddr)
     111{
     112        istate->eip = retaddr;
     113}
     114
     115NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
     116{
     117        return istate->eip;
     118}
     119
     120NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
     121{
     122        return istate->ebp;
     123}
     124
    73125extern void (* disable_irqs_function)(uint16_t);
    74126extern void (* enable_irqs_function)(uint16_t);
  • kernel/arch/ia64/include/interrupt.h

    r60898b6 ra63ff7d  
    3737
    3838#include <typedefs.h>
    39 #include <arch/istate.h>
     39#include <arch/register.h>
     40#include <trace.h>
    4041
    4142/** ia64 has 256 INRs. */
     
    7374#define EOI  0  /**< The actual value doesn't matter. */
    7475
     76typedef 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
    75136extern void *ivt;
     137
     138NO_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
     145NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
     146{
     147        return istate->cr_iip;
     148}
     149
     150NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
     151{
     152        /* FIXME */
     153       
     154        return 0;
     155}
     156
     157NO_TRACE static inline int istate_from_uspace(istate_t *istate)
     158{
     159        return (istate->cr_iip) < 0xe000000000000000ULL;
     160}
    76161
    77162extern void general_exception(uint64_t, istate_t *);
  • kernel/arch/ia64/include/register.h

    r60898b6 ra63ff7d  
    142142#ifndef __ASM__
    143143
    144 #ifdef KERNEL
    145144#include <typedefs.h>
    146 #else
    147 #include <sys/types.h>
    148 #endif
    149145
    150146/** Processor Status Register. */
  • kernel/arch/mips32/include/cp0.h

    r60898b6 ra63ff7d  
    3636#define KERN_mips32_CP0_H_
    3737
    38 #ifdef KERNEL
    3938#include <typedefs.h>
    40 #else
    41 #include <sys/types.h>
    42 #endif
    4339
    4440#define cp0_status_ie_enabled_bit     (1 << 0)
  • kernel/arch/mips32/include/exception.h

    r60898b6 ra63ff7d  
    3737
    3838#include <typedefs.h>
    39 #include <arch/istate.h>
     39#include <arch/cp0.h>
     40#include <trace.h>
    4041
    4142#define EXC_Int    0
     
    5859#define EXC_VCED   31
    5960
     61typedef 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
     107NO_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 */
     114NO_TRACE static inline int istate_from_uspace(istate_t *istate)
     115{
     116        return istate->status & cp0_status_um_bit;
     117}
     118
     119NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
     120{
     121        return istate->epc;
     122}
     123
     124NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
     125{
     126        return istate->sp;
     127}
     128
    60129extern void exception(istate_t *istate);
    61130extern void tlb_refill_entry(void);
  • kernel/arch/sparc64/include/interrupt.h

    r60898b6 ra63ff7d  
    3838
    3939#include <typedefs.h>
    40 #include <arch/istate.h>
     40#include <arch/regdef.h>
     41#include <trace.h>
    4142
    4243#define IVT_ITEMS  15
     
    5051};
    5152
     53typedef struct istate {
     54        uint64_t tnpc;
     55        uint64_t tpc;
     56        uint64_t tstate;
     57} istate_t;
     58
     59NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
     60    uintptr_t retaddr)
     61{
     62        istate->tpc = retaddr;
     63}
     64
     65NO_TRACE static inline int istate_from_uspace(istate_t *istate)
     66{
     67        return !(istate->tstate & TSTATE_PRIV_BIT);
     68}
     69
     70NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
     71{
     72        return istate->tpc;
     73}
     74
     75NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
     76{
     77        /* TODO */
     78       
     79        return 0;
     80}
     81
    5282#endif
    5383
  • kernel/generic/src/ipc/kbox.c

    r60898b6 ra63ff7d  
    107107                /* Terminate debugging session (if any). */
    108108                LOG("Terminate debugging session.");
    109                 mutex_lock(&TASK->udebug.lock);
     109                irq_spinlock_lock(&TASK->lock, true);
    110110                udebug_task_cleanup(TASK);
    111                 mutex_unlock(&TASK->udebug.lock);
     111                irq_spinlock_unlock(&TASK->lock, true);
    112112        } else {
    113113                LOG("Was not debugger.");
  • kernel/tools/amd64/decpt.py

    r60898b6 ra63ff7d  
    77def main():
    88    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]
    1010        sys.exit(1)
    1111   
     
    1616    ptl1 = (address >> 30) & 0x1ff
    1717    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
    2323
    2424if __name__ == '__main__':
  • kernel/tools/genmap.py

    r60898b6 ra63ff7d  
    8686        obdump = read_obdump(obmapf)
    8787       
    88         def key_sorter(x):
    89                 return x[0]
     88        def sorter(x,y):
     89                return cmp(x[0],y[0])
    9090       
    9191        for line in kmapf:
     
    9393                res = startfile.match(line)
    9494               
    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)))):
    9696                        offset = int(res.group(2), 16)
    9797                        fname = res.group(3)
    9898                        symbols = obdump[res.group(1)][fname]
    99                         symbols.sort(key = key_sorter)
     99                        symbols.sort(sorter)
    100100                        for addr, symbol in symbols:
    101101                                value = fname + ':' + symbol
     
    107107def main():
    108108        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]
    110110                return 1
    111111       
    112112        kmapf = open(sys.argv[1], 'r')
    113113        obmapf = open(sys.argv[2], 'r')
    114         out = open(sys.argv[3], 'wb')
     114        out = open(sys.argv[3], 'w')
    115115       
    116116        generate(kmapf, obmapf, out)
  • kernel/tools/ia32/decpt.py

    r60898b6 ra63ff7d  
    77def main():
    88    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]
    1010        sys.exit(1)
    1111   
     
    1414    ptl1 = (address >> 12) & 0x3ff
    1515    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
    1919
    2020if __name__ == '__main__':
  • tools/autotool.py

    r60898b6 ra63ff7d  
    7575        "Read HelenOS build configuration"
    7676       
    77         inf = open(fname, 'r')
     77        inf = file(fname, 'r')
    7878       
    7979        for line in inf:
     
    191191        check_common(common, "CC")
    192192       
    193         outf = open(PROBE_SOURCE, 'w')
     193        outf = file(PROBE_SOURCE, 'w')
    194194        outf.write(PROBE_HEAD)
    195195       
     
    212212        if (not os.path.isfile(PROBE_OUTPUT)):
    213213                sys.stderr.write("failed\n")
    214                 print(output[1])
     214                print output[1]
    215215                print_error(["Error executing \"%s\"." % " ".join(args),
    216216                             "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT,
     
    221221        sys.stderr.write("ok\n")
    222222       
    223         inf = open(PROBE_OUTPUT, 'r')
     223        inf = file(PROBE_OUTPUT, 'r')
    224224        lines = inf.readlines()
    225225        inf.close()
     
    343343        "Create makefile output"
    344344       
    345         outmk = open(mkname, 'w')
     345        outmk = file(mkname, 'w')
    346346       
    347347        outmk.write('#########################################\n')
     
    357357        "Create header output"
    358358       
    359         outhd = open(hdname, 'w')
     359        outhd = file(hdname, 'w')
    360360       
    361361        outhd.write('/***************************************\n')
  • tools/checkers/clang.py

    r60898b6 ra63ff7d  
    4242def usage(prname):
    4343        "Print usage syntax"
    44         print(prname + " <ROOT>")
     44        print prname + " <ROOT>"
    4545
    4646def clang(root, job):
     
    5050       
    5151        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?"
    5454                return False
    5555       
    56         inf = open(inname, "r")
     56        inf = file(inname, "r")
    5757        records = inf.read().splitlines()
    5858        inf.close()
     
    6464               
    6565                if (len(arg) < 6):
    66                         print("Not enough jobfile record arguments")
     66                        print "Not enought jobfile record arguments"
    6767                        return False
    6868               
     
    7676                srcfqname = os.path.join(base, srcfname)
    7777                if (not os.path.isfile(srcfqname)):
    78                         print("Source %s not found" % srcfqname)
     78                        print "Source %s not found" % srcfqname
    7979                        return False
    8080               
     
    108108       
    109109        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."
    112112                return
    113113       
     
    115115                if (not clang(rootdir, job)):
    116116                        print
    117                         print("Failed job: %s" % job)
     117                        print "Failed job: %s" % job
    118118                        return
    119119       
    120120        print
    121         print("All jobs passed")
     121        print "All jobs passed"
    122122
    123123if __name__ == '__main__':
  • tools/checkers/jobfile.py

    r60898b6 ra63ff7d  
    5454                                nil = True
    5555                        else:
    56                                 print("Unexpected '%s'" % record[i])
     56                                print "Unexpected '%s'" % record[i]
    5757                                return False
    5858               
  • tools/checkers/stanse.py

    r60898b6 ra63ff7d  
    4343def usage(prname):
    4444        "Print usage syntax"
    45         print(prname + " <ROOT>")
     45        print prname + " <ROOT>"
    4646
    4747def stanse(root, job):
     
    5454       
    5555        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?"
    5858                return False
    5959       
    60         inf = open(inname, "r")
     60        inf = file(inname, "r")
    6161        records = inf.read().splitlines()
    6262        inf.close()
     
    6969               
    7070                if (len(arg) < 6):
    71                         print("Not enough jobfile record arguments")
     71                        print "Not enought jobfile record arguments"
    7272                        return False
    7373               
     
    8181                srcfqname = os.path.join(base, srcfname)
    8282                if (not os.path.isfile(srcfqname)):
    83                         print("Source %s not found" % srcfqname)
     83                        print "Source %s not found" % srcfqname
    8484                        return False
    8585               
     
    9090                output.append([srcfname, tgtfname, base, options])
    9191       
    92         outf = open(outname, "w")
     92        outf = file(outname, "w")
    9393        for record in output:
    9494                outf.write("{%s},{%s},{%s},{%s}\n" % (record[0], record[1], record[2], record[3]))
     
    121121       
    122122        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."
    125125                return
    126126       
     
    128128                if (not stanse(rootdir, job)):
    129129                        print
    130                         print("Failed job: %s" % job)
     130                        print "Failed job: %s" % job
    131131                        return
    132132       
    133133        print
    134         print("All jobs passed")
     134        print "All jobs passed"
    135135
    136136if __name__ == '__main__':
  • tools/checkers/vcc.py

    r60898b6 ra63ff7d  
    4949def usage(prname):
    5050        "Print usage syntax"
    51         print(prname + " <ROOT> [VCC_PATH]")
     51        print prname + " <ROOT> [VCC_PATH]"
    5252
    5353def cygpath(upath):
     
    7272        preproc = subprocess.Popen(args, stdout = subprocess.PIPE).communicate()[0]
    7373       
    74         tmpf = open(tmpfname, "w")
     74        tmpf = file(tmpfname, "w")
    7575        tmpf.write(specification)
    7676       
     
    108108       
    109109        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?"
    112112                return False
    113113       
    114         inf = open(inname, "r")
     114        inf = file(inname, "r")
    115115        records = inf.read().splitlines()
    116116        inf.close()
     
    122122               
    123123                if (len(arg) < 6):
    124                         print("Not enough jobfile record arguments")
     124                        print "Not enought jobfile record arguments"
    125125                        return False
    126126               
     
    134134                srcfqname = os.path.join(base, srcfname)
    135135                if (not os.path.isfile(srcfqname)):
    136                         print("Source %s not found" % srcfqname)
     136                        print "Source %s not found" % srcfqname
    137137                        return False
    138138               
     
    153153               
    154154                # Run Vcc
    155                 print(" -- %s --" % srcfname)
     155                print " -- %s --" % srcfname           
    156156                retval = subprocess.Popen([vcc_path, '/pointersize:32', '/newsyntax', cygpath(tmpfqname)]).wait()
    157157               
     
    182182       
    183183        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."
    186186                return
    187187       
     
    189189       
    190190        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."
    193193                return
    194194       
    195195        specpath = os.path.join(rootdir, "tools/checkers/vcc.h")
    196196        if (not os.path.isfile(specpath)):
    197                 print("%s not found." % config)
     197                print "%s not found." % config
    198198                return
    199199       
     
    205205                if (not vcc(vcc_path, rootdir, job)):
    206206                        print
    207                         print("Failed job: %s" % job)
     207                        print "Failed job: %s" % job
    208208                        return
    209209       
    210210        print
    211         print("All jobs passed")
     211        print "All jobs passed"
    212212
    213213if __name__ == '__main__':
  • tools/config.py

    r60898b6 ra63ff7d  
    4848        "Read saved values from last configuration run"
    4949       
    50         inf = open(fname, 'r')
     50        inf = file(fname, 'r')
    5151       
    5252        for line in inf:
     
    103103                condval = res.group(3)
    104104               
    105                 if (not condname in defaults):
     105                if (not defaults.has_key(condname)):
    106106                        varval = ''
    107107                else:
     
    131131        "Parse configuration file"
    132132       
    133         inf = open(fname, 'r')
     133        inf = file(fname, 'r')
    134134       
    135135        name = ''
     
    219219                        continue
    220220               
    221                 if (not varname in defaults):
     221                if (not defaults.has_key(varname)):
    222222                        return False
    223223       
     
    232232       
    233233        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(':')
    235235                sys.stderr.write("ok\n")
    236236        except:
     
    246246                revision = None
    247247       
    248         outmk = open(mkname, 'w')
    249         outmc = open(mcname, 'w')
     248        outmk = file(mkname, 'w')
     249        outmc = file(mcname, 'w')
    250250       
    251251        outmk.write('#########################################\n')
     
    263263                        continue
    264264               
    265                 if (not varname in defaults):
     265                if (not defaults.has_key(varname)):
    266266                        default = ''
    267267                else:
     
    368368                        # Cancel out all defaults which have to be deduced
    369369                        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] == '*')):
    371371                                        defaults[varname] = None
    372372                       
     
    385385                                        position = cnt
    386386                               
    387                                 if (not varname in defaults):
     387                                if (not defaults.has_key(varname)):
    388388                                        default = None
    389389                                else:
     
    428428                                cnt += 1
    429429                       
    430                         if (position != None) and (position >= len(options)):
     430                        if (position >= options):
    431431                                position = None
    432432                       
     
    449449                       
    450450                        position = None
    451                         if (not value in opt2row):
     451                        if (not opt2row.has_key(value)):
    452452                                raise RuntimeError("Error selecting value: %s" % value)
    453453                       
    454454                        (selname, seltype, name, choices) = opt2row[value]
    455455                       
    456                         if (not selname in defaults):
     456                        if (not defaults.has_key(selname)):
    457457                                        default = None
    458458                        else:
  • tools/jobfile.py

    r60898b6 ra63ff7d  
    3838def usage(prname):
    3939        "Print usage syntax"
    40         print(prname + " <JOBFILE> <SOURCE> <TARGET> <TOOL> <CATEGORY> [OPTIONS ...]")
     40        print prname + " <JOBFILE> <SOURCE> <TARGET> <TOOL> <CATEGORY> [OPTIONS ...]"
    4141
    4242def main():
     
    5353        options = " ".join(sys.argv[6:])
    5454       
    55         jobfile = open(jobfname, "a")
     55        jobfile = file(jobfname, "a")
    5656        fcntl.lockf(jobfile, fcntl.LOCK_EX)
    5757        jobfile.write("{%s},{%s},{%s},{%s},{%s},{%s}\n" % (srcfname, tgtfname, toolname, category, cwd, options))
  • tools/mkfat.py

    r60898b6 ra63ff7d  
    4646                return size
    4747       
    48         return ((size // alignment) + 1) * alignment
     48        return (((size / alignment) + 1) * alignment)
    4949
    5050def subtree_size(root, cluster_size, dirent_size):
     
    7979        first = 0
    8080       
    81         inf = open(path, "rb")
     81        inf = file(path, "r")
    8282        rd = 0;
    8383        while (rd < size):
     
    9292                prev = empty_cluster
    9393               
    94                 data = bytes(inf.read(cluster_size));
     94                data = inf.read(cluster_size);
    9595                outf.seek(data_start + (empty_cluster - reserved_clusters) * cluster_size)
    9696                outf.write(data)
     
    120120                prev = empty_cluster
    121121               
    122                 data = bytes()
     122                data = ''
    123123                data_len = 0
    124124                while ((i < length) and (data_len < cluster_size)):
     
    343343def usage(prname):
    344344        "Print usage syntax"
    345         print(prname + " <EXTRA_BYTES> <PATH> <IMAGE>")
     345        print prname + " <EXTRA_BYTES> <PATH> <IMAGE>"
    346346
    347347def main():
     
    351351       
    352352        if (not sys.argv[1].isdigit()):
    353                 print("<EXTRA_BYTES> must be a number")
     353                print "<EXTRA_BYTES> must be a number"
    354354                return
    355355       
     
    358358        path = os.path.abspath(sys.argv[2])
    359359        if (not os.path.isdir(path)):
    360                 print("<PATH> must be a directory")
     360                print "<PATH> must be a directory"
    361361                return
    362362       
     
    370370        reserved_clusters = 2
    371371       
    372         # Make sure the filesystem is large enough for FAT16
     372        # Make sure the filesystem is large enought for FAT16
    373373        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):
    375375                if (cluster_size > sector_size):
    376                         cluster_size = cluster_size // 2
     376                        cluster_size /= 2
    377377                        size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size + extra_bytes
    378378                else:
     
    381381        root_size = align_up(root_entries(path) * dirent_size, cluster_size)
    382382       
    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_size
     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_size
    386386        root_start = cluster_size + fat_count * fat_size
    387387        data_start = root_start + root_size
    388388       
    389         outf = open(sys.argv[3], "wb")
     389        outf = file(sys.argv[3], "w")
    390390       
    391391        boot_sector = xstruct.create(BOOT_SECTOR)
    392392        boot_sector.jmp = [0xEB, 0x3C, 0x90]
    393         boot_sector.oem = b'MSDOS5.0'
     393        boot_sector.oem = "MSDOS5.0"
    394394        boot_sector.sector = sector_size
    395         boot_sector.cluster = cluster_size // sector_size
    396         boot_sector.reserved = cluster_size // sector_size
     395        boot_sector.cluster = cluster_size / sector_size
     396        boot_sector.reserved = cluster_size / sector_size
    397397        boot_sector.fats = fat_count
    398         boot_sector.rootdir = root_size // dirent_size
     398        boot_sector.rootdir = root_size / dirent_size
    399399        if (sectors <= 65535):
    400400                boot_sector.sectors = sectors
     
    402402                boot_sector.sectors = 0
    403403        boot_sector.descriptor = 0xF8
    404         boot_sector.fat_sectors = fat_size // sector_size
     404        boot_sector.fat_sectors = fat_size / sector_size
    405405        boot_sector.track_sectors = 63
    406406        boot_sector.heads = 6
     
    414414        boot_sector.extboot_signature = 0x29
    415415        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   "
    418418        boot_sector.boot_signature = [0x55, 0xAA]
    419419       
     
    423423       
    424424        # Reserved sectors
    425         for i in range(1, cluster_size // sector_size):
     425        for i in range(1, cluster_size / sector_size):
    426426                outf.write(empty_sector.pack())
    427427       
    428428        # FAT tables
    429429        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):
    431431                        outf.write(empty_sector.pack())
    432432       
    433433        # Root directory
    434         for i in range(0, root_size // sector_size):
     434        for i in range(0, root_size / sector_size):
    435435                outf.write(empty_sector.pack())
    436436       
    437437        # Data
    438         for i in range(0, size // sector_size):
     438        for i in range(0, size / sector_size):
    439439                outf.write(empty_sector.pack())
    440440       
    441         fat = array.array('L', [0] * (fat_size // fatent_size))
     441        fat = array.array('L', [0] * (fat_size / fatent_size))
    442442        fat[0] = 0xfff8
    443443        fat[1] = 0xffff
     
    449449        for i in range(0, fat_count):
    450450                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):
    452452                        fat_entry.next = fat[j]
    453453                        outf.write(fat_entry.pack())
  • tools/mkhord.py

    r60898b6 ra63ff7d  
    5252def usage(prname):
    5353        "Print usage syntax"
    54         print(prname + " <ALIGNMENT> <FS_IMAGE> <HORD_IMAGE>")
     54        print prname + " <ALIGNMENT> <FS_IMAGE> <HORD_IMAGE>"
    5555
    5656def main():
     
    6060       
    6161        if (not sys.argv[1].isdigit()):
    62                 print("<ALIGNMENT> must be a number")
     62                print "<ALIGNMENT> must be a number"
    6363                return
    6464       
    6565        align = int(sys.argv[1], 0)
    6666        if (align <= 0):
    67                 print("<ALIGNMENT> must be positive")
     67                print "<ALIGNMENT> must be positive"
    6868                return
    6969       
    7070        fs_image = os.path.abspath(sys.argv[2])
    7171        if (not os.path.isfile(fs_image)):
    72                 print("<FS_IMAGE> must be a file")
     72                print "<FS_IMAGE> must be a file"
    7373                return
    7474       
    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")
    7777       
    7878        header = xstruct.create(HEADER)
  • tools/mktmpfs.py

    r60898b6 ra63ff7d  
    6666def usage(prname):
    6767        "Print usage syntax"
    68         print(prname + " <PATH> <IMAGE>")
     68        print prname + " <PATH> <IMAGE>"
    6969
    7070def recursion(root, outf):
     
    8585                        outf.write(dentry.pack())
    8686                       
    87                         inf = open(canon, "rb")
     87                        inf = file(canon, "r")
    8888                        rd = 0;
    8989                        while (rd < size):
     
    116116        path = os.path.abspath(sys.argv[1])
    117117        if (not os.path.isdir(path)):
    118                 print("<PATH> must be a directory")
     118                print "<PATH> must be a directory"
    119119                return
    120120       
    121         outf = open(sys.argv[2], "wb")
     121        outf = file(sys.argv[2], "w")
    122122       
    123123        header = xstruct.create(HEADER)
  • tools/mkuimage.py

    r60898b6 ra63ff7d  
    7272                        start_addr = (int)(optarg, 0)
    7373                else:
    74                         print(base_name + ": Unrecognized option.")
     74                        print base_name + ": Unrecognized option."
    7575                        print_syntax(cmd_name)
    7676                        return
    7777
    7878        if len(args) < 2:
    79                 print(base_name + ": Argument missing.")
     79                print base_name + ": Argument missing."
    8080                print_syntax(cmd_name)
    8181                return
     
    9191
    9292def 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')
    9595
    9696        header = xstruct.create(UIMAGE_HEADER)
     
    140140        signed_crc = zlib.crc32(byteseq, 0)
    141141        if signed_crc < 0:
    142                 return (long(signed_crc) + (long(2) ** long(32))) # 2^32L
     142                return (long(signed_crc) + 4294967296L) # 2^32L
    143143        else:
    144144                return signed_crc
     
    147147#
    148148def print_syntax(cmd):
    149         print("syntax: " + cmd + " [<options>] <raw_image> <uImage>")
     149        print "syntax: " + cmd + " [<options>] <raw_image> <uImage>"
    150150        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)"
    153153        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)"
    158158
    159159if __name__ == '__main__':
  • tools/pack.py

    r60898b6 ra63ff7d  
    4343def usage(prname):
    4444        "Print usage syntax"
    45         print("%s <OBJCOPY> <FORMAT> <ARCH> <ARCH_PATH> [COMPONENTS ...]" % prname)
     45        print "%s <OBJCOPY> <FORMAT> <ARCH> <ARCH_PATH> [COMPONENTS ...]" % prname
    4646
    4747def deflate(data):
     
    110110                symbol = "_binary_%s" % basename.replace(".", "_")
    111111               
    112                 print("%s -> %s" % (component, obj))
     112                print "%s -> %s" % (component, obj)
    113113               
    114                 comp_in = open(component, "rb")
    115                 comp_data = comp_in.read()
     114                comp_in = file(component, "rb")
     115                comp_data = comp_in.read();
    116116                comp_in.close()
    117117               
     
    121121               
    122122                try:
    123                         comp_out = open(basename, "wb")
     123                        comp_out = file(basename, "wb")
    124124                        comp_out.write(comp_deflate)
    125125                        comp_out.close()
     
    151151                cnt += 1
    152152       
    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")
    154154       
    155155        header.write('/***************************************\n')
     
    173173        header.close()
    174174       
    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")
    176176       
    177177        data.write('/***************************************\n')
     
    187187        data.close()
    188188       
    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")
    190190        template = link_in.read()
    191191        link_in.close()
    192192       
    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")
    194194        link_out.write(template.replace("[[COMPONENTS]]", "\n".join(link_ctx)))
    195195        link_out.close()
  • uspace/drv/ns8250/ns8250.c

    r60898b6 ra63ff7d  
    123123static void delete_ns8250_dev_data(ns8250_dev_data_t *data)
    124124{
    125         if (data != NULL)
     125        if (NULL != data)
    126126                free(data);
    127127}
     
    251251static void ns8250_dev_cleanup(device_t *dev)
    252252{
    253         if (dev->driver_data != NULL) {
     253        if (NULL != dev->driver_data) {
    254254                delete_ns8250_dev_data((ns8250_dev_data_t*) dev->driver_data);
    255255                dev->driver_data = NULL;
     
    332332        /* Allocate driver data for the device. */
    333333        ns8250_dev_data_t *data = create_ns8250_dev_data();
    334         if (data == NULL)
     334        if (NULL == data)
    335335                return ENOMEM;
    336336        dev->driver_data = data;
     
    436436        /* Enable interrupt globally. */
    437437        res = interrupt_enable(data->irq);
    438         if (res != EOK)
     438        if (EOK != res)
    439439                return res;
    440440       
     
    480480        uint8_t div_low, div_high;
    481481       
    482         if (baud_rate < 50 || MAX_BAUD_RATE % baud_rate != 0) {
     482        if (50 > baud_rate || 0 != MAX_BAUD_RATE % baud_rate) {
    483483                printf(NAME ": error - somebody tried to set invalid baud rate "
    484484                    "%d\n", baud_rate);
     
    534534 * @param stop_bits     The number of stop bits used (one or two).
    535535 */
    536 static void ns8250_port_get_com_props(ioport8_t *port, unsigned int *parity,
     536static void
     537ns8250_port_get_com_props(ioport8_t *port, unsigned int *parity,
    537538    unsigned int *word_length, unsigned int *stop_bits)
    538539{
     
    571572 *                      is invalid.
    572573 */
    573 static int ns8250_port_set_com_props(ioport8_t *port, unsigned int parity,
     574static int
     575ns8250_port_set_com_props(ioport8_t *port, unsigned int parity,
    574576    unsigned int word_length, unsigned int stop_bits)
    575577{
     
    689691 * @param dev           The serial port device.
    690692 */
    691 static inline void ns8250_interrupt_handler(device_t *dev, ipc_callid_t iid,
    692     ipc_call_t *icall)
     693static inline void
     694ns8250_interrupt_handler(device_t *dev, ipc_callid_t iid, ipc_call_t *icall)
    693695{
    694696        ns8250_read_from_device(dev);
     
    724726 * @param dev           The serial port device.
    725727 */
    726 static int ns8250_add_device(device_t *dev)
     728static int ns8250_add_device(device_t *dev) 
    727729{
    728730        printf(NAME ": ns8250_add_device %s (handle = %d)\n",
     
    730732       
    731733        int res = ns8250_dev_initialize(dev);
    732         if (res != EOK)
     734        if (EOK != res)
    733735                return res;
    734736       
     
    748750       
    749751        /* Register interrupt handler. */
    750         if (ns8250_register_interrupt_handler(dev) != EOK) {
     752        if (EOK != ns8250_register_interrupt_handler(dev)) {
    751753                printf(NAME ": failed to register interrupt handler.\n");
    752754                ns8250_dev_cleanup(dev);
     
    756758        /* Enable interrupt. */
    757759        res = ns8250_interrupt_enable(dev);
    758         if (res != EOK) {
     760        if (EOK != res) {
    759761                printf(NAME ": failed to enable the interrupt. Error code = "
    760762                    "%d.\n", res);
     
    857859 * @param stop_bits     The number of stop bits to be used.
    858860 */
    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)
     861static int
     862ns8250_set_props(device_t *dev, unsigned int baud_rate, unsigned int parity,
     863    unsigned int word_length, unsigned int stop_bits)
    861864{
    862865        printf(NAME ": ns8250_set_props: baud rate %d, parity 0x%x, word "
     
    871874        ns8250_port_interrupts_disable(port);
    872875        ret = ns8250_port_set_baud_rate(port, baud_rate);
    873         if (ret == EOK)
     876        if (EOK == ret)
    874877                ret = ns8250_port_set_com_props(port, parity, word_length, stop_bits);
    875878        ns8250_port_interrupts_enable(port);
     
    884887 * Configure the parameters of the serial communication.
    885888 */
    886 static void ns8250_default_handler(device_t *dev, ipc_callid_t callid,
    887     ipc_call_t *call)
     889static void
     890ns8250_default_handler(device_t *dev, ipc_callid_t callid, ipc_call_t *call)
    888891{
    889892        ipcarg_t method = IPC_GET_METHOD(*call);
  • uspace/drv/pciintel/pci.c

    r60898b6 ra63ff7d  
    6565        pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
    6666       
    67         if (dev_data == NULL)
     67        if (NULL == dev_data)
    6868                return NULL;
    6969        return &dev_data->hw_resources;
     
    109109       
    110110        bus_data = (pci_bus_data_t *) malloc(sizeof(pci_bus_data_t));
    111         if (bus_data != NULL) {
     111        if (NULL != bus_data) {
    112112                memset(bus_data, 0, sizeof(pci_bus_data_t));
    113113                fibril_mutex_initialize(&bus_data->conf_mutex);
    114114        }
    115 
    116115        return bus_data;
    117116}
     
    124123static void pci_conf_read(device_t *dev, int reg, uint8_t *buf, size_t len)
    125124{
    126         assert(dev->parent != NULL);
     125        assert(NULL != dev->parent);
    127126       
    128127        pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
     
    154153static void pci_conf_write(device_t *dev, int reg, uint8_t *buf, size_t len)
    155154{
    156         assert(dev->parent != NULL);
     155        assert(NULL != dev->parent);
    157156       
    158157        pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
     
    225224       
    226225        match_id = create_match_id();
    227         if (match_id != NULL) {
     226        if (NULL != match_id) {
    228227                asprintf(&match_id_str, "pci/ven=%04x&dev=%04x",
    229228                    dev_data->vendor_id, dev_data->device_id);
     
    231230                match_id->score = 90;
    232231                add_match_id(&dev->match_ids, match_id);
    233         }
    234 
     232        }       
    235233        /* TODO add more ids (with subsys ids, using class id etc.) */
    236234}
     
    244242        size_t count = hw_res_list->count;
    245243       
    246         assert(hw_resources != NULL);
     244        assert(NULL != hw_resources);
    247245        assert(count < PCI_MAX_HW_RES);
    248246       
     
    277275        bool io;
    278276        /* 64-bit wide address */
    279         bool addrw64;
     277        bool w64;
    280278       
    281279        /* Size of the io or memory range specified by the BAR */
     
    289287        io = (bool) (val & 1);
    290288        if (io) {
    291                 addrw64 = false;
     289                w64 = false;
    292290        } else {
    293291                switch ((val >> 1) & 3) {
    294292                case 0:
    295                         addrw64 = false;
     293                        w64 = false;
    296294                        break;
    297295                case 2:
    298                         addrw64 = true;
     296                        w64 = true;
    299297                        break;
    300298                default:
     
    314312        range_size = pci_bar_mask_to_size(mask);
    315313       
    316         if (addrw64) {
     314        if (w64) {
    317315                range_addr = ((uint64_t)pci_conf_read_32(dev, addr + 4) << 32) |
    318316                    (val & 0xfffffff0);
     
    321319        }
    322320       
    323         if (range_addr != 0) {
     321        if (0 != range_addr) {
    324322                printf(NAME ": device %s : ", dev->name);
    325323                printf("address = %x", range_addr);
     
    329327        pci_add_range(dev, range_addr, range_size, io);
    330328       
    331         if (addrw64)
     329        if (w64)
    332330                return addr + 8;
    333331       
     
    356354{
    357355        uint8_t irq = pci_conf_read_8(dev, PCI_BRIDGE_INT_LINE);
    358         if (irq != 0xff)
     356        if (0xff != irq)
    359357                pci_add_interrupt(dev, irq);
    360358}
     
    417415                        create_pci_match_ids(dev);
    418416                       
    419                         if (child_device_register(dev, parent) != EOK) {
     417                        if (EOK != child_device_register(dev, parent)) {
    420418                                pci_clean_resource_list(dev);
    421419                                clean_match_ids(&dev->match_ids);
     
    426424                       
    427425                        if (header_type == PCI_HEADER_TYPE_BRIDGE ||
    428                             header_type == PCI_HEADER_TYPE_CARDBUS) {
     426                            header_type == PCI_HEADER_TYPE_CARDBUS ) {
    429427                                child_bus = pci_conf_read_8(dev,
    430428                                    PCI_BRIDGE_SEC_BUS_NUM);
    431429                                printf(NAME ": device is pci-to-pci bridge, "
    432430                                    "secondary bus number = %d.\n", bus_num);
    433                                 if (child_bus > bus_num)
     431                                if(child_bus > bus_num)
    434432                                        pci_bus_scan(parent, child_bus);
    435433                        }
     
    455453       
    456454        pci_bus_data_t *bus_data = create_pci_bus_data();
    457         if (bus_data == NULL) {
     455        if (NULL == bus_data) {
    458456                printf(NAME ": pci_add_device allocation failed.\n");
    459457                return ENOMEM;
     
    515513}
    516514
    517 pci_dev_data_t *create_pci_dev_data(void)
    518 {
    519         pci_dev_data_t *res = (pci_dev_data_t *) malloc(sizeof(pci_dev_data_t));
    520        
    521         if (res != NULL)
    522                 memset(res, 0, sizeof(pci_dev_data_t));
    523         return res;
    524 }
    525 
    526 void init_pci_dev_data(pci_dev_data_t *dev_data, int bus, int dev, int fn)
    527 {
    528         dev_data->bus = bus;
    529         dev_data->dev = dev;
    530         dev_data->fn = fn;
    531 }
    532 
    533 void delete_pci_dev_data(pci_dev_data_t *dev_data)
    534 {
    535         if (dev_data != NULL) {
    536                 clean_hw_resource_list(&dev_data->hw_resources);
    537                 free(dev_data);
    538         }
    539 }
    540 
    541 void create_pci_dev_name(device_t *dev)
    542 {
    543         pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
    544         char *name = NULL;
    545        
    546         asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev,
    547             dev_data->fn);
    548         dev->name = name;
    549 }
    550 
    551 bool pci_alloc_resource_list(device_t *dev)
    552 {
    553         pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
    554        
    555         dev_data->hw_resources.resources =
    556             (hw_resource_t *) malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t));
    557         return dev_data->hw_resources.resources != NULL;
    558 }
    559 
    560 void pci_clean_resource_list(device_t *dev)
    561 {
    562         pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
    563        
    564         if (dev_data->hw_resources.resources != NULL) {
    565                 free(dev_data->hw_resources.resources);
    566                 dev_data->hw_resources.resources = NULL;
    567         }
    568 }
    569 
    570 /** Read the base address registers (BARs) of the device and adds the addresses
    571  * to its hw resource list.
    572  *
    573  * @param dev the pci device.
    574  */
    575 void pci_read_bars(device_t *dev)
    576 {
    577         /*
    578          * Position of the BAR in the PCI configuration address space of the
    579          * device.
    580          */
    581         int addr = PCI_BASE_ADDR_0;
    582        
    583         while (addr <= PCI_BASE_ADDR_5)
    584                 addr = pci_read_bar(dev, addr);
    585 }
    586 
    587 size_t pci_bar_mask_to_size(uint32_t mask)
    588 {
    589         return ((mask & 0xfffffff0) ^ 0xffffffff) + 1;
    590 }
    591 
    592515int main(int argc, char *argv[])
    593516{
  • uspace/drv/pciintel/pci.h

    r60898b6 ra63ff7d  
    6969extern void pci_bus_scan(device_t *, int);
    7070
    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 *);
     71static 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}
    7579
    76 extern bool pci_alloc_resource_list(device_t *);
    77 extern void pci_clean_resource_list(device_t *);
     80static inline void
     81init_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}
    7887
    79 extern void pci_read_bars(device_t *);
    80 extern size_t pci_bar_mask_to_size(uint32_t);
     88static 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
     96static 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
     106static 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
     115static 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 */
     130static 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
     142static inline size_t pci_bar_mask_to_size(uint32_t mask)
     143{
     144        return ((mask & 0xfffffff0) ^ 0xffffffff) + 1;
     145}
    81146
    82147#endif
  • uspace/lib/c/arch/abs32le/include/fibril.h

    r60898b6 ra63ff7d  
    4444                (ctx)->pc = (uintptr_t) (_pc); \
    4545                (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \
    46                 (ctx)->fp = 0; \
    4746                (ctx)->tls = ((uintptr_t) (ptls)) + sizeof(tcb_t); \
    4847        } while (0)
     
    5453typedef struct {
    5554        uintptr_t sp;
    56         uintptr_t fp;
    5755        uintptr_t pc;
    5856        uintptr_t tls;
    5957} 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 }
    6658
    6759#endif
  • uspace/lib/c/arch/abs32le/include/istate.h

    r60898b6 ra63ff7d  
    3636#define LIBC_abs32le__ISTATE_H_
    3737
    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 */
     45typedef struct istate {
     46        uintptr_t ip;
     47        uintptr_t fp;
     48        uint32_t stack[];
     49} istate_t;
     50
     51static inline uintptr_t istate_get_pc(istate_t *istate)
     52{
     53        return istate->ip;
     54}
     55
     56static inline uintptr_t istate_get_fp(istate_t *istate)
     57{
     58        return istate->fp;
     59}
    3960
    4061#endif
  • uspace/lib/c/arch/amd64/include/fibril.h

    r60898b6 ra63ff7d  
    5656 */
    5757typedef 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;
    6063
    61         uint64_t rbx;
    62         uint64_t rbp;
     64    uint64_t r12;
     65    uint64_t r13;
     66    uint64_t r14;
     67    uint64_t r15;
    6368
    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;
    7070} context_t;
    71 
    72 static inline uintptr_t context_get_fp(context_t *ctx)
    73 {
    74         return ctx->rbp;
    75 }
    7671
    7772#endif
  • uspace/lib/c/arch/amd64/include/istate.h

    r60898b6 ra63ff7d  
    3636#define LIBC_amd64_ISTATE_H_
    3737
    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 */
     44typedef 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
     62static inline uintptr_t istate_get_pc(istate_t *istate)
     63{
     64        return istate->rip;
     65}
     66
     67static inline uintptr_t istate_get_fp(istate_t *istate)
     68{
     69        return istate->rbp;
     70}
    3971
    4072#endif
  • uspace/lib/c/arch/amd64/src/entry.s

    r60898b6 ra63ff7d  
    4242        #
    4343        pushq $0
    44         movq %rsp, %rbp
     44        mov %rsp, %rbp
    4545       
    4646        # %rdi was deliberately chosen as the first argument is also in %rdi
  • uspace/lib/c/arch/amd64/src/fibril.S

    r60898b6 ra63ff7d  
    4949        movq %rax, OFFSET_TLS(%rdi)
    5050               
    51         xorl %eax, %eax         # context_save returns 1
    52         incl %eax
     51        xorq %rax,%rax          # context_save returns 1
     52        incq %rax
    5353        ret
    5454
     
    6767        # Set thread local storage
    6868        movq OFFSET_TLS(%rdi), %rdi   # Set arg1 to TLS addr
    69         movl $1, %eax           # SYS_TLS_SET
     69        movq $1, %rax           # SYS_TLS_SET
    7070        syscall
    7171
    72         xorl %eax, %eax         # context_restore returns 0
     72        xorq %rax,%rax          # context_restore returns 0
    7373        ret
  • uspace/lib/c/arch/arm32/include/fibril.h

    r60898b6 ra63ff7d  
    8686} context_t;
    8787
    88 static inline uintptr_t context_get_fp(context_t *ctx)
    89 {
    90         return ctx->fp;
    91 }
    92 
    9388
    9489#endif
  • uspace/lib/c/arch/arm32/include/istate.h

    r60898b6 ra63ff7d  
    3636#define LIBC_arm32__ISTATE_H_
    3737
    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 */
     44typedef 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
     66static inline uintptr_t istate_get_pc(istate_t *istate)
     67{
     68        return istate->pc;
     69}
     70
     71static inline uintptr_t istate_get_fp(istate_t *istate)
     72{
     73        return istate->fp;
     74}
    3975
    4076#endif
  • uspace/lib/c/arch/ia32/include/fibril.h

    r60898b6 ra63ff7d  
    6767} context_t;
    6868
    69 static inline uintptr_t context_get_fp(context_t *ctx)
    70 {
    71         return ctx->ebp;
    72 }
    73 
    7469#endif
    7570
  • uspace/lib/c/arch/ia32/include/istate.h

    r60898b6 ra63ff7d  
    3636#define LIBC_ia32__ISTATE_H_
    3737
    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 */
     44typedef 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
     62static inline uintptr_t istate_get_pc(istate_t *istate)
     63{
     64        return istate->eip;
     65}
     66
     67static inline uintptr_t istate_get_fp(istate_t *istate)
     68{
     69        return istate->ebp;
     70}
    3971
    4072#endif
  • uspace/lib/c/arch/ia64/include/fibril.h

    r60898b6 ra63ff7d  
    130130} context_t;
    131131
    132 static inline uintptr_t context_get_fp(context_t *ctx)
    133 {
    134         return 0;       /* FIXME */
    135 }
    136 
    137132#endif
    138133
  • uspace/lib/c/arch/ia64/include/istate.h

    r60898b6 ra63ff7d  
    3636#define LIBC_ia64_ISTATE_H_
    3737
    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 */
     44typedef struct istate {
     45        /* TODO */
     46} istate_t;
     47
     48static inline uintptr_t istate_get_pc(istate_t *istate)
     49{
     50        /* TODO */
     51        return 0;
     52}
     53
     54static inline uintptr_t istate_get_fp(istate_t *istate)
     55{
     56        /* TODO */
     57        return 0;
     58}
    3959
    4060#endif
  • uspace/lib/c/arch/mips32/include/fibril.h

    r60898b6 ra63ff7d  
    8585} context_t;
    8686
    87 static inline uintptr_t context_get_fp(context_t *ctx)
    88 {
    89         return ctx->sp;
    90 }
    91 
    9287#endif
    9388
  • uspace/lib/c/arch/mips32/include/istate.h

    r60898b6 ra63ff7d  
    3636#define LIBC_mips32__ISTATE_H_
    3737
    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 */
     44typedef 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
     74static inline uintptr_t istate_get_pc(istate_t *istate)
     75{
     76        return istate->epc;
     77}
     78
     79static inline uintptr_t istate_get_fp(istate_t *istate)
     80{
     81        /* TODO */
     82        return 0;
     83}
    3984
    4085#endif
  • uspace/lib/c/arch/ppc32/include/fibril.h

    r60898b6 ra63ff7d  
    7878} __attribute__ ((packed)) context_t;
    7979
    80 static inline uintptr_t context_get_fp(context_t *ctx)
    81 {
    82         return ctx->sp;
    83 }
    84 
    8580#endif
    8681
  • uspace/lib/c/arch/sparc64/include/fibril.h

    r60898b6 ra63ff7d  
    7777} context_t;
    7878
    79 static inline uintptr_t context_get_fp(context_t *ctx)
    80 {
    81         return ctx->sp + STACK_BIAS;
    82 }
    83 
    8479#endif
    8580
  • uspace/lib/c/arch/sparc64/include/istate.h

    r60898b6 ra63ff7d  
    3636#define LIBC_sparc64_ISTATE_H_
    3737
    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 */
     44typedef struct istate {
     45        /* TODO */
     46} istate_t;
     47
     48static inline uintptr_t istate_get_pc(istate_t *istate)
     49{
     50        /* TODO */
     51        return 0;
     52}
     53
     54static inline uintptr_t istate_get_fp(istate_t *istate)
     55{
     56        /* TODO */
     57        return 0;
     58}
    3959
    4060#endif
  • uspace/lib/c/generic/fibril.c

    r60898b6 ra63ff7d  
    275275        fibril->func = func;
    276276        fibril->arg = arg;
    277 
    278         fibril->waits_for = NULL;
    279277       
    280278        context_save(&fibril->ctx);
  • uspace/lib/c/generic/fibril_synch.c

    r60898b6 ra63ff7d  
    4242#include <errno.h>
    4343#include <assert.h>
    44 #include <stacktrace.h>
    45 #include <stdlib.h>
    4644
    4745static void optimize_execution_power(void)
     
    5856}
    5957
    60 static void print_deadlock(fibril_owner_info_t *oi)
    61 {
    62         fibril_t *f = (fibril_t *) fibril_get_id();
    63 
    64         printf("Deadlock detected.\n");
    65         stacktrace_print();
    66 
    67         printf("Fibril %p waits for primitive %p.\n", f, oi);
    68 
    69         while (oi && oi->owned_by) {
    70                 printf("Primitive %p is owned by fibril %p.\n",
    71                     oi, oi->owned_by);
    72                 if (oi->owned_by == f)
    73                         break;
    74                 stacktrace_print_fp_pc(context_get_fp(&oi->owned_by->ctx),
    75                     oi->owned_by->ctx.pc);
    76                 printf("Fibril %p waits for primitive %p.\n",
    77                      oi->owned_by, oi->owned_by->waits_for);
    78                 oi = oi->owned_by->waits_for;
    79         }
    80 }
    81 
    82 
    83 static void check_for_deadlock(fibril_owner_info_t *oi)
    84 {
    85         while (oi && oi->owned_by) {
    86                 if (oi->owned_by == (fibril_t *) fibril_get_id()) {
    87                         print_deadlock(oi);
    88                         abort();
    89                 }
    90                 oi = oi->owned_by->waits_for;
    91         }
    92 }
    93 
    94 
    9558void fibril_mutex_initialize(fibril_mutex_t *fm)
    9659{
    97         fm->oi.owned_by = NULL;
    9860        fm->counter = 1;
    9961        list_initialize(&fm->waiters);
     
    10264void fibril_mutex_lock(fibril_mutex_t *fm)
    10365{
    104         fibril_t *f = (fibril_t *) fibril_get_id();
    105 
    10666        futex_down(&async_futex);
    10767        if (fm->counter-- <= 0) {
     
    11373                link_initialize(&wdata.wu_event.link);
    11474                list_append(&wdata.wu_event.link, &fm->waiters);
    115                 check_for_deadlock(&fm->oi);
    116                 f->waits_for = &fm->oi;
    11775                fibril_switch(FIBRIL_TO_MANAGER);
    11876        } else {
    119                 fm->oi.owned_by = f;
    12077                futex_up(&async_futex);
    12178        }
     
    12986        if (fm->counter > 0) {
    13087                fm->counter--;
    131                 fm->oi.owned_by = (fibril_t *) fibril_get_id();
    13288                locked = true;
    13389        }
     
    14399                link_t *tmp;
    144100                awaiter_t *wdp;
    145                 fibril_t *f;
    146101       
    147102                assert(!list_empty(&fm->waiters));
     
    150105                wdp->active = true;
    151106                wdp->wu_event.inlist = false;
    152 
    153                 f = (fibril_t *) wdp->fid;
    154                 fm->oi.owned_by = f;
    155                 f->waits_for = NULL;
    156 
    157107                list_remove(&wdp->wu_event.link);
    158108                fibril_add_ready(wdp->fid);
    159109                optimize_execution_power();
    160         } else {
    161                 fm->oi.owned_by = NULL;
    162110        }
    163111}
     
    172120void fibril_rwlock_initialize(fibril_rwlock_t *frw)
    173121{
    174         frw->oi.owned_by = NULL;
    175122        frw->writers = 0;
    176123        frw->readers = 0;
     
    191138                f->flags &= ~FIBRIL_WRITER;
    192139                list_append(&wdata.wu_event.link, &frw->waiters);
    193                 check_for_deadlock(&frw->oi);
    194                 f->waits_for = &frw->oi;
    195140                fibril_switch(FIBRIL_TO_MANAGER);
    196141        } else {
     
    202147void fibril_rwlock_write_lock(fibril_rwlock_t *frw)
    203148{
    204         fibril_t *f = (fibril_t *) fibril_get_id();
    205        
    206149        futex_down(&async_futex);
    207150        if (frw->writers || frw->readers) {
     151                fibril_t *f = (fibril_t *) fibril_get_id();
    208152                awaiter_t wdata;
    209153
     
    214158                f->flags |= FIBRIL_WRITER;
    215159                list_append(&wdata.wu_event.link, &frw->waiters);
    216                 check_for_deadlock(&frw->oi);
    217                 f->waits_for = &frw->oi;
    218160                fibril_switch(FIBRIL_TO_MANAGER);
    219161        } else {
    220                 frw->oi.owned_by = f;
    221162                frw->writers++;
    222163                futex_up(&async_futex);
     
    236177       
    237178        assert(!frw->readers && !frw->writers);
    238        
    239         frw->oi.owned_by = NULL;
    240179       
    241180        while (!list_empty(&frw->waiters)) {
     
    246185                wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
    247186                f = (fibril_t *) wdp->fid;
    248                
    249                 f->waits_for = NULL;
    250187               
    251188                if (f->flags & FIBRIL_WRITER) {
     
    257194                        fibril_add_ready(wdp->fid);
    258195                        frw->writers++;
    259                         frw->oi.owned_by = f;
    260196                        optimize_execution_power();
    261197                        break;
  • uspace/lib/c/include/fibril.h

    r60898b6 ra63ff7d  
    4848#define FIBRIL_WRITER      2
    4949
    50 struct fibril;
    51 
    52 typedef struct {
    53         struct fibril *owned_by;
    54 } fibril_owner_info_t;
    55 
    5650typedef enum {
    5751        FIBRIL_PREEMPT,
     
    7468        int retval;
    7569        int flags;
    76 
    77         fibril_owner_info_t *waits_for;
    7870} fibril_t;
    7971
  • uspace/lib/c/include/fibril_synch.h

    r60898b6 ra63ff7d  
    4343
    4444typedef struct {
    45         fibril_owner_info_t oi;         /* Keep this the first thing. */
    4645        int counter;
    4746        link_t waiters;
     
    5049#define FIBRIL_MUTEX_INITIALIZER(name) \
    5150        { \
    52                 .oi = { \
    53                         .owned_by = NULL \
    54                 }, \
    5551                .counter = 1, \
    5652                .waiters = { \
     
    6460
    6561typedef struct {
    66         fibril_owner_info_t oi; /* Keep this the first thing. */
    6762        unsigned writers;
    6863        unsigned readers;
     
    7267#define FIBRIL_RWLOCK_INITIALIZER(name) \
    7368        { \
    74                 .oi = { \
    75                         .owned_by = NULL \
    76                 }, \
    7769                .readers = 0, \
    7870                .writers = 0, \
  • uspace/srv/devman/devman.c

    r60898b6 ra63ff7d  
    7676        .remove_callback = devices_remove_callback
    7777};
    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 }
    9278
    9379/** Allocate and initialize a new driver structure.
     
    562548}
    563549
    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 }
    605550
    606551/** Create devmap path and name for the device. */
     
    740685}
    741686
    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 
    811687/** Create and set device's full path in device tree.
    812688 *
     
    949825        return NULL;
    950826}
    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 
    998827
    999828/** Create unique device name within the class.
     
    1092921}
    1093922
    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 
    1099923void init_class_list(class_list_t *class_list)
    1100924{
     
    1106930
    1107931
    1108 /* Devmap devices */
     932/* devmap devices */
    1109933
    1110934node_t *find_devmap_tree_device(dev_tree_t *tree, dev_handle_t devmap_handle)
     
    1143967}
    1144968
    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 
    1162969/** @}
    1163970 */
  • uspace/srv/devman/devman.h

    r60898b6 ra63ff7d  
    283283/* Drivers */
    284284
    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 */
     291static 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
    286299extern driver_t *create_driver(void);
    287300extern bool get_driver_info(const char *, const char *, driver_t *);
     
    298311extern driver_t *find_driver(driver_list_t *, const char *);
    299312extern 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 *);
     313void initialize_running_driver(driver_t *, dev_tree_t *);
     314
     315/** Initialize device driver structure.
     316 *
     317 * @param drv           The device driver structure.
     318 */
     319static 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 */
     333static 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 */
     349static inline void delete_driver(driver_t *drv)
     350{
     351        assert(drv != NULL);
     352       
     353        clean_driver(drv);
     354        free(drv);
     355}
     356
    305357
    306358/* Device nodes */
    307359
    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 */
     364static 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 */
     382static 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 */
     402static 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 */
     416static 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
    313427extern node_t *find_dev_node_by_path(dev_tree_t *, char *);
    314428extern node_t *find_node_child(node_t *, const char *);
     429
    315430
    316431/* Device tree */
     
    320435extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *);
    321436
     437
    322438/* Device classes */
    323439
    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 */
     444static 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 */
     462static 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
     473static 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
    327484extern char *create_dev_name_for_class(dev_class_t *, const char *);
    328485extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *,
     
    333490extern dev_class_t *get_dev_class(class_list_t *, char *);
    334491extern 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
     493static 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
    336499
    337500/* Devmap devices */
     
    340503extern node_t *find_devmap_class_device(class_list_t *, dev_handle_t);
    341504
    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 *);
     505static 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
     515static 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}
    344522
    345523#endif
  • uspace/srv/devman/main.c

    r60898b6 ra63ff7d  
    6666static driver_t *devman_driver_register(void)
    6767{
     68        printf(NAME ": devman_driver_register \n");
     69       
    6870        ipc_call_t icall;
    69         ipc_callid_t iid;
     71        ipc_callid_t iid = async_get_call(&icall);
    7072        driver_t *driver = NULL;
    71 
    72         printf(NAME ": devman_driver_register \n");
    73        
    74         iid = async_get_call(&icall);
     73       
    7574        if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) {
    7675                ipc_answer_0(iid, EREFUSED);
     
    8685                return NULL;
    8786        }
    88 
    8987        printf(NAME ": the %s driver is trying to register by the service.\n",
    9088            drv_name);
     
    9391        driver = find_driver(&drivers_list, drv_name);
    9492       
    95         if (driver == NULL) {
     93        if (NULL == driver) {
    9694                printf(NAME ": no driver named %s was found.\n", drv_name);
    9795                free(drv_name);
     
    148146        }
    149147       
    150         if (match_id == NULL) {
     148        if (NULL == match_id) {
    151149                printf(NAME ": ERROR: devman_receive_match_id - failed to "
    152150                    "allocate match id.\n");
     
    162160        rc = async_data_write_accept((void **) &match_id_str, true, 0, 0, 0, 0);
    163161        match_id->id = match_id_str;
    164         if (rc != EOK) {
     162        if (EOK != rc) {
    165163                delete_match_id(match_id);
    166164                printf(NAME ": devman_receive_match_id - failed to receive "
     
    183181 * @return              Zero on success, negative error code otherwise.
    184182 */
    185 static int devman_receive_match_ids(ipcarg_t match_count,
    186     match_id_list_t *match_ids)
     183static int
     184devman_receive_match_ids(ipcarg_t match_count, match_id_list_t *match_ids)
    187185{
    188186        int ret = EOK;
     
    207205       
    208206        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) {
    212210                fibril_rwlock_write_unlock(&tree->rwlock);
    213211                ipc_answer_0(callid, ENOENT);
    214212                return;
    215         }
     213        }       
    216214       
    217215        char *dev_name = NULL;
    218216        int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
    219         if (rc != EOK) {
     217        if (EOK != rc) {
    220218                fibril_rwlock_write_unlock(&tree->rwlock);
    221219                ipc_answer_0(callid, rc);
     
    229227                ipc_answer_0(callid, ENOMEM);
    230228                return;
    231         }
    232 
     229        }       
    233230        fibril_rwlock_write_unlock(&tree->rwlock);
    234231       
     
    248245        /* Create devmap path and name for the device. */
    249246        char *devmap_pathname = NULL;
    250 
    251247        asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE,
    252248            cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name);
    253         if (devmap_pathname == NULL)
     249        if (NULL == devmap_pathname)
    254250                return;
    255251       
     
    283279       
    284280        node_t *dev = find_dev_node(&device_tree, handle);
    285         if (dev == NULL) {
     281        if (NULL == dev) {
    286282                ipc_answer_0(callid, ENOENT);
    287283                return;
     
    322318       
    323319        driver_t *driver = devman_driver_register();
    324         if (driver == NULL)
     320        if (NULL == driver)
    325321                return;
    326322       
     
    377373        free(pathname);
    378374
    379         if (dev == NULL) {
     375        if (NULL == dev) {
    380376                ipc_answer_0(iid, ENOENT);
    381377                return;
     
    408404                                ipc_answer_0(callid, ENOENT);
    409405                }
    410         }
    411 }
    412 
    413 static void devman_forward(ipc_callid_t iid, ipc_call_t *icall,
    414     bool drv_to_parent)
     406        }       
     407}
     408
     409static void
     410devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent)
    415411{
    416412        device_handle_t handle = IPC_GET_ARG2(*icall);
    417413       
    418414        node_t *dev = find_dev_node(&device_tree, handle);
    419         if (dev == NULL) {
     415        if (NULL == dev) {
    420416                printf(NAME ": devman_forward error - no device with handle %x "
    421417                    "was found.\n", handle);
     
    427423       
    428424        if (drv_to_parent) {
    429                 if (dev->parent != NULL)
     425                if (NULL != dev->parent)
    430426                        driver = dev->parent->drv;
    431         } else if (dev->state == DEVICE_USABLE) {
     427        } else if (DEVICE_USABLE == dev->state) {
    432428                driver = dev->drv;
    433                 assert(driver != NULL);
    434         }
    435        
    436         if (driver == NULL) {
     429                assert(NULL != driver);
     430        }
     431       
     432        if (NULL == driver) {
    437433                printf(NAME ": devman_forward error - the device is not in "
    438434                    "usable state.\n", handle);
     
    454450                return;
    455451        }
    456 
    457452        printf(NAME ": devman_forward: forward connection to device %s to "
    458453            "driver %s.\n", dev->pathname, driver->name);
     
    465460{
    466461        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)
    471465                dev = find_devmap_class_device(&class_list, devmap_handle);
    472466       
    473         if (dev == NULL || dev->drv == NULL) {
     467        if (NULL == dev || NULL == dev->drv) {
    474468                ipc_answer_0(iid, ENOENT);
    475469                return;
    476470        }
    477471       
    478         if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
     472        if (DEVICE_USABLE != dev->state || dev->drv->phone <= 0) {
    479473                ipc_answer_0(iid, EINVAL);
    480474                return;
     
    499493         * passes device handle to the driver as an ipc method.)
    500494         */
    501         if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO)
     495        if (IPC_M_CONNECT_ME_TO != IPC_GET_METHOD(*icall))
    502496                devman_connection_devmapper(iid, icall);
    503497
     
    537531        /* Initialize list of available drivers. */
    538532        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)) {
    541535                printf(NAME " no drivers found.");
    542536                return false;
    543537        }
    544 
    545538        printf(NAME ": devman_init  - list of drivers has been initialized.\n");
    546539
  • uspace/srv/devman/match.c

    r60898b6 ra63ff7d  
    5555                match_id_t *tmp_ma_id;
    5656       
    57                 if (str_cmp(drv_id->id, dev_id->id) == 0) {
     57                if (0 == str_cmp(drv_id->id, dev_id->id)) {
    5858                        /*
    5959                         * We found a match.
     
    6767                 * list of match ids.
    6868                 */
    69                 if (drv_link->next != drv_head) {
     69                if (drv_head != drv_link->next) {
    7070                        tmp_ma_id = list_get_instance(drv_link->next,
    7171                            match_id_t, link);
     
    7979                 * list of match ids.
    8080                 */
    81                 if (dev_link->next != dev_head) {
     81                if (dev_head != dev_link->next) {
    8282                        tmp_ma_id = list_get_instance(dev_link->next,
    8383                            match_id_t, link);
     
    9999                }
    100100               
    101         } while (drv_link->next != drv_head && dev_link->next != dev_head);
     101        } while (drv_head != drv_link->next && dev_head != dev_link->next);
    102102       
    103103        return 0;
  • uspace/srv/devman/util.c

    r60898b6 ra63ff7d  
    6161char *get_path_elem_end(char *path)
    6262{
    63         while (*path != '\0' && *path != '/')
     63        while (0 != *path && '/' != *path)
    6464                path++;
    6565        return path;
    6666}
    6767
    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 
    11368/** @}
    11469 */
  • uspace/srv/devman/util.h

    r60898b6 ra63ff7d  
    4141extern char *get_path_elem_end(char *);
    4242
    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);
     43static inline bool skip_spaces(char **buf)
     44{
     45        while (isspace(**buf))
     46                (*buf)++;
     47        return *buf != 0;
     48}
     49
     50static 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
     61static inline void free_not_null(const void *ptr)
     62{
     63        if (NULL != ptr)
     64                free(ptr);
     65}
     66
     67static 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
     78static 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}
    4886
    4987#endif
Note: See TracChangeset for help on using the changeset viewer.