Adding upstream version 4.00~pre53+dfsg.
[syslinux-debian/hramrach.git] / com32 / gpllib / dmi / dmi_memory.c
bloba1f2b440771bbb594963e0edde09b28cbb00e51d
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.
29 #include <dmi/dmi.h>
30 #include <stdio.h>
32 void dmi_memory_array_error_handle(uint16_t code, char *array)
34 if (code == 0xFFFE)
35 sprintf(array, "%s", "Not Provided");
36 else if (code == 0xFFFF)
37 sprintf(array, "%s", "No Error");
38 else
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");
50 else
51 sprintf(width, "%u bits", code);
54 void dmi_memory_device_size(uint16_t code, char *size)
56 if (code == 0)
57 sprintf(size, "%s", "Free");
58 else if (code == 0xFFFF)
59 sprintf(size, "%s", "Unknown");
60 else {
61 if (code & 0x8000)
62 sprintf(size, "%u kB", code & 0x7FFF);
63 else
64 sprintf(size, "%u MB", code);
68 const char *dmi_memory_device_form_factor(uint8_t code)
70 /* 3.3.18.1 */
71 static const char *form_factor[] = {
72 "Other", /* 0x01 */
73 "Unknown",
74 "SIMM",
75 "SIP",
76 "Chip",
77 "DIP",
78 "ZIP",
79 "Proprietary Card",
80 "DIMM",
81 "TSOP",
82 "Row Of Chips",
83 "RIMM",
84 "SODIMM",
85 "SRIMM",
86 "FB-DIMM" /* 0x0F */
89 if (code >= 0x01 && code <= 0x0F)
90 return form_factor[code - 0x01];
91 return out_of_spec;
94 void dmi_memory_device_set(uint8_t code, char *set)
96 if (code == 0)
97 sprintf(set, "%s", "None");
98 else if (code == 0xFF)
99 sprintf(set, "%s", "Unknown");
100 else
101 sprintf(set, "%u", code);
104 const char *dmi_memory_device_type(uint8_t code)
106 /* 3.3.18.2 */
107 static const char *type[] = {
108 "Other", /* 0x01 */
109 "Unknown",
110 "DRAM",
111 "EDRAM",
112 "VRAM",
113 "SRAM",
114 "RAM",
115 "ROM",
116 "Flash",
117 "EEPROM",
118 "FEPROM",
119 "EPROM",
120 "CDRAM",
121 "3DRAM",
122 "SDRAM",
123 "SGRAM",
124 "RDRAM",
125 "DDR",
126 "DDR2",
127 "DDR2 FB-DIMM" /* 0x14 */
130 if (code >= 0x01 && code <= 0x14)
131 return type[code - 0x01];
132 return out_of_spec;
135 void dmi_memory_device_type_detail(uint16_t code, char *type_detail)
137 /* 3.3.18.3 */
138 static const char *detail[] = {
139 "Other", /* 1 */
140 "Unknown",
141 "Fast-paged",
142 "Static Column",
143 "Pseudo-static",
144 "RAMBus",
145 "Synchronous",
146 "CMOS",
147 "EDO",
148 "Window DRAM",
149 "Cache DRAM",
150 "Non-Volatile" /* 12 */
153 if ((code & 0x1FFE) == 0)
154 sprintf(type_detail, "%s", "None");
155 else {
156 int i;
158 for (i = 1; i <= 12; i++)
159 if (code & (1 << i))
160 snprintf(type_detail,sizeof(type_detail), "%s", detail[i - 1]);
164 void dmi_memory_device_speed(uint16_t code, char *speed)
166 if (code == 0)
167 sprintf(speed, "%s", "Unknown");
168 else
169 sprintf(speed, "%u MHz", code);
173 * 3.3.7 Memory Module Information (Type 6)
176 void dmi_memory_module_types(uint16_t code, const char *sep, char *type)
178 /* 3.3.7.1 */
179 static const char *types[] = {
180 "Other", /* 0 */
181 "Unknown",
182 "Standard",
183 "FPM",
184 "EDO",
185 "Parity",
186 "ECC",
187 "SIMM",
188 "DIMM",
189 "Burst EDO",
190 "SDRAM" /* 10 */
193 if ((code & 0x07FF) == 0)
194 sprintf(type, "%s", "None");
195 else {
196 int i;
198 for (i = 0; i <= 10; i++)
199 if (code & (1 << i))
200 snprintf(type,sizeof(type), "%s%s%s", type, sep, types[i]);
204 void dmi_memory_module_connections(uint8_t code, char *connection)
206 if (code == 0xFF)
207 sprintf(connection, "%s", "None");
208 else {
209 if ((code & 0xF0) != 0xF0)
210 sprintf(connection, "%u ", code >> 4);
211 if ((code & 0x0F) != 0x0F)
212 snprintf(connection,sizeof(connection), "%s%u", connection, code & 0x0F);
216 void dmi_memory_module_speed(uint8_t code, char *speed)
218 if (code == 0)
219 sprintf(speed, "%s", "Unknown");
220 else
221 sprintf(speed, "%u ns", code);
224 void dmi_memory_module_size(uint8_t code, char *size)
226 /* 3.3.7.2 */
227 switch (code & 0x7F) {
228 case 0x7D:
229 sprintf(size, "%s", "Not Determinable");
230 break;
231 case 0x7E:
232 sprintf(size, "%s", "Disabled");
233 break;
234 case 0x7F:
235 sprintf(size, "%s", "Not Installed");
236 return;
237 default:
238 sprintf(size, "%u MB", 1 << (code & 0x7F));
241 if (code & 0x80)
242 snprintf(size,sizeof(size),"%s %s", size, "(Double-bank Connection)");
243 else
244 snprintf(size,sizeof(size), "%s %s", size, "(Single-bank Connection)");
247 void dmi_memory_module_error(uint8_t code, const char *prefix, char *error)
249 if (code & (1 << 2))
250 sprintf(error, "%s", "See Event Log\n");
251 else {
252 if ((code & 0x03) == 0)
253 sprintf(error, "%s", "OK\n");
254 if (code & (1 << 0))
255 sprintf(error, "%sUncorrectable Errors\n", prefix);
256 if (code & (1 << 1))
257 sprintf(error, "%sCorrectable Errors\n", prefix);