2 * (C) Copyright 2000, 2001, 2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
11 /*-----------------------------------------------------------------------
12 * Process Hardware Information Block:
14 * If we boot on a system fresh from factory, check if the Hardware
15 * Information Block exists and save the information it contains.
17 * The TQM8xxL / TQM82xx Hardware Information Block is defined as
19 * - located in first flash bank
20 * - starts at offset 0x0003FFC0
24 * - sequence of ASCII character strings
25 * - fields separated by a single space character (0x20)
26 * - last field terminated by NUL character (0x00)
27 * - remaining space filled with NUL characters (0x00)
29 * Fields in Hardware Information Block:
32 * 3) First MAC Address
33 * 4) Number of additional MAC addresses
36 void load_sernum_ethaddr (void)
39 unsigned char serial [CONFIG_SYS_HWINFO_SIZE];
40 unsigned char ethaddr[CONFIG_SYS_HWINFO_SIZE];
41 unsigned short ih, is, ie, part;
43 hwi = (unsigned char *)(CONFIG_SYS_FLASH_BASE + CONFIG_SYS_HWINFO_OFFSET);
46 if (*((unsigned long *)hwi) != (unsigned long)CONFIG_SYS_HWINFO_MAGIC) {
52 /* copy serial # / MAC address */
53 while ((hwi[ih] != '\0') && (ih < CONFIG_SYS_HWINFO_SIZE)) {
54 if (hwi[ih] < ' ' || hwi[ih] > '~') { /* ASCII strings! */
58 default: /* Copy serial # */
62 serial[is++] = hwi[ih];
64 case 3: /* Copy MAC address */
69 ethaddr[ie++] = hwi[ih];
77 if (ie && ethaddr[ie-1] == ':')
81 /* set serial# and ethaddr if not yet defined */
82 if (getenv("serial#") == NULL) {
83 setenv ((char *)"serial#", (char *)serial);
86 if (getenv("ethaddr") == NULL) {
87 setenv ((char *)"ethaddr", (char *)ethaddr);