Changeset 8071af9f in mainline for pci/libpci/names.c
- Timestamp:
- 2006-05-14T09:33:09Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8a568e3
- Parents:
- 57ff9ab
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pci/libpci/names.c
r57ff9ab r8071af9f 4 4 * Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz> 5 5 * 6 * M odified and ported to HelenOS by Jakub Jermar.6 * May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar. 7 7 * 8 8 * Can be freely distributed and used under the terms of the GNU GPL. … … 176 176 if (!nest) { /* Top-level entries */ 177 177 if (p[0] == 'C' && p[1] == ' ') { /* Class block */ 178 if ((id1 = id_hex(p + 2, 2)) < 0 179 || !id_white_p(p[4])) 178 if ((id1 = id_hex(p + 2, 2)) < 0 || !id_white_p(p[4])) 180 179 return parse_error; 181 180 cat = ID_CLASS; … … 193 192 } else { /* Vendor ID */ 194 193 195 if ((id1 = id_hex(p, 4)) < 0 196 || !id_white_p(p[4])) 194 if ((id1 = id_hex(p, 4)) < 0 || !id_white_p(p[4])) 197 195 return parse_error; 198 196 cat = ID_VENDOR; … … 207 205 case ID_DEVICE: 208 206 case ID_SUBSYSTEM: 209 if ((id2 = id_hex(p, 4)) < 0 210 || !id_white_p(p[4])) 207 if ((id2 = id_hex(p, 4)) < 0 || !id_white_p(p[4])) 211 208 return parse_error; 212 209 p += 5; … … 215 212 break; 216 213 case ID_GEN_SUBSYSTEM: 217 if ((id2 = id_hex(p, 4)) < 0 218 || !id_white_p(p[4])) 214 if ((id2 = id_hex(p, 4)) < 0 || !id_white_p(p[4])) 219 215 return parse_error; 220 216 p += 5; … … 224 220 case ID_SUBCLASS: 225 221 case ID_PROGIF: 226 if ((id2 = id_hex(p, 2)) < 0 227 || !id_white_p(p[2])) 222 if ((id2 = id_hex(p, 2)) < 0 || !id_white_p(p[2])) 228 223 return parse_error; 229 224 p += 3; … … 237 232 case ID_DEVICE: 238 233 case ID_SUBSYSTEM: 239 if ((id3 = id_hex(p, 4)) < 0 240 || !id_white_p(p[4]) 241 || (id4 = id_hex(p + 5, 4)) < 0 242 || !id_white_p(p[9])) 234 if ((id3 = id_hex(p, 4)) < 0 || !id_white_p(p[4]) 235 || (id4 = id_hex(p + 5, 4)) < 0 || !id_white_p(p[9])) 243 236 return parse_error; 244 237 p += 10; … … 248 241 case ID_SUBCLASS: 249 242 case ID_PROGIF: 250 if ((id3 = id_hex(p, 2)) < 0 251 || !id_white_p(p[2])) 243 if ((id3 = id_hex(p, 2)) < 0 || !id_white_p(p[2])) 252 244 return parse_error; 253 245 p += 3; … … 342 334 return (char *) v->name; 343 335 else 344 res = 345 snprintf(buf, size, "Unknown vendor %04x", iv); 336 res = snprintf(buf, size, "Unknown vendor %04x", iv); 346 337 break; 347 338 case PCI_LOOKUP_DEVICE: … … 353 344 return (char *) d->name; 354 345 else if (synth) 355 res = 356 snprintf(buf, size, "Unknown device %04x", id); 346 res = snprintf(buf, size, "Unknown device %04x", id); 357 347 else 358 348 return NULL; … … 367 357 d = id_lookup(a, ID_DEVICE, iv, id, 0, 0); 368 358 if (v && d) 369 res = 370 snprintf(buf, size, "%s %s", v->name, 359 res = snprintf(buf, size, "%s %s", v->name, 371 360 d->name); 372 361 else if (!synth) 373 362 return NULL; 374 363 else if (!v) 375 res = 376 snprintf(buf, size, 377 "Unknown device %04x:%04x", 378 iv, id); 364 res = snprintf(buf, size, "Unknown device %04x:%04x", iv, id); 379 365 else /* !d */ 380 res = 381 snprintf(buf, size, 382 "%s Unknown device %04x", 383 v->name, id); 366 res = snprintf(buf, size, "%s Unknown device %04x", v->name, id); 384 367 } 385 368 break; … … 391 374 return (char *) v->name; 392 375 else if (synth) 393 res = 394 snprintf(buf, size, "Unknown vendor %04x", 395 isv); 376 res = snprintf(buf, size, "Unknown vendor %04x", isv); 396 377 else 397 378 return NULL; … … 407 388 return (char *) d->name; 408 389 else if (synth) 409 res = 410 snprintf(buf, size, "Unknown device %04x", 411 isd); 390 res = snprintf(buf, size, "Unknown device %04x", isd); 412 391 else 413 392 return NULL; … … 424 403 d = id_lookup_subsys(a, iv, id, isv, isd); 425 404 if (v && d) 426 res = 427 snprintf(buf, size, "%s %s", v->name, 428 d->name); 405 res = snprintf(buf, size, "%s %s", v->name, d->name); 429 406 else if (!synth) 430 407 return NULL; 431 408 else if (!v) 432 res = 433 snprintf(buf, size, 434 "Unknown device %04x:%04x", 435 isv, isd); 409 res = snprintf(buf, size, "Unknown device %04x:%04x", isv, isd); 436 410 else /* !d */ 437 res = 438 snprintf(buf, size, 439 "%s Unknown device %04x", 440 v->name, isd); 411 res = snprintf(buf, size, "%s Unknown device %04x", v->name, isd); 441 412 } 442 413 break; … … 445 416 if (num) 446 417 res = snprintf(buf, size, "%04x", icls); 447 else if (cls = 448 id_lookup(a, ID_SUBCLASS, icls >> 8, icls & 0xff, 449 0, 0)) 418 else if (cls = id_lookup(a, ID_SUBCLASS, icls >> 8, icls & 0xff, 0, 0)) 450 419 return (char *) cls->name; 451 420 else if (cls = id_lookup(a, ID_CLASS, icls, 0, 0, 0)) 452 res = 453 snprintf(buf, size, "%s [%04x]", cls->name, 454 icls); 421 res = snprintf(buf, size, "%s [%04x]", cls->name, icls); 455 422 else if (synth) 456 423 res = snprintf(buf, size, "Class %04x", icls); … … 463 430 if (num) 464 431 res = snprintf(buf, size, "%02x", ipif); 465 else if (pif = 466 id_lookup(a, ID_PROGIF, icls >> 8, icls & 0xff, 467 ipif, 0)) 432 else if (pif = id_lookup(a, ID_PROGIF, icls >> 8, icls & 0xff, ipif, 0)) 468 433 return (char *) pif->name; 469 434 else if (icls == 0x0101 && !(ipif & 0x70)) {
Note:
See TracChangeset
for help on using the changeset viewer.