00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00051 #ifndef TOPPERS_CPUEXCEPTION_HPP_
00052 #define TOPPERS_CPUEXCEPTION_HPP_
00053
00054 #include <toppers/context.hpp>
00055 #include <toppers/kernelstatus.hpp>
00056
00057 namespace toppers
00058 {
00059
00060 template <class Body> void cpuexception_entry();
00061
00062 template <class Diagnostics, class Stub> class cpuexception_body;
00063
00075 template <class Diagnostics = TOPPERS_DEFAULT_DIAGNOSTICS,
00076 class Stub = TOPPERS_DEFAULT_STUB >
00077 class cpuexception : Diagnostics
00078 {
00079 public:
00081 typedef t_dexc definition;
00083 typedef cpuexception_body<Diagnostics, Stub> body;
00084
00085
00086 static ER define(EXCNO excno, definition* pk_dobj)
00087 {
00088 ER ercd = Stub::stub_def_exc(excno, pk_dobj);
00089 return static_handle_error(ercd);
00090 }
00092 static ER define(EXCNO excno, const definition* pk_dobj)
00093 {
00094 ER ercd = Stub::stub_def_exc(excno, pk_dobj);
00095 return static_handle_error(ercd);
00096 }
00098 static ER define(EXCNO excno, ATR excatr, void (*exchdr)(VP))
00099 {
00100 t_dexc packet;
00101 packet.excatr = excatr;
00102 packet.exchdr = FP(exchdr);
00103 return define(excno, &packet);
00104 }
00106 template <class Body>
00107 static ER define(EXCNO excno, ATR excatr = 0)
00108 {
00109 return define(excno, excatr, &cpuexception_entry<Body>);
00110 }
00112 static ER undefine(EXCNO excno)
00113 {
00114 return define(excno, static_cast<definition*>(0));
00115 }
00116 };
00117
00129 template <class Diagnostics = TOPPERS_DEFAULT_DIAGNOSTICS,
00130 class Stub = TOPPERS_DEFAULT_STUB >
00131 class cpuexception_body
00132 #if TKERNEL_MAKER == 0x0118
00133 : public non_task_context_body<Diagnostics, Stub>
00134 #endif
00135 {
00136 TOPPERS_STATIC_ASSERT(!Diagnostics::use_exception);
00137 VP_INT exinf_;
00138
00139 protected:
00141 ~cpuexception_body() {}
00142
00143 public:
00145 explicit cpuexception_body(VP_INT exinf) : exinf_(exinf) {}
00146
00148 static bool sense_context(VP_INT exinf)
00149 {
00150 return Stub::stub_vxsns_ctx(VP(exinf));
00151 }
00152
00154 static bool sense_cpulock(VP_INT exinf)
00155 {
00156 return Stub::stub_vxsns_loc(VP(exinf));
00157 }
00158
00160 static bool sense_dispatch(VP_INT exinf)
00161 {
00162 return Stub::stub_vxsns_dsp(VP(exinf));
00163 }
00164
00166 static bool sense_dispatch_pending(VP_INT exinf)
00167 {
00168 return Stub::stub_vxsns_dpn(VP(exinf));
00169 }
00170
00172 static bool sense_taskexception(VP_INT exinf)
00173 {
00174 return Stub::stub_vxsns_tex(VP(exinf));
00175 }
00176
00178 VP_INT get_extended_info() const { return exinf_; }
00179 };
00180
00191 template <class Body>
00192 inline void cpuexception_entry(VP p_exinf)
00193 {
00194 Body body((VP_INT)p_exinf);
00195 body.run();
00196 }
00197
00198 }
00199
00200 #endif // ! TOPPERS_CPUEXCEPTION_HPP_