summaryrefslogtreecommitdiff
path: root/ArmPkg/Library/ArmLib/Arm9/Arm9CacheInformation.c
blob: a8207b905f82ff6e8a687997c2db128edc5c93f1 (plain)
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/** @file

  Copyright (c) 2008-2009, Apple Inc. All rights reserved.
  
  All rights reserved. This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#include <Library/ArmLib.h>
#include "ArmLibPrivate.h"

ARM_CACHE_TYPE
EFIAPI
ArmCacheType (
  VOID
  )
{
  switch (CACHE_TYPE(Cp15CacheInfo()))
  {
    case CACHE_TYPE_WRITE_BACK: return ARM_CACHE_TYPE_WRITE_BACK;
    default:                    return ARM_CACHE_TYPE_UNKNOWN;
  }
}

ARM_CACHE_ARCHITECTURE
EFIAPI
ArmCacheArchitecture (
  VOID
  )
{
  switch (CACHE_ARCHITECTURE(Cp15CacheInfo()))
  {
    case CACHE_ARCHITECTURE_UNIFIED:  return ARM_CACHE_ARCHITECTURE_UNIFIED;
    case CACHE_ARCHITECTURE_SEPARATE: return ARM_CACHE_ARCHITECTURE_SEPARATE;
    default:                          return ARM_CACHE_ARCHITECTURE_UNKNOWN;
  }
}

BOOLEAN
EFIAPI
ArmDataCachePresent (
  VOID
  )
{
  switch (DATA_CACHE_PRESENT(Cp15CacheInfo()))
  {
    case CACHE_PRESENT:     return TRUE;
    case CACHE_NOT_PRESENT: return FALSE;
    default:                return FALSE;
  }
}
  
UINTN
EFIAPI
ArmDataCacheSize (
  VOID
  )
{
  switch (DATA_CACHE_SIZE(Cp15CacheInfo()))
  {
    case CACHE_SIZE_4_KB:   return   4 * 1024;      
    case CACHE_SIZE_8_KB:   return   8 * 1024;
    case CACHE_SIZE_16_KB:  return  16 * 1024;      
    case CACHE_SIZE_32_KB:  return  32 * 1024;
    case CACHE_SIZE_64_KB:  return  64 * 1024;
    case CACHE_SIZE_128_KB: return 128 * 1024;
    default:                return   0;
  }
}
  
UINTN
EFIAPI
ArmDataCacheAssociativity (
  VOID
  )
{
  switch (DATA_CACHE_ASSOCIATIVITY(Cp15CacheInfo()))
  {
    case CACHE_ASSOCIATIVITY_4_WAY:   return 4;
    case CACHE_ASSOCIATIVITY_DIRECT:  return 1;
    default:                          return 0;
  }
}
  
UINTN
EFIAPI
ArmDataCacheLineLength (
  VOID
  )
{
  switch (DATA_CACHE_LINE_LENGTH(Cp15CacheInfo()))
  {
    case CACHE_LINE_LENGTH_32_BYTES: return 32;
    default:                         return  0;
  }
}
  
BOOLEAN
EFIAPI
ArmInstructionCachePresent (
  VOID
  )
{
  switch (INSTRUCTION_CACHE_PRESENT(Cp15CacheInfo()))
  {
    case CACHE_PRESENT:     return TRUE;
    case CACHE_NOT_PRESENT: return FALSE;
    default:                return FALSE;
  }
}
  
UINTN
EFIAPI
ArmInstructionCacheSize (
  VOID
  )
{
  switch (INSTRUCTION_CACHE_SIZE(Cp15CacheInfo()))
  {
    case CACHE_SIZE_4_KB:   return   4 * 1024;      
    case CACHE_SIZE_8_KB:   return   8 * 1024;
    case CACHE_SIZE_16_KB:  return  16 * 1024;      
    case CACHE_SIZE_32_KB:  return  32 * 1024;
    case CACHE_SIZE_64_KB:  return  64 * 1024;
    case CACHE_SIZE_128_KB: return 128 * 1024;
    default:                return   0;
  }
}
  
UINTN
EFIAPI
ArmInstructionCacheAssociativity (
  VOID
  )
{
  switch (INSTRUCTION_CACHE_ASSOCIATIVITY(Cp15CacheInfo()))
  {
    case CACHE_ASSOCIATIVITY_8_WAY:   return 8;
    case CACHE_ASSOCIATIVITY_4_WAY:   return 4;
    case CACHE_ASSOCIATIVITY_DIRECT:  return 1;
    default:                          return 0;
  }
}
  
UINTN
EFIAPI
ArmInstructionCacheLineLength (
  VOID
  )
{
  switch (INSTRUCTION_CACHE_LINE_LENGTH(Cp15CacheInfo()))
  {
    case CACHE_LINE_LENGTH_32_BYTES: return 32;
    default:                         return  0;
  }
}