3 EXTENSION class Context
6 void set_ignore_mem_op_in_progress(bool val);
7 bool is_ignore_mem_op_in_progress() const { return _ignore_mem_op_in_progess; }
10 bool _ignore_mem_op_in_progess;
13 // ------------------------------------------------------------------------
14 INTERFACE [armv6plus]:
16 EXTENSION class Context
25 // ------------------------------------------------------------------------
31 #include "globals.h" // current()
35 #include "lock_guard.h"
37 #include "thread_state.h"
38 #include "utcb_support.h"
43 Context::fill_user_state()
45 // do not use 'Return_frame const *rf = regs();' here as it triggers an
46 // optimization bug in gcc-4.4(.1)
47 Entry_frame const *ef = regs();
48 asm volatile ("ldmia %[rf], {sp, lr}^"
49 : : "m"(ef->usp), "m"(ef->ulr), [rf] "r" (&ef->usp));
54 Context::spill_user_state()
56 Entry_frame *ef = regs();
57 assert_kdb (current() == this);
58 asm volatile ("stmia %[rf], {sp, lr}^"
59 : "=m"(ef->usp), "=m"(ef->ulr) : [rf] "r" (&ef->usp));
62 IMPLEMENT inline NEEDS[Context::spill_user_state, Context::store_tpidrurw,
63 Context::load_tpidrurw, Context::load_tpidruro]
65 Context::switch_cpu(Context *t)
67 update_consumed_time();
76 register Mword _old_this asm("r1") = (Mword)this;
77 register Mword _new_this asm("r0") = (Mword)t;
78 unsigned long dummy1, dummy2;
81 (// save context of old thread
84 " str lr, [sp, #-4]! \n"
85 " str sp, [%[old_sp]] \n"
87 // switch to new stack
88 " mov sp, %[new_sp] \n"
90 // deliver requests to new thread
91 " bl switchin_context_label \n" // call Context::switchin_context(Context *)
93 // return to new context
94 " ldr pc, [sp], #4 \n"
95 "1: ldmia sp!, {fp} \n"
100 [old_sp] "=r" (dummy1),
101 [new_sp] "=r" (dummy2)
107 : "r4", "r5", "r6", "r7", "r8", "r9",
108 "r10", "r12", "r14", "memory");
112 /** Thread context switchin. Called on every re-activation of a
113 thread (switch_exec()). This method is public only because it is
114 called by an ``extern "C"'' function that is called
115 from assembly code (call_switchin_context).
118 void Context::switchin_context(Context *from)
120 assert_kdb (this == current());
121 assert_kdb (state() & Thread_ready_mask);
123 // switch to our page directory if nessecary
124 vcpu_aware_space()->switchin_context(from->vcpu_aware_space());
126 Utcb_support::current(current()->utcb().usr());
131 Context::set_ignore_mem_op_in_progress(bool val)
133 _ignore_mem_op_in_progess = val;
137 // ------------------------------------------------------------------------
138 IMPLEMENTATION [armv6plus]:
140 PROTECTED inline void Context::arch_setup_utcb_ptr()
142 _tpidruro = reinterpret_cast<Mword>(utcb().usr().get());
147 Context::arch_load_vcpu_kern_state(Vcpu_state *vcpu, bool do_load)
149 _tpidruro = vcpu->_tpidruro;
156 Context::arch_load_vcpu_user_state(Vcpu_state *vcpu, bool do_load)
158 _tpidruro = vcpu->_ts.tpidruro;
165 Context::arch_update_vcpu_state(Vcpu_state *vcpu)
167 vcpu->_tpidruro = _tpidruro;
172 Context::store_tpidrurw()
174 asm volatile ("mrc p15, 0, %0, c13, c0, 2" : "=r" (_tpidrurw));
179 Context::load_tpidrurw() const
181 asm volatile ("mcr p15, 0, %0, c13, c0, 2" : : "r" (_tpidrurw));
186 Context::load_tpidruro() const
188 asm volatile ("mcr p15, 0, %0, c13, c0, 3" : : "r" (_tpidruro));
193 Context::tpidrurw() const
200 Context::tpidruro() const
205 // ------------------------------------------------------------------------
206 IMPLEMENTATION [!armv6plus]:
208 PROTECTED inline void Context::arch_setup_utcb_ptr()
213 Context::store_tpidrurw() const
218 Context::load_tpidrurw() const
223 Context::load_tpidruro() const
228 Context::tpidrurw() const
235 Context::tpidruro() const