Changes in / [45e9cc6:4144630] in mainline
- Files:
-
- 1 added
- 8 deleted
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
r45e9cc6 r4144630 94 94 ./uspace/dist/drv/rootia32/ 95 95 ./uspace/dist/drv/uhci/ 96 ./uspace/dist/drv/usbhub/97 96 ./uspace/dist/drv/usbkbd/ 98 97 ./uspace/dist/drv/vhc/ … … 131 130 ./uspace/drv/rootia32/rootia32 132 131 ./uspace/drv/uhci/uhci 133 ./uspace/drv/usbhub/usbhub134 132 ./uspace/drv/usbkbd/usbkbd 135 133 ./uspace/drv/vhc/vhc -
boot/arch/amd64/Makefile.inc
r45e9cc6 r4144630 42 42 ns8250 \ 43 43 uhci \ 44 usbhub \45 44 usbkbd 46 45 -
boot/arch/mips32/include/arch.h
r45e9cc6 r4144630 40 40 41 41 #define MSIM_VIDEORAM_ADDRESS 0xb0000000 42 #define MSIM_DORDER_ADDRESS 0xb0000 10042 #define MSIM_DORDER_ADDRESS 0xb0000004 43 43 44 44 #ifndef __ASM__ -
contrib/conf/msim.conf
r45e9cc6 r4144630 16 16 add dprinter printer 0x10000000 17 17 add dkeyboard keyboard 0x10000000 2 18 add dorder order 0x10000 100518 add dorder order 0x10000004 5 -
kernel/arch/mips32/src/exception.c
r45e9cc6 r4144630 74 74 void istate_decode(istate_t *istate) 75 75 { 76 printf("epc=%p\tsta=%#0 10" PRIx32 "\t"77 "lo =%#0 10" PRIx32 "\thi =%#010" PRIx32 "\n",76 printf("epc=%p\tsta=%#0" PRIx32 "\t" 77 "lo =%#0" PRIx32 "\thi =%#0" PRIx32 "\n", 78 78 (void *) istate->epc, istate->status, 79 79 istate->lo, istate->hi); 80 80 81 printf("a0 =%#0 10" PRIx32 "\ta1 =%#010" PRIx32 "\t"82 "a2 =%#0 10" PRIx32 "\ta3 =%#010" PRIx32 "\n",81 printf("a0 =%#0" PRIx32 "\ta1 =%#0" PRIx32 "\t" 82 "a2 =%#0" PRIx32 "\ta3 =%#0" PRIx32 "\n", 83 83 istate->a0, istate->a1, istate->a2, istate->a3); 84 84 85 printf("t0 =%#0 10" PRIx32 "\tt1 =%#010" PRIx32 "\t"86 "t2 =%#0 10" PRIx32 "\tt3 =%#010" PRIx32 "\n",85 printf("t0 =%#0" PRIx32 "\tt1 =%#0" PRIx32 "\t" 86 "t2 =%#0" PRIx32 "\tt3 =%#0" PRIx32 "\n", 87 87 istate->t0, istate->t1, istate->t2, istate->t3); 88 88 89 printf("t4 =%#0 10" PRIx32 "\tt5 =%#010" PRIx32 "\t"90 "t6 =%#0 10" PRIx32 "\tt7 =%#010" PRIx32 "\n",89 printf("t4 =%#0" PRIx32 "\tt5 =%#0" PRIx32 "\t" 90 "t6 =%#0" PRIx32 "\tt7 =%#0" PRIx32 "\n", 91 91 istate->t4, istate->t5, istate->t6, istate->t7); 92 92 93 printf("t8 =%#0 10" PRIx32 "\tt9 =%#010" PRIx32 "\t"94 "v0 =%#0 10" PRIx32 "\tv1 =%#010" PRIx32 "\n",93 printf("t8 =%#0" PRIx32 "\tt9 =%#0" PRIx32 "\t" 94 "v0 =%#0" PRIx32 "\tv1 =%#0" PRIx32 "\n", 95 95 istate->t8, istate->t9, istate->v0, istate->v1); 96 96 97 printf("s0 =%#0 10" PRIx32 "\ts1 =%#010" PRIx32 "\t"98 "s2 =%#0 10" PRIx32 "\ts3 =%#010" PRIx32 "\n",97 printf("s0 =%#0" PRIx32 "\ts1 =%#0" PRIx32 "\t" 98 "s2 =%#0" PRIx32 "\ts3 =%#0" PRIx32 "\n", 99 99 istate->s0, istate->s1, istate->s2, istate->s3); 100 100 101 printf("s4 =%#0 10" PRIx32 "\ts5 =%#010" PRIx32 "\t"102 "s6 =%#0 10" PRIx32 "\ts7 =%#010" PRIx32 "\n",101 printf("s4 =%#0" PRIx32 "\ts5 =%#0" PRIx32 "\t" 102 "s6 =%#0" PRIx32 "\ts7 =%#0" PRIx32 "\n", 103 103 istate->s4, istate->s5, istate->s6, istate->s7); 104 104 105 printf("s8 =%#0 10" PRIx32 "\tat =%#010" PRIx32 "\t"106 "kt0=%#0 10" PRIx32 "\tkt1=%#010" PRIx32 "\n",105 printf("s8 =%#0" PRIx32 "\tat =%#0" PRIx32 "\t" 106 "kt0=%#0" PRIx32 "\tkt1=%#0" PRIx32 "\n", 107 107 istate->s8, istate->at, istate->kt0, istate->kt1); 108 108 -
kernel/arch/mips32/src/smp/dorder.c
r45e9cc6 r4144630 37 37 #include <arch/smp/dorder.h> 38 38 39 #define MSIM_DORDER_ADDRESS 0xB0000 10039 #define MSIM_DORDER_ADDRESS 0xB0000004 40 40 41 41 #ifdef CONFIG_SMP -
kernel/generic/include/ipc/ipc.h
r45e9cc6 r4144630 45 45 /** Maximum active async calls per thread */ 46 46 #ifdef CONFIG_DEBUG 47 #define IPC_MAX_ASYNC_CALLS 1647 #define IPC_MAX_ASYNC_CALLS 4 48 48 #else 49 49 #define IPC_MAX_ASYNC_CALLS 4000 -
tools/config.py
r45e9cc6 r4144630 3 3 # Copyright (c) 2006 Ondrej Palkovsky 4 4 # Copyright (c) 2009 Martin Decky 5 # Copyright (c) 2010 Jiri Svoboda6 5 # All rights reserved. 7 6 # … … 41 40 import xtui 42 41 43 RULES_FILE= sys.argv[1]42 INPUT = sys.argv[1] 44 43 MAKEFILE = 'Makefile.config' 45 44 MACROS = 'config.h' 46 PRE SETS_DIR= 'defaults'47 48 def read_ config(fname, config):45 PRECONF = 'defaults' 46 47 def read_defaults(fname, defaults): 49 48 "Read saved values from last configuration run" 50 49 … … 53 52 for line in inf: 54 53 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) 57 56 58 57 inf.close() 59 58 60 def check_condition(text, config, rules):59 def check_condition(text, defaults, ask_names): 61 60 "Check that the condition specified on input line is True (only CNF and DNF is supported)" 62 61 63 62 ctype = 'cnf' 64 63 65 if ( ')|' in text) or ('|(' in text):64 if ((')|' in text) or ('|(' in text)): 66 65 ctype = 'dnf' 67 66 68 if ctype == 'cnf':67 if (ctype == 'cnf'): 69 68 conds = text.split('&') 70 69 else: … … 72 71 73 72 for cond in conds: 74 if cond.startswith('(') and cond.endswith(')'):73 if (cond.startswith('(')) and (cond.endswith(')')): 75 74 cond = cond[1:-1] 76 75 77 inside = check_inside(cond, config, ctype)76 inside = check_inside(cond, defaults, ctype) 78 77 79 78 if (ctype == 'cnf') and (not inside): 80 79 return False 81 80 82 if (ctype == 'dnf') and inside:81 if (ctype == 'dnf') and (inside): 83 82 return True 84 83 85 if ctype == 'cnf':84 if (ctype == 'cnf'): 86 85 return True 87 86 return False 88 87 89 def check_inside(text, config, ctype):88 def check_inside(text, defaults, ctype): 90 89 "Check for condition" 91 90 92 if ctype == 'cnf':91 if (ctype == 'cnf'): 93 92 conds = text.split('|') 94 93 else: … … 97 96 for cond in conds: 98 97 res = re.match(r'^(.*?)(!?=)(.*)$', cond) 99 if not res:98 if (not res): 100 99 raise RuntimeError("Invalid condition: %s" % cond) 101 100 … … 104 103 condval = res.group(3) 105 104 106 if not condname in config:105 if (not condname in defaults): 107 106 varval = '' 108 107 else: 109 varval = config[condname]108 varval = defaults[condname] 110 109 if (varval == '*'): 111 110 varval = 'y' 112 111 113 if ctype == 'cnf':112 if (ctype == 'cnf'): 114 113 if (oper == '=') and (condval == varval): 115 114 return True … … 124 123 return False 125 124 126 if ctype == 'cnf':125 if (ctype == 'cnf'): 127 126 return False 128 127 129 128 return True 130 129 131 def parse_ rules(fname, rules):132 "Parse rulesfile"130 def parse_config(fname, ask_names): 131 "Parse configuration file" 133 132 134 133 inf = open(fname, 'r') … … 139 138 for line in inf: 140 139 141 if line.startswith('!'):140 if (line.startswith('!')): 142 141 # Ask a question 143 142 res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line) 144 143 145 if not res:144 if (not res): 146 145 raise RuntimeError("Weird line: %s" % line) 147 146 … … 150 149 vartype = res.group(3) 151 150 152 rules.append((varname, vartype, name, choices, cond))151 ask_names.append((varname, vartype, name, choices, cond)) 153 152 name = '' 154 153 choices = [] 155 154 continue 156 155 157 if line.startswith('@'):156 if (line.startswith('@')): 158 157 # Add new line into the 'choices' array 159 158 res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line) … … 165 164 continue 166 165 167 if line.startswith('%'):166 if (line.startswith('%')): 168 167 # Name of the option 169 168 name = line[1:].strip() 170 169 continue 171 170 172 if line.startswith('#') or (line == '\n'):171 if ((line.startswith('#')) or (line == '\n')): 173 172 # Comment or empty line 174 173 continue … … 182 181 "Return '*' if yes, ' ' if no" 183 182 184 if default == 'y':183 if (default == 'y'): 185 184 return '*' 186 185 … … 200 199 cnt = 0 201 200 for key, val in choices: 202 if ( default) and (key == default):201 if ((default) and (key == default)): 203 202 position = cnt 204 203 … … 208 207 (button, value) = xtui.choice_window(screen, name, 'Choose value', options, position) 209 208 210 if button == 'cancel':209 if (button == 'cancel'): 211 210 return None 212 211 213 212 return choices[value][0] 214 213 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: 214 def 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): 248 222 return False 249 223 250 224 return True 251 225 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): 226 def create_output(mkname, mcname, defaults, ask_names): 341 227 "Create output configuration" 342 228 … … 352 238 sys.stderr.write("failed\n") 353 239 354 if len(version) == 3:240 if (len(version) == 3): 355 241 revision = version[1] 356 if version[0] != 1:242 if (version[0] != 1): 357 243 revision += 'M' 358 244 revision += ' (%s)' % version[2] … … 373 259 defs = 'CONFIG_DEFS =' 374 260 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 = '' 381 267 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"): 390 276 outmc.write('/* %s */\n#define %s\n\n' % (name, varname)) 391 277 defs += ' -D%s' % varname 392 278 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): 397 283 outmk.write('REVISION = %s\n' % revision) 398 284 outmc.write('#define REVISION %s\n' % revision) … … 413 299 return list 414 300 415 ## Choose a profile and load configuration presets. 416 # 417 def load_presets(root, fname, screen, config): 301 def read_preconfigured(root, fname, screen, defaults): 418 302 options = [] 419 303 opt2path = {} … … 425 309 canon = os.path.join(path, fname) 426 310 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))): 428 312 subprofile = False 429 313 … … 433 317 subcanon = os.path.join(subpath, fname) 434 318 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))): 436 320 subprofile = True 437 321 options.append("%s (%s)" % (name, subname)) … … 439 323 cnt += 1 440 324 441 if not subprofile:325 if (not subprofile): 442 326 options.append(name) 443 327 opt2path[cnt] = (canon, None) … … 446 330 (button, value) = xtui.choice_window(screen, 'Load preconfigured defaults', 'Choose configuration profile', options, None) 447 331 448 if button == 'cancel':332 if (button == 'cancel'): 449 333 return None 450 334 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) 454 338 455 339 def main(): 456 config= {}457 rules = []458 459 # Parse rulesfile460 parse_ rules(RULES_FILE, rules)461 462 # Read configurationfrom previous run340 defaults = {} 341 ask_names = [] 342 343 # Parse configuration file 344 parse_config(INPUT, ask_names) 345 346 # Read defaults from previous run 463 347 if os.path.exists(MAKEFILE): 464 read_ config(MAKEFILE, config)465 466 # Default mode: only check values and regenerate configuration files467 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) 470 354 return 0 471 355 472 # Check mode: only check configuration473 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)): 475 359 return 0 476 360 return 1 … … 482 366 while True: 483 367 484 # Cancel out all values which have to be deduced485 for varname, vartype, name, choices, cond in rules:486 if ( vartype == 'y') and (varname in config) and (config[varname] == '*'):487 config[varname] = None368 # 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 488 372 489 373 options = [] … … 493 377 options.append(" --- Load preconfigured defaults ... ") 494 378 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))): 499 382 continue 500 383 501 if varname == selname:384 if (varname == selname): 502 385 position = cnt 503 386 504 if not varname in config:505 value= None387 if (not varname in defaults): 388 default = None 506 389 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) 520 425 521 426 opt2row[cnt] = (varname, vartype, name, choices) … … 528 433 (button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position) 529 434 530 if button == 'cancel':435 if (button == 'cancel'): 531 436 return 'Configuration canceled' 532 437 533 if button == 'done':534 if ( infer_verify_choices(config, rules)):438 if (button == 'done'): 439 if (check_choices(defaults, ask_names)): 535 440 break 536 441 else: … … 538 443 continue 539 444 540 if value == 0:541 load_presets(PRESETS_DIR, MAKEFILE, screen, config)445 if (value == 0): 446 read_preconfigured(PRECONF, MAKEFILE, screen, defaults) 542 447 position = 1 543 448 continue 544 449 545 450 position = None 546 if not value in opt2row:451 if (not value in opt2row): 547 452 raise RuntimeError("Error selecting value: %s" % value) 548 453 549 454 (selname, seltype, name, choices) = opt2row[value] 550 455 551 if not selname in config:552 value= None456 if (not selname in defaults): 457 default = None 553 458 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' 561 466 else: 562 config[selname] = 'y'467 defaults[selname] = 'y' 563 468 finally: 564 469 xtui.screen_done(screen) 565 470 566 create_output(MAKEFILE, MACROS, config, rules)471 create_output(MAKEFILE, MACROS, defaults, ask_names) 567 472 return 0 568 473 -
uspace/Makefile
r45e9cc6 r4144630 118 118 DIRS += drv/ns8250 119 119 DIRS += drv/uhci 120 DIRS += drv/usbhub121 120 DIRS += drv/usbkbd 122 121 endif -
uspace/drv/uhci/Makefile
r45e9cc6 r4144630 33 33 34 34 SOURCES = \ 35 main.c \ 36 transfers.c 35 main.c 37 36 38 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/uhci/main.c
r45e9cc6 r4144630 28 28 #include <usb/hcdhubd.h> 29 29 #include <errno.h> 30 #include "uhci.h"31 30 32 static device_ops_t uhci_ops = { 33 .interfaces[USBHC_DEV_IFACE] = &uhci_iface, 31 static int enqueue_transfer_out(usb_hc_device_t *hc, 32 usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint, 33 void *buffer, size_t size, 34 usb_hcd_transfer_callback_out_t callback, void *arg) 35 { 36 printf("UHCI: transfer OUT [%d.%d (%s); %u]\n", 37 dev->address, endpoint->endpoint, 38 usb_str_transfer_type(endpoint->transfer_type), 39 size); 40 return ENOTSUP; 41 } 42 43 static int enqueue_transfer_setup(usb_hc_device_t *hc, 44 usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint, 45 void *buffer, size_t size, 46 usb_hcd_transfer_callback_out_t callback, void *arg) 47 { 48 printf("UHCI: transfer SETUP [%d.%d (%s); %u]\n", 49 dev->address, endpoint->endpoint, 50 usb_str_transfer_type(endpoint->transfer_type), 51 size); 52 return ENOTSUP; 53 } 54 55 static int enqueue_transfer_in(usb_hc_device_t *hc, 56 usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint, 57 void *buffer, size_t size, 58 usb_hcd_transfer_callback_in_t callback, void *arg) 59 { 60 printf("UHCI: transfer IN [%d.%d (%s); %u]\n", 61 dev->address, endpoint->endpoint, 62 usb_str_transfer_type(endpoint->transfer_type), 63 size); 64 return ENOTSUP; 65 } 66 67 static usb_hcd_transfer_ops_t uhci_transfer_ops = { 68 .transfer_out = enqueue_transfer_out, 69 .transfer_in = enqueue_transfer_in, 70 .transfer_setup = enqueue_transfer_setup 34 71 }; 35 72 36 static int uhci_add_ device(device_t *device)73 static int uhci_add_hc(usb_hc_device_t *device) 37 74 { 38 device-> ops = &uhci_ops;75 device->transfer_ops = &uhci_transfer_ops; 39 76 40 77 /* 41 78 * We need to announce the presence of our root hub. 79 * Commented out until the problem which causes the whole task to 80 * block is solved. 42 81 */ 43 usb_hcd_add_root_hub(device);82 //usb_hcd_add_root_hub(device); 44 83 45 84 return EOK; 46 85 } 47 86 48 static driver_ops_t uhci_driver_ops = { 49 .add_device = uhci_add_device, 50 }; 51 52 static driver_t uhci_driver = { 53 .name = NAME, 54 .driver_ops = &uhci_driver_ops 87 usb_hc_driver_t uhci_driver = { 88 .name = "uhci", 89 .add_hc = uhci_add_hc 55 90 }; 56 91 … … 60 95 * Do some global initializations. 61 96 */ 62 sleep(5);63 97 64 return driver_main(&uhci_driver);98 return usb_hcd_main(&uhci_driver); 65 99 } -
uspace/drv/uhci/uhci.ma
r45e9cc6 r4144630 1 1 10 pci/ven=8086&dev=7020 2 2 10 usb&hc=uhci 3 10 usb&hc=uhci&hub -
uspace/drv/vhc/Makefile
r45e9cc6 r4144630 39 39 40 40 SOURCES = \ 41 addrmgm.c \42 41 conndev.c \ 43 42 connhost.c \ -
uspace/drv/vhc/conn.h
r45e9cc6 r4144630 38 38 #include <usb/usb.h> 39 39 #include <usb/hcdhubd.h> 40 #include <usbhc_iface.h>41 40 #include "vhcd.h" 42 41 #include "devices.h" … … 45 44 46 45 usb_hcd_transfer_ops_t vhc_transfer_ops; 47 usbhc_iface_t vhc_iface;48 49 void address_init(void);50 int reserve_default_address(device_t *);51 int release_default_address(device_t *);52 int request_address(device_t *, usb_address_t *);53 int release_address(device_t *, usb_address_t);54 int bind_address(device_t *, usb_address_t, devman_handle_t);55 56 int tell_address(device_t *, devman_handle_t, usb_address_t *);57 46 58 47 void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *); -
uspace/drv/vhc/connhost.c
r45e9cc6 r4144630 43 43 typedef struct { 44 44 usb_direction_t direction; 45 usb hc_iface_transfer_out_callback_t out_callback;46 usb hc_iface_transfer_in_callback_t in_callback;47 device_t *dev;45 usb_hcd_transfer_callback_out_t out_callback; 46 usb_hcd_transfer_callback_in_t in_callback; 47 usb_hc_device_t *hc; 48 48 void *arg; 49 49 } transfer_info_t; … … 56 56 switch (transfer->direction) { 57 57 case USB_DIRECTION_IN: 58 transfer->in_callback(transfer-> dev,58 transfer->in_callback(transfer->hc, 59 59 size, outcome, 60 60 transfer->arg); 61 61 break; 62 62 case USB_DIRECTION_OUT: 63 transfer->out_callback(transfer-> dev,63 transfer->out_callback(transfer->hc, 64 64 outcome, 65 65 transfer->arg); … … 73 73 } 74 74 75 static transfer_info_t *create_transfer_info( device_t *dev,75 static transfer_info_t *create_transfer_info(usb_hc_device_t *hc, 76 76 usb_direction_t direction, void *arg) 77 77 { … … 82 82 transfer->out_callback = NULL; 83 83 transfer->arg = arg; 84 transfer-> dev = dev;84 transfer->hc = hc; 85 85 86 86 return transfer; 87 87 } 88 88 89 static int enqueue_transfer_out( device_t *dev,90 usb_ target_t target, usb_transfer_type_t transfer_type,89 static int enqueue_transfer_out(usb_hc_device_t *hc, 90 usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint, 91 91 void *buffer, size_t size, 92 usb hc_iface_transfer_out_callback_t callback, void *arg)92 usb_hcd_transfer_callback_out_t callback, void *arg) 93 93 { 94 94 printf(NAME ": transfer OUT [%d.%d (%s); %u]\n", 95 target.address, target.endpoint,96 usb_str_transfer_type( transfer_type),95 dev->address, endpoint->endpoint, 96 usb_str_transfer_type(endpoint->transfer_type), 97 97 size); 98 98 99 99 transfer_info_t *transfer 100 = create_transfer_info( dev, USB_DIRECTION_OUT, arg);100 = create_transfer_info(hc, USB_DIRECTION_OUT, arg); 101 101 transfer->out_callback = callback; 102 103 usb_target_t target = { 104 .address = dev->address, 105 .endpoint = endpoint->endpoint 106 }; 102 107 103 108 hc_add_transaction_to_device(false, target, buffer, size, … … 107 112 } 108 113 109 static int enqueue_transfer_setup( device_t *dev,110 usb_ target_t target, usb_transfer_type_t transfer_type,114 static int enqueue_transfer_setup(usb_hc_device_t *hc, 115 usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint, 111 116 void *buffer, size_t size, 112 usb hc_iface_transfer_out_callback_t callback, void *arg)117 usb_hcd_transfer_callback_out_t callback, void *arg) 113 118 { 114 119 printf(NAME ": transfer SETUP [%d.%d (%s); %u]\n", 115 target.address, target.endpoint,116 usb_str_transfer_type( transfer_type),120 dev->address, endpoint->endpoint, 121 usb_str_transfer_type(endpoint->transfer_type), 117 122 size); 118 123 119 124 transfer_info_t *transfer 120 = create_transfer_info( dev, USB_DIRECTION_OUT, arg);125 = create_transfer_info(hc, USB_DIRECTION_OUT, arg); 121 126 transfer->out_callback = callback; 127 128 usb_target_t target = { 129 .address = dev->address, 130 .endpoint = endpoint->endpoint 131 }; 122 132 123 133 hc_add_transaction_to_device(true, target, buffer, size, … … 127 137 } 128 138 129 static int enqueue_transfer_in( device_t *dev,130 usb_ target_t target, usb_transfer_type_t transfer_type,139 static int enqueue_transfer_in(usb_hc_device_t *hc, 140 usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint, 131 141 void *buffer, size_t size, 132 usb hc_iface_transfer_in_callback_t callback, void *arg)142 usb_hcd_transfer_callback_in_t callback, void *arg) 133 143 { 134 144 printf(NAME ": transfer IN [%d.%d (%s); %u]\n", 135 target.address, target.endpoint,136 usb_str_transfer_type( transfer_type),145 dev->address, endpoint->endpoint, 146 usb_str_transfer_type(endpoint->transfer_type), 137 147 size); 138 148 139 149 transfer_info_t *transfer 140 = create_transfer_info( dev, USB_DIRECTION_IN, arg);150 = create_transfer_info(hc, USB_DIRECTION_IN, arg); 141 151 transfer->in_callback = callback; 152 153 usb_target_t target = { 154 .address = dev->address, 155 .endpoint = endpoint->endpoint 156 }; 142 157 143 158 hc_add_transaction_from_device(target, buffer, size, … … 148 163 149 164 150 static int interrupt_out(device_t *dev, usb_target_t target, 151 void *data, size_t size, 152 usbhc_iface_transfer_out_callback_t callback, void *arg) 153 { 154 return enqueue_transfer_out(dev, target, USB_TRANSFER_INTERRUPT, 155 data, size, 156 callback, arg); 157 } 158 159 static int interrupt_in(device_t *dev, usb_target_t target, 160 void *data, size_t size, 161 usbhc_iface_transfer_in_callback_t callback, void *arg) 162 { 163 return enqueue_transfer_in(dev, target, USB_TRANSFER_INTERRUPT, 164 data, size, 165 callback, arg); 166 } 167 168 static int control_write_setup(device_t *dev, usb_target_t target, 169 void *data, size_t size, 170 usbhc_iface_transfer_out_callback_t callback, void *arg) 171 { 172 return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL, 173 data, size, 174 callback, arg); 175 } 176 177 static int control_write_data(device_t *dev, usb_target_t target, 178 void *data, size_t size, 179 usbhc_iface_transfer_out_callback_t callback, void *arg) 180 { 181 return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL, 182 data, size, 183 callback, arg); 184 } 185 186 static int control_write_status(device_t *dev, usb_target_t target, 187 usbhc_iface_transfer_in_callback_t callback, void *arg) 188 { 189 return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL, 190 NULL, 0, 191 callback, arg); 192 } 193 194 static int control_read_setup(device_t *dev, usb_target_t target, 195 void *data, size_t size, 196 usbhc_iface_transfer_out_callback_t callback, void *arg) 197 { 198 return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL, 199 data, size, 200 callback, arg); 201 } 202 203 static int control_read_data(device_t *dev, usb_target_t target, 204 void *data, size_t size, 205 usbhc_iface_transfer_in_callback_t callback, void *arg) 206 { 207 return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL, 208 data, size, 209 callback, arg); 210 } 211 212 static int control_read_status(device_t *dev, usb_target_t target, 213 usbhc_iface_transfer_out_callback_t callback, void *arg) 214 { 215 return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL, 216 NULL, 0, 217 callback, arg); 218 } 219 220 221 usbhc_iface_t vhc_iface = { 222 .tell_address = tell_address, 223 224 .reserve_default_address = reserve_default_address, 225 .release_default_address = release_default_address, 226 .request_address = request_address, 227 .bind_address = bind_address, 228 .release_address = release_address, 229 230 .interrupt_out = interrupt_out, 231 .interrupt_in = interrupt_in, 232 233 .control_write_setup = control_write_setup, 234 .control_write_data = control_write_data, 235 .control_write_status = control_write_status, 236 237 .control_read_setup = control_read_setup, 238 .control_read_data = control_read_data, 239 .control_read_status = control_read_status 165 usb_hcd_transfer_ops_t vhc_transfer_ops = { 166 .transfer_out = enqueue_transfer_out, 167 .transfer_in = enqueue_transfer_in, 168 .transfer_setup = enqueue_transfer_setup 240 169 }; 241 170 -
uspace/drv/vhc/hcd.c
r45e9cc6 r4144630 52 52 #include "conn.h" 53 53 54 static device_ops_t vhc_ops = {55 .interfaces[USBHC_DEV_IFACE] = &vhc_iface,56 .default_handler = default_connection_handler57 };58 54 59 55 static int vhc_count = 0; 60 static int vhc_add_device( device_t *dev)56 static int vhc_add_device(usb_hc_device_t *dev) 61 57 { 62 58 /* … … 69 65 vhc_count++; 70 66 71 dev->ops = &vhc_ops; 72 73 /* 74 * Initialize address management. 75 */ 76 address_init(); 67 dev->transfer_ops = &vhc_transfer_ops; 68 dev->generic->ops->default_handler = default_connection_handler; 77 69 78 70 /* … … 87 79 } 88 80 89 static driver_ops_t vhc_driver_ops = { 90 .add_device = vhc_add_device, 91 }; 92 93 static driver_t vhc_driver = { 81 static usb_hc_driver_t vhc_driver = { 94 82 .name = NAME, 95 . driver_ops = &vhc_driver_ops83 .add_hc = &vhc_add_device 96 84 }; 97 85 … … 126 114 sleep(4); 127 115 128 return driver_main(&vhc_driver);116 return usb_hcd_main(&vhc_driver); 129 117 } 130 118 -
uspace/drv/vhc/vhc.ma
r45e9cc6 r4144630 1 1 10 usb&hc=vhc 2 2 10 usb&hc=vhc&hub -
uspace/lib/block/libblock.c
r45e9cc6 r4144630 66 66 fibril_mutex_t lock; 67 67 size_t lblock_size; /**< Logical block size. */ 68 unsigned blocks_cluster; /**< Physical blocks per block_t */69 68 unsigned block_count; /**< Total number of blocks. */ 70 69 unsigned blocks_cached; /**< Number of cached blocks. */ … … 91 90 static int get_block_size(int dev_phone, size_t *bsize); 92 91 static int get_num_blocks(int dev_phone, aoff64_t *nblocks); 93 static aoff64_t ba_ltop(devcon_t *devcon, aoff64_t lba);94 92 95 93 static devcon_t *devcon_search(devmap_handle_t devmap_handle) … … 261 259 { 262 260 block_t *b = hash_table_get_instance(item, block_t, hash_link); 263 return b-> lba== *key;261 return b->boff == *key; 264 262 } 265 263 … … 294 292 cache->mode = mode; 295 293 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); 301 296 302 297 if (!hash_table_create(&cache->block_hash, CACHE_BUCKETS, 1, … … 334 329 if (b->dirty) { 335 330 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); 337 332 if (rc != EOK) 338 333 return rc; 339 334 } 340 335 341 unsigned long key = b-> lba;336 unsigned long key = b->boff; 342 337 hash_table_remove(&cache->block_hash, &key, 1); 343 338 … … 380 375 * block pointer on success. 381 376 * @param devmap_handle Device handle of the block device. 382 * @param b a Block address (logical).377 * @param boff Block offset. 383 378 * @param flags If BLOCK_FLAGS_NOREAD is specified, block_get() 384 379 * will not read the contents of the block from the … … 387 382 * @return EOK on success or a negative error code. 388 383 */ 389 int block_get(block_t **block, devmap_handle_t devmap_handle, aoff64_t b a, int flags)384 int block_get(block_t **block, devmap_handle_t devmap_handle, aoff64_t boff, int flags) 390 385 { 391 386 devcon_t *devcon; … … 393 388 block_t *b; 394 389 link_t *l; 395 unsigned long key = b a;390 unsigned long key = boff; 396 391 int rc; 397 392 … … 470 465 fibril_mutex_lock(&devcon->comm_area_lock); 471 466 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); 474 468 fibril_mutex_unlock(&devcon->comm_area_lock); 475 469 if (rc != EOK) { … … 501 495 */ 502 496 list_remove(&b->free_link); 503 temp_key = b-> lba;497 temp_key = b->boff; 504 498 hash_table_remove(&cache->block_hash, &temp_key, 1); 505 499 } … … 508 502 b->devmap_handle = devmap_handle; 509 503 b->size = cache->lblock_size; 510 b->lba = ba; 511 b->pba = ba_ltop(devcon, b->lba); 504 b->boff = boff; 512 505 hash_table_insert(&cache->block_hash, &key, &b->hash_link); 513 506 … … 526 519 */ 527 520 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); 529 522 memcpy(b->data, devcon->comm_area, cache->lblock_size); 530 523 fibril_mutex_unlock(&devcon->comm_area_lock); … … 587 580 fibril_mutex_lock(&devcon->comm_area_lock); 588 581 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); 590 583 fibril_mutex_unlock(&devcon->comm_area_lock); 591 584 block->dirty = false; … … 621 614 * Take the block out of the cache and free it. 622 615 */ 623 unsigned long key = block-> lba;616 unsigned long key = block->boff; 624 617 hash_table_remove(&cache->block_hash, &key, 1); 625 618 free(block); … … 719 712 * 720 713 * @param devmap_handle Device handle of the block device. 721 * @param ba Address of first block (physical).714 * @param ba Address of first block. 722 715 * @param cnt Number of blocks. 723 716 * @param src Buffer for storing the data. … … 747 740 * 748 741 * @param devmap_handle Device handle of the block device. 749 * @param ba Address of first block (physical).742 * @param ba Address of first block. 750 743 * @param cnt Number of blocks. 751 744 * @param src The data to be written. … … 886 879 } 887 880 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 895 881 /** @} 896 882 */ -
uspace/lib/block/libblock.h
r45e9cc6 r4144630 73 73 /** Handle of the device where the block resides. */ 74 74 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; 79 77 /** Size of the block. */ 80 78 size_t size; -
uspace/lib/drv/generic/remote_usbhc.c
r45e9cc6 r4144630 52 52 static void remote_usbhc_control_read_data(device_t *, void *, ipc_callid_t, ipc_call_t *); 53 53 static void remote_usbhc_control_read_status(device_t *, void *, ipc_callid_t, ipc_call_t *); 54 static void remote_usbhc_reserve_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);55 static void remote_usbhc_release_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);56 static void remote_usbhc_request_address(device_t *, void *, ipc_callid_t, ipc_call_t *);57 static void remote_usbhc_bind_address(device_t *, void *, ipc_callid_t, ipc_call_t *);58 static void remote_usbhc_release_address(device_t *, void *, ipc_callid_t, ipc_call_t *);59 54 //static void remote_usbhc(device_t *, void *, ipc_callid_t, ipc_call_t *); 60 55 … … 62 57 static remote_iface_func_ptr_t remote_usbhc_iface_ops [] = { 63 58 remote_usbhc_get_address, 64 65 59 remote_usbhc_get_buffer, 66 67 remote_usbhc_reserve_default_address,68 remote_usbhc_release_default_address,69 70 remote_usbhc_request_address,71 remote_usbhc_bind_address,72 remote_usbhc_release_address,73 74 60 remote_usbhc_interrupt_out, 75 61 remote_usbhc_interrupt_in, 76 77 62 remote_usbhc_control_write_setup, 78 63 remote_usbhc_control_write_data, 79 64 remote_usbhc_control_write_status, 80 81 65 remote_usbhc_control_read_setup, 82 66 remote_usbhc_control_read_data, … … 150 134 free(trans->buffer); 151 135 free(trans); 152 }153 154 void remote_usbhc_reserve_default_address(device_t *device, void *iface,155 ipc_callid_t callid, ipc_call_t *call)156 {157 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;158 159 if (!usb_iface->reserve_default_address) {160 ipc_answer_0(callid, ENOTSUP);161 return;162 }163 164 int rc = usb_iface->reserve_default_address(device);165 166 ipc_answer_0(callid, rc);167 }168 169 void remote_usbhc_release_default_address(device_t *device, void *iface,170 ipc_callid_t callid, ipc_call_t *call)171 {172 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;173 174 if (!usb_iface->release_default_address) {175 ipc_answer_0(callid, ENOTSUP);176 return;177 }178 179 int rc = usb_iface->release_default_address(device);180 181 ipc_answer_0(callid, rc);182 }183 184 void remote_usbhc_request_address(device_t *device, void *iface,185 ipc_callid_t callid, ipc_call_t *call)186 {187 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;188 189 if (!usb_iface->request_address) {190 ipc_answer_0(callid, ENOTSUP);191 return;192 }193 194 usb_address_t address;195 int rc = usb_iface->request_address(device, &address);196 if (rc != EOK) {197 ipc_answer_0(callid, rc);198 } else {199 ipc_answer_1(callid, EOK, (ipcarg_t) address);200 }201 }202 203 void remote_usbhc_bind_address(device_t *device, void *iface,204 ipc_callid_t callid, ipc_call_t *call)205 {206 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;207 208 if (!usb_iface->bind_address) {209 ipc_answer_0(callid, ENOTSUP);210 return;211 }212 213 usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call);214 devman_handle_t handle = (devman_handle_t) IPC_GET_ARG2(*call);215 216 int rc = usb_iface->bind_address(device, address, handle);217 218 ipc_answer_0(callid, rc);219 }220 221 void remote_usbhc_release_address(device_t *device, void *iface,222 ipc_callid_t callid, ipc_call_t *call)223 {224 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;225 226 if (!usb_iface->release_address) {227 ipc_answer_0(callid, ENOTSUP);228 return;229 }230 231 usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call);232 233 int rc = usb_iface->release_address(device, address);234 235 ipc_answer_0(callid, rc);236 136 } 237 137 -
uspace/lib/drv/include/usbhc_iface.h
r45e9cc6 r4144630 111 111 112 112 113 /** Reserve usage of default address.114 * This call informs the host controller that the caller will be115 * using default USB address. It is duty of the HC driver to ensure116 * that only single entity will have it reserved.117 * The address is returned via IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS.118 * The caller can start using the address after receiving EOK119 * answer.120 */121 IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS,122 123 /** Release usage of default address.124 * @see IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS125 */126 IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS,127 128 /** Asks for address assignment by host controller.129 * Answer:130 * - ELIMIT - host controller run out of address131 * - EOK - address assigned132 * Answer arguments:133 * - assigned address134 *135 * The address must be released by via IPC_M_USBHC_RELEASE_ADDRESS.136 */137 IPC_M_USBHC_REQUEST_ADDRESS,138 139 /** Bind USB address with devman handle.140 * Parameters:141 * - USB address142 * - devman handle143 * Answer:144 * - EOK - address binded145 * - ENOENT - address is not in use146 */147 IPC_M_USBHC_BIND_ADDRESS,148 149 /** Release address in use.150 * Arguments:151 * - address to be released152 * Answer:153 * - ENOENT - address not in use154 * - EPERM - trying to release default USB address155 */156 IPC_M_USBHC_RELEASE_ADDRESS,157 158 159 113 /** Send interrupt data to device. 160 114 * See explanation at usb_iface_funcs_t (OUT transaction). … … 229 183 typedef struct { 230 184 int (*tell_address)(device_t *, devman_handle_t, usb_address_t *); 231 232 int (*reserve_default_address)(device_t *);233 int (*release_default_address)(device_t *);234 int (*request_address)(device_t *, usb_address_t *);235 int (*bind_address)(device_t *, usb_address_t, devman_handle_t);236 int (*release_address)(device_t *, usb_address_t);237 185 238 186 usbhc_iface_transfer_out_t interrupt_out; -
uspace/lib/usb/Makefile
r45e9cc6 r4144630 35 35 src/hcdhubd.c \ 36 36 src/hcdrv.c \ 37 src/hubdrv.c \ 37 38 src/localdrv.c \ 38 39 src/remotedrv.c \ -
uspace/lib/usb/include/usb/hcdhubd.h
r45e9cc6 r4144630 166 166 167 167 int usb_hcd_main(usb_hc_driver_t *); 168 int usb_hcd_add_root_hub( device_t *dev);168 int usb_hcd_add_root_hub(usb_hc_device_t *dev); 169 169 170 170 /** … … 191 191 */ 192 192 193 device_t *usb_hc_connect(device_t *);194 193 195 194 int usb_hc_async_interrupt_out(usb_hc_device_t *, usb_target_t, -
uspace/lib/usb/include/usb/usbdrv.h
r45e9cc6 r4144630 41 41 int usb_drv_hc_connect(device_t *, unsigned int); 42 42 43 int usb_drv_reserve_default_address(int);44 int usb_drv_release_default_address(int);45 usb_address_t usb_drv_request_address(int);46 int usb_drv_bind_address(int, usb_address_t, devman_handle_t);47 int usb_drv_release_address(int, usb_address_t);48 49 43 usb_address_t usb_drv_get_my_address(int, device_t *); 50 44 -
uspace/lib/usb/src/hcdhubd.c
r45e9cc6 r4144630 51 51 */ 52 52 static int add_device(device_t *dev) { 53 return ENOTSUP; 53 bool is_hc = str_cmp(dev->name, USB_HUB_DEVICE_NAME) != 0; 54 printf("%s: add_device(name=\"%s\")\n", hc_driver->name, dev->name); 55 56 if (is_hc) { 57 /* 58 * We are the HC itself. 59 */ 60 return usb_add_hc_device(dev); 61 } else { 62 /* 63 * We are some (maybe deeply nested) hub. 64 * Thus, assign our own operations and explore already 65 * connected devices. 66 */ 67 return usb_add_hub_device(dev); 68 } 54 69 } 55 70 … … 90 105 * @return Error code. 91 106 */ 92 int usb_hcd_add_root_hub(device_t *dev) 93 { 107 int usb_hcd_add_root_hub(usb_hc_device_t *dev) { 94 108 char *id; 95 int rc = asprintf(&id, "usb&h ub");109 int rc = asprintf(&id, "usb&hc=%s&hub", dev->generic->name); 96 110 if (rc <= 0) { 97 111 return rc; 98 112 } 99 113 100 rc = usb_hc_add_child_device(dev , USB_HUB_DEVICE_NAME, id, true);114 rc = usb_hc_add_child_device(dev->generic, USB_HUB_DEVICE_NAME, id, true); 101 115 if (rc != EOK) { 102 116 free(id); … … 119 133 int rc; 120 134 121 async_usleep(1000);122 123 135 device_t *child = create_device(); 124 136 match_id_t *match_id = NULL; … … 184 196 printf("%s: about to add child device `%s' (%s)\n", hc_driver->name, 185 197 name, match_id); 186 187 /*188 * Seems that creating fibril which postpones the action189 * is the best solution.190 */191 create_fibril = true;192 198 193 199 struct child_device_info *child_info -
uspace/lib/usb/src/hcdhubd_private.h
r45e9cc6 r4144630 46 46 usb_address_t usb_get_address_by_handle(devman_handle_t); 47 47 int usb_add_hc_device(device_t *); 48 int usb_add_hub_device(device_t *); 48 49 49 50 /** lowest allowed usb address */ -
uspace/lib/usb/src/hcdrv.c
r45e9cc6 r4144630 47 47 LIST_INITIALIZE(hc_list); 48 48 49 /* Fake driver to have the name item initialized. */50 static usb_hc_driver_t hc_driver_fake = {51 .name = "HCD",52 };53 54 49 /** Our HC driver. */ 55 usb_hc_driver_t *hc_driver = &hc_driver_fake;50 usb_hc_driver_t *hc_driver = NULL; 56 51 57 52 int usb_lowest_address = 1; … … 91 86 int usb_add_hc_device(device_t *dev) 92 87 { 93 return ENOTSUP;94 88 usb_hc_device_t *hc_dev = usb_hc_device_create(dev); 95 89 -
uspace/lib/usb/src/localdrv.c
r45e9cc6 r4144630 39 39 #include <errno.h> 40 40 41 /** Find host controller when handled by current task.42 *43 * @param dev Device asking for connection.44 * @return Device structure corresponding to parent host controller.45 * @retval NULL Corresponding host controller not found.46 */47 device_t *usb_hc_connect(device_t *dev)48 {49 /*50 * FIXME: this will not work when some hub on the path is51 * not driven by the same task.52 */53 device_t *parent = dev;54 while (parent->parent != NULL) {55 parent = parent->parent;56 }57 58 if (dev == parent) {59 printf("FIXME in %s:%d encountered!\n", __FILE__, __LINE__);60 parent = NULL;61 }62 63 return parent;64 }65 66 41 /** Information about pending transaction on HC. */ 67 42 typedef struct { -
uspace/lib/usb/src/usbdrv.c
r45e9cc6 r4144630 55 55 /** Connect to host controller the device is physically attached to. 56 56 * 57 * @param dev Device asking for connection.57 * @param handle Device handle. 58 58 * @param flags Connection flags (blocking connection). 59 59 * @return Phone to corresponding HC or error code. … … 98 98 99 99 return (usb_address_t) address; 100 }101 102 /** Tell HC to reserve default address.103 *104 * @param phone Open phone to host controller driver.105 * @return Error code.106 */107 int usb_drv_reserve_default_address(int phone)108 {109 return async_req_0_0(phone, IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS);110 }111 112 /** Tell HC to release default address.113 *114 * @param phone Open phone to host controller driver.115 * @return Error code.116 */117 int usb_drv_release_default_address(int phone)118 {119 return async_req_0_0(phone, IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS);120 }121 122 /** Ask HC for free address assignment.123 *124 * @param phone Open phone to host controller driver.125 * @return Assigned USB address or negative error code.126 */127 usb_address_t usb_drv_request_address(int phone)128 {129 ipcarg_t address;130 int rc = async_req_0_1(phone, IPC_M_USBHC_REQUEST_ADDRESS, &address);131 if (rc != EOK) {132 return rc;133 } else {134 return (usb_address_t) address;135 }136 }137 138 /** Inform HC about binding address with devman handle.139 *140 * @param phone Open phone to host controller driver.141 * @param address Address to be binded.142 * @param handle Devman handle of the device.143 * @return Error code.144 */145 int usb_drv_bind_address(int phone, usb_address_t address,146 devman_handle_t handle)147 {148 int rc = async_req_2_0(phone, IPC_M_USBHC_BIND_ADDRESS,149 address, handle);150 151 return rc;152 }153 154 /** Inform HC about address release.155 *156 * @param phone Open phone to host controller driver.157 * @param address Address to be released.158 * @return Error code.159 */160 int usb_drv_release_address(int phone, usb_address_t address)161 {162 return async_req_1_0(phone, IPC_M_USBHC_RELEASE_ADDRESS, address);163 100 } 164 101 -
uspace/srv/bd/file_bd/file_bd.c
r45e9cc6 r4144630 56 56 #define NAME "file_bd" 57 57 58 #define DEFAULT_BLOCK_SIZE 512 59 60 static size_t block_size; 58 static const size_t block_size = 512; 61 59 static aoff64_t num_blocks; 62 60 static FILE *img; … … 65 63 static fibril_mutex_t dev_lock; 66 64 67 static void print_usage(void);68 65 static int file_bd_init(const char *fname); 69 66 static void file_bd_connection(ipc_callid_t iid, ipc_call_t *icall); … … 74 71 { 75 72 int rc; 76 char *image_name;77 char *device_name;78 73 79 74 printf(NAME ": File-backed block device driver\n"); 80 75 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"); 111 78 return -1; 112 79 } 113 80 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) 118 82 return -1; 119 83 120 rc = devmap_device_register( device_name, &devmap_handle);84 rc = devmap_device_register(argv[2], &devmap_handle); 121 85 if (rc != EOK) { 122 86 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]); 125 89 return rc; 126 90 } … … 132 96 /* Not reached */ 133 97 return 0; 134 }135 136 static void print_usage(void)137 {138 printf("Usage: " NAME " [-b <block_size>] <image_file> <device_name>\n");139 98 } 140 99
Note:
See TracChangeset
for help on using the changeset viewer.