Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 9370b4d

Browse files
jeremy-compostellabuildslave
authored andcommitted
driver/abl: set the SMBIOS Type 2 Version to the platform ID
It allows to identify the board/platform from fastboot by using the `fastboot getvar board' command. Change-Id: I5054fb5ed52e86a488e4859a995db07502667c50 Tracked-On: https://jira01.devtools.intel.com/browse/OAM-70868 Signed-off-by: Jason Dutra <[email protected]> Signed-off-by: Jeremy Compostella <[email protected]> Reviewed-on: https://android.intel.com:443/650230
1 parent d824e19 commit 9370b4d

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

drivers/abl/abl.c

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,49 @@
5252
*
5353
* This structure is serialized as the "ABL.hwver" command line
5454
* parameter built as follow:
55-
* "$cpu,$cpuNcores,$cpuFreq,$sku,$resetCause,$platformId,$moduleId"
55+
*
56+
* "$cpu,$cpuNcores,$cpuFreq,$platformId,$sku,$MRC_amap.TOM"
57+
*
58+
* where $MRC_amap.TOM is the total amount of memory present.
5659
*/
57-
static const char *get_cpu_stepping(const char *str)
60+
static const char *get_hwver_token(const char *hwver, size_t index,
61+
char *token, size_t token_size)
5862
{
59-
static char out[4];
60-
unsigned long stepping;
61-
char *data, *endptr;
62-
int ret;
63+
char *data, *cur;
64+
size_t i;
6365

64-
data = strdup(str);
66+
data = strdup(hwver);
6567
if (!data)
6668
return SMBIOS_UNDEFINED;
6769

68-
data = strtok(data, ",");
69-
if (!data)
70+
cur = strtok(data, ",");
71+
if (!cur)
7072
return SMBIOS_UNDEFINED;
7173

72-
stepping = strtoul(data, &endptr, 16);
73-
free(data);
74-
if (*endptr != '\0')
75-
return SMBIOS_UNDEFINED;
74+
for (i = 0; i < index; i++) {
75+
cur = strtok(NULL, ",");
76+
if (!cur)
77+
return SMBIOS_UNDEFINED;
78+
}
7679

77-
if (stepping > 0xff)
80+
if (strlen(cur) > token_size)
7881
return SMBIOS_UNDEFINED;
7982

80-
ret = snprintf(out, sizeof(out), "%lx", stepping);
81-
if (ret < 0)
82-
return SMBIOS_UNDEFINED;
83+
strcpy(token, cur);
84+
free(data);
85+
return token;
86+
}
87+
88+
static const char *get_platform_id(const char *str)
89+
{
90+
static char platform_id[5];
91+
return get_hwver_token(str, 3, platform_id, sizeof(platform_id));
92+
}
8393

84-
return out;
94+
static const char *get_cpu_stepping(const char *str)
95+
{
96+
static char stepping[3];
97+
return get_hwver_token(str, 0, stepping, sizeof(stepping));
8598
}
8699

87100
static const char *identity(const char *str)
@@ -100,6 +113,7 @@ static const struct {
100113
{ "androidboot.name", 1, offsetof(SMBIOS_TYPE1, ProductName), identity },
101114
{ "androidboot.brand", 2, offsetof(SMBIOS_TYPE2, Manufacturer), identity },
102115
{ "androidboot.device", 2, offsetof(SMBIOS_TYPE2, ProductName), identity },
116+
{ "ABL.hwver", 2, offsetof(SMBIOS_TYPE2, Version), get_platform_id },
103117
{ "ABL.hwver", 1, offsetof(SMBIOS_TYPE1, Version), get_cpu_stepping }
104118
};
105119

0 commit comments

Comments
 (0)