MCPcopy Create free account
hub / github.com/coreboot/coreboot / get_chip

Function get_chip

util/sconfig/main.c:289–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289static 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
336struct chip_instance *new_chip_instance(char *path)
337{

Callers 1

new_chip_instanceFunction · 0.85

Calls 9

translate_nameFunction · 0.85
strlenFunction · 0.85
sprintfFunction · 0.85
fprintfFunction · 0.85
exitFunction · 0.85
statClass · 0.70
strcmpFunction · 0.50
strstrFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected