52
52
*
53
53
* This structure is serialized as the "ABL.hwver" command line
54
54
* 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.
56
59
*/
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 )
58
62
{
59
- static char out [4 ];
60
- unsigned long stepping ;
61
- char * data , * endptr ;
62
- int ret ;
63
+ char * data , * cur ;
64
+ size_t i ;
63
65
64
- data = strdup (str );
66
+ data = strdup (hwver );
65
67
if (!data )
66
68
return SMBIOS_UNDEFINED ;
67
69
68
- data = strtok (data , "," );
69
- if (!data )
70
+ cur = strtok (data , "," );
71
+ if (!cur )
70
72
return SMBIOS_UNDEFINED ;
71
73
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
+ }
76
79
77
- if (stepping > 0xff )
80
+ if (strlen ( cur ) > token_size )
78
81
return SMBIOS_UNDEFINED ;
79
82
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
+ }
83
93
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 ));
85
98
}
86
99
87
100
static const char * identity (const char * str )
@@ -100,6 +113,7 @@ static const struct {
100
113
{ "androidboot.name" , 1 , offsetof(SMBIOS_TYPE1 , ProductName ), identity },
101
114
{ "androidboot.brand" , 2 , offsetof(SMBIOS_TYPE2 , Manufacturer ), identity },
102
115
{ "androidboot.device" , 2 , offsetof(SMBIOS_TYPE2 , ProductName ), identity },
116
+ { "ABL.hwver" , 2 , offsetof(SMBIOS_TYPE2 , Version ), get_platform_id },
103
117
{ "ABL.hwver" , 1 , offsetof(SMBIOS_TYPE1 , Version ), get_cpu_stepping }
104
118
};
105
119
0 commit comments