1 #ifndef __ARM_SHORT_DESC_H__
2 #define __ARM_SHORT_DESC_H__
3 
4 /*
5  * First level translation table descriptor types used by the AArch32
6  * short-descriptor translation table format.
7  */
8 #define L1DESC_INVALID                      (0)
9 #define L1DESC_PAGE_TABLE                   (1)
10 #define L1DESC_SECTION                      (2)
11 #define L1DESC_SECTION_PXN                  (3)
12 
13 /* Defines for section and supersection shifts. */
14 #define L1DESC_SECTION_SHIFT                (20)
15 #define L1DESC_SUPERSECTION_SHIFT           (24)
16 #define L1DESC_SUPERSECTION_EXT_BASE1_SHIFT (32)
17 #define L1DESC_SUPERSECTION_EXT_BASE2_SHIFT (36)
18 
19 /* Second level translation table descriptor types. */
20 #define L2DESC_INVALID                      (0)
21 
22 /* Defines for small (4K) and large page (64K) shifts. */
23 #define L2DESC_SMALL_PAGE_SHIFT             (12)
24 #define L2DESC_LARGE_PAGE_SHIFT             (16)
25 
26 /*
27  * Comprises bits of the level 1 short-descriptor format representing
28  * a section.
29  */
30 typedef struct __packed {
31     bool pxn:1;                 /* Privileged Execute Never */
32     bool sec:1;                 /* == 1 if section or supersection */
33     bool b:1;                   /* Bufferable */
34     bool c:1;                   /* Cacheable */
35     bool xn:1;                  /* Execute Never */
36     unsigned int dom:4;         /* Domain field */
37     bool impl:1;                /* Implementation defined */
38     unsigned int ap:2;          /* AP[1:0] */
39     unsigned int tex:3;         /* TEX[2:0] */
40     bool ro:1;                  /* AP[2] */
41     bool s:1;                   /* Shareable */
42     bool ng:1;                  /* Non-global */
43     bool supersec:1;            /* Must be 0 for sections */
44     bool ns:1;                  /* Non-secure */
45     unsigned int base:12;       /* Section base address */
46 } short_desc_l1_sec_t;
47 
48 /*
49  * Comprises bits of the level 1 short-descriptor format representing
50  * a supersection.
51  */
52 typedef struct __packed {
53     bool pxn:1;                 /* Privileged Execute Never */
54     bool sec:1;                 /* == 1 if section or supersection */
55     bool b:1;                   /* Bufferable */
56     bool c:1;                   /* Cacheable */
57     bool xn:1;                  /* Execute Never */
58     unsigned int extbase2:4;    /* Extended base address, PA[39:36] */
59     bool impl:1;                /* Implementation defined */
60     unsigned int ap:2;          /* AP[1:0] */
61     unsigned int tex:3;         /* TEX[2:0] */
62     bool ro:1;                  /* AP[2] */
63     bool s:1;                   /* Shareable */
64     bool ng:1;                  /* Non-global */
65     bool supersec:1;            /* Must be 0 for sections */
66     bool ns:1;                  /* Non-secure */
67     unsigned int extbase1:4;    /* Extended base address, PA[35:32] */
68     unsigned int base:8;        /* Supersection base address */
69 } short_desc_l1_supersec_t;
70 
71 /*
72  * Comprises bits of the level 2 short-descriptor format representing
73  * a small page.
74  */
75 typedef struct __packed {
76     bool xn:1;                  /* Execute Never */
77     bool page:1;                /* ==1 if small page */
78     bool b:1;                   /* Bufferable */
79     bool c:1;                   /* Cacheable */
80     unsigned int ap:2;          /* AP[1:0] */
81     unsigned int tex:3;         /* TEX[2:0] */
82     bool ro:1;                  /* AP[2] */
83     bool s:1;                   /* Shareable */
84     bool ng:1;                  /* Non-global */
85     unsigned int base:20;       /* Small page base address */
86 } short_desc_l2_page_t;
87 
88 /*
89  * Comprises bits of the level 2 short-descriptor format representing
90  * a large page.
91  */
92 typedef struct __packed {
93     bool lpage:1;               /* ==1 if large page */
94     bool page:1;                /* ==0 if large page */
95     bool b:1;                   /* Bufferable */
96     bool c:1;                   /* Cacheable */
97     unsigned int ap:2;          /* AP[1:0] */
98     unsigned int sbz:3;         /* Should be zero */
99     bool ro:1;                  /* AP[2] */
100     bool s:1;                   /* Shareable */
101     bool ng:1;                  /* Non-global */
102     unsigned int tex:3;         /* TEX[2:0] */
103     bool xn:1;                  /* Execute Never */
104     unsigned int base:16;       /* Large page base address */
105 } short_desc_l2_lpage_t;
106 
107 /*
108  * Comprises the bits required to walk page tables adhering to the
109  * short-descriptor translation table format.
110  */
111 typedef struct __packed {
112     unsigned int dt:2;          /* Descriptor type */
113     unsigned int pad1:8;
114     unsigned int base:22;       /* Base address of block or next table */
115 } short_desc_walk_t;
116 
117 /*
118  * Represents page table entries adhering to the short-descriptor translation
119  * table format.
120  */
121 typedef union {
122     uint32_t bits;
123     short_desc_walk_t walk;
124     short_desc_l1_sec_t sec;
125     short_desc_l1_supersec_t supersec;
126     short_desc_l2_page_t pg;
127     short_desc_l2_lpage_t lpg;
128 } short_desc_t;
129 
130 #endif /* __ARM_SHORT_DESC_H__ */
131