7 /* These things must be defined in arch part in
8 the most efficent way according to the architecture.
13 USER_NO = xxx, ///< User No access
14 USER_RO = xxx, ///< User Read only
15 USER_RW = xxx, ///< User Read/Write
16 USER_RX = xxx, ///< User Read/Execute
17 USER_XO = xxx, ///< User Execute only
18 USER_RWX = xxx, ///< User Read/Write/Execute
20 NONCACHEABLE = xxx, ///< Caching is off
21 CACHEABLE = xxx, ///< Cahe is enabled
32 static Mword is_translation_error( Mword error );
33 static Mword is_usermode_error( Mword error );
34 static Mword is_read_error( Mword error );
35 static Mword addr_to_msgword0( Address pfa, Mword error );
36 static Mword pc_to_msgword1( Address pc, Mword error );
44 void *alloc(unsigned long) const { return 0; }
45 void free(void *, unsigned long) const {}
46 bool valid() const { return false; }
49 template<typename ALLOC>
50 class Pdir_alloc_simple
53 Pdir_alloc_simple(ALLOC *a = 0) : _a(a) {}
55 void *alloc(unsigned long size) const
56 { return _a->unaligned_alloc(size); }
58 void free(void *block, unsigned long size) const
59 { return _a->unaligned_free(size, block); }
61 bool valid() const { return _a; }
68 class Pdir : public Ptab::Base<Pte_base, Ptab_traits_vpn, Ptab_va_vpn >
71 enum { Super_level = Pte_base::Super_level };
74 static bool _have_superpages;
75 static unsigned _super_level;
79 //---------------------------------------------------------------------------
81 bool Pdir::_have_superpages;
82 unsigned Pdir::_super_level;
84 template<typename ALLOC>
85 inline Pdir_alloc_simple<ALLOC> pdir_alloc(ALLOC *a)
86 { return Pdir_alloc_simple<ALLOC>(a); }
90 Pdir::have_superpages(bool yes)
92 _have_superpages = yes;
93 _super_level = yes ? Super_level : (Super_level + 1);
99 { return _super_level; }
102 IMPLEMENT inline NEEDS[PF::is_usermode_error]
103 Mword PF::pc_to_msgword1(Address pc, Mword error)
105 return is_usermode_error(error) ? pc : (Mword)-1;
108 //---------------------------------------------------------------------------
109 IMPLEMENTATION[!ppc32]:
113 Pdir::virt_to_phys(Address virt) const
115 Iter i = walk(Virt_addr(virt));
119 return i.e->addr() | (virt & ~(~0UL << i.shift()));
122 //---------------------------------------------------------------------------
123 IMPLEMENTATION[ppc32]:
127 Pdir::virt_to_phys(Address virt) const
129 Iter i = walk(Virt_addr(virt));
135 Pte_htab::pte_lookup(i.e, &phys);
136 return phys | (virt & ~(~0UL << i.shift()));