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
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Copyright (c) 2018-2022 by the author(s)
//
// Author(s):
//   - Valentin B. <valentin.be@protonmail.com>

//! Cache Size Selection Register - EL1
//!
//! Selects the current Cache Size ID Register, CCSIDR_EL1, by specifying the
//! required cache level and the cache type (either instruction or data cache).

use tock_registers::{
    interfaces::{Readable, Writeable},
    register_bitfields,
};

register_bitfields! {u64,
    pub CSSELR_EL1 [
        /// ** When `FEAT_MTE2` is implemented:**
        ///
        /// Allocation Tag not Data bit.
        ///
        /// When [`CSSELR_EL1::InD`] is set, this bit is considered reserved.
        ///
        /// When [`CSSELR_EL1::Level`] is programmed to a cache level that is
        /// not implemented, this field's value will be undefined for reads.
        ///
        /// NOTE: On a Warm reset, this field resets to an architecturally
        /// undefined value.
        ///
        /// **Otherwise:**
        ///
        /// Reserved.
        TnD OFFSET(4) NUMBITS(1) [
            /// Data, Instruction or Unified cache.
            Data = 0b0,
            /// Separate Allocation Tag cache.
            AllocationTag = 0b1
        ],

        /// Cache level of required cache.
        ///
        /// Any value other than the pre-defined ones are considered reserved
        /// and shall not be written to this field.
        ///
        /// When [`CSSELR_EL1::Level`] is programmed to a cache level that is
        /// not implemented, this field's value will be undefined for reads.
        ///
        /// NOTE: On a Warm reset, this field resets to an architecturally
        /// undefined value.
        Level OFFSET(1) NUMBITS(3) [
            /// Level 1 Cache.
            L1 = 0b000,
            /// Level 2 Cache.
            L2 = 0b001,
            /// Level 3 Cache.
            L3 = 0b010,
            /// Level 4 Cache.
            L4 = 0b011,
            /// Level 5 Cache.
            L5 = 0b100,
            /// Level 6 Cache.
            L6 = 0b101,
            /// Level 7 Cache.
            L7 = 0b110
        ],

        /// Instruction not Data bit.
        ///
        /// When [`CSSELR_EL1::Level`] is programmed to a cache level that is
        /// not implemented, this field's value will be undefined for reads.
        ///
        /// NOTE: On a Warm reset, this field resets to an architecturally
        /// undefined value.
        InD OFFSET(0) NUMBITS(1) [
            /// Data or Unified cache.
            Data = 0b0,
            /// Instruction cache.
            Instruction = 0b1
        ]
    ]
}

pub struct Reg;

impl Readable for Reg {
    type T = u64;
    type R = CSSELR_EL1::Register;

    sys_coproc_read_raw!(u64, "CSSELR_EL1", "x");
}

impl Writeable for Reg {
    type T = u64;
    type R = CSSELR_EL1::Register;

    sys_coproc_write_raw!(u64, "CSSELR_EL1", "x");
}

pub const CSSELR_EL1: Reg = Reg;