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 // ------------------------------------------------------------------------
19 #include "globals.h" // current()
23 #include "lock_guard.h"
25 #include "thread_state.h"
26 #include "utcb_support.h"
31 Context::fill_user_state()
33 // do not use 'Return_frame const *rf = regs();' here as it triggers an
34 // optimization bug in gcc-4.4(.1)
35 Entry_frame const *ef = regs();
36 asm volatile ("ldmia %[rf], {sp, lr}^"
37 : : "m"(ef->usp), "m"(ef->ulr), [rf] "r" (&ef->usp));
42 Context::spill_user_state()
44 Entry_frame *ef = regs();
45 assert_kdb (current() == this);
46 asm volatile ("stmia %[rf], {sp, lr}^"
47 : "=m"(ef->usp), "=m"(ef->ulr) : [rf] "r" (&ef->usp));
52 Context::switch_cpu(Context *t)
54 update_consumed_time();
60 register Mword _old_this asm("r1") = (Mword)this;
61 register Mword _new_this asm("r0") = (Mword)t;
62 unsigned long dummy1, dummy2;
65 (// save context of old thread
68 " str lr, [sp, #-4]! \n"
69 " str sp, [%[old_sp]] \n"
71 // switch to new stack
72 " mov sp, %[new_sp] \n"
74 // deliver requests to new thread
75 " bl switchin_context_label \n" // call Context::switchin_context(Context *)
77 // return to new context
78 " ldr pc, [sp], #4 \n"
79 "1: ldmia sp!, {fp} \n"
84 [old_sp] "=r" (dummy1),
85 [new_sp] "=r" (dummy2)
91 : "r4", "r5", "r6", "r7", "r8", "r9",
92 "r10", "r12", "r14", "memory");
96 /** Thread context switchin. Called on every re-activation of a
97 thread (switch_exec()). This method is public only because it is
98 called by an ``extern "C"'' function that is called
99 from assembly code (call_switchin_context).
102 void Context::switchin_context(Context *from)
104 assert_kdb (this == current());
105 assert_kdb (state() & Thread_ready_mask);
108 printf("switch in address space: %p\n",_space);
111 // switch to our page directory if nessecary
112 vcpu_aware_space()->switchin_context(from->vcpu_aware_space());
114 Utcb_support::current((Utcb*)local_id());
120 Context::set_ignore_mem_op_in_progress(bool val)
122 _ignore_mem_op_in_progess = val;
126 //-----------------------------------------------------------------------------
127 IMPLEMENTATION [arm && vcache]:
131 Context::access_utcb() const
133 // Do not use the alias mapping of the UTCB for the current address space
134 return Mem_space::current_mem_space(current_cpu()) == mem_space()
141 Context::access_vcpu(bool is_current = false) const
143 // Do not use the alias mapping of the UTCB for the current address space
144 return is_current || Mem_space::current_mem_space(current_cpu()) == mem_space()
145 ? reinterpret_cast<Vcpu_state *>(local_id() + sizeof(Utcb))
150 //-----------------------------------------------------------------------------
151 IMPLEMENTATION [arm && !vcache]:
155 Context::access_utcb() const
157 return current_cpu() == cpu() && Mem_space::current_mem_space(current_cpu()) == mem_space()
164 Context::access_vcpu(bool is_current = false) const
166 // Do not use the alias mapping of the vCPU for the current address space
167 return is_current || Mem_space::current_mem_space(current_cpu()) == mem_space()
168 ? reinterpret_cast<Vcpu_state *>(local_id() + sizeof(Utcb))