Changeset 1d53a78 in mainline for uspace/drv/bus/pci/pciintel/pci.c
- Timestamp:
- 2011-10-28T10:42:39Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 992b47ea
- Parents:
- 8a363ab3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/pci/pciintel/pci.c
r8a363ab3 r1d53a78 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 /* … … 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
Note:
See TracChangeset
for help on using the changeset viewer.