Changes in / [b00dbb9:9ca0013] in mainline


Ignore:
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/mips32/include/arch.h

    rb00dbb9 r9ca0013  
    4040
    4141#define MSIM_VIDEORAM_ADDRESS  0xb0000000
    42 #define MSIM_DORDER_ADDRESS    0xb0000100
     42#define MSIM_DORDER_ADDRESS    0xb0000004
    4343
    4444#ifndef __ASM__
  • contrib/conf/msim.conf

    rb00dbb9 r9ca0013  
    1616add dprinter printer 0x10000000
    1717add dkeyboard keyboard 0x10000000 2
    18 add dorder order 0x10000100 5
     18add dorder order 0x10000004 5
  • kernel/arch/mips32/src/exception.c

    rb00dbb9 r9ca0013  
    7474void istate_decode(istate_t *istate)
    7575{
    76         printf("epc=%p\tsta=%#010" PRIx32 "\t"
    77             "lo =%#010" PRIx32 "\thi =%#010" PRIx32 "\n",
     76        printf("epc=%p\tsta=%#0" PRIx32 "\t"
     77            "lo =%#0" PRIx32 "\thi =%#0" PRIx32 "\n",
    7878            (void *) istate->epc, istate->status,
    7979            istate->lo, istate->hi);
    8080       
    81         printf("a0 =%#010" PRIx32 "\ta1 =%#010" PRIx32 "\t"
    82             "a2 =%#010" PRIx32 "\ta3 =%#010" PRIx32 "\n",
     81        printf("a0 =%#0" PRIx32 "\ta1 =%#0" PRIx32 "\t"
     82            "a2 =%#0" PRIx32 "\ta3 =%#0" PRIx32 "\n",
    8383            istate->a0, istate->a1, istate->a2, istate->a3);
    8484       
    85         printf("t0 =%#010" PRIx32 "\tt1 =%#010" PRIx32 "\t"
    86             "t2 =%#010" PRIx32 "\tt3 =%#010" PRIx32 "\n",
     85        printf("t0 =%#0" PRIx32 "\tt1 =%#0" PRIx32 "\t"
     86            "t2 =%#0" PRIx32 "\tt3 =%#0" PRIx32 "\n",
    8787            istate->t0, istate->t1, istate->t2, istate->t3);
    8888       
    89         printf("t4 =%#010" PRIx32 "\tt5 =%#010" PRIx32 "\t"
    90             "t6 =%#010" PRIx32 "\tt7 =%#010" PRIx32 "\n",
     89        printf("t4 =%#0" PRIx32 "\tt5 =%#0" PRIx32 "\t"
     90            "t6 =%#0" PRIx32 "\tt7 =%#0" PRIx32 "\n",
    9191            istate->t4, istate->t5, istate->t6, istate->t7);
    9292       
    93         printf("t8 =%#010" PRIx32 "\tt9 =%#010" PRIx32 "\t"
    94             "v0 =%#010" PRIx32 "\tv1 =%#010" PRIx32 "\n",
     93        printf("t8 =%#0" PRIx32 "\tt9 =%#0" PRIx32 "\t"
     94            "v0 =%#0" PRIx32 "\tv1 =%#0" PRIx32 "\n",
    9595            istate->t8, istate->t9, istate->v0, istate->v1);
    9696       
    97         printf("s0 =%#010" PRIx32 "\ts1 =%#010" PRIx32 "\t"
    98             "s2 =%#010" PRIx32 "\ts3 =%#010" PRIx32 "\n",
     97        printf("s0 =%#0" PRIx32 "\ts1 =%#0" PRIx32 "\t"
     98            "s2 =%#0" PRIx32 "\ts3 =%#0" PRIx32 "\n",
    9999            istate->s0, istate->s1, istate->s2, istate->s3);
    100100       
    101         printf("s4 =%#010" PRIx32 "\ts5 =%#010" PRIx32 "\t"
    102             "s6 =%#010" PRIx32 "\ts7 =%#010" PRIx32 "\n",
     101        printf("s4 =%#0" PRIx32 "\ts5 =%#0" PRIx32 "\t"
     102            "s6 =%#0" PRIx32 "\ts7 =%#0" PRIx32 "\n",
    103103            istate->s4, istate->s5, istate->s6, istate->s7);
    104104       
    105         printf("s8 =%#010" PRIx32 "\tat =%#010" PRIx32 "\t"
    106             "kt0=%#010" PRIx32 "\tkt1=%#010" PRIx32 "\n",
     105        printf("s8 =%#0" PRIx32 "\tat =%#0" PRIx32 "\t"
     106            "kt0=%#0" PRIx32 "\tkt1=%#0" PRIx32 "\n",
    107107            istate->s8, istate->at, istate->kt0, istate->kt1);
    108108       
  • kernel/arch/mips32/src/smp/dorder.c

    rb00dbb9 r9ca0013  
    3737#include <arch/smp/dorder.h>
    3838
    39 #define MSIM_DORDER_ADDRESS  0xB0000100
     39#define MSIM_DORDER_ADDRESS  0xB0000004
    4040
    4141#ifdef CONFIG_SMP
  • tools/config.py

    rb00dbb9 r9ca0013  
    33# Copyright (c) 2006 Ondrej Palkovsky
    44# Copyright (c) 2009 Martin Decky
    5 # Copyright (c) 2010 Jiri Svoboda
    65# All rights reserved.
    76#
     
    4140import xtui
    4241
    43 RULES_FILE = sys.argv[1]
     42INPUT = sys.argv[1]
    4443MAKEFILE = 'Makefile.config'
    4544MACROS = 'config.h'
    46 PRESETS_DIR = 'defaults'
    47 
    48 def read_config(fname, config):
     45PRECONF = 'defaults'
     46
     47def read_defaults(fname, defaults):
    4948        "Read saved values from last configuration run"
    5049       
     
    5352        for line in inf:
    5453                res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
    55                 if res:
    56                         config[res.group(1)] = res.group(2)
     54                if (res):
     55                        defaults[res.group(1)] = res.group(2)
    5756       
    5857        inf.close()
    5958
    60 def check_condition(text, config, rules):
     59def check_condition(text, defaults, ask_names):
    6160        "Check that the condition specified on input line is True (only CNF and DNF is supported)"
    6261       
    6362        ctype = 'cnf'
    6463       
    65         if (')|' in text) or ('|(' in text):
     64        if ((')|' in text) or ('|(' in text)):
    6665                ctype = 'dnf'
    6766       
    68         if ctype == 'cnf':
     67        if (ctype == 'cnf'):
    6968                conds = text.split('&')
    7069        else:
     
    7271       
    7372        for cond in conds:
    74                 if cond.startswith('(') and cond.endswith(')'):
     73                if (cond.startswith('(')) and (cond.endswith(')')):
    7574                        cond = cond[1:-1]
    7675               
    77                 inside = check_inside(cond, config, ctype)
     76                inside = check_inside(cond, defaults, ctype)
    7877               
    7978                if (ctype == 'cnf') and (not inside):
    8079                        return False
    8180               
    82                 if (ctype == 'dnf') and inside:
     81                if (ctype == 'dnf') and (inside):
    8382                        return True
    8483       
    85         if ctype == 'cnf':
     84        if (ctype == 'cnf'):
    8685                return True
    8786        return False
    8887
    89 def check_inside(text, config, ctype):
     88def check_inside(text, defaults, ctype):
    9089        "Check for condition"
    9190       
    92         if ctype == 'cnf':
     91        if (ctype == 'cnf'):
    9392                conds = text.split('|')
    9493        else:
     
    9796        for cond in conds:
    9897                res = re.match(r'^(.*?)(!?=)(.*)$', cond)
    99                 if not res:
     98                if (not res):
    10099                        raise RuntimeError("Invalid condition: %s" % cond)
    101100               
     
    104103                condval = res.group(3)
    105104               
    106                 if not condname in config:
     105                if (not condname in defaults):
    107106                        varval = ''
    108107                else:
    109                         varval = config[condname]
     108                        varval = defaults[condname]
    110109                        if (varval == '*'):
    111110                                varval = 'y'
    112111               
    113                 if ctype == 'cnf':
     112                if (ctype == 'cnf'):
    114113                        if (oper == '=') and (condval == varval):
    115114                                return True
     
    124123                                return False
    125124       
    126         if ctype == 'cnf':
     125        if (ctype == 'cnf'):
    127126                return False
    128127       
    129128        return True
    130129
    131 def parse_rules(fname, rules):
    132         "Parse rules file"
     130def parse_config(fname, ask_names):
     131        "Parse configuration file"
    133132       
    134133        inf = open(fname, 'r')
     
    139138        for line in inf:
    140139               
    141                 if line.startswith('!'):
     140                if (line.startswith('!')):
    142141                        # Ask a question
    143142                        res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
    144143                       
    145                         if not res:
     144                        if (not res):
    146145                                raise RuntimeError("Weird line: %s" % line)
    147146                       
     
    150149                        vartype = res.group(3)
    151150                       
    152                         rules.append((varname, vartype, name, choices, cond))
     151                        ask_names.append((varname, vartype, name, choices, cond))
    153152                        name = ''
    154153                        choices = []
    155154                        continue
    156155               
    157                 if line.startswith('@'):
     156                if (line.startswith('@')):
    158157                        # Add new line into the 'choices' array
    159158                        res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
     
    165164                        continue
    166165               
    167                 if line.startswith('%'):
     166                if (line.startswith('%')):
    168167                        # Name of the option
    169168                        name = line[1:].strip()
    170169                        continue
    171170               
    172                 if line.startswith('#') or (line == '\n'):
     171                if ((line.startswith('#')) or (line == '\n')):
    173172                        # Comment or empty line
    174173                        continue
     
    182181        "Return '*' if yes, ' ' if no"
    183182       
    184         if default == 'y':
     183        if (default == 'y'):
    185184                return '*'
    186185       
     
    200199        cnt = 0
    201200        for key, val in choices:
    202                 if (default) and (key == default):
     201                if ((default) and (key == default)):
    203202                        position = cnt
    204203               
     
    208207        (button, value) = xtui.choice_window(screen, name, 'Choose value', options, position)
    209208       
    210         if button == 'cancel':
     209        if (button == 'cancel'):
    211210                return None
    212211       
    213212        return choices[value][0]
    214213
    215 ## Infer and verify configuration values.
    216 #
    217 # Augment @a config with values that can be inferred, purge invalid ones
    218 # and verify that all variables have a value (previously specified or inferred).
    219 #
    220 # @param config Configuration to work on
    221 # @param rules  Rules
    222 #
    223 # @return       True if configuration is complete and valid, False
    224 #               otherwise.
    225 #
    226 def infer_verify_choices(config, rules):
    227         "Infer and verify configuration values."
    228        
    229         for rule in rules:
    230                 varname, vartype, name, choices, cond = rule
    231 
    232                 if cond and (not check_condition(cond, config, rules)):
    233                         continue
    234                
    235                 if not varname in config:
    236                         value = None
    237                 else:
    238                         value = config[varname]
    239 
    240                 if not rule_value_is_valid(rule, value):
    241                         value = None
    242 
    243                 default = rule_get_default(rule)
    244                 if default != None:
    245                         config[varname] = default
    246 
    247                 if not varname in config:
     214def check_choices(defaults, ask_names):
     215        "Check whether all accessible variables have a default"
     216       
     217        for varname, vartype, name, choices, cond in ask_names:
     218                if ((cond) and (not check_condition(cond, defaults, ask_names))):
     219                        continue
     220               
     221                if (not varname in defaults):
    248222                        return False
    249223       
    250224        return True
    251225
    252 ## Get default value from a rule.
    253 def rule_get_default(rule):
    254         varname, vartype, name, choices, cond = rule
    255 
    256         default = None
    257 
    258         if vartype == 'choice':
    259                 # If there is just one option, use it
    260                 if len(choices) == 1:
    261                         default = choices[0][0]
    262         elif vartype == 'y':
    263                 default = '*'
    264         elif vartype == 'n':
    265                 default = 'n'
    266         elif vartype == 'y/n':
    267                 default = 'y'
    268         elif vartype == 'n/y':
    269                 default = 'n'
    270         else:
    271                 raise RuntimeError("Unknown variable type: %s" % vartype)
    272 
    273         return default
    274 
    275 ## Get option from a rule.
    276 #
    277 # @param rule   Rule for a variable
    278 # @param value  Current value of the variable
    279 #
    280 # @return Option (string) to ask or None which means not to ask.
    281 #
    282 def rule_get_option(rule, value):
    283         varname, vartype, name, choices, cond = rule
    284 
    285         option = None
    286 
    287         if vartype == 'choice':
    288                 # If there is just one option, don't ask
    289                 if len(choices) != 1:
    290                         if (value == None):
    291                                 option = "?     %s --> " % name
    292                         else:
    293                                 option = "      %s [%s] --> " % (name, value)
    294         elif vartype == 'y':
    295                 pass
    296         elif vartype == 'n':
    297                 pass
    298         elif vartype == 'y/n':
    299                 option = "  <%s> %s " % (yes_no(value), name)
    300         elif vartype == 'n/y':
    301                 option ="  <%s> %s " % (yes_no(value), name)
    302         else:
    303                 raise RuntimeError("Unknown variable type: %s" % vartype)
    304 
    305         return option
    306 
    307 ## Check if variable value is valid.
    308 #
    309 # @param rule   Rule for the variable
    310 # @param value  Value of the variable
    311 #
    312 # @return       True if valid, False if not valid.
    313 #
    314 def rule_value_is_valid(rule, value):
    315         varname, vartype, name, choices, cond = rule
    316        
    317         if value == None:
    318                 return True
    319 
    320         if vartype == 'choice':
    321                 if not value in [choice[0] for choice in choices]:
    322                         return False
    323         elif vartype == 'y':
    324                 if value != 'y':
    325                         return False
    326         elif vartype == 'n':
    327                 if value != 'n':
    328                         return False
    329         elif vartype == 'y/n':
    330                 if not value in ['y', 'n']:
    331                         return False
    332         elif vartype == 'n/y':
    333                 if not value in ['y', 'n']:
    334                         return False
    335         else:
    336                 raise RuntimeError("Unknown variable type: %s" % vartype)
    337 
    338         return True
    339 
    340 def create_output(mkname, mcname, config, rules):
     226def create_output(mkname, mcname, defaults, ask_names):
    341227        "Create output configuration"
    342228       
     
    352238                sys.stderr.write("failed\n")
    353239       
    354         if len(version) == 3:
     240        if (len(version) == 3):
    355241                revision = version[1]
    356                 if version[0] != 1:
     242                if (version[0] != 1):
    357243                        revision += 'M'
    358244                revision += ' (%s)' % version[2]
     
    373259        defs = 'CONFIG_DEFS ='
    374260       
    375         for varname, vartype, name, choices, cond in rules:
    376                 if cond and (not check_condition(cond, config, rules)):
    377                         continue
    378                
    379                 if not varname in config:
    380                         value = ''
     261        for varname, vartype, name, choices, cond in ask_names:
     262                if ((cond) and (not check_condition(cond, defaults, ask_names))):
     263                        continue
     264               
     265                if (not varname in defaults):
     266                        default = ''
    381267                else:
    382                         value = config[varname]
    383                         if (value == '*'):
    384                                 value = 'y'
    385                
    386                 outmk.write('# %s\n%s = %s\n\n' % (name, varname, value))
    387                
    388                 if vartype in ["y", "n", "y/n", "n/y"]:
    389                         if value == "y":
     268                        default = defaults[varname]
     269                        if (default == '*'):
     270                                default = 'y'
     271               
     272                outmk.write('# %s\n%s = %s\n\n' % (name, varname, default))
     273               
     274                if ((vartype == "y") or (vartype == "n") or (vartype == "y/n") or (vartype == "n/y")):
     275                        if (default == "y"):
    390276                                outmc.write('/* %s */\n#define %s\n\n' % (name, varname))
    391277                                defs += ' -D%s' % varname
    392278                else:
    393                         outmc.write('/* %s */\n#define %s %s\n#define %s_%s\n\n' % (name, varname, value, varname, value))
    394                         defs += ' -D%s=%s -D%s_%s' % (varname, value, varname, value)
    395        
    396         if revision is not None:
     279                        outmc.write('/* %s */\n#define %s %s\n#define %s_%s\n\n' % (name, varname, default, varname, default))
     280                        defs += ' -D%s=%s -D%s_%s' % (varname, default, varname, default)
     281       
     282        if (revision is not None):
    397283                outmk.write('REVISION = %s\n' % revision)
    398284                outmc.write('#define REVISION %s\n' % revision)
     
    413299        return list
    414300
    415 ## Choose a profile and load configuration presets.
    416 #
    417 def load_presets(root, fname, screen, config):
     301def read_preconfigured(root, fname, screen, defaults):
    418302        options = []
    419303        opt2path = {}
     
    425309                canon = os.path.join(path, fname)
    426310               
    427                 if os.path.isdir(path) and os.path.exists(canon) and os.path.isfile(canon):
     311                if ((os.path.isdir(path)) and (os.path.exists(canon)) and (os.path.isfile(canon))):
    428312                        subprofile = False
    429313                       
     
    433317                                subcanon = os.path.join(subpath, fname)
    434318                               
    435                                 if os.path.isdir(subpath) and os.path.exists(subcanon) and os.path.isfile(subcanon):
     319                                if ((os.path.isdir(subpath)) and (os.path.exists(subcanon)) and (os.path.isfile(subcanon))):
    436320                                        subprofile = True
    437321                                        options.append("%s (%s)" % (name, subname))
     
    439323                                        cnt += 1
    440324                       
    441                         if not subprofile:
     325                        if (not subprofile):
    442326                                options.append(name)
    443327                                opt2path[cnt] = (canon, None)
     
    446330        (button, value) = xtui.choice_window(screen, 'Load preconfigured defaults', 'Choose configuration profile', options, None)
    447331       
    448         if button == 'cancel':
     332        if (button == 'cancel'):
    449333                return None
    450334       
    451         read_config(opt2path[value][0], config)
    452         if opt2path[value][1] != None:
    453                 read_config(opt2path[value][1], config)
     335        read_defaults(opt2path[value][0], defaults)
     336        if (opt2path[value][1] != None):
     337                read_defaults(opt2path[value][1], defaults)
    454338
    455339def main():
    456         config = {}
    457         rules = []
    458        
    459         # Parse rules file
    460         parse_rules(RULES_FILE, rules)
    461        
    462         # Read configuration from previous run
     340        defaults = {}
     341        ask_names = []
     342       
     343        # Parse configuration file
     344        parse_config(INPUT, ask_names)
     345       
     346        # Read defaults from previous run
    463347        if os.path.exists(MAKEFILE):
    464                 read_config(MAKEFILE, config)
    465        
    466         # Default mode: only check values and regenerate configuration files
    467         if (len(sys.argv) >= 3) and (sys.argv[2] == 'default'):
    468                 if (infer_verify_choices(config, rules)):
    469                         create_output(MAKEFILE, MACROS, config, rules)
     348                read_defaults(MAKEFILE, defaults)
     349       
     350        # Default mode: only check defaults and regenerate configuration
     351        if ((len(sys.argv) >= 3) and (sys.argv[2] == 'default')):
     352                if (check_choices(defaults, ask_names)):
     353                        create_output(MAKEFILE, MACROS, defaults, ask_names)
    470354                        return 0
    471355       
    472         # Check mode: only check configuration
    473         if (len(sys.argv) >= 3) and (sys.argv[2] == 'check'):
    474                 if infer_verify_choices(config, rules):
     356        # Check mode: only check defaults
     357        if ((len(sys.argv) >= 3) and (sys.argv[2] == 'check')):
     358                if (check_choices(defaults, ask_names)):
    475359                        return 0
    476360                return 1
     
    482366                while True:
    483367                       
    484                         # Cancel out all values which have to be deduced
    485                         for varname, vartype, name, choices, cond in rules:
    486                                 if (vartype == 'y') and (varname in config) and (config[varname] == '*'):
    487                                         config[varname] = None
     368                        # Cancel out all defaults which have to be deduced
     369                        for varname, vartype, name, choices, cond in ask_names:
     370                                if ((vartype == 'y') and (varname in defaults) and (defaults[varname] == '*')):
     371                                        defaults[varname] = None
    488372                       
    489373                        options = []
     
    493377                        options.append("  --- Load preconfigured defaults ... ")
    494378                       
    495                         for rule in rules:
    496                                 varname, vartype, name, choices, cond = rule
    497                                
    498                                 if cond and (not check_condition(cond, config, rules)):
     379                        for varname, vartype, name, choices, cond in ask_names:
     380                               
     381                                if ((cond) and (not check_condition(cond, defaults, ask_names))):
    499382                                        continue
    500383                               
    501                                 if varname == selname:
     384                                if (varname == selname):
    502385                                        position = cnt
    503386                               
    504                                 if not varname in config:
    505                                         value = None
     387                                if (not varname in defaults):
     388                                        default = None
    506389                                else:
    507                                         value = config[varname]
    508                                
    509                                 if not rule_value_is_valid(rule, value):
    510                                         value = None
    511 
    512                                 default = rule_get_default(rule)
    513                                 if default != None:
    514                                         value = default
    515                                         config[varname] = default
    516 
    517                                 option = rule_get_option(rule, value)
    518                                 if option != None:
    519                                         options.append(option)
     390                                        default = defaults[varname]
     391                               
     392                                if (vartype == 'choice'):
     393                                        # Check if the default is an acceptable value
     394                                        if ((default) and (not default in [choice[0] for choice in choices])):
     395                                                default = None
     396                                                defaults.pop(varname)
     397                                       
     398                                        # If there is just one option, use it
     399                                        if (len(choices) == 1):
     400                                                defaults[varname] = choices[0][0]
     401                                                continue
     402                                       
     403                                        if (default == None):
     404                                                options.append("?     %s --> " % name)
     405                                        else:
     406                                                options.append("      %s [%s] --> " % (name, default))
     407                                elif (vartype == 'y'):
     408                                        defaults[varname] = '*'
     409                                        continue
     410                                elif (vartype == 'n'):
     411                                        defaults[varname] = 'n'
     412                                        continue
     413                                elif (vartype == 'y/n'):
     414                                        if (default == None):
     415                                                default = 'y'
     416                                                defaults[varname] = default
     417                                        options.append("  <%s> %s " % (yes_no(default), name))
     418                                elif (vartype == 'n/y'):
     419                                        if (default == None):
     420                                                default = 'n'
     421                                                defaults[varname] = default
     422                                        options.append("  <%s> %s " % (yes_no(default), name))
     423                                else:
     424                                        raise RuntimeError("Unknown variable type: %s" % vartype)
    520425                               
    521426                                opt2row[cnt] = (varname, vartype, name, choices)
     
    528433                        (button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position)
    529434                       
    530                         if button == 'cancel':
     435                        if (button == 'cancel'):
    531436                                return 'Configuration canceled'
    532437                       
    533                         if button == 'done':
    534                                 if (infer_verify_choices(config, rules)):
     438                        if (button == 'done'):
     439                                if (check_choices(defaults, ask_names)):
    535440                                        break
    536441                                else:
     
    538443                                        continue
    539444                       
    540                         if value == 0:
    541                                 load_presets(PRESETS_DIR, MAKEFILE, screen, config)
     445                        if (value == 0):
     446                                read_preconfigured(PRECONF, MAKEFILE, screen, defaults)
    542447                                position = 1
    543448                                continue
    544449                       
    545450                        position = None
    546                         if not value in opt2row:
     451                        if (not value in opt2row):
    547452                                raise RuntimeError("Error selecting value: %s" % value)
    548453                       
    549454                        (selname, seltype, name, choices) = opt2row[value]
    550455                       
    551                         if not selname in config:
    552                                 value = None
     456                        if (not selname in defaults):
     457                                        default = None
    553458                        else:
    554                                 value = config[selname]
    555                        
    556                         if seltype == 'choice':
    557                                 config[selname] = subchoice(screen, name, choices, value)
    558                         elif (seltype == 'y/n') or (seltype == 'n/y'):
    559                                 if config[selname] == 'y':
    560                                         config[selname] = 'n'
     459                                default = defaults[selname]
     460                       
     461                        if (seltype == 'choice'):
     462                                defaults[selname] = subchoice(screen, name, choices, default)
     463                        elif ((seltype == 'y/n') or (seltype == 'n/y')):
     464                                if (defaults[selname] == 'y'):
     465                                        defaults[selname] = 'n'
    561466                                else:
    562                                         config[selname] = 'y'
     467                                        defaults[selname] = 'y'
    563468        finally:
    564469                xtui.screen_done(screen)
    565470       
    566         create_output(MAKEFILE, MACROS, config, rules)
     471        create_output(MAKEFILE, MACROS, defaults, ask_names)
    567472        return 0
    568473
  • uspace/lib/block/libblock.c

    rb00dbb9 r9ca0013  
    6666        fibril_mutex_t lock;
    6767        size_t lblock_size;             /**< Logical block size. */
    68         unsigned blocks_cluster;        /**< Physical blocks per block_t */
    6968        unsigned block_count;           /**< Total number of blocks. */
    7069        unsigned blocks_cached;         /**< Number of cached blocks. */
     
    9190static int get_block_size(int dev_phone, size_t *bsize);
    9291static int get_num_blocks(int dev_phone, aoff64_t *nblocks);
    93 static aoff64_t ba_ltop(devcon_t *devcon, aoff64_t lba);
    9492
    9593static devcon_t *devcon_search(devmap_handle_t devmap_handle)
     
    261259{
    262260        block_t *b = hash_table_get_instance(item, block_t, hash_link);
    263         return b->lba == *key;
     261        return b->boff == *key;
    264262}
    265263
     
    294292        cache->mode = mode;
    295293
    296         /* Allow 1:1 or small-to-large block size translation */
    297         if (cache->lblock_size % devcon->pblock_size != 0)
    298                 return ENOTSUP;
    299 
    300         cache->blocks_cluster = cache->lblock_size / devcon->pblock_size;
     294        /* No block size translation a.t.m. */
     295        assert(cache->lblock_size == devcon->pblock_size);
    301296
    302297        if (!hash_table_create(&cache->block_hash, CACHE_BUCKETS, 1,
     
    334329                if (b->dirty) {
    335330                        memcpy(devcon->comm_area, b->data, b->size);
    336                         rc = write_blocks(devcon, b->pba, cache->blocks_cluster);
     331                        rc = write_blocks(devcon, b->boff, 1);
    337332                        if (rc != EOK)
    338333                                return rc;
    339334                }
    340335
    341                 unsigned long key = b->lba;
     336                unsigned long key = b->boff;
    342337                hash_table_remove(&cache->block_hash, &key, 1);
    343338               
     
    380375 *                              block pointer on success.
    381376 * @param devmap_handle         Device handle of the block device.
    382  * @param ba                    Block address (logical).
     377 * @param boff                  Block offset.
    383378 * @param flags                 If BLOCK_FLAGS_NOREAD is specified, block_get()
    384379 *                              will not read the contents of the block from the
     
    387382 * @return                      EOK on success or a negative error code.
    388383 */
    389 int block_get(block_t **block, devmap_handle_t devmap_handle, aoff64_t ba, int flags)
     384int block_get(block_t **block, devmap_handle_t devmap_handle, aoff64_t boff, int flags)
    390385{
    391386        devcon_t *devcon;
     
    393388        block_t *b;
    394389        link_t *l;
    395         unsigned long key = ba;
     390        unsigned long key = boff;
    396391        int rc;
    397392       
     
    470465                                fibril_mutex_lock(&devcon->comm_area_lock);
    471466                                memcpy(devcon->comm_area, b->data, b->size);
    472                                 rc = write_blocks(devcon, b->pba,
    473                                     cache->blocks_cluster);
     467                                rc = write_blocks(devcon, b->boff, 1);
    474468                                fibril_mutex_unlock(&devcon->comm_area_lock);
    475469                                if (rc != EOK) {
     
    501495                         */
    502496                        list_remove(&b->free_link);
    503                         temp_key = b->lba;
     497                        temp_key = b->boff;
    504498                        hash_table_remove(&cache->block_hash, &temp_key, 1);
    505499                }
     
    508502                b->devmap_handle = devmap_handle;
    509503                b->size = cache->lblock_size;
    510                 b->lba = ba;
    511                 b->pba = ba_ltop(devcon, b->lba);
     504                b->boff = boff;
    512505                hash_table_insert(&cache->block_hash, &key, &b->hash_link);
    513506
     
    526519                         */
    527520                        fibril_mutex_lock(&devcon->comm_area_lock);
    528                         rc = read_blocks(devcon, b->pba, cache->blocks_cluster);
     521                        rc = read_blocks(devcon, b->boff, 1);
    529522                        memcpy(b->data, devcon->comm_area, cache->lblock_size);
    530523                        fibril_mutex_unlock(&devcon->comm_area_lock);
     
    587580                fibril_mutex_lock(&devcon->comm_area_lock);
    588581                memcpy(devcon->comm_area, block->data, block->size);
    589                 rc = write_blocks(devcon, block->pba, cache->blocks_cluster);
     582                rc = write_blocks(devcon, block->boff, 1);
    590583                fibril_mutex_unlock(&devcon->comm_area_lock);
    591584                block->dirty = false;
     
    621614                         * Take the block out of the cache and free it.
    622615                         */
    623                         unsigned long key = block->lba;
     616                        unsigned long key = block->boff;
    624617                        hash_table_remove(&cache->block_hash, &key, 1);
    625618                        free(block);
     
    719712 *
    720713 * @param devmap_handle Device handle of the block device.
    721  * @param ba            Address of first block (physical).
     714 * @param ba            Address of first block.
    722715 * @param cnt           Number of blocks.
    723716 * @param src           Buffer for storing the data.
     
    747740 *
    748741 * @param devmap_handle Device handle of the block device.
    749  * @param ba            Address of first block (physical).
     742 * @param ba            Address of first block.
    750743 * @param cnt           Number of blocks.
    751744 * @param src           The data to be written.
     
    886879}
    887880
    888 /** Convert logical block address to physical block address. */
    889 static aoff64_t ba_ltop(devcon_t *devcon, aoff64_t lba)
    890 {
    891         assert(devcon->cache != NULL);
    892         return lba * devcon->cache->blocks_cluster;
    893 }
    894 
    895881/** @}
    896882 */
  • uspace/lib/block/libblock.h

    rb00dbb9 r9ca0013  
    7373        /** Handle of the device where the block resides. */
    7474        devmap_handle_t devmap_handle;
    75         /** Logical block address */
    76         aoff64_t lba;
    77         /** Physical block address */
    78         aoff64_t pba;
     75        /** Block offset on the block device. Counted in 'size'-byte blocks. */
     76        aoff64_t boff;
    7977        /** Size of the block. */
    8078        size_t size;
  • uspace/srv/bd/file_bd/file_bd.c

    rb00dbb9 r9ca0013  
    5656#define NAME "file_bd"
    5757
    58 #define DEFAULT_BLOCK_SIZE 512
    59 
    60 static size_t block_size;
     58static const size_t block_size = 512;
    6159static aoff64_t num_blocks;
    6260static FILE *img;
     
    6563static fibril_mutex_t dev_lock;
    6664
    67 static void print_usage(void);
    6865static int file_bd_init(const char *fname);
    6966static void file_bd_connection(ipc_callid_t iid, ipc_call_t *icall);
     
    7471{
    7572        int rc;
    76         char *image_name;
    77         char *device_name;
    7873
    7974        printf(NAME ": File-backed block device driver\n");
    8075
    81         block_size = DEFAULT_BLOCK_SIZE;
    82 
    83         ++argv; --argc;
    84         while (*argv != NULL && (*argv)[0] == '-') {
    85                 /* Option */
    86                 if (str_cmp(*argv, "-b") == 0) {
    87                         if (argc < 2) {
    88                                 printf("Argument missing.\n");
    89                                 print_usage();
    90                                 return -1;
    91                         }
    92 
    93                         rc = str_size_t(argv[1], NULL, 10, true, &block_size);
    94                         if (rc != EOK || block_size == 0) {
    95                                 printf("Invalid block size '%s'.\n", argv[1]);
    96                                 print_usage();
    97                                 return -1;
    98                         }
    99                         ++argv; --argc;
    100                 } else {
    101                         printf("Invalid option '%s'.\n", *argv);
    102                         print_usage();
    103                         return -1;
    104                 }
    105                 ++argv; --argc;
    106         }
    107 
    108         if (argc < 2) {
    109                 printf("Missing arguments.\n");
    110                 print_usage();
     76        if (argc != 3) {
     77                printf("Expected two arguments (image name, device name).\n");
    11178                return -1;
    11279        }
    11380
    114         image_name = argv[0];
    115         device_name = argv[1];
    116 
    117         if (file_bd_init(image_name) != EOK)
     81        if (file_bd_init(argv[1]) != EOK)
    11882                return -1;
    11983
    120         rc = devmap_device_register(device_name, &devmap_handle);
     84        rc = devmap_device_register(argv[2], &devmap_handle);
    12185        if (rc != EOK) {
    12286                devmap_hangup_phone(DEVMAP_DRIVER);
    123                 printf(NAME ": Unable to register device '%s'.\n",
    124                         device_name);
     87                printf(NAME ": Unable to register device %s.\n",
     88                        argv[2]);
    12589                return rc;
    12690        }
     
    13296        /* Not reached */
    13397        return 0;
    134 }
    135 
    136 static void print_usage(void)
    137 {
    138         printf("Usage: " NAME " [-b <block_size>] <image_file> <device_name>\n");
    13998}
    14099
Note: See TracChangeset for help on using the changeset viewer.