blob: b7cc0464baa7a0bb7bc55e581e7c76426fca8e68 [file] [log] [blame]
Artem Alekseev653d5812019-07-02 17:52:25 +03001// Copyright 2017 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef CPU_FEATURES_INCLUDE_CPUINFO_COMMON_H_
16#define CPU_FEATURES_INCLUDE_CPUINFO_COMMON_H_
17
18#include "cpu_features_macros.h"
19
20CPU_FEATURES_START_CPP_NAMESPACE
21
22typedef enum {
23 CPU_FEATURE_CACHE_NULL = 0,
24 CPU_FEATURE_CACHE_DATA = 1,
25 CPU_FEATURE_CACHE_INSTRUCTION = 2,
26 CPU_FEATURE_CACHE_UNIFIED = 3,
27 CPU_FEATURE_CACHE_TLB = 4,
28 CPU_FEATURE_CACHE_DTLB = 5,
29 CPU_FEATURE_CACHE_STLB = 6,
30 CPU_FEATURE_CACHE_PREFETCH = 7
31} CacheType;
32
33typedef struct {
34 int level;
35 CacheType cache_type;
36 int cache_size; // Cache size in bytes
37 int ways; // Associativity, 0 undefined, 0xFF fully associative
38 int line_size; // Cache line size in bytes
39 int tlb_entries; // number of entries for TLB
40 int partitioning; // number of lines per sector
41} CacheLevelInfo;
42
43// Increase this value if more cache levels are needed.
44#ifndef CPU_FEATURES_MAX_CACHE_LEVEL
45#define CPU_FEATURES_MAX_CACHE_LEVEL 10
46#endif
47typedef struct {
48 int size;
49 CacheLevelInfo levels[CPU_FEATURES_MAX_CACHE_LEVEL];
50} CacheInfo;
51
52CPU_FEATURES_END_CPP_NAMESPACE
53
54#endif // CPU_FEATURES_INCLUDE_CPUINFO_COMMON_H_