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
/***********************************************************************************************************************
 * Copyright (c) 2020 by the authors
 *
 * Author: André Borrmann <pspwizard@gmx.de>
 * License: Apache License 2.0 / MIT
 **********************************************************************************************************************/

//! # TCR_EL1 - Translation Control Register EL1
//!
//! Determines which Translation Base Registers defines the base address register for a translation
//! table walk required for stage 1 translation of a memory access from EL0 or EL1 and holds
//! cacheability and shareability information.
//!
//! ## Usage Constraints
//! EL0 | EL1 (NS) | EL1(S) | EL2 | EL3(NS) | EL3(S)
//! ----|----------|--------|-----|---------|-------
//!  -  | R/W      | R/W    | R/W | R/W     | R/W
//!

use crate::register::*;
use crate::{define_aarch64_register, impl_system_register_rw};

define_aarch64_register! {
    @tcr_el1<u32> {
        /// Size offset of the memory reagion addressed by ttbr0_el1 (size = 2^(64-t0sz))
        T0SZ    OFFSET(0) BITS(6),
        /// Disable tlb walks using ttbr0_el1
        EPD0    OFFSET(7) [
            ENABLE =     0b0,
            DISABLE =    0b1
        ],
        /// Inner cacheability attribute for memory associated with tlb walks using ttbr0_el1
        IRGN0   OFFSET(8) BITS(2) [
            /// normal memory, inner non-cacheable
            NM_INC =         0b00,
            /// normal memory, inner write-back, read-allocate, write-allocate, cacheable
            NM_IWB_RA_WA =   0b01,
            /// normal memory, inner write-through, read-allocate, no write-allocate, cacheable
            NM_IWT_RA_NWA =  0b10,
            /// normal memory, inner write-back, read-allocate, no write-allocate, caheable
            NM_IWB_RA_NWA =  0b11
        ],
        /// Outer cacheability attribute for memory associated with tlb walks using ttbr0_el1
        ORGN0   OFFSET(10) BITS(2) [
            /// normal memory, outer non-cacheable
            NM_ONC =         0b00,
            /// normal memory, outer write-back, read-allocate, write-allocate, cacheable
            NM_OWB_RA_WA =   0b01,
            /// normal memory, outer write-through, read-allocate, no write-allocate, cacheable
            NM_OWT_RA_NWA =  0b10,
            /// normal memory, outer write-back, read-allocate, no write-allocate, caheable
            NM_OWB_RA_NWA =  0b11
        ],
        /// Shareability attribute for memory associated with tlb walks using ttbr0_el1
        SH0     OFFSET(12) BITS(2) [
            /// non shareable
            NS =     0b00,
            /// outer shareable
            OS =     0b10,
            /// inner shareable
            IS =     0b11
        ],
        /// Granule size for the ttbr0_el2
        TG0     OFFSET(14) BITS(2) [
            _4KB =   0b00,
            _64KB =  0b10
        ],
        /// Size offset of the memory reagion addressed by ttbr1_el1 (size = 2^(64-t0sz))
        T1SZ    OFFSET(16) BITS(5),
        /// ASID definition by TTBR0_EL1 or TTBR1_EL1
        A1      OFFSET(22) [
            TTBR0 =  0b0,
            TTBR1 =  0b1
        ],
        /// disable tlb walks using ttbr1_el1
        EPD1    OFFSET(23) [
            ENABLE =     0b0,
            DISABLE =    0b1
        ],
        /// Inner cacheability attribute for memory associated with tlb walks using ttbr1_el1
        IRGN1   OFFSET(24) BITS(2) [
            /// normal memory, inner non-cacheable
            NM_INC =         0b00,
            /// normal memory, inner write-back, read-allocate, write-allocate, cacheable
            NM_IWB_RA_WA =   0b01,
            /// normal memory, inner write-through, read-allocate, no write-allocate, cacheable
            NM_IWT_RA_NWA =  0b10,
            /// normal memory, inner write-back, read-allocate, no write-allocate, caheable
            NM_IWB_RA_NWA =  0b11
        ],
        /// Outer cacheability attribute for memory associated with tlb walks using ttbr1_el1
        ORGN1   OFFSET(26) BITS(2) [
            /// normal memory, outer non-cacheable
            NM_ONC =         0b00,
            /// normal memory, outer write-back, read-allocate, write-allocate, cacheable
            NM_OWB_RA_WA =   0b01,
            /// normal memory, outer write-through, read-allocate, no write-allocate, cacheable
            NM_OWT_RA_NWA =  0b10,
            /// normal memory, outer write-back, read-allocate, no write-allocate, caheable
            NM_OWB_RA_NWA =  0b11
        ],
        /// Shareability attribute for memory associated with tlb walks using ttbr1_el1
        SH1     OFFSET(28) BITS(2) [
            /// non shareable
            NS =     0b00,
            /// outer shareable
            OS =     0b10,
            /// inner shareable
            IS =     0b11
        ],
        /// Granule size for the ttbr0_el2
        TG1     OFFSET(30) BITS(2) [
            _4KB =   0b00,
            _64KB =  0b10
        ],
        /// Intermediate Physical address size
        IPS      OFFSET(32) BITS(3) [
            /// 4GB address size
            _32BITS =    0b000,
            /// 64GB address size
            _36BITS =    0b001,
            /// 1TB address size
            _40BITS =    0b010
        ],
        /// ASID size
        AS      OFFSET(36) [
            _8BITS =     0b0,
            _16BITS =    0b1
        ],
        /// Top Byte Ignored for ttbr0_el1
        TBI0    OFFSET(27) [
            /// Typ byte is used for address calculation
            USE =        0b0,
            /// Top byte is ignored for address calculation
            IGNORE =     0b1
        ],
        /// Top Byte Ignored for ttbr1_el1
        TBI1    OFFSET(27) [
            /// Typ byte is used for address calculation
            USE =        0b0,
            /// Top byte is ignored for address calculation
            IGNORE =     0b1
        ]
    }
}