void lb_table_add_macs_from_vpd(struct lb_header *header) { /* * Mac addresses in the VPD can be stored in two groups, for ethernet * and WiFi, with keys 'ethernet_macX and wifi_macX. */ const char *mac_addr_key_bases[] = {"ethernet_mac0", "wifi_mac0"}; char mac_addr_key[20]; /* large enough for either key */ char mac_addr_str[13]; /* 12 symbols and the trailing zero. */ int i, count; struct lb_macs *macs = NULL; /* Make sure the copy is always zero terminated. */ mac_addr_key[sizeof(mac_addr_key) - 1] = '\0'; count = 0; for (i = 0; i < ARRAY_SIZE(mac_addr_key_bases); i++) { int index_of_index; strncpy(mac_addr_key, mac_addr_key_bases[i], sizeof(mac_addr_key) - 1); index_of_index = strlen(mac_addr_key) - 1; do { /* * If there are no more MAC addresses of this template * in the VPD - move on. */ if (!cros_vpd_gets(mac_addr_key, mac_addr_str, sizeof(mac_addr_str))) break; if (!macs) { macs = (struct lb_macs *)lb_new_record(header); macs->tag = LB_TAG_MAC_ADDRS; } decode_mac(macs->mac_addrs + count, mac_addr_str, mac_addr_key); count++; mac_addr_key[index_of_index]++; } while (count < 10); } if (!count) return; /* No MAC addresses in the VPD. */ macs->count = count; macs->size = sizeof(*macs) + count * sizeof(struct mac_address); }
void lb_table_add_serialno_from_vpd(struct lb_header *header) { struct lb_string *serialno_rec = NULL; const char serialno_key[] = "serial_number"; char serialno[32]; size_t len; if (!cros_vpd_gets(serialno_key, serialno, sizeof(serialno))) { printk(BIOS_ERR, "no serial number in vpd\n"); return; } printk(BIOS_DEBUG, "serial number is %s\n", serialno); len = strlen(serialno) + 1; ASSERT(len <= 32); serialno_rec = (struct lb_string *)lb_new_record(header); serialno_rec->tag = LB_TAG_SERIALNO; serialno_rec->size = ALIGN_UP(sizeof(*serialno_rec) + len, 8); memcpy(&serialno_rec->string, serialno, len); }