summaryrefslogtreecommitdiffstats
path: root/contrib/syslinux-4.02/com32/gpllib/dmi/dmi_cache.c
blob: 4c3f83ce34da6dc772784fec99a3632255e25888 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* ----------------------------------------------------------------------- *
 *
 *   Copyright 2009 Pierre-Alexandre Meyer - All Rights Reserved
 *
 *   Some part borrowed from DMI Decode:
 *
 *   (C) 2000-2002 Alan Cox <alan@redhat.com>
 *   (C) 2002-2007 Jean Delvare <khali@linux-fr.org>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
 *   Boston MA 02111-1307, USA; either version 2 of the License, or
 *   (at your option) any later version; incorporated herein by reference.
 *
 * ----------------------------------------------------------------------- */

#include <dmi/dmi.h>
#include <dmi/dmi_cache.h>
#include <stdio.h>

/*
 * 3.3.8 Cache Information (Type 7)
 */

const char *dmi_cache_mode(uint8_t code)
{
    static const char *mode[] = {
	"Write Through",	/* 0x00 */
	"Write Back",
	"Varies With Memory Address",
	"Unknown"		/* 0x03 */
    };

    return mode[code];
}

const char *dmi_cache_location(uint8_t code)
{
    static const char *location[4] = {
	"Internal",		/* 0x00 */
	"External",
	"<OUT OF SPEC",		/* 0x02 */
	"Unknown"		/* 0x03 */
    };

    if (location[code] != NULL)
	return location[code];
    return out_of_spec;
}

uint16_t dmi_cache_size(uint16_t code)
{
    if (code & 0x8000)
	return (code & 0x7FFF) << 6;	/* KB */
    else
	return code;		/* KB */
}

void dmi_cache_types(uint16_t code, const char *sep, char *array)
{
    /* 3.3.8.2 */
    static const char *types[] = {
	"Other",		/* 0 */
	"Unknown",
	"Non-burst",
	"Burst",
	"Pipeline Burst",
	"Synchronous",
	"Asynchronous"		/* 6 */
    };

    if ((code & 0x007F) == 0)
	strcpy(array, "None");
    else {
	int i;

	for (i = 0; i <= 6; i++)
	    if (code & (1 << i))
		sprintf(array, "%s%s", sep, types[i]);
    }
}

const char *dmi_cache_ec_type(uint8_t code)
{
    /* 3.3.8.3 */
    static const char *type[] = {
	"Other",		/* 0x01 */
	"Unknown",
	"None",
	"Parity",
	"Single-bit ECC",
	"Multi-bit ECC"		/* 0x06 */
    };

    if (code >= 0x01 && code <= 0x06)
	return type[code - 0x01];
    return out_of_spec;
}

const char *dmi_cache_type(uint8_t code)
{
    /* 3.3.8.4 */
    static const char *type[] = {
	"Other",		/* 0x01 */
	"Unknown",
	"Instruction",
	"Data",
	"Unified"		/* 0x05 */
    };

    if (code >= 0x01 && code <= 0x05)
	return type[code - 0x01];
    return out_of_spec;
}

const char *dmi_cache_associativity(uint8_t code)
{
    /* 3.3.8.5 */
    static const char *type[] = {
	"Other",		/* 0x01 */
	"Unknown",
	"Direct Mapped",
	"2-way Set-associative",
	"4-way Set-associative",
	"Fully Associative",
	"8-way Set-associative",
	"16-way Set-associative"	/* 0x08 */
    };

    if (code >= 0x01 && code <= 0x08)
	return type[code - 0x01];
    return out_of_spec;
}