Changeset c289457 in mainline
- Timestamp:
- 2011-11-03T22:19:03Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 54de4836
- Parents:
- 3ce78580 (diff), cb94e69b (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. - Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/pci/pciintel/pci.c
r3ce78580 rc289457 225 225 fibril_mutex_lock(&bus->conf_mutex); 226 226 227 uint32_t conf_addr; 228 conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 227 const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 229 228 void *addr = bus->conf_data_port + (reg & 3); 230 229 … … 311 310 void pci_fun_create_match_ids(pci_fun_t *fun) 312 311 { 313 char *match_id_str; 312 #define ID_MAX_STR_LEN 50 /* Max is 47, align to something nice. */ 313 314 314 int rc; 315 316 asprintf(&match_id_str, "pci/ven=%04x&dev=%04x", 315 char match_id_str[ID_MAX_STR_LEN]; 316 317 /* Vendor ID & Device ID, length(incl \0) 22 */ 318 rc = snprintf(match_id_str, ID_MAX_STR_LEN, "pci/ven=%04x&dev=%04x", 317 319 fun->vendor_id, fun->device_id); 318 319 if (match_id_str == NULL) { 320 ddf_msg(LVL_ERROR, "Out of memory creating match ID."); 321 return; 320 if (rc < 0) { 321 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 322 str_error(rc)); 322 323 } 323 324 324 325 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90); 325 326 if (rc != EOK) { 326 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", 327 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 328 } 329 330 /* Class, subclass, prog IF, revision, length(incl \0) 47 */ 331 rc = snprintf(match_id_str, ID_MAX_STR_LEN, 332 "pci/class=%02x&subclass=%02x&progif=%02x&revision=%02x", 333 fun->class_code, fun->subclass_code, fun->prog_if, fun->revision); 334 if (rc < 0) { 335 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 327 336 str_error(rc)); 328 337 } 329 330 free(match_id_str); 331 332 /* TODO add more ids (with subsys ids, using class id etc.) */ 338 339 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 70); 340 if (rc != EOK) { 341 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 342 } 343 344 /* Class, subclass, prog IF, length(incl \0) 35 */ 345 rc = snprintf(match_id_str, ID_MAX_STR_LEN, 346 "pci/class=%02x&subclass=%02x&progif=%02x", 347 fun->class_code, fun->subclass_code, fun->prog_if); 348 if (rc < 0) { 349 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 350 str_error(rc)); 351 } 352 353 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 60); 354 if (rc != EOK) { 355 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 356 } 357 358 /* Class, subclass, length(incl \0) 25 */ 359 rc = snprintf(match_id_str, ID_MAX_STR_LEN, 360 "pci/class=%02x&subclass=%02x", 361 fun->class_code, fun->subclass_code); 362 if (rc < 0) { 363 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 364 str_error(rc)); 365 } 366 367 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 50); 368 if (rc != EOK) { 369 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 370 } 371 372 /* Class, length(incl \0) 13 */ 373 rc = snprintf(match_id_str, ID_MAX_STR_LEN, "pci/class=%02x", 374 fun->class_code); 375 if (rc < 0) { 376 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 377 str_error(rc)); 378 } 379 380 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 40); 381 if (rc != EOK) { 382 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 383 } 384 385 /* TODO add subsys ids, but those exist only in header type 0 */ 333 386 } 334 387 … … 481 534 for (fnum = 0; multi && fnum < 8; fnum++) { 482 535 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);487 536 if (fun->vendor_id == 0xffff) { 488 537 /* … … 511 560 512 561 fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name); 562 free(fun_name); 513 563 if (fnode == NULL) { 514 564 ddf_msg(LVL_ERROR, "Failed creating function."); … … 516 566 } 517 567 518 free(fun_name);519 568 fun->fnode = fnode; 520 569 … … 691 740 fun->dev = dev; 692 741 fun->fn = fn; 742 fun->vendor_id = pci_conf_read_16(fun, PCI_VENDOR_ID); 743 fun->device_id = pci_conf_read_16(fun, PCI_DEVICE_ID); 744 fun->class_code = pci_conf_read_8(fun, PCI_BASE_CLASS); 745 fun->subclass_code = pci_conf_read_8(fun, PCI_SUB_CLASS); 746 fun->prog_if = pci_conf_read_8(fun, PCI_PROG_IF); 747 fun->revision = pci_conf_read_8(fun, PCI_REVISION_ID); 693 748 } 694 749 … … 711 766 bool pci_alloc_resource_list(pci_fun_t *fun) 712 767 { 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; 768 fun->hw_resources.resources = fun->resources; 769 return true; 716 770 } 717 771 718 772 void pci_clean_resource_list(pci_fun_t *fun) 719 773 { 720 if (fun->hw_resources.resources != NULL) { 721 free(fun->hw_resources.resources); 722 fun->hw_resources.resources = NULL; 723 } 774 fun->hw_resources.resources = NULL; 724 775 } 725 776 -
uspace/drv/bus/pci/pciintel/pci.h
r3ce78580 rc289457 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; 62 66 hw_resource_list_t hw_resources; 67 hw_resource_t resources[PCI_MAX_HW_RES]; 63 68 } pci_fun_t; 64 69 -
uspace/lib/drv/generic/driver.c
r3ce78580 rc289457 970 970 971 971 match_id->id = str_dup(match_id_str); 972 match_id->score = 90;972 match_id->score = match_score; 973 973 974 974 add_match_id(&fun->match_ids, match_id);
Note:
See TracChangeset
for help on using the changeset viewer.