cacheattr
Information about the on-chip and off-chip cache system configuration
In addition to storing information about the configuration of the on-chip and off-chip cache system, the cacheattr area contains the control() kernel callout used for cache control operations.
- init_cpuinfo(), which looks after caches implemented on the CPU itself
- init_cacheattr(), which looks after board-level caches
- next
- Index to next lower level entry
- line_size
- Size of cache line, in bytes
- num_lines
- Number of cache lines
- flags
- Cache capabilities; see
flags
below. - ways
- Number of cache lines in a cache set. This is useful for implementations of the cache control callout that applies to all cache levels that perform operations based on sets and ways rather than directly with addresses. It may also be informative to user code, so this field should be populated regardless of the needs of the cache control callout.
- control
- Kernel callout supplied by the startup code
(see
Cache control
in the Kernel Callouts chapter)
The total number of bytes described by a particular cacheattr entry is defined by line_size × num_lines.
flags
This constant: | Means that the cache: |
---|---|
CACHE_FLAG_INSTR | Holds instructions |
CACHE_FLAG_DATA | Holds data |
CACHE_FLAG_UNIFIED | Holds both instructions and data |
CACHE_FLAG_SHARED | Is shared between multiple processors in an SMP system |
CACHE_FLAG_SNOOPED | Implements a bus-snooping protocol |
CACHE_FLAG_VIRT_TAG | Is virtually tagged |
CACHE_FLAG_VIRTUAL | Contains virtual addresses |
CACHE_FLAG_WRITEBACK | Does write-back, not write-through |
CACHE_FLAG_CTRL_PHYS | Takes physical addresses via its control() function |
CACHE_FLAG_SUBSET | Obeys the subset property. This means that if something is in a given
cache level, it will also be in all lower-level caches.
This impacts cache flushing operations because a subsettedlevel can be effectively ignored by the control() function, which knows that the operation will be performed on the lower-level caches. |
CACHE_FLAG_NONCOHERENT | Is noncoherent on SMP |
CACHE_FLAG_NONISA | Doesn't obey ISA cache instructions |
CACHE_FLAG_NOBROADCAST | Has operations that aren't broadcast on the bus for SMP |
CACHE_FLAG_VIRT_IDX | Is virtually indexed |
CACHE_FLAG_CTRL_PHYS64 | Control function takes 64-bit paddr
(see Cache controland Patcher routines) |
Organization of cacheattr entries
The cacheattr entries are organized in a linked list, with the next member indicating the index of the next lower cache entry. Some architectures have separate instruction and data caches at one level but a unified cache at another level. This linking of entries allows the system page to efficiently contain information for different cache levels.
The cpuinfo area's ins_cache and data_cache members provide index pointers to cacheattr tables that store details about the instruction cache and data cache.
/* CPUINFO */
cpuinfo [0].ins_cache = 0;
cpuinfo [0].data_cache = 1;
cpuinfo [1].ins_cache = 0;
cpuinfo [1].data_cache = 1;
/* CACHEATTR */
cacheattr [0].next = 2;
cacheattr [0].linesize = linesize;
cacheattr [0].numlines = numlines;
cacheattr [0].flags = CACHE_FLAG_INSTR;
cacheattr [1].next = 2;
cacheattr [1].linesize = linesize;
cacheattr [1].numlines = numlines;
cacheattr [1].flags = CACHE_FLAG_DATA;
cacheattr [2].next = CACHE_LIST_END;
cacheattr [2].linesize = linesize;
cacheattr [2].numlines = numlines;
cacheattr [2].flags = CACHE_FLAG_UNIFIED;