| 287 | } |
| 288 | |
| 289 | static struct chip *get_chip(char *path) |
| 290 | { |
| 291 | struct chip *h = &chip_header; |
| 292 | |
| 293 | while (h->next) { |
| 294 | int result = strcmp(path, h->next->name); |
| 295 | if (result == 0) |
| 296 | return h->next; |
| 297 | |
| 298 | if (result < 0) |
| 299 | break; |
| 300 | |
| 301 | h = h->next; |
| 302 | } |
| 303 | |
| 304 | struct chip *new_chip = S_ALLOC(sizeof(struct chip)); |
| 305 | new_chip->next = h->next; |
| 306 | h->next = new_chip; |
| 307 | |
| 308 | new_chip->chiph_exists = 1; |
| 309 | new_chip->name = path; |
| 310 | new_chip->name_underscore = translate_name(path, UNSLASH); |
| 311 | |
| 312 | struct stat st; |
| 313 | char *chip_h = S_ALLOC(strlen(path) + 18); |
| 314 | sprintf(chip_h, "src/%s", path); |
| 315 | if ((stat(chip_h, &st) == -1) && (errno == ENOENT)) { |
| 316 | /* root_complex gets away without a separate directory, but |
| 317 | * exists on pretty much all AMD chipsets. |
| 318 | */ |
| 319 | if (!strstr(path, "/root_complex")) { |
| 320 | fprintf(stderr, "ERROR: Chip component %s does not exist.\n", |
| 321 | path); |
| 322 | exit(1); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | sprintf(chip_h, "src/%s/chip.h", path); |
| 327 | |
| 328 | if ((stat(chip_h, &st) == -1) && (errno == ENOENT)) |
| 329 | new_chip->chiph_exists = 0; |
| 330 | |
| 331 | free(chip_h); |
| 332 | |
| 333 | return new_chip; |
| 334 | } |
| 335 | |
| 336 | struct chip_instance *new_chip_instance(char *path) |
| 337 | { |
no test coverage detected