1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 Pierre-Alexandre Meyer - All Rights Reserved
5 * Some part borrowed from DMI Decode:
7 * (C) 2000-2002 Alan Cox <alan@redhat.com>
8 * (C) 2002-2007 Jean Delvare <khali@linux-fr.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
13 * Boston MA 02111-1307, USA; either version 2 of the License, or
14 * (at your option) any later version; incorporated herein by reference.
16 * ----------------------------------------------------------------------- */
19 #include <dmi/dmi_cache.h>
23 * 3.3.8 Cache Information (Type 7)
26 const char *dmi_cache_mode(uint8_t code
)
28 static const char *mode
[] = {
29 "Write Through", /* 0x00 */
31 "Varies With Memory Address",
38 const char *dmi_cache_location(uint8_t code
)
40 static const char *location
[4] = {
41 "Internal", /* 0x00 */
43 "<OUT OF SPEC", /* 0x02 */
47 if (location
[code
] != NULL
)
48 return location
[code
];
52 uint16_t dmi_cache_size(uint16_t code
)
55 return (code
& 0x7FFF) << 6; /* KB */
60 void dmi_cache_types(uint16_t code
, const char *sep
, char *array
)
63 static const char *types
[] = {
70 "Asynchronous" /* 6 */
73 if ((code
& 0x007F) == 0)
74 strcpy(array
, "None");
78 for (i
= 0; i
<= 6; i
++)
80 sprintf(array
, "%s%s", sep
, types
[i
]);
84 const char *dmi_cache_ec_type(uint8_t code
)
87 static const char *type
[] = {
93 "Multi-bit ECC" /* 0x06 */
96 if (code
>= 0x01 && code
<= 0x06)
97 return type
[code
- 0x01];
101 const char *dmi_cache_type(uint8_t code
)
104 static const char *type
[] = {
112 if (code
>= 0x01 && code
<= 0x05)
113 return type
[code
- 0x01];
117 const char *dmi_cache_associativity(uint8_t code
)
120 static const char *type
[] = {
124 "2-way Set-associative",
125 "4-way Set-associative",
127 "8-way Set-associative",
128 "16-way Set-associative", /* 0x08 */
129 "12-way Set-associative",
130 "24-way Set-associative",
131 "32-way Set-associative",
132 "48-way Set-associative",
133 "64-way Set-associative" /* 0x0D */
136 if (code
>= 0x01 && code
<= 0x0D)
137 return type
[code
- 0x01];