Changeset c01255c in mainline
- Timestamp:
- 2010-12-10T15:12:25Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 10096231
- Parents:
- 98d06b8 (diff), 7964475 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 23 added
- 2 deleted
- 49 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
r98d06b8 rc01255c 62 62 ./uspace/app/trace/trace 63 63 ./uspace/app/usb/usb 64 ./uspace/app/usbinfo/usbinfo 64 65 ./uspace/app/virtusbkbd/vuk 65 ./uspace/dist/app/bdsh 66 ./uspace/dist/app/edit 67 ./uspace/dist/app/getterm 68 ./uspace/dist/app/klog 69 ./uspace/dist/app/mkfat 70 ./uspace/dist/app/netecho 71 ./uspace/dist/app/netstart 72 ./uspace/dist/app/nettest1 73 ./uspace/dist/app/nettest2 74 ./uspace/dist/app/ping 75 ./uspace/dist/app/redir 76 ./uspace/dist/app/sbi 77 ./uspace/dist/app/stats 78 ./uspace/dist/app/taskdump 79 ./uspace/dist/app/tasks 80 ./uspace/dist/app/tester 81 ./uspace/dist/app/test_serial 82 ./uspace/dist/app/tetris 83 ./uspace/dist/app/top 84 ./uspace/dist/app/trace 85 ./uspace/dist/app/usb 86 ./uspace/dist/app/vuk 66 ./uspace/dist/app/* 87 67 ./uspace/dist/cfg/net/general 88 68 ./uspace/dist/cfg/net/lo 89 69 ./uspace/dist/cfg/net/ne2k 90 ./uspace/dist/drv/isa/ 91 ./uspace/dist/drv/ns8250/ 92 ./uspace/dist/drv/pciintel/ 93 ./uspace/dist/drv/root/ 94 ./uspace/dist/drv/rootia32/ 95 ./uspace/dist/drv/uhci/ 96 ./uspace/dist/drv/usbhub/ 97 ./uspace/dist/drv/usbkbd/ 98 ./uspace/dist/drv/vhc/ 99 ./uspace/dist/srv/arp 100 ./uspace/dist/srv/ata_bd 101 ./uspace/dist/srv/char_ms 102 ./uspace/dist/srv/clip 103 ./uspace/dist/srv/console 104 ./uspace/dist/srv/devfs 105 ./uspace/dist/srv/devman 106 ./uspace/dist/srv/dp8390 107 ./uspace/dist/srv/eth 108 ./uspace/dist/srv/fat 109 ./uspace/dist/srv/fb 110 ./uspace/dist/srv/file_bd 111 ./uspace/dist/srv/g_part 112 ./uspace/dist/srv/i8042 113 ./uspace/dist/srv/icmp 114 ./uspace/dist/srv/ip 115 ./uspace/dist/srv/kbd 116 ./uspace/dist/srv/lo 117 ./uspace/dist/srv/mbr_part 118 ./uspace/dist/srv/net 119 ./uspace/dist/srv/netstart 120 ./uspace/dist/srv/nildummy 121 ./uspace/dist/srv/pci 122 ./uspace/dist/srv/taskmon 123 ./uspace/dist/srv/tcp 124 ./uspace/dist/srv/tmpfs 125 ./uspace/dist/srv/udp 126 ./uspace/dist/srv/vhcd 70 ./uspace/dist/drv/* 71 ./uspace/dist/srv/* 127 72 ./uspace/drv/root/root 128 73 ./uspace/drv/isa/isa 129 74 ./uspace/drv/ns8250/ns8250 130 75 ./uspace/drv/pciintel/pciintel 131 ./uspace/drv/rootia32/rootia32 76 ./uspace/drv/rootpc/rootpc 77 ./uspace/drv/rootvirt/rootvirt 78 ./uspace/drv/test1/test1 79 ./uspace/drv/test2/test2 132 80 ./uspace/drv/uhci/uhci 133 81 ./uspace/drv/usbhub/usbhub -
HelenOS.config
r98d06b8 rc01255c 545 545 % Line debugging information 546 546 ! [CONFIG_STRIP_BINARIES!=y] CONFIG_LINE_DEBUG (n/y) 547 548 % Launch (devman) test drivers 549 ! [CONFIG_DEBUG=y] CONFIG_TEST_DRIVERS (y/n) 550 -
Makefile
r98d06b8 rc01255c 41 41 CONFIG_HEADER = config.h 42 42 43 .PHONY: all precheck cscope autotool config_ default config distclean clean43 .PHONY: all precheck cscope autotool config_auto config_default config distclean clean 44 44 45 45 all: $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) … … 66 66 67 67 config_default: $(CONFIG_RULES) 68 $(CONFIG) $< default 68 ifeq ($(HANDS_OFF),y) 69 $(CONFIG) $< hands-off $(PROFILE) 70 else 71 $(CONFIG) $< default $(PROFILE) 72 endif 69 73 70 74 config: $(CONFIG_RULES) -
boot/Makefile.common
r98d06b8 rc01255c 111 111 RD_DRVS = \ 112 112 root \ 113 rootvirt \ 114 test1 \ 115 test2 \ 113 116 vhc 114 117 … … 142 145 $(USPACE_PATH)/app/ping/ping \ 143 146 $(USPACE_PATH)/app/stats/stats \ 144 $(USPACE_PATH)/app/virtusbkbd/vuk \145 147 $(USPACE_PATH)/app/tasks/tasks \ 146 $(USPACE_PATH)/app/top/top 148 $(USPACE_PATH)/app/top/top \ 149 $(USPACE_PATH)/app/usbinfo/usbinfo \ 150 $(USPACE_PATH)/app/virtusbkbd/vuk 147 151 148 152 ifneq ($(CONFIG_BAREBONE),y) -
boot/arch/amd64/Makefile.inc
r98d06b8 rc01255c 37 37 38 38 RD_DRVS += \ 39 root ia32\39 rootpc \ 40 40 pciintel \ 41 41 isa \ -
tools/config.py
r98d06b8 rc01255c 47 47 48 48 def read_config(fname, config): 49 "Read saved values from last configuration run "49 "Read saved values from last configuration run or a preset file" 50 50 51 51 inf = open(fname, 'r') … … 218 218 # and verify that all variables have a value (previously specified or inferred). 219 219 # 220 # @param config 221 # @param rules 222 # 223 # @return 224 # 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 225 # 226 226 def infer_verify_choices(config, rules): … … 229 229 for rule in rules: 230 230 varname, vartype, name, choices, cond = rule 231 231 232 232 if cond and (not check_condition(cond, config, rules)): 233 233 continue … … 237 237 else: 238 238 value = config[varname] 239 240 if not rule_value_is_valid(rule, value):239 240 if not validate_rule_value(rule, value): 241 241 value = None 242 243 default = rule_get_default(rule) 244 if default != None: 242 243 default = get_default_rule(rule) 244 245 # 246 # If we don't have a value but we do have 247 # a default, use it. 248 # 249 if value == None and default != None: 250 value = default 245 251 config[varname] = default 246 252 247 253 if not varname in config: 248 254 return False … … 251 257 252 258 ## Get default value from a rule. 253 def rule_get_default(rule):259 def get_default_rule(rule): 254 260 varname, vartype, name, choices, cond = rule 255 261 256 262 default = None 257 263 258 264 if vartype == 'choice': 259 265 # If there is just one option, use it … … 270 276 else: 271 277 raise RuntimeError("Unknown variable type: %s" % vartype) 272 278 273 279 return default 274 280 275 281 ## Get option from a rule. 276 282 # 277 # @param rule 278 # @param value 283 # @param rule Rule for a variable 284 # @param value Current value of the variable 279 285 # 280 286 # @return Option (string) to ask or None which means not to ask. 281 287 # 282 def rule_get_option(rule, value):288 def get_rule_option(rule, value): 283 289 varname, vartype, name, choices, cond = rule 284 290 285 291 option = None 286 292 287 293 if vartype == 'choice': 288 294 # If there is just one option, don't ask … … 302 308 else: 303 309 raise RuntimeError("Unknown variable type: %s" % vartype) 304 310 305 311 return option 306 312 307 313 ## Check if variable value is valid. 308 314 # 309 # @param rule 310 # @param value 311 # 312 # @return 313 # 314 def rule_value_is_valid(rule, value):315 # @param rule Rule for the variable 316 # @param value Value of the variable 317 # 318 # @return True if valid, False if not valid. 319 # 320 def validate_rule_value(rule, value): 315 321 varname, vartype, name, choices, cond = rule 316 322 317 323 if value == None: 318 324 return True 319 325 320 326 if vartype == 'choice': 321 327 if not value in [choice[0] for choice in choices]: … … 335 341 else: 336 342 raise RuntimeError("Unknown variable type: %s" % vartype) 337 343 338 344 return True 339 345 … … 413 419 return list 414 420 415 ## Choose a profile and load configuration presets.416 # 417 def load_presets(root, fname, screen, config):421 ## Ask user to choose a configuration profile. 422 # 423 def choose_profile(root, fname, screen, config): 418 424 options = [] 419 425 opt2path = {} … … 436 442 subprofile = True 437 443 options.append("%s (%s)" % (name, subname)) 438 opt2path[cnt] = (canon, subcanon)444 opt2path[cnt] = [name, subname] 439 445 cnt += 1 440 446 441 447 if not subprofile: 442 448 options.append(name) 443 opt2path[cnt] = (canon, None)449 opt2path[cnt] = [name] 444 450 cnt += 1 445 451 … … 449 455 return None 450 456 451 read_config(opt2path[value][0], config) 452 if opt2path[value][1] != None: 453 read_config(opt2path[value][1], config) 457 return opt2path[value] 458 459 ## Read presets from a configuration profile. 460 # 461 # @param profile Profile to load from (a list of string components) 462 # @param config Output configuration 463 # 464 def read_presets(profile, config): 465 path = os.path.join(PRESETS_DIR, profile[0], MAKEFILE) 466 read_config(path, config) 467 468 if len(profile) > 1: 469 path = os.path.join(PRESETS_DIR, profile[0], profile[1], MAKEFILE) 470 read_config(path, config) 471 472 ## Parse profile name (relative OS path) into a list of components. 473 # 474 # @param profile_name Relative path (using OS separator) 475 # @return List of components 476 # 477 def parse_profile_name(profile_name): 478 profile = [] 479 480 head, tail = os.path.split(profile_name) 481 if head != '': 482 profile.append(head) 483 484 profile.append(tail) 485 return profile 454 486 455 487 def main(): 488 profile = None 456 489 config = {} 457 490 rules = [] … … 460 493 parse_rules(RULES_FILE, rules) 461 494 462 # Read configuration from previous run 463 if os.path.exists(MAKEFILE): 495 # Input configuration file can be specified on command line 496 # otherwise configuration from previous run is used. 497 if len(sys.argv) >= 4: 498 profile = parse_profile_name(sys.argv[3]) 499 read_presets(profile, config) 500 elif os.path.exists(MAKEFILE): 464 501 read_config(MAKEFILE, config) 465 502 466 # Default mode: onlycheck values and regenerate configuration files503 # Default mode: check values and regenerate configuration files 467 504 if (len(sys.argv) >= 3) and (sys.argv[2] == 'default'): 468 505 if (infer_verify_choices(config, rules)): 469 506 create_output(MAKEFILE, MACROS, config, rules) 470 507 return 0 508 509 # Hands-off mode: check values and regenerate configuration files, 510 # but no interactive fallback 511 if (len(sys.argv) >= 3) and (sys.argv[2] == 'hands-off'): 512 # We deliberately test sys.argv >= 4 because we do not want 513 # to read implicitly any possible previous run configuration 514 if len(sys.argv) < 4: 515 sys.stderr.write("Configuration error: No presets specified\n") 516 return 2 517 518 if (infer_verify_choices(config, rules)): 519 create_output(MAKEFILE, MACROS, config, rules) 520 return 0 521 522 sys.stderr.write("Configuration error: The presets are ambiguous\n") 523 return 1 471 524 472 525 # Check mode: only check configuration … … 507 560 value = config[varname] 508 561 509 if not rule_value_is_valid(rule, value):562 if not validate_rule_value(rule, value): 510 563 value = None 511 512 default = rule_get_default(rule) 513 if default != None: 564 565 default = get_default_rule(rule) 566 567 # 568 # If we don't have a value but we do have 569 # a default, use it. 570 # 571 if value == None and default != None: 514 572 value = default 515 573 config[varname] = default 516 517 option = rule_get_option(rule, value)574 575 option = get_rule_option(rule, value) 518 576 if option != None: 519 577 options.append(option) 578 else: 579 continue 520 580 521 581 opt2row[cnt] = (varname, vartype, name, choices) … … 539 599 540 600 if value == 0: 541 load_presets(PRESETS_DIR, MAKEFILE, screen, config) 601 profile = choose_profile(PRESETS_DIR, MAKEFILE, screen, config) 602 if profile != None: 603 read_presets(profile, config) 542 604 position = 1 543 605 continue -
uspace/Makefile
r98d06b8 rc01255c 49 49 app/trace \ 50 50 app/top \ 51 app/usbinfo \ 51 52 app/virtusbkbd \ 52 53 app/netecho \ … … 87 88 srv/net/net \ 88 89 drv/root \ 90 drv/rootvirt \ 91 drv/test1 \ 92 drv/test2 \ 89 93 drv/vhc 90 94 … … 110 114 111 115 ifeq ($(UARCH),amd64) 116 DIRS += drv/rootpc 117 DIRS += drv/pciintel 118 DIRS += drv/isa 119 DIRS += drv/ns8250 112 120 endif 113 121 114 122 ifeq ($(UARCH),ia32) 115 DIRS += drv/root ia32123 DIRS += drv/rootpc 116 124 DIRS += drv/pciintel 117 125 DIRS += drv/isa -
uspace/app/netecho/print_error.c
r98d06b8 rc01255c 164 164 case EDESTADDRREQ: 165 165 fprintf(output, "Destination address required (%d) error", error_code); 166 case TRY_AGAIN:166 case EAGAIN: 167 167 fprintf(output, "Try again (%d) error", error_code); 168 168 default: -
uspace/app/tester/Makefile
r98d06b8 rc01255c 31 31 BINARY = tester 32 32 33 LIBS += $(LIBUSB_PREFIX)/libusb.a 34 EXTRA_CFLAGS += -I$(LIBUSB_PREFIX)/include 35 33 36 SOURCES = \ 34 37 tester.c \ 38 adt/usbaddrkeep.c \ 35 39 thread/thread1.c \ 36 40 print/print1.c \ -
uspace/app/tester/tester.c
r98d06b8 rc01255c 65 65 #include "mm/malloc1.def" 66 66 #include "hw/serial/serial1.def" 67 #include "adt/usbaddrkeep.def" 67 68 {NULL, NULL, NULL, false} 68 69 }; -
uspace/app/tester/tester.h
r98d06b8 rc01255c 82 82 extern const char *test_malloc1(void); 83 83 extern const char *test_serial1(void); 84 extern const char *test_usbaddrkeep(void); 84 85 85 86 extern test_t tests[]; -
uspace/drv/isa/isa.c
r98d06b8 rc01255c 282 282 283 283 printf(NAME ": added io range (addr=0x%x, size=0x%x) to " 284 "device %s\n", addr, len, dev->name); 284 "device %s\n", (unsigned int) addr, (unsigned int) len, 285 dev->name); 285 286 } 286 287 } … … 489 490 static int isa_add_device(device_t *dev) 490 491 { 491 printf(NAME ": isa_add_device, device handle = %d\n", dev->handle); 492 printf(NAME ": isa_add_device, device handle = %d\n", 493 (int) dev->handle); 492 494 493 495 /* Add child devices. */ -
uspace/drv/ns8250/ns8250.c
r98d06b8 rc01255c 274 274 275 275 /* Gain control over port's registers. */ 276 if (pio_enable((void *) data->io_addr, REG_COUNT,276 if (pio_enable((void *)(uintptr_t) data->io_addr, REG_COUNT, 277 277 (void **) &data->port)) { 278 278 printf(NAME ": error - cannot gain the port %#" PRIx32 " for device " … … 727 727 { 728 728 printf(NAME ": ns8250_add_device %s (handle = %d)\n", 729 dev->name, dev->handle);729 dev->name, (int) dev->handle); 730 730 731 731 int res = ns8250_dev_initialize(dev); -
uspace/drv/pciintel/pci.c
r98d06b8 rc01255c 324 324 printf(NAME ": device %s : ", dev->name); 325 325 printf("address = %" PRIx64, range_addr); 326 printf(", size = %x\n", range_size);326 printf(", size = %x\n", (unsigned int) range_size); 327 327 } 328 328 … … 489 489 (uint32_t) hw_resources.resources[0].res.io_range.address; 490 490 491 if (pio_enable((void *) bus_data->conf_io_addr, 8,491 if (pio_enable((void *)(uintptr_t)bus_data->conf_io_addr, 8, 492 492 &bus_data->conf_addr_port)) { 493 493 printf(NAME ": failed to enable configuration ports.\n"); -
uspace/drv/root/root.c
r98d06b8 rc01255c 1 1 /* 2 2 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2010 Vojtech Horky 3 4 * All rights reserved. 4 5 * … … 53 54 #define NAME "root" 54 55 56 #define PLATFORM_DEVICE_NAME "hw" 57 #define PLATFORM_DEVICE_MATCH_ID STRING(UARCH) 58 #define PLATFORM_DEVICE_MATCH_SCORE 100 59 60 #define VIRTUAL_DEVICE_NAME "virt" 61 #define VIRTUAL_DEVICE_MATCH_ID "rootvirt" 62 #define VIRTUAL_DEVICE_MATCH_SCORE 100 63 55 64 static int root_add_device(device_t *dev); 56 65 … … 66 75 }; 67 76 77 /** Create the device which represents the root of virtual device tree. 78 * 79 * @param parent Parent of the newly created device. 80 * @return Error code. 81 */ 82 static int add_virtual_root_child(device_t *parent) 83 { 84 printf(NAME ": adding new child for virtual devices.\n"); 85 printf(NAME ": device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME, 86 VIRTUAL_DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID); 87 88 int res = child_device_register_wrapper(parent, VIRTUAL_DEVICE_NAME, 89 VIRTUAL_DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE); 90 91 return res; 92 } 93 68 94 /** Create the device which represents the root of HW device tree. 69 95 * … … 74 100 { 75 101 printf(NAME ": adding new child for platform device.\n"); 102 printf(NAME ": device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME, 103 PLATFORM_DEVICE_MATCH_SCORE, PLATFORM_DEVICE_MATCH_ID); 76 104 77 int res = EOK; 78 device_t *platform = NULL; 79 match_id_t *match_id = NULL; 80 81 /* Create new device. */ 82 platform = create_device(); 83 if (NULL == platform) { 84 res = ENOMEM; 85 goto failure; 86 } 87 88 platform->name = "hw"; 89 printf(NAME ": the new device's name is %s.\n", platform->name); 90 91 /* Initialize match id list. */ 92 match_id = create_match_id(); 93 if (NULL == match_id) { 94 res = ENOMEM; 95 goto failure; 96 } 97 98 /* TODO - replace this with some better solution (sysinfo ?) */ 99 match_id->id = STRING(UARCH); 100 match_id->score = 100; 101 add_match_id(&platform->match_ids, match_id); 102 103 /* Register child device. */ 104 res = child_device_register(platform, parent); 105 if (EOK != res) 106 goto failure; 107 105 int res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME, 106 PLATFORM_DEVICE_MATCH_ID, PLATFORM_DEVICE_MATCH_SCORE); 107 108 108 return res; 109 110 failure:111 if (NULL != match_id)112 match_id->id = NULL;113 114 if (NULL != platform) {115 platform->name = NULL;116 delete_device(platform);117 }118 119 return res;120 }121 122 /** Create virtual USB host controller device.123 * Note that the virtual HC is actually device and driver in one124 * task.125 *126 * @param parent Parent device.127 * @return Error code.128 */129 static int add_virtual_usb_host_controller(device_t *parent)130 {131 printf(NAME ": adding virtual host contoller.\n");132 133 int rc;134 device_t *vhc = NULL;135 match_id_t *match_id = NULL;136 137 vhc = create_device();138 if (vhc == NULL) {139 rc = ENOMEM;140 goto failure;141 }142 143 vhc->name = "vhc";144 printf(NAME ": the new device's name is %s.\n", vhc->name);145 146 /* Initialize match id list. */147 match_id = create_match_id();148 if (match_id == NULL) {149 rc = ENOMEM;150 goto failure;151 }152 153 match_id->id = "usb&hc=vhc";154 match_id->score = 100;155 add_match_id(&vhc->match_ids, match_id);156 157 /* Register child device. */158 rc = child_device_register(vhc, parent);159 if (rc != EOK)160 goto failure;161 162 return EOK;163 164 failure:165 if (match_id != NULL)166 match_id->id = NULL;167 168 if (vhc != NULL) {169 vhc->name = NULL;170 delete_device(vhc);171 }172 173 return rc;174 109 } 175 110 … … 184 119 dev->handle); 185 120 121 /* 122 * Register virtual devices root. 123 * We ignore error occurrence because virtual devices shall not be 124 * vital for the system. 125 */ 126 add_virtual_root_child(dev); 127 186 128 /* Register root device's children. */ 187 129 int res = add_platform_child(dev); … … 189 131 printf(NAME ": failed to add child device for platform.\n"); 190 132 191 /* Register virtual USB host controller. */192 int rc = add_virtual_usb_host_controller(dev);193 if (EOK != rc) {194 printf(NAME ": failed to add child device - virtual USB HC.\n");195 }196 197 133 return res; 198 134 } -
uspace/drv/rootpc/Makefile
r98d06b8 rc01255c 30 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a 31 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include 32 BINARY = root ia3232 BINARY = rootpc 33 33 34 34 SOURCES = \ 35 root ia32.c35 rootpc.c 36 36 37 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/rootpc/rootpc.c
r98d06b8 rc01255c 28 28 29 29 /** 30 * @defgroup root_ ia32 Root HW device driver for ia32platform.31 * @brief HelenOS root HW device driver for ia32 platform.30 * @defgroup root_pc Root HW device driver for ia32 and amd64 platform. 31 * @brief HelenOS root HW device driver for ia32 and amd64 platform. 32 32 * @{ 33 33 */ … … 53 53 #include <device/hw_res.h> 54 54 55 #define NAME "root ia32"56 57 typedef struct root ia32_child_dev_data {55 #define NAME "rootpc" 56 57 typedef struct rootpc_child_dev_data { 58 58 hw_resource_list_t hw_resources; 59 } root ia32_child_dev_data_t;60 61 static int root ia32_add_device(device_t *dev);62 static void root_ ia32_init(void);59 } rootpc_child_dev_data_t; 60 61 static int rootpc_add_device(device_t *dev); 62 static void root_pc_init(void); 63 63 64 64 /** The root device driver's standard operations. */ 65 static driver_ops_t root ia32_ops = {66 .add_device = &root ia32_add_device65 static driver_ops_t rootpc_ops = { 66 .add_device = &rootpc_add_device 67 67 }; 68 68 69 69 /** The root device driver structure. */ 70 static driver_t root ia32_driver = {70 static driver_t rootpc_driver = { 71 71 .name = NAME, 72 .driver_ops = &root ia32_ops72 .driver_ops = &rootpc_ops 73 73 }; 74 74 … … 82 82 }; 83 83 84 static root ia32_child_dev_data_t pci_data = {84 static rootpc_child_dev_data_t pci_data = { 85 85 .hw_resources = { 86 86 1, … … 89 89 }; 90 90 91 static hw_resource_list_t *root ia32_get_child_resources(device_t *dev)92 { 93 root ia32_child_dev_data_t *data;94 95 data = (root ia32_child_dev_data_t *) dev->driver_data;91 static hw_resource_list_t *rootpc_get_child_resources(device_t *dev) 92 { 93 rootpc_child_dev_data_t *data; 94 95 data = (rootpc_child_dev_data_t *) dev->driver_data; 96 96 if (NULL == data) 97 97 return NULL; … … 100 100 } 101 101 102 static bool root ia32_enable_child_interrupt(device_t *dev)102 static bool rootpc_enable_child_interrupt(device_t *dev) 103 103 { 104 104 /* TODO */ … … 108 108 109 109 static resource_iface_t child_res_iface = { 110 &root ia32_get_child_resources,111 &root ia32_enable_child_interrupt112 }; 113 114 /* Initialized in root_ ia32_init() function. */115 static device_ops_t root ia32_child_ops;110 &rootpc_get_child_resources, 111 &rootpc_enable_child_interrupt 112 }; 113 114 /* Initialized in root_pc_init() function. */ 115 static device_ops_t rootpc_child_ops; 116 116 117 117 static bool 118 root ia32_add_child(device_t *parent, const char *name, const char *str_match_id,119 root ia32_child_dev_data_t *drv_data)118 rootpc_add_child(device_t *parent, const char *name, const char *str_match_id, 119 rootpc_child_dev_data_t *drv_data) 120 120 { 121 121 printf(NAME ": adding new child device '%s'.\n", name); … … 142 142 143 143 /* Set provided operations to the device. */ 144 child->ops = &root ia32_child_ops;144 child->ops = &rootpc_child_ops; 145 145 146 146 /* Register child device. */ … … 164 164 } 165 165 166 static bool root ia32_add_children(device_t *dev)167 { 168 return root ia32_add_child(dev, "pci0", "intel_pci", &pci_data);166 static bool rootpc_add_children(device_t *dev) 167 { 168 return rootpc_add_child(dev, "pci0", "intel_pci", &pci_data); 169 169 } 170 170 … … 175 175 * @return Zero on success, negative error number otherwise. 176 176 */ 177 static int rootia32_add_device(device_t *dev) 178 { 179 printf(NAME ": rootia32_add_device, device handle = %d\n", dev->handle); 177 static int rootpc_add_device(device_t *dev) 178 { 179 printf(NAME ": rootpc_add_device, device handle = %d\n", 180 (int)dev->handle); 180 181 181 182 /* Register child devices. */ 182 if (!root ia32_add_children(dev)) {183 if (!rootpc_add_children(dev)) { 183 184 printf(NAME ": failed to add child devices for platform " 184 185 "ia32.\n"); … … 188 189 } 189 190 190 static void root_ ia32_init(void)191 { 192 root ia32_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_res_iface;191 static void root_pc_init(void) 192 { 193 rootpc_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_res_iface; 193 194 } 194 195 195 196 int main(int argc, char *argv[]) 196 197 { 197 printf(NAME ": HelenOS root ia32device driver\n");198 root_ ia32_init();199 return driver_main(&root ia32_driver);198 printf(NAME ": HelenOS rootpc device driver\n"); 199 root_pc_init(); 200 return driver_main(&rootpc_driver); 200 201 } 201 202 -
uspace/drv/uhci/main.c
r98d06b8 rc01255c 27 27 */ 28 28 #include <usb/hcdhubd.h> 29 #include <usb/debug.h> 29 30 #include <errno.h> 30 31 #include "uhci.h" … … 36 37 static int uhci_add_device(device_t *device) 37 38 { 39 usb_dprintf(NAME, 1, "uhci_add_device() called\n"); 38 40 device->ops = &uhci_ops; 39 41 … … 41 43 * We need to announce the presence of our root hub. 42 44 */ 45 usb_dprintf(NAME, 2, "adding root hub\n"); 43 46 usb_hcd_add_root_hub(device); 44 47 … … 61 64 */ 62 65 sleep(5); 66 usb_dprintf_enable(NAME, 5); 63 67 64 68 return driver_main(&uhci_driver); -
uspace/drv/vhc/Makefile
r98d06b8 rc01255c 39 39 40 40 SOURCES = \ 41 addrmgm.c \42 41 conndev.c \ 43 42 connhost.c \ -
uspace/drv/vhc/conn.h
r98d06b8 rc01255c 48 48 49 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 50 56 int tell_address(device_t *, devman_handle_t, usb_address_t *);57 51 58 52 void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *); -
uspace/drv/vhc/connhost.c
r98d06b8 rc01255c 36 36 #include <errno.h> 37 37 #include <usb/usb.h> 38 #include <usb/hcd.h> 38 39 39 40 #include "vhcd.h" … … 57 58 case USB_DIRECTION_IN: 58 59 transfer->in_callback(transfer->dev, 59 size, outcome,60 outcome, size, 60 61 transfer->arg); 61 62 break; … … 218 219 } 219 220 221 static usb_address_keeping_t addresses; 222 223 224 static int reserve_default_address(device_t *dev) 225 { 226 usb_address_keeping_reserve_default(&addresses); 227 return EOK; 228 } 229 230 static int release_default_address(device_t *dev) 231 { 232 usb_address_keeping_release_default(&addresses); 233 return EOK; 234 } 235 236 static int request_address(device_t *dev, usb_address_t *address) 237 { 238 usb_address_t addr = usb_address_keeping_request(&addresses); 239 if (addr < 0) { 240 return (int)addr; 241 } 242 243 *address = addr; 244 return EOK; 245 } 246 247 static int release_address(device_t *dev, usb_address_t address) 248 { 249 return usb_address_keeping_release(&addresses, address); 250 } 251 252 static int bind_address(device_t *dev, usb_address_t address, 253 devman_handle_t handle) 254 { 255 usb_address_keeping_devman_bind(&addresses, address, handle); 256 return EOK; 257 } 258 259 static int tell_address(device_t *dev, devman_handle_t handle, 260 usb_address_t *address) 261 { 262 usb_address_t addr = usb_address_keeping_find(&addresses, handle); 263 if (addr < 0) { 264 return addr; 265 } 266 267 *address = addr; 268 return EOK; 269 } 270 271 void address_init(void) 272 { 273 usb_address_keeping_init(&addresses, 50); 274 } 220 275 221 276 usbhc_iface_t vhc_iface = { -
uspace/drv/vhc/debug.c
r98d06b8 rc01255c 35 35 #include <stdio.h> 36 36 #include <ipc/ipc.h> 37 #include <usb/debug.h> 37 38 38 39 #include "vhcd.h" 39 40 40 /** Current debug level. */41 int debug_level = 0;42 43 /** Debugging printf.44 * This function is intended for single-line messages as it45 * automatically prints debugging prefix at the beginning of the46 * line.47 *48 * @see printf49 * @param level Debugging level.50 */51 void dprintf(int level, const char *format, ...)52 {53 if (level > debug_level) {54 return;55 }56 57 printf("%s(%d): ", NAME, level);58 va_list args;59 va_start(args, format);60 vprintf(format, args);61 va_end(args);62 printf("\n");63 }64 41 65 42 /** Debug print informing of invalid call. -
uspace/drv/vhc/hcd.c
r98d06b8 rc01255c 111 111 printf("%s: virtual USB host controller driver.\n", NAME); 112 112 113 debug_level = 10;113 usb_dprintf_enable(NAME, 10); 114 114 115 115 fid_t fid = fibril_create(hc_manager_fibril, NULL); -
uspace/drv/vhc/vhcd.h
r98d06b8 rc01255c 36 36 #define VHCD_VHCD_H_ 37 37 38 #include <usb/debug.h> 39 38 40 #define NAME "vhc" 39 41 #define NAME_DEV "hcd-virt-dev" … … 43 45 #define DEVMAP_PATH_DEV NAMESPACE "/" NAME_DEV 44 46 45 extern int debug_level; 46 void dprintf(int, const char *, ...); 47 #define dprintf(level, format, ...) \ 48 usb_dprintf(NAME, (level), format "\n", ##__VA_ARGS__) 47 49 void dprintf_inval_call(int, ipc_call_t, ipcarg_t); 48 50 -
uspace/lib/c/generic/adt/char_map.c
r98d06b8 rc01255c 90 90 } 91 91 92 map->items[map->next]->c = * 93 ++ identifier;94 ++ map->next;95 if ((length > 1) || ((length == 0) && (*identifier))) {92 map->items[map->next]->c = *identifier; 93 identifier++; 94 map->next++; 95 if ((length > 1) || ((length == 0) && *identifier)) { 96 96 map->items[map->next - 1]->value = CHAR_MAP_NULL; 97 97 return char_map_add_item(map->items[map->next - 1], identifier, … … 142 142 const int value) 143 143 { 144 if (char_map_is_valid(map) && (identifier) && 145 ((length) || (*identifier))) { 144 if (char_map_is_valid(map) && identifier && (length || *identifier)) { 146 145 int index; 147 146 148 for (index = 0; index < map->next; ++ index) {147 for (index = 0; index < map->next; index++) { 149 148 if (map->items[index]->c != *identifier) 150 149 continue; 151 150 152 ++ identifier;153 if((length > 1) || ((length == 0) && (*identifier))) {151 identifier++; 152 if((length > 1) || ((length == 0) && *identifier)) { 154 153 return char_map_add(map->items[index], 155 154 identifier, length ? length - 1 : 0, value); … … 178 177 179 178 map->magic = 0; 180 for (index = 0; index < map->next; ++index)179 for (index = 0; index < map->next; index++) 181 180 char_map_destroy(map->items[index]); 182 181 … … 207 206 return NULL; 208 207 209 if (length || (*identifier)) {208 if (length || *identifier) { 210 209 int index; 211 210 212 for (index = 0; index < map->next; ++index) {211 for (index = 0; index < map->next; index++) { 213 212 if (map->items[index]->c == *identifier) { 214 ++identifier;213 identifier++; 215 214 if (length == 1) 216 215 return map->items[index]; -
uspace/lib/c/generic/devman.c
r98d06b8 rc01255c 116 116 { 117 117 ipc_call_t answer; 118 a sync_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer);118 aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer); 119 119 int retval = async_data_write_start(phone, match_id->id, str_size(match_id->id)); 120 return retval; 120 async_wait_for(req, NULL); 121 return retval; 121 122 } 122 123 -
uspace/lib/c/include/adt/generic_field.h
r98d06b8 rc01255c 91 91 } \ 92 92 field->items[field->next] = value; \ 93 ++field->next; \93 field->next++; \ 94 94 field->items[field->next] = NULL; \ 95 95 return field->next - 1; \ … … 108 108 int index; \ 109 109 field->magic = 0; \ 110 for (index = 0; index < field->next; ++ index) { \110 for (index = 0; index < field->next; index++) { \ 111 111 if (field->items[index]) \ 112 112 free(field->items[index]); \ -
uspace/lib/c/include/errno.h
r98d06b8 rc01255c 83 83 #define ENOTCONN (-10057) 84 84 85 /** The requested operation was not performed. 86 * Try again later. 87 */ 88 #define TRY_AGAIN (-11002) 85 /** The requested operation was not performed. Try again later. */ 86 #define EAGAIN (-11002) 89 87 90 88 /** No data. -
uspace/lib/c/include/ipc/dev_iface.h
r98d06b8 rc01255c 54 54 DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX) 55 55 56 /* 57 * The first argument is actually method (as the "real" method is used 58 * for indexing into interfaces. 59 */ 60 61 #define DEV_IPC_GET_ARG1(call) IPC_GET_ARG2((call)) 62 #define DEV_IPC_GET_ARG2(call) IPC_GET_ARG3((call)) 63 #define DEV_IPC_GET_ARG3(call) IPC_GET_ARG4((call)) 64 #define DEV_IPC_GET_ARG4(call) IPC_GET_ARG5((call)) 65 56 66 57 67 #endif -
uspace/lib/c/include/ipc/vfs.h
r98d06b8 rc01255c 36 36 #define LIBC_IPC_VFS_H_ 37 37 38 #include <ipc/ipc.h> 38 39 #include <sys/types.h> 39 #include < ipc/ipc.h>40 #include <bool.h> 40 41 41 42 #define FS_NAME_MAXLEN 20 … … 55 56 /** Unique identifier of the fs. */ 56 57 char name[FS_NAME_MAXLEN + 1]; 58 bool concurrent_read_write; 59 bool write_retains_size; 57 60 } vfs_info_t; 58 61 -
uspace/lib/drv/generic/driver.c
r98d06b8 rc01255c 381 381 } 382 382 383 /** Wrapper for child_device_register for devices with single match id. 384 * 385 * @param parent Parent device. 386 * @param child_name Child device name. 387 * @param child_match_id Child device match id. 388 * @param child_match_score Child device match score. 389 * @return Error code. 390 */ 391 int child_device_register_wrapper(device_t *parent, const char *child_name, 392 const char *child_match_id, int child_match_score) 393 { 394 device_t *child = NULL; 395 match_id_t *match_id = NULL; 396 int rc; 397 398 child = create_device(); 399 if (child == NULL) { 400 rc = ENOMEM; 401 goto failure; 402 } 403 404 child->name = child_name; 405 406 match_id = create_match_id(); 407 if (match_id == NULL) { 408 rc = ENOMEM; 409 goto failure; 410 } 411 412 match_id->id = child_match_id; 413 match_id->score = child_match_score; 414 add_match_id(&child->match_ids, match_id); 415 416 rc = child_device_register(child, parent); 417 if (EOK != rc) 418 goto failure; 419 420 return EOK; 421 422 failure: 423 if (match_id != NULL) { 424 match_id->id = NULL; 425 delete_match_id(match_id); 426 } 427 428 if (child != NULL) { 429 child->name = NULL; 430 delete_device(child); 431 } 432 433 return rc; 434 } 435 383 436 int driver_main(driver_t *drv) 384 437 { -
uspace/lib/drv/generic/remote_usbhc.c
r98d06b8 rc01255c 108 108 } 109 109 110 devman_handle_t handle = IPC_GET_ARG1(*call);110 devman_handle_t handle = DEV_IPC_GET_ARG1(*call); 111 111 112 112 usb_address_t address; … … 122 122 ipc_callid_t callid, ipc_call_t *call) 123 123 { 124 ipcarg_t buffer_hash = IPC_GET_ARG1(*call);124 ipcarg_t buffer_hash = DEV_IPC_GET_ARG1(*call); 125 125 async_transaction_t * trans = (async_transaction_t *)buffer_hash; 126 126 if (trans == NULL) { … … 144 144 accepted_size = trans->size; 145 145 } 146 async_data_read_finalize(c allid, trans->buffer, accepted_size);146 async_data_read_finalize(cid, trans->buffer, accepted_size); 147 147 148 148 ipc_answer_1(callid, EOK, accepted_size); … … 211 211 } 212 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);213 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 214 devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call); 215 215 216 216 int rc = usb_iface->bind_address(device, address, handle); … … 229 229 } 230 230 231 usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call);231 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 232 232 233 233 int rc = usb_iface->release_address(device, address); … … 275 275 } 276 276 277 size_t expected_len = IPC_GET_ARG3(*call);277 size_t expected_len = DEV_IPC_GET_ARG3(*call); 278 278 usb_target_t target = { 279 .address = IPC_GET_ARG1(*call),280 .endpoint = IPC_GET_ARG2(*call)279 .address = DEV_IPC_GET_ARG1(*call), 280 .endpoint = DEV_IPC_GET_ARG2(*call) 281 281 }; 282 282 … … 327 327 } 328 328 329 size_t len = IPC_GET_ARG3(*call);329 size_t len = DEV_IPC_GET_ARG3(*call); 330 330 usb_target_t target = { 331 .address = IPC_GET_ARG1(*call),332 .endpoint = IPC_GET_ARG2(*call)331 .address = DEV_IPC_GET_ARG1(*call), 332 .endpoint = DEV_IPC_GET_ARG2(*call) 333 333 }; 334 334 … … 384 384 385 385 usb_target_t target = { 386 .address = IPC_GET_ARG1(*call),387 .endpoint = IPC_GET_ARG2(*call)386 .address = DEV_IPC_GET_ARG1(*call), 387 .endpoint = DEV_IPC_GET_ARG2(*call) 388 388 }; 389 389 -
uspace/lib/drv/include/driver.h
r98d06b8 rc01255c 199 199 200 200 int child_device_register(device_t *, device_t *); 201 int child_device_register_wrapper(device_t *, const char *, const char *, int); 201 202 202 203 -
uspace/lib/usb/Makefile
r98d06b8 rc01255c 33 33 34 34 SOURCES = \ 35 src/addrkeep.c \ 36 src/debug.c \ 37 src/drvpsync.c \ 35 38 src/hcdhubd.c \ 36 39 src/hcdrv.c \ … … 38 41 src/remotedrv.c \ 39 42 src/usb.c \ 43 src/usbdrvreq.c \ 40 44 src/usbdrv.c 41 45 -
uspace/lib/usb/include/usb/devreq.h
r98d06b8 rc01255c 38 38 #include <ipc/ipc.h> 39 39 #include <async.h> 40 #include <usb/usb.h> 41 #include <usb/descriptor.h> 40 42 41 43 /** Standard device request. */ … … 83 85 } __attribute__ ((packed)) usb_device_request_setup_packet_t; 84 86 87 int usb_drv_req_set_address(int, usb_address_t, usb_address_t); 88 int usb_drv_req_get_device_descriptor(int, usb_address_t, 89 usb_standard_device_descriptor_t *); 90 int usb_drv_req_get_bare_configuration_descriptor(int, usb_address_t, int, 91 usb_standard_configuration_descriptor_t *); 92 int usb_drv_req_get_full_configuration_descriptor(int, usb_address_t, int, 93 void *, size_t, size_t *); 94 95 85 96 #endif 86 97 /** -
uspace/lib/usb/include/usb/usb.h
r98d06b8 rc01255c 69 69 typedef int usb_address_t; 70 70 71 /** Default USB address. */ 72 #define USB_ADDRESS_DEFAULT 0 73 /** Maximum address number in USB 1.1. */ 74 #define USB11_ADDRESS_MAX 128 75 71 76 /** USB endpoint number type. 72 77 * Negative values could be used to indicate error. -
uspace/lib/usb/include/usb/usbdrv.h
r98d06b8 rc01255c 36 36 #define LIBUSB_USBDRV_H_ 37 37 38 #include "usb.h"38 #include <usb/usb.h> 39 39 #include <driver.h> 40 #include <usb/devreq.h> 41 #include <usb/descriptor.h> 40 42 41 43 int usb_drv_hc_connect(device_t *, unsigned int); … … 54 56 void *, size_t, size_t *, usb_handle_t *); 55 57 58 int usb_drv_psync_interrupt_out(int, usb_target_t, void *, size_t); 59 int usb_drv_psync_interrupt_in(int, usb_target_t, void *, size_t, size_t *); 60 61 62 56 63 int usb_drv_async_control_write_setup(int, usb_target_t, 57 64 void *, size_t, usb_handle_t *); … … 60 67 int usb_drv_async_control_write_status(int, usb_target_t, 61 68 usb_handle_t *); 69 70 int usb_drv_psync_control_write_setup(int, usb_target_t, void *, size_t); 71 int usb_drv_psync_control_write_data(int, usb_target_t, void *, size_t); 72 int usb_drv_psync_control_write_status(int, usb_target_t); 73 74 int usb_drv_psync_control_write(int, usb_target_t, 75 void *, size_t, void *, size_t); 76 62 77 63 78 int usb_drv_async_control_read_setup(int, usb_target_t, … … 68 83 usb_handle_t *); 69 84 85 int usb_drv_psync_control_read_setup(int, usb_target_t, void *, size_t); 86 int usb_drv_psync_control_read_data(int, usb_target_t, void *, size_t, size_t *); 87 int usb_drv_psync_control_read_status(int, usb_target_t); 88 89 int usb_drv_psync_control_read(int, usb_target_t, 90 void *, size_t, void *, size_t, size_t *); 91 92 93 70 94 int usb_drv_async_wait_for(usb_handle_t); 95 71 96 72 97 #endif -
uspace/lib/usb/src/usbdrv.c
r98d06b8 rc01255c 71 71 devman_handle_t handle; 72 72 73 rc = devman_device_get_handle("/v hc", &handle, 0);73 rc = devman_device_get_handle("/virt/usbhc", &handle, 0); 74 74 if (rc != EOK) { 75 75 return rc; -
uspace/lib/usbvirt/main.c
r98d06b8 rc01255c 183 183 } 184 184 185 /** Create necessary phones for com unication with virtual HCD.185 /** Create necessary phones for communication with virtual HCD. 186 186 * This function wraps following calls: 187 * -# open <code>/dev/devices/\\v hc for reading187 * -# open <code>/dev/devices/\\virt\\usbhc for reading 188 188 * -# access phone of file opened in previous step 189 189 * -# create callback through just opened phone … … 193 193 * @warning This function is wrapper for several actions and therefore 194 194 * it is not possible - in case of error - to determine at which point 195 * error occured. 196 * 197 * @param hcd_path HCD identification under devfs 198 * (without <code>/dev/usb/</code>). 195 * error occurred. 196 * 199 197 * @param dev Device to connect. 200 198 * @return EOK on success or error code from errno.h. … … 207 205 } 208 206 209 const char *vhc_path = "/v hc";207 const char *vhc_path = "/virt/usbhc"; 210 208 int rc; 211 209 devman_handle_t handle; -
uspace/srv/devman/devman.c
r98d06b8 rc01255c 516 516 /** Notify driver about the devices to which it was assigned. 517 517 * 518 * The driver's mutex must be locked.519 *520 518 * @param driver The driver to which the devices are passed. 521 519 */ … … 526 524 int phone; 527 525 528 printf(NAME ": pass_devices_to_driver\n"); 529 530 phone = ipc_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0); 531 if (phone > 0) { 532 526 printf(NAME ": pass_devices_to_driver(`%s')\n", driver->name); 527 528 fibril_mutex_lock(&driver->driver_mutex); 529 530 phone = async_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0); 531 532 if (phone < 0) { 533 fibril_mutex_unlock(&driver->driver_mutex); 534 return; 535 } 536 537 /* 538 * Go through devices list as long as there is some device 539 * that has not been passed to the driver. 540 */ 541 link = driver->devices.next; 542 while (link != &driver->devices) { 543 dev = list_get_instance(link, node_t, driver_devices); 544 if (dev->passed_to_driver) { 545 link = link->next; 546 continue; 547 } 548 549 /* 550 * We remove the device from the list to allow safe adding 551 * of new devices (no one will touch our item this way). 552 */ 553 list_remove(link); 554 555 /* 556 * Unlock to avoid deadlock when adding device 557 * handled by itself. 558 */ 559 fibril_mutex_unlock(&driver->driver_mutex); 560 561 add_device(phone, driver, dev, tree); 562 563 /* 564 * Lock again as we will work with driver's 565 * structure. 566 */ 567 fibril_mutex_lock(&driver->driver_mutex); 568 569 /* 570 * Insert the device back. 571 * The order is not relevant here so no harm is done 572 * (actually, the order would be preserved in most cases). 573 */ 574 list_append(link, &driver->devices); 575 576 /* 577 * Restart the cycle to go through all devices again. 578 */ 533 579 link = driver->devices.next; 534 while (link != &driver->devices) { 535 dev = list_get_instance(link, node_t, driver_devices); 536 add_device(phone, driver, dev, tree); 537 link = link->next; 538 } 539 540 ipc_hangup(phone); 541 } 580 } 581 582 ipc_hangup(phone); 583 584 /* 585 * Once we passed all devices to the driver, we need to mark the 586 * driver as running. 587 * It is vital to do it here and inside critical section. 588 * 589 * If we would change the state earlier, other devices added to 590 * the driver would be added to the device list and started 591 * immediately and possibly started here as well. 592 */ 593 printf(NAME ": driver %s goes into running state.\n", driver->name); 594 driver->state = DRIVER_RUNNING; 595 596 fibril_mutex_unlock(&driver->driver_mutex); 542 597 } 543 598 … … 553 608 void initialize_running_driver(driver_t *driver, dev_tree_t *tree) 554 609 { 555 printf(NAME ": initialize_running_driver\n"); 556 fibril_mutex_lock(&driver->driver_mutex); 610 printf(NAME ": initialize_running_driver (`%s')\n", driver->name); 557 611 558 612 /* … … 561 615 */ 562 616 pass_devices_to_driver(driver, tree); 563 564 /* Change driver's state to running. */565 driver->state = DRIVER_RUNNING;566 567 fibril_mutex_unlock(&driver->driver_mutex);568 617 } 569 618 … … 637 686 } 638 687 688 static FIBRIL_MUTEX_INITIALIZE(add_device_guard); 639 689 640 690 /** Pass a device to running driver. … … 645 695 void add_device(int phone, driver_t *drv, node_t *node, dev_tree_t *tree) 646 696 { 647 printf(NAME ": add_device\n"); 697 fibril_mutex_lock(&add_device_guard); 698 699 /* 700 * We do not expect to have driver's mutex locked as we do not 701 * access any structures that would affect driver_t. 702 */ 703 printf(NAME ": add_device (driver `%s', device `%s')\n", drv->name, 704 node->name); 648 705 649 706 ipcarg_t rc; … … 657 714 parent_handle = 0; 658 715 } 716 659 717 aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, node->handle, 660 718 parent_handle, &answer); … … 666 724 /* TODO handle error */ 667 725 } 668 726 669 727 /* Wait for answer from the driver. */ 670 728 async_wait_for(req, &rc); 729 730 fibril_mutex_unlock(&add_device_guard); 731 671 732 switch(rc) { 672 733 case EOK: … … 681 742 } 682 743 744 node->passed_to_driver = true; 745 683 746 return; 684 747 } … … 706 769 attach_driver(node, drv); 707 770 771 fibril_mutex_lock(&drv->driver_mutex); 708 772 if (drv->state == DRIVER_NOT_STARTED) { 709 773 /* Start the driver. */ 710 774 start_driver(drv); 711 775 } 712 713 if (drv->state == DRIVER_RUNNING) { 776 bool is_running = drv->state == DRIVER_RUNNING; 777 fibril_mutex_unlock(&drv->driver_mutex); 778 779 if (is_running) { 714 780 /* Notify the driver about the new device. */ 715 int phone = ipc_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);781 int phone = async_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0); 716 782 if (phone > 0) { 717 783 add_device(phone, drv, node, tree); … … 875 941 node->name = dev_name; 876 942 if (!set_dev_path(node, parent)) { 877 fibril_rwlock_write_unlock(&tree->rwlock);878 943 return false; 879 944 } … … 1097 1162 while (link != &class_list->classes) { 1098 1163 cl = list_get_instance(link, dev_class_t, link); 1099 if (str_cmp(cl->name, class_name) == 0) 1164 if (str_cmp(cl->name, class_name) == 0) { 1100 1165 return cl; 1166 } 1167 link = link->next; 1101 1168 } 1102 1169 -
uspace/srv/devman/devman.h
r98d06b8 rc01255c 168 168 */ 169 169 link_t devmap_link; 170 171 /** 172 * Whether this device was already passed to the driver. 173 */ 174 bool passed_to_driver; 170 175 }; 171 176 -
uspace/srv/devman/main.c
r98d06b8 rc01255c 197 197 } 198 198 199 static int assign_driver_fibril(void *arg) 200 { 201 node_t *node = (node_t *) arg; 202 assign_driver(node, &drivers_list, &device_tree); 203 return EOK; 204 } 205 199 206 /** Handle child device registration. 200 207 * … … 237 244 238 245 devman_receive_match_ids(match_count, &node->match_ids); 239 246 247 /* 248 * Try to find a suitable driver and assign it to the device. We do 249 * not want to block the current fibril that is used for processing 250 * incoming calls: we will launch a separate fibril to handle the 251 * driver assigning. That is because assign_driver can actually include 252 * task spawning which could take some time. 253 */ 254 fid_t assign_fibril = fibril_create(assign_driver_fibril, node); 255 if (assign_fibril == 0) { 256 /* 257 * Fallback in case we are out of memory. 258 * Probably not needed as we will die soon anyway ;-). 259 */ 260 (void) assign_driver_fibril(node); 261 } else { 262 fibril_add_ready(assign_fibril); 263 } 264 240 265 /* Return device handle to parent's driver. */ 241 266 ipc_answer_1(callid, EOK, node->handle); 242 243 /* Try to find suitable driver and assign it to the device. */244 assign_driver(node, &drivers_list, &device_tree);245 267 } 246 268 … … 297 319 printf(NAME ": device '%s' added to class '%s', class name '%s' was " 298 320 "asigned to it\n", dev->pathname, class_name, class_info->dev_name); 299 321 300 322 ipc_answer_0(callid, EOK); 301 323 } -
uspace/srv/devman/match.c
r98d06b8 rc01255c 46 46 if (str_cmp(driver->id, device->id) == 0) { 47 47 /* 48 * The strings match es, return their score multiplied.48 * The strings match, return the product of their scores. 49 49 */ 50 50 return driver->score * device->score; … … 66 66 67 67 /* 68 * Go through all pairs, return the highest score obtaine td.68 * Go through all pairs, return the highest score obtained. 69 69 */ 70 70 int highest_score = 0; -
uspace/srv/fs/devfs/devfs.c
r98d06b8 rc01255c 53 53 static vfs_info_t devfs_vfs_info = { 54 54 .name = NAME, 55 .concurrent_read_write = false, 56 .write_retains_size = false, 55 57 }; 56 58 -
uspace/srv/fs/fat/fat.c
r98d06b8 rc01255c 52 52 vfs_info_t fat_vfs_info = { 53 53 .name = NAME, 54 .concurrent_read_write = false, 55 .write_retains_size = false, 54 56 }; 55 57 -
uspace/srv/fs/tmpfs/tmpfs.c
r98d06b8 rc01255c 57 57 vfs_info_t tmpfs_vfs_info = { 58 58 .name = NAME, 59 .concurrent_read_write = false, 60 .write_retains_size = false, 59 61 }; 60 62 -
uspace/srv/net/il/arp/arp.c
r98d06b8 rc01255c 72 72 #define NAME "arp" 73 73 74 /** Number of microseconds to wait for an ARP reply. */ 75 #define ARP_TRANS_WAIT 1000000 76 74 77 /** ARP global data. */ 75 78 arp_globals_t arp_globals; … … 77 80 DEVICE_MAP_IMPLEMENT(arp_cache, arp_device_t); 78 81 INT_MAP_IMPLEMENT(arp_protos, arp_proto_t); 79 GENERIC_CHAR_MAP_IMPLEMENT(arp_addr, measured_string_t); 82 GENERIC_CHAR_MAP_IMPLEMENT(arp_addr, arp_trans_t); 83 84 static void arp_clear_trans(arp_trans_t *trans) 85 { 86 if (trans->hw_addr) { 87 free(trans->hw_addr); 88 trans->hw_addr = NULL; 89 } 90 fibril_condvar_broadcast(&trans->cv); 91 } 92 93 static void arp_clear_addr(arp_addr_t *addresses) 94 { 95 int count; 96 arp_trans_t *trans; 97 98 for (count = arp_addr_count(addresses) - 1; count >= 0; count--) { 99 trans = arp_addr_items_get_index(&addresses->values, count); 100 if (trans) 101 arp_clear_trans(trans); 102 } 103 } 104 80 105 81 106 /** Clears the device specific data. … … 96 121 if (proto->addr_data) 97 122 free(proto->addr_data); 123 arp_clear_addr(&proto->addresses); 98 124 arp_addr_destroy(&proto->addresses); 99 125 } … … 107 133 arp_device_t *device; 108 134 109 fibril_ rwlock_write_lock(&arp_globals.lock);135 fibril_mutex_lock(&arp_globals.lock); 110 136 for (count = arp_cache_count(&arp_globals.cache) - 1; count >= 0; 111 137 count--) { … … 120 146 } 121 147 arp_cache_clear(&arp_globals.cache); 122 fibril_ rwlock_write_unlock(&arp_globals.lock);148 fibril_mutex_unlock(&arp_globals.lock); 123 149 printf("Cache cleaned\n"); 124 150 return EOK; … … 130 156 arp_device_t *device; 131 157 arp_proto_t *proto; 132 133 fibril_rwlock_write_lock(&arp_globals.lock); 158 arp_trans_t *trans; 159 160 fibril_mutex_lock(&arp_globals.lock); 134 161 device = arp_cache_find(&arp_globals.cache, device_id); 135 162 if (!device) { 136 fibril_ rwlock_write_unlock(&arp_globals.lock);163 fibril_mutex_unlock(&arp_globals.lock); 137 164 return ENOENT; 138 165 } 139 166 proto = arp_protos_find(&device->protos, protocol); 140 167 if (!proto) { 141 fibril_ rwlock_write_unlock(&arp_globals.lock);168 fibril_mutex_unlock(&arp_globals.lock); 142 169 return ENOENT; 143 170 } 171 trans = arp_addr_find(&proto->addresses, address->value, address->length); 172 if (trans) 173 arp_clear_trans(trans); 144 174 arp_addr_exclude(&proto->addresses, address->value, address->length); 145 fibril_ rwlock_write_unlock(&arp_globals.lock);175 fibril_mutex_unlock(&arp_globals.lock); 146 176 return EOK; 147 177 } … … 152 182 arp_device_t *device; 153 183 154 fibril_ rwlock_write_lock(&arp_globals.lock);184 fibril_mutex_lock(&arp_globals.lock); 155 185 device = arp_cache_find(&arp_globals.cache, device_id); 156 186 if (!device) { 157 fibril_ rwlock_write_unlock(&arp_globals.lock);187 fibril_mutex_unlock(&arp_globals.lock); 158 188 return ENOENT; 159 189 } 160 190 arp_clear_device(device); 161 191 printf("Device %d cleared\n", device_id); 162 fibril_ rwlock_write_unlock(&arp_globals.lock);192 fibril_mutex_unlock(&arp_globals.lock); 163 193 return EOK; 164 194 } … … 221 251 int rc; 222 252 223 fibril_ rwlock_write_lock(&arp_globals.lock);253 fibril_mutex_lock(&arp_globals.lock); 224 254 225 255 /* An existing device? */ … … 229 259 if (device->service != service) { 230 260 printf("Device %d already exists\n", device->device_id); 231 fibril_ rwlock_write_unlock(&arp_globals.lock);261 fibril_mutex_unlock(&arp_globals.lock); 232 262 return EEXIST; 233 263 } … … 241 271 rc = arp_proto_create(&proto, protocol, address); 242 272 if (rc != EOK) { 243 fibril_ rwlock_write_unlock(&arp_globals.lock);273 fibril_mutex_unlock(&arp_globals.lock); 244 274 return rc; 245 275 } … … 247 277 proto); 248 278 if (index < 0) { 249 fibril_ rwlock_write_unlock(&arp_globals.lock);279 fibril_mutex_unlock(&arp_globals.lock); 250 280 free(proto); 251 281 return index; … … 262 292 device = (arp_device_t *) malloc(sizeof(arp_device_t)); 263 293 if (!device) { 264 fibril_ rwlock_write_unlock(&arp_globals.lock);294 fibril_mutex_unlock(&arp_globals.lock); 265 295 return ENOMEM; 266 296 } … … 269 299 rc = arp_protos_initialize(&device->protos); 270 300 if (rc != EOK) { 271 fibril_ rwlock_write_unlock(&arp_globals.lock);301 fibril_mutex_unlock(&arp_globals.lock); 272 302 free(device); 273 303 return rc; … … 275 305 rc = arp_proto_create(&proto, protocol, address); 276 306 if (rc != EOK) { 277 fibril_ rwlock_write_unlock(&arp_globals.lock);307 fibril_mutex_unlock(&arp_globals.lock); 278 308 free(device); 279 309 return rc; … … 281 311 index = arp_protos_add(&device->protos, proto->service, proto); 282 312 if (index < 0) { 283 fibril_ rwlock_write_unlock(&arp_globals.lock);313 fibril_mutex_unlock(&arp_globals.lock); 284 314 arp_protos_destroy(&device->protos); 285 315 free(device); … … 293 323 arp_globals.client_connection); 294 324 if (device->phone < 0) { 295 fibril_ rwlock_write_unlock(&arp_globals.lock);325 fibril_mutex_unlock(&arp_globals.lock); 296 326 arp_protos_destroy(&device->protos); 297 327 free(device); … … 303 333 &device->packet_dimension); 304 334 if (rc != EOK) { 305 fibril_ rwlock_write_unlock(&arp_globals.lock);335 fibril_mutex_unlock(&arp_globals.lock); 306 336 arp_protos_destroy(&device->protos); 307 337 free(device); … … 313 343 &device->addr_data); 314 344 if (rc != EOK) { 315 fibril_ rwlock_write_unlock(&arp_globals.lock);345 fibril_mutex_unlock(&arp_globals.lock); 316 346 arp_protos_destroy(&device->protos); 317 347 free(device); … … 323 353 &device->broadcast_addr, &device->broadcast_data); 324 354 if (rc != EOK) { 325 fibril_ rwlock_write_unlock(&arp_globals.lock);355 fibril_mutex_unlock(&arp_globals.lock); 326 356 free(device->addr); 327 357 free(device->addr_data); … … 334 364 device); 335 365 if (rc != EOK) { 336 fibril_ rwlock_write_unlock(&arp_globals.lock);366 fibril_mutex_unlock(&arp_globals.lock); 337 367 free(device->addr); 338 368 free(device->addr_data); … … 347 377 device->service, protocol); 348 378 } 349 fibril_ rwlock_write_unlock(&arp_globals.lock);379 fibril_mutex_unlock(&arp_globals.lock); 350 380 351 381 return EOK; … … 363 393 int rc; 364 394 365 fibril_ rwlock_initialize(&arp_globals.lock);366 fibril_ rwlock_write_lock(&arp_globals.lock);395 fibril_mutex_initialize(&arp_globals.lock); 396 fibril_mutex_lock(&arp_globals.lock); 367 397 arp_globals.client_connection = client_connection; 368 398 rc = arp_cache_initialize(&arp_globals.cache); 369 fibril_ rwlock_write_unlock(&arp_globals.lock);399 fibril_mutex_unlock(&arp_globals.lock); 370 400 371 401 return rc; … … 383 413 arp_device_t *device; 384 414 385 fibril_ rwlock_write_lock(&arp_globals.lock);415 fibril_mutex_lock(&arp_globals.lock); 386 416 device = arp_cache_find(&arp_globals.cache, device_id); 387 417 if (!device) { 388 fibril_ rwlock_write_unlock(&arp_globals.lock);418 fibril_mutex_unlock(&arp_globals.lock); 389 419 return ENOENT; 390 420 } 391 421 device->packet_dimension.content = mtu; 392 fibril_ rwlock_write_unlock(&arp_globals.lock);422 fibril_mutex_unlock(&arp_globals.lock); 393 423 printf("arp - device %d changed mtu to %zu\n\n", device_id, mtu); 394 424 return EOK; … … 421 451 arp_device_t *device; 422 452 arp_proto_t *proto; 423 measured_string_t *hw_source;453 arp_trans_t *trans; 424 454 uint8_t *src_hw; 425 455 uint8_t *src_proto; … … 452 482 des_hw = src_proto + header->protocol_length; 453 483 des_proto = des_hw + header->hardware_length; 454 hw_source= arp_addr_find(&proto->addresses, (char *) src_proto,484 trans = arp_addr_find(&proto->addresses, (char *) src_proto, 455 485 CONVERT_SIZE(uint8_t, char, header->protocol_length)); 456 486 /* Exists? */ 457 if ( hw_source) {458 if ( hw_source->length != CONVERT_SIZE(uint8_t, char,487 if (trans && trans->hw_addr) { 488 if (trans->hw_addr->length != CONVERT_SIZE(uint8_t, char, 459 489 header->hardware_length)) { 460 490 return EINVAL; 461 491 } 462 memcpy( hw_source->value, src_hw, hw_source->length);492 memcpy(trans->hw_addr->value, src_hw, trans->hw_addr->length); 463 493 } 464 494 /* Is my protocol address? */ … … 470 500 proto->addr->length)) { 471 501 /* Not already updated? */ 472 if (!hw_source) { 473 hw_source = measured_string_create_bulk((char *) src_hw, 474 CONVERT_SIZE(uint8_t, char, 502 if (!trans) { 503 trans = (arp_trans_t *) malloc(sizeof(arp_trans_t)); 504 if (!trans) 505 return ENOMEM; 506 trans->hw_addr = NULL; 507 fibril_condvar_initialize(&trans->cv); 508 rc = arp_addr_add(&proto->addresses, (char *) src_proto, 509 CONVERT_SIZE(uint8_t, char, header->protocol_length), 510 trans); 511 if (rc != EOK) { 512 /* The generic char map has already freed trans! */ 513 return rc; 514 } 515 } 516 if (!trans->hw_addr) { 517 trans->hw_addr = measured_string_create_bulk( 518 (char *) src_hw, CONVERT_SIZE(uint8_t, char, 475 519 header->hardware_length)); 476 if (! hw_source)520 if (!trans->hw_addr) 477 521 return ENOMEM; 478 522 479 rc = arp_addr_add(&proto->addresses, (char *) src_proto, 480 CONVERT_SIZE(uint8_t, char, 481 header->protocol_length), hw_source); 482 if (rc != EOK) 483 return rc; 523 /* Notify the fibrils that wait for the translation. */ 524 fibril_condvar_broadcast(&trans->cv); 484 525 } 485 526 if (ntohs(header->operation) == ARPOP_REQUEST) { … … 490 531 memcpy(src_hw, device->addr->value, 491 532 device->packet_dimension.addr_len); 492 memcpy(des_hw, hw_source->value,533 memcpy(des_hw, trans->hw_addr->value, 493 534 header->hardware_length); 494 535 … … 516 557 * @param[in] protocol The protocol service. 517 558 * @param[in] target The target protocol address. 518 * @return The hardware address of the target. 519 * @return NULL if the target parameter is NULL. 520 * @return NULL if the device is not found. 521 * @return NULL if the device packet is too small to send a 522 * request. 523 * @return NULL if the hardware address is not found in the cache. 524 */ 525 static measured_string_t * 559 * @param[out] translation Where the hardware address of the target is stored. 560 * @return EOK on success. 561 * @return EAGAIN if the caller should try again. 562 * @return Other error codes in case of error. 563 */ 564 static int 526 565 arp_translate_message(device_id_t device_id, services_t protocol, 527 measured_string_t *target )566 measured_string_t *target, measured_string_t **translation) 528 567 { 529 568 arp_device_t *device; 530 569 arp_proto_t *proto; 531 measured_string_t *addr;570 arp_trans_t *trans; 532 571 size_t length; 533 572 packet_t *packet; 534 573 arp_header_t *header; 535 536 if (!target) 537 return NULL; 574 bool retry = false; 575 int rc; 576 577 restart: 578 if (!target || !translation) 579 return EBADMEM; 538 580 539 581 device = arp_cache_find(&arp_globals.cache, device_id); 540 582 if (!device) 541 return NULL;583 return ENOENT; 542 584 543 585 proto = arp_protos_find(&device->protos, protocol); 544 586 if (!proto || (proto->addr->length != target->length)) 545 return NULL; 546 547 addr = arp_addr_find(&proto->addresses, target->value, target->length); 548 if (addr) 549 return addr; 587 return ENOENT; 588 589 trans = arp_addr_find(&proto->addresses, target->value, target->length); 590 if (trans) { 591 if (trans->hw_addr) { 592 *translation = trans->hw_addr; 593 return EOK; 594 } 595 if (retry) 596 return EAGAIN; 597 rc = fibril_condvar_wait_timeout(&trans->cv, &arp_globals.lock, 598 ARP_TRANS_WAIT); 599 if (rc == ETIMEOUT) 600 return ENOENT; 601 retry = true; 602 goto restart; 603 } 604 if (retry) 605 return EAGAIN; 550 606 551 607 /* ARP packet content size = header + (address + translation) * 2 */ … … 553 609 CONVERT_SIZE(char, uint8_t, device->addr->length)); 554 610 if (length > device->packet_dimension.content) 555 return NULL;611 return ELIMIT; 556 612 557 613 packet = packet_get_4_remote(arp_globals.net_phone, … … 559 615 length, device->packet_dimension.suffix); 560 616 if (!packet) 561 return NULL;617 return ENOMEM; 562 618 563 619 header = (arp_header_t *) packet_suffix(packet, length); 564 620 if (!header) { 565 621 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 566 return NULL;622 return ENOMEM; 567 623 } 568 624 … … 583 639 memcpy(((uint8_t *) header) + length, target->value, target->length); 584 640 585 if (packet_set_addr(packet, (uint8_t *) device->addr->value,641 rc = packet_set_addr(packet, (uint8_t *) device->addr->value, 586 642 (uint8_t *) device->broadcast_addr->value, 587 CONVERT_SIZE(char, uint8_t, device->addr->length)) != EOK) { 643 CONVERT_SIZE(char, uint8_t, device->addr->length)); 644 if (rc != EOK) { 588 645 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 589 return NULL;646 return rc; 590 647 } 591 648 592 649 nil_send_msg(device->phone, device_id, packet, SERVICE_ARP); 593 return NULL; 650 651 trans = (arp_trans_t *) malloc(sizeof(arp_trans_t)); 652 if (!trans) 653 return ENOMEM; 654 trans->hw_addr = NULL; 655 fibril_condvar_initialize(&trans->cv); 656 rc = arp_addr_add(&proto->addresses, target->value, target->length, 657 trans); 658 if (rc != EOK) { 659 /* The generic char map has already freed trans! */ 660 return rc; 661 } 662 663 rc = fibril_condvar_wait_timeout(&trans->cv, &arp_globals.lock, 664 ARP_TRANS_WAIT); 665 if (rc == ETIMEOUT) 666 return ENOENT; 667 retry = true; 668 goto restart; 594 669 } 595 670 … … 642 717 return rc; 643 718 644 fibril_ rwlock_read_lock(&arp_globals.lock);645 translation= arp_translate_message(IPC_GET_DEVICE(call),646 IPC_GET_SERVICE(call), address );719 fibril_mutex_lock(&arp_globals.lock); 720 rc = arp_translate_message(IPC_GET_DEVICE(call), 721 IPC_GET_SERVICE(call), address, &translation); 647 722 free(address); 648 723 free(data); 724 if (rc != EOK) { 725 fibril_mutex_unlock(&arp_globals.lock); 726 return rc; 727 } 649 728 if (!translation) { 650 fibril_ rwlock_read_unlock(&arp_globals.lock);729 fibril_mutex_unlock(&arp_globals.lock); 651 730 return ENOENT; 652 731 } 653 732 rc = measured_strings_reply(translation, 1); 654 fibril_ rwlock_read_unlock(&arp_globals.lock);733 fibril_mutex_unlock(&arp_globals.lock); 655 734 return rc; 656 735 … … 682 761 return rc; 683 762 684 fibril_ rwlock_read_lock(&arp_globals.lock);763 fibril_mutex_lock(&arp_globals.lock); 685 764 do { 686 765 next = pq_detach(packet); … … 692 771 packet = next; 693 772 } while (packet); 694 fibril_ rwlock_read_unlock(&arp_globals.lock);773 fibril_mutex_unlock(&arp_globals.lock); 695 774 696 775 return EOK; -
uspace/srv/net/il/arp/arp.h
r98d06b8 rc01255c 65 65 typedef struct arp_proto arp_proto_t; 66 66 67 /** Type definition of the ARP address translation record. 68 * @see arp_trans 69 */ 70 typedef struct arp_trans arp_trans_t; 71 67 72 /** ARP address map. 68 73 * … … 70 75 * @see generic_char_map.h 71 76 */ 72 GENERIC_CHAR_MAP_DECLARE(arp_addr, measured_string_t);77 GENERIC_CHAR_MAP_DECLARE(arp_addr, arp_trans_t); 73 78 74 79 /** ARP address cache. … … 89 94 struct arp_device { 90 95 /** Actual device hardware address. */ 91 measured_string_t * 96 measured_string_t *addr; 92 97 /** Actual device hardware address data. */ 93 98 char *addr_data; 94 99 /** Broadcast device hardware address. */ 95 measured_string_t * 100 measured_string_t *broadcast_addr; 96 101 /** Broadcast device hardware address data. */ 97 102 char *broadcast_data; … … 129 134 int net_phone; 130 135 /** Safety lock. */ 131 fibril_ rwlock_t lock;136 fibril_mutex_t lock; 132 137 }; 133 138 … … 144 149 }; 145 150 151 /** ARP address translation record. */ 152 struct arp_trans { 153 /** 154 * Hardware address for the translation. NULL denotes an incomplete 155 * record with possible waiters. 156 */ 157 measured_string_t *hw_addr; 158 /** Condition variable used for waiting for completion of the record. */ 159 fibril_condvar_t cv; 160 }; 161 146 162 #endif 147 163 148 164 /** @} 149 165 */ 166 -
uspace/srv/vfs/vfs.h
r98d06b8 rc01255c 172 172 173 173 extern fs_handle_t fs_name_to_handle(char *, bool); 174 extern vfs_info_t *fs_handle_to_info(fs_handle_t); 174 175 175 176 extern int vfs_lookup_internal(char *, int, vfs_lookup_res_t *, -
uspace/srv/vfs/vfs_ops.c
r98d06b8 rc01255c 781 781 static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) 782 782 { 783 vfs_info_t *vi; 783 784 784 785 /* … … 807 808 fibril_mutex_lock(&file->lock); 808 809 810 vi = fs_handle_to_info(file->node->fs_handle); 811 assert(vi); 812 809 813 /* 810 814 * Lock the file's node so that no other client can read/write to it at 811 * the same time. 812 */ 813 if (read) 815 * the same time unless the FS supports concurrent reads/writes and its 816 * write implementation does not modify the file size. 817 */ 818 if (read || (vi->concurrent_read_write && vi->write_retains_size)) 814 819 fibril_rwlock_read_lock(&file->node->contents_rwlock); 815 820 else … … 857 862 858 863 /* Unlock the VFS node. */ 859 if (read )864 if (read || (vi->concurrent_read_write && vi->write_retains_size)) 860 865 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 861 866 else { -
uspace/srv/vfs/vfs_register.c
r98d06b8 rc01255c 333 333 } 334 334 335 /** Find the VFS info structure. 336 * 337 * @param handle FS handle for which the VFS info structure is sought. 338 * @return VFS info structure on success or NULL otherwise. 339 */ 340 vfs_info_t *fs_handle_to_info(fs_handle_t handle) 341 { 342 vfs_info_t *info = NULL; 343 link_t *cur; 344 345 fibril_mutex_lock(&fs_head_lock); 346 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 347 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 348 if (fs->fs_handle == handle) { 349 info = &fs->vfs_info; 350 break; 351 } 352 } 353 fibril_mutex_unlock(&fs_head_lock); 354 355 return info; 356 } 357 335 358 /** 336 359 * @}
Note:
See TracChangeset
for help on using the changeset viewer.