]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/arm/paging-arm.cpp
update
[l4.git] / kernel / fiasco / src / kern / arm / paging-arm.cpp
1 INTERFACE [arm]:
2
3
4 class PF {};
5
6 //-----------------------------------------------------------------------------
7 INTERFACE [arm && armv5]:
8
9 #include "types.h"
10
11
12 namespace Page
13 {
14   typedef Unsigned32 Attribs;
15
16   enum Attribs_enum
17   {
18     KERN_RW  = 0x0400, ///< User No access
19     USER_RO  = 0x0000, ///< User Read only
20     USER_RW  = 0x0c00, ///< User Read/Write
21
22     USER_BIT = 0x00800,
23
24     Cache_mask    = 0x0c,
25     NONCACHEABLE  = 0x00, ///< Caching is off
26     CACHEABLE     = 0x0c, ///< Cache is enabled
27
28     // The next are ARM specific
29     WRITETHROUGH = 0x08, ///< Write through cached
30     BUFFERED     = 0x04, ///< Write buffer enabled
31
32     MAX_ATTRIBS  = 0x0dec,
33     Local_page   = 0,
34   };
35 };
36
37
38
39
40
41 //----------------------------------------------------------------------------
42 INTERFACE [arm && (armv6 || armv7)]:
43
44 #include "types.h"
45
46 namespace Page
47 {
48   typedef Unsigned32 Attribs;
49
50   enum Attribs_enum
51   {
52     KERN_RO  = 0x0210,
53     KERN_RW  = 0x0010, ///< User No access
54     USER_RO  = 0x0230, ///< User Read only
55     USER_RW  = 0x0030, ///< User Read/Write
56
57     USER_BIT = 0x0020,
58
59     Cache_mask    = 0x1cc,
60     NONCACHEABLE  = 0x000, ///< Caching is off
61     CACHEABLE     = 0x144, ///< Cache is enabled
62
63     // The next are ARM specific
64     WRITETHROUGH = 0x08, ///< Write through cached
65     BUFFERED     = 0x40, ///< Write buffer enabled -- Normal, non-cached
66
67     MAX_ATTRIBS  = 0x0ffc,
68     Local_page   = 0x800,
69   };
70 };
71
72
73 //-----------------------------------------------------------------------------
74 INTERFACE [arm]:
75
76 #include "ptab_base.h"
77
78
79 // dummy for JDB
80 class Pte_base
81 {
82 public:
83   enum
84   {
85     Super_level    = 0,
86     Valid          = 0x3,
87     Type_mask      = 0x3,
88     Type_1MB       = 0x2,
89     Type_4KB       = 0x2,
90     Type_coarse_pt = 0x1,
91   };
92   typedef Mword Raw;
93   Raw raw() const  { return _raw; }
94   Address addr() const { return _raw & (~0UL << 12); }
95
96 protected:
97   Raw _raw;
98 };
99
100 class Pd_entry : public Pte_base
101 {
102 public:
103   enum { Page_shift = Config::SUPERPAGE_SHIFT };
104   Mword leaf() const { return (_raw & Type_mask) == Type_1MB; }
105   void set(Address p, bool intermed, bool present, unsigned long attrs = 0)
106   {
107     _raw = (p & (~0UL << Page_shift))
108       | (present ? (intermed ? Type_coarse_pt : Type_1MB) : 0) | attrs;
109   }
110 };
111
112 class Pt_entry : public Pte_base
113 {
114 public:
115   enum { Page_shift = Config::PAGE_SHIFT };
116   Mword leaf() const { return true; }
117   void set(Address p, bool, bool present, unsigned long attrs = 0)
118   {
119     _raw = (p & (~0UL << Page_shift)) | (present ? Type_4KB : 0) | attrs;
120   }
121 };
122
123 typedef Ptab::List< Ptab::Traits< Pd_entry, 20, 12, true>,
124                     Ptab::Traits< Pt_entry, 12, 8, true> > Ptab_traits;
125
126 typedef Ptab_traits Ptab_traits_vpn;
127 typedef Ptab::Page_addr_wrap<Virt_addr, 0> Ptab_va_vpn;
128
129 //---------------------------------------------------------------------------
130 IMPLEMENTATION [arm && armv5]:
131
132 PUBLIC static inline
133 Mword PF::is_alignment_error(Mword error)
134 { return (error & 0xf0000d) == 0x400001; }
135
136 //---------------------------------------------------------------------------
137 IMPLEMENTATION [arm && (armv6 || armv7)]:
138
139 PUBLIC static inline
140 Mword PF::is_alignment_error(Mword error)
141 { return (error & 0xf0040f) == 0x400001; }
142
143 //---------------------------------------------------------------------------
144 IMPLEMENTATION [arm]:
145
146 PUBLIC inline
147 void
148 Pte_base::clear()
149 { _raw = 0; }
150
151 PUBLIC inline
152 int
153 Pte_base::valid() const
154 {
155   return _raw & Valid;
156 }
157
158 IMPLEMENT inline
159 Mword PF::is_translation_error( Mword error )
160 {
161   return (error & 0x0d/*FSR_STATUS_MASK*/) == 0x05/*FSR_TRANSL*/;
162 }
163
164 IMPLEMENT inline
165 Mword PF::is_usermode_error( Mword error )
166 {
167   return (error & 0x00010000/*PF_USERMODE*/);
168 }
169
170 IMPLEMENT inline
171 Mword PF::is_read_error( Mword error )
172 {
173   return !(error & (1UL << 11));
174 }
175
176 IMPLEMENT inline
177 Mword PF::addr_to_msgword0( Address pfa, Mword error )
178 {
179   Mword a = pfa & ~3;
180   if(is_translation_error( error ))
181     a |= 1;
182   if(!is_read_error(error))
183     a |= 2;
184   return a;
185 }
186