|
| 1 | +// SPDX-License-Identifier: Apache-2.0 OR MIT |
| 2 | +// |
| 3 | +// Copyright (c) 2018-2022 by the author(s) |
| 4 | +// |
| 5 | +// Author(s): |
| 6 | +// - Valentin B. <valentin.be@protonmail.com> |
| 7 | + |
| 8 | +//! Current Cache Size ID Register - EL1 |
| 9 | +//! |
| 10 | +//! Provides information about the architecture of the currently selected cache. |
| 11 | +
|
| 12 | +use tock_registers::{ |
| 13 | + interfaces::{Readable, Writeable}, |
| 14 | + register_bitfields, |
| 15 | +}; |
| 16 | + |
| 17 | +register_bitfields! {u64, |
| 18 | + /// The representation of `CCSIDR_EL1` when `FEAT_CCIDX` is implemented. |
| 19 | + pub CCSIDR_EL1_WITH_FEAT_CCIDX [ |
| 20 | + /// Number of sets in cache. |
| 21 | + /// |
| 22 | + /// A value of 0 indicates 1 set in the cache. The number does not |
| 23 | + /// necessarily have to be a power of 2. |
| 24 | + NumSets OFFSET(32) NUMBITS(24) [], |
| 25 | + |
| 26 | + /// Associativity of cache. |
| 27 | + /// |
| 28 | + /// A value of 0 indicates an associativity of 1. The value does not |
| 29 | + /// necessarily have to be a power of 2. |
| 30 | + Associativity OFFSET(3) NUMBITS(21) [], |
| 31 | + |
| 32 | + /// Log2(Number of bytes in cache lline) - 4. |
| 33 | + /// |
| 34 | + /// **Examples:** |
| 35 | + /// |
| 36 | + /// - For a line length of 16 bytes: Log2(16) - 4 = 0. This is the minimum line length. |
| 37 | + /// |
| 38 | + /// - For a line length of 32 bytes: Log2(32) - 4 = 1. |
| 39 | + LineSize OFFSET(0) NUMBITS(3) [] |
| 40 | + ], |
| 41 | + |
| 42 | + /// The representation of `CCSIDR_EL1` otherwise. |
| 43 | + pub CCSIDR_EL1 [ |
| 44 | + /// Number of sets in cache. |
| 45 | + /// |
| 46 | + /// A value of 0 indicates 1 set in the cache. The number does not |
| 47 | + /// necessarily have to be a power of 2. |
| 48 | + NumSets OFFSET(13) NUMBITS(15) [], |
| 49 | + |
| 50 | + /// Associativity of cache. |
| 51 | + /// |
| 52 | + /// A value of 0 indicates an associativity of 1. The value does not |
| 53 | + /// necessarily have to be a power of 2. |
| 54 | + Associativity OFFSET(3) NUMBITS(10) [], |
| 55 | + |
| 56 | + /// Log2(Number of bytes in cache lline) - 4. |
| 57 | + /// |
| 58 | + /// **Examples:** |
| 59 | + /// |
| 60 | + /// - For a line length of 16 bytes: Log2(16) - 4 = 0. This is the minimum line length. |
| 61 | + /// |
| 62 | + /// - For a line length of 32 bytes: Log2(32) - 4 = 1. |
| 63 | + LineSize OFFSET(0) NUMBITS(3) [] |
| 64 | + ] |
| 65 | +} |
| 66 | + |
| 67 | +pub struct RegWithFeatCcidx; |
| 68 | +pub struct Reg; |
| 69 | + |
| 70 | +impl Readable for RegWithFeatCcidx { |
| 71 | + type T = u64; |
| 72 | + type R = CCSIDR_EL1_WITH_FEAT_CCIDX::Register; |
| 73 | + |
| 74 | + sys_coproc_read_raw!(u64, "CCSIDR_EL1", "x"); |
| 75 | +} |
| 76 | + |
| 77 | +impl Writeable for RegWithFeatCcidx { |
| 78 | + type T = u64; |
| 79 | + type R = CCSIDR_EL1_WITH_FEAT_CCIDX::Register; |
| 80 | + |
| 81 | + sys_coproc_write_raw!(u64, "CCSIDR_EL1", "x"); |
| 82 | +} |
| 83 | + |
| 84 | +impl Readable for Reg { |
| 85 | + type T = u64; |
| 86 | + type R = CCSIDR_EL1::Register; |
| 87 | + |
| 88 | + sys_coproc_read_raw!(u64, "CCSIDR_EL1", "x"); |
| 89 | +} |
| 90 | + |
| 91 | +impl Writeable for Reg { |
| 92 | + type T = u64; |
| 93 | + type R = CCSIDR_EL1::Register; |
| 94 | + |
| 95 | + sys_coproc_write_raw!(u64, "CCSIDR_EL1", "x"); |
| 96 | +} |
| 97 | + |
| 98 | +pub const CCSIDR_EL1_WITH_FEAT_CCIDX: RegWithFeatCcidx = RegWithFeatCcidx; |
| 99 | +pub const CCSIDR_EL1: Reg = Reg; |
0 commit comments