Changes in / [3569955:d5a78e28] in mainline
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/pci/pciintel/pci.c
r3569955 rd5a78e28 78 78 #define PCI_BUS_FROM_FUN(fun) ((fun)->busptr) 79 79 80 /** Max is 47, align to something nice. */81 #define ID_MAX_STR_LEN 5082 83 80 static hw_resource_list_t *pciintel_get_resources(ddf_fun_t *fnode) 84 81 { … … 228 225 fibril_mutex_lock(&bus->conf_mutex); 229 226 230 const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 227 uint32_t conf_addr; 228 conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 231 229 void *addr = bus->conf_data_port + (reg & 3); 232 230 … … 313 311 void pci_fun_create_match_ids(pci_fun_t *fun) 314 312 { 313 char *match_id_str; 315 314 int rc; 316 char match_id_str[ID_MAX_STR_LEN]; 317 318 /* Vendor ID & Device ID, length(incl \0) 22 */ 319 rc = snprintf(match_id_str, ID_MAX_STR_LEN, "pci/ven=%04x&dev=%04x", 315 316 asprintf(&match_id_str, "pci/ven=%04x&dev=%04x", 320 317 fun->vendor_id, fun->device_id); 321 if (rc < 0) { 322 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 323 str_error(rc)); 318 319 if (match_id_str == NULL) { 320 ddf_msg(LVL_ERROR, "Out of memory creating match ID."); 321 return; 324 322 } 325 323 326 324 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90); 327 325 if (rc != EOK) { 328 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 329 } 330 331 /* Class, subclass, prog IF, revision, length(incl \0) 47 */ 332 rc = snprintf(match_id_str, ID_MAX_STR_LEN, 333 "pci/class=%02x&subclass=%02x&progif=%02x&revision=%02x", 334 fun->class_code, fun->subclass_code, fun->prog_if, fun->revision); 335 if (rc < 0) { 336 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 326 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", 337 327 str_error(rc)); 338 328 } 339 340 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 70); 341 if (rc != EOK) { 342 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 343 } 344 345 /* Class, subclass, prog IF, length(incl \0) 35 */ 346 rc = snprintf(match_id_str, ID_MAX_STR_LEN, 347 "pci/class=%02x&subclass=%02x&progif=%02x", 348 fun->class_code, fun->subclass_code, fun->prog_if); 349 if (rc < 0) { 350 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 351 str_error(rc)); 352 } 353 354 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 60); 355 if (rc != EOK) { 356 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 357 } 358 359 /* Class, subclass, length(incl \0) 25 */ 360 rc = snprintf(match_id_str, ID_MAX_STR_LEN, 361 "pci/class=%02x&subclass=%02x", 362 fun->class_code, fun->subclass_code); 363 if (rc < 0) { 364 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 365 str_error(rc)); 366 } 367 368 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 50); 369 if (rc != EOK) { 370 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 371 } 372 373 /* Class, length(incl \0) 13 */ 374 rc = snprintf(match_id_str, ID_MAX_STR_LEN, "pci/class=%02x", 375 fun->class_code); 376 if (rc < 0) { 377 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 378 str_error(rc)); 379 } 380 381 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 40); 382 if (rc != EOK) { 383 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 384 } 385 386 /* TODO add subsys ids, but those exist only in header type 0 */ 329 330 free(match_id_str); 331 332 /* TODO add more ids (with subsys ids, using class id etc.) */ 387 333 } 388 334 … … 535 481 for (fnum = 0; multi && fnum < 8; fnum++) { 536 482 pci_fun_init(fun, bus_num, dnum, fnum); 483 fun->vendor_id = pci_conf_read_16(fun, 484 PCI_VENDOR_ID); 485 fun->device_id = pci_conf_read_16(fun, 486 PCI_DEVICE_ID); 537 487 if (fun->vendor_id == 0xffff) { 538 488 /* … … 561 511 562 512 fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name); 563 free(fun_name);564 513 if (fnode == NULL) { 565 514 ddf_msg(LVL_ERROR, "Failed creating function."); … … 567 516 } 568 517 518 free(fun_name); 569 519 fun->fnode = fnode; 570 520 … … 741 691 fun->dev = dev; 742 692 fun->fn = fn; 743 fun->vendor_id = pci_conf_read_16(fun, PCI_VENDOR_ID);744 fun->device_id = pci_conf_read_16(fun, PCI_DEVICE_ID);745 fun->class_code = pci_conf_read_8(fun, PCI_BASE_CLASS);746 fun->subclass_code = pci_conf_read_8(fun, PCI_SUB_CLASS);747 fun->prog_if = pci_conf_read_8(fun, PCI_PROG_IF);748 fun->revision = pci_conf_read_8(fun, PCI_REVISION_ID);749 693 } 750 694 … … 767 711 bool pci_alloc_resource_list(pci_fun_t *fun) 768 712 { 769 fun->hw_resources.resources = fun->resources; 770 return true; 713 fun->hw_resources.resources = 714 (hw_resource_t *) malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t)); 715 return fun->hw_resources.resources != NULL; 771 716 } 772 717 773 718 void pci_clean_resource_list(pci_fun_t *fun) 774 719 { 775 fun->hw_resources.resources = NULL; 720 if (fun->hw_resources.resources != NULL) { 721 free(fun->hw_resources.resources); 722 fun->hw_resources.resources = NULL; 723 } 776 724 } 777 725 -
uspace/drv/bus/pci/pciintel/pci.h
r3569955 rd5a78e28 60 60 int vendor_id; 61 61 int device_id; 62 uint8_t class_code;63 uint8_t subclass_code;64 uint8_t prog_if;65 uint8_t revision;66 62 hw_resource_list_t hw_resources; 67 hw_resource_t resources[PCI_MAX_HW_RES];68 63 } pci_fun_t; 69 64 -
uspace/lib/drv/generic/driver.c
r3569955 rd5a78e28 970 970 971 971 match_id->id = str_dup(match_id_str); 972 match_id->score = match_score;972 match_id->score = 90; 973 973 974 974 add_match_id(&fun->match_ids, match_id);
Note:
See TracChangeset
for help on using the changeset viewer.