1 /* ----------------------------------------------------------------------- *
3 * Pportions of this file taken from the dmidecode project
5 * Copyright (C) 2000-2002 Alan Cox <alan@redhat.com>
6 * Copyright (C) 2002-2008 Jean Delvare <khali@linux-fr.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * For the avoidance of doubt the "preferred form" of this code is one which
23 * is in an open unpatent encumbered format. Where cryptographic key signing
24 * forms part of the process of creating an executable the information
25 * including keys needed to generate an equivalently functional executable
26 * are deemed to be part of the source code.
32 void dmi_memory_array_error_handle(uint16_t code
, char *array
)
35 sprintf(array
, "%s", "Not Provided");
36 else if (code
== 0xFFFF)
37 sprintf(array
, "%s", "No Error");
39 sprintf(array
, "0x%04X", code
);
42 void dmi_memory_device_width(uint16_t code
, char *width
)
45 * 3.3.18 Memory Device (Type 17)
46 * If no memory module is present, width may be 0
48 if (code
== 0xFFFF || code
== 0)
49 sprintf(width
, "%s", "Unknown");
51 sprintf(width
, "%u bits", code
);
54 void dmi_memory_device_size(uint16_t code
, char *size
)
57 sprintf(size
, "%s", "Free");
58 else if (code
== 0xFFFF)
59 sprintf(size
, "%s", "Unknown");
62 sprintf(size
, "%u kB", code
& 0x7FFF);
64 sprintf(size
, "%u MB", code
);
68 const char *dmi_memory_device_form_factor(uint8_t code
)
71 static const char *form_factor
[] = {
89 if (code
>= 0x01 && code
<= 0x0F)
90 return form_factor
[code
- 0x01];
94 void dmi_memory_device_set(uint8_t code
, char *set
)
97 sprintf(set
, "%s", "None");
98 else if (code
== 0xFF)
99 sprintf(set
, "%s", "Unknown");
101 sprintf(set
, "%u", code
);
104 const char *dmi_memory_device_type(uint8_t code
)
107 static const char *type
[] = {
127 "DDR2 FB-DIMM", /* 0x14 */
135 if (code
>= 0x01 && code
<= 0x19)
136 return type
[code
- 0x01];
140 void dmi_memory_device_type_detail(uint16_t code
, char *type_detail
, int sizeof_type_detail
)
143 static const char *detail
[] = {
155 "Non-Volatile" /* 12 */
158 if ((code
& 0x1FFE) == 0)
159 sprintf(type_detail
, "%s", "None");
163 for (i
= 1; i
<= 12; i
++)
165 snprintf(type_detail
, sizeof_type_detail
, "%s", detail
[i
- 1]);
169 void dmi_memory_device_speed(uint16_t code
, char *speed
)
172 sprintf(speed
, "%s", "Unknown");
174 sprintf(speed
, "%u MHz", code
);
178 * 3.3.7 Memory Module Information (Type 6)
181 void dmi_memory_module_types(uint16_t code
, const char *sep
, char *type
, int sizeof_type
)
184 static const char *types
[] = {
198 if ((code
& 0x07FF) == 0)
199 sprintf(type
, "%s", "None");
203 for (i
= 0; i
<= 10; i
++)
205 snprintf(type
, sizeof_type
, "%s%s%s", type
, sep
, types
[i
]);
209 void dmi_memory_module_connections(uint8_t code
, char *connection
, int sizeof_connection
)
212 sprintf(connection
, "%s", "None");
214 if ((code
& 0xF0) != 0xF0)
215 sprintf(connection
, "%u ", code
>> 4);
216 if ((code
& 0x0F) != 0x0F)
217 snprintf(connection
, sizeof_connection
, "%s%u", connection
, code
& 0x0F);
221 void dmi_memory_module_speed(uint8_t code
, char *speed
)
224 sprintf(speed
, "%s", "Unknown");
226 sprintf(speed
, "%u ns", code
);
229 void dmi_memory_module_size(uint8_t code
, char *size
, int sizeof_size
)
232 switch (code
& 0x7F) {
234 sprintf(size
, "%s", "Not Determinable");
237 sprintf(size
, "%s", "Disabled");
240 sprintf(size
, "%s", "Not Installed");
243 sprintf(size
, "%u MB", 1 << (code
& 0x7F));
247 snprintf(size
, sizeof_size
, "%s %s", size
, "(Double-bank Connection)");
249 snprintf(size
, sizeof_size
, "%s %s", size
, "(Single-bank Connection)");
252 void dmi_memory_module_error(uint8_t code
, const char *prefix
, char *error
)
255 sprintf(error
, "%s", "See Event Log\n");
257 if ((code
& 0x03) == 0)
258 sprintf(error
, "%s", "OK\n");
260 sprintf(error
, "%sUncorrectable Errors\n", prefix
);
262 sprintf(error
, "%sCorrectable Errors\n", prefix
);