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

Function set_option_from_string

payloads/libpayload/drivers/options.c:347–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347int set_option_from_string(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, const char *value, const char *name)
348{
349 void *raw;
350 struct cb_cmos_entries *cmos_entry = lookup_cmos_entry(option_table, name);
351 if (!cmos_entry)
352 return 1;
353
354 struct cb_cmos_enums *cmos_enum;
355 switch (cmos_entry->config) {
356 case 'h':
357 /* only works on little endian */
358 raw = malloc(sizeof(u64));
359 *(u64*)raw = strtoull(value, NULL, 0);
360 break;
361 case 's':
362 raw = malloc(cmos_entry->length);
363 if (!raw)
364 return 1;
365 memset(raw, 0x00, cmos_entry->length);
366 strncpy(raw, value, cmos_entry->length);
367 break;
368 case 'e':
369 cmos_enum = lookup_cmos_enum_by_label(option_table, cmos_entry->config_id, value);
370 raw = malloc(sizeof(u32));
371 *(u32*)raw = cmos_enum->value;
372 break;
373 default: /* fail */
374 return 1;
375 }
376
377 int ret = set_option_with(nvram, option_table, raw, name);
378 free(raw);
379 return ret;
380}

Callers 1

mainFunction · 0.85

Calls 8

lookup_cmos_entryFunction · 0.85
set_option_withFunction · 0.85
mallocFunction · 0.50
strtoullFunction · 0.50
memsetFunction · 0.50
strncpyFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected