4 #include "l4_msg_item.h"
10 /* These things must be defined in arch part in
11 the most efficent way according to the architecture.
16 USER_NO = xxx, ///< User No access
17 USER_RO = xxx, ///< User Read only
18 USER_RW = xxx, ///< User Read/Write
19 USER_RX = xxx, ///< User Read/Execute
20 USER_XO = xxx, ///< User Execute only
21 USER_RWX = xxx, ///< User Read/Write/Execute
23 NONCACHEABLE = xxx, ///< Caching is off
24 CACHEABLE = xxx, ///< Cahe is enabled
28 typedef L4_msg_item::Memory_type Type;
31 : cxx::int_type_base<unsigned char, Kern>,
32 cxx::int_bit_ops<Kern>,
33 cxx::int_null_chk<Kern>
36 explicit Kern(Value v) : cxx::int_type_base<unsigned char, Kern>(v) {}
38 static Kern Global() { return Kern(1); }
41 typedef L4_fpage::Rights Rights;
50 explicit Attr(Rights r, Type t = Type::Normal(), Kern k = Kern(0))
51 : rights(r), type(t), kern(k) {}
53 Attr apply(Attr o) const
57 if ((o.type & Type::Set()) == Type::Set())
58 n.type = o.type & ~Type::Set();
66 static Mword is_translation_error( Mword error );
67 static Mword is_usermode_error( Mword error );
68 static Mword is_read_error( Mword error );
69 static Mword addr_to_msgword0( Address pfa, Mword error );
70 static Mword pc_to_msgword1( Address pc, Mword error );
78 void *alloc(unsigned long) const { return 0; }
79 void free(void *, unsigned long) const {}
80 bool valid() const { return false; }
83 template<typename ALLOC>
84 class Pdir_alloc_simple
87 Pdir_alloc_simple(ALLOC *a = 0) : _a(a) {}
89 void *alloc(unsigned long size) const
90 { return _a->unaligned_alloc(size); }
92 void free(void *block, unsigned long size) const
93 { return _a->unaligned_free(size, block); }
95 bool valid() const { return _a; }
98 to_phys(void *v) const { return _a->to_phys(v); }
106 : public Ptab::Base<Pte_ptr, Ptab_traits_vpn, Ptab_va_vpn >
109 enum { Super_level = Pte_ptr::Super_level };
113 //---------------------------------------------------------------------------
115 template<typename ALLOC>
116 inline Pdir_alloc_simple<ALLOC> pdir_alloc(ALLOC *a)
117 { return Pdir_alloc_simple<ALLOC>(a); }
119 IMPLEMENT inline NEEDS[PF::is_usermode_error]
120 Mword PF::pc_to_msgword1(Address pc, Mword error)
122 return is_usermode_error(error) ? pc : (Mword)-1;
125 //---------------------------------------------------------------------------
126 IMPLEMENTATION[!ppc32]:
130 Pdir::virt_to_phys(Address virt) const
137 return i.page_addr() | cxx::get_lsb(virt, i.page_order());
140 //---------------------------------------------------------------------------
141 IMPLEMENTATION[ppc32]:
145 Pdir::virt_to_phys(Address virt) const
147 auto i = walk(Virt_addr(virt));
154 Pte_htab::pte_lookup(i.e, &phys);
155 return phys | (virt & ~(~0UL << i.page_order()));