00001
00007
00008 #ifndef __L4_KTRACE_H__
00009 #define __L4_KTRACE_H__
00010
00011 #include <l4/sys/types.h>
00012 #include <l4/sys/ktrace_events.h>
00013
00014 #define LOG_EVENT_CONTEXT_SWITCH 0
00017 #define LOG_EVENT_IPC_SHORTCUT 1
00020 #define LOG_EVENT_IRQ_RAISED 2
00023 #define LOG_EVENT_TIMER_IRQ 3
00026 #define LOG_EVENT_THREAD_EX_REGS 4
00029 #define LOG_EVENT_TRAP 5
00032 #define LOG_EVENT_PF_RES 6
00035 #define LOG_EVENT_SCHED 7
00039 #define LOG_EVENT_PREEMPTION 8
00042 #define LOG_EVENT_ID_NEAREST 9
00045 #define LOG_EVENT_TASK_NEW 10
00049 #define LOG_EVENT_MAX_EVENTS 16
00057 // keep in sync with fiasco/src/jabi/jdb_ktrace.cpp
00058 typedef struct
00059 {
00061 l4_tracebuffer_entry_t * tracebuffer0;
00063 l4_umword_t size0;
00065 volatile l4_uint64_t version0;
00067 l4_tracebuffer_entry_t * tracebuffer1;
00069 l4_umword_t size1;
00071 volatile l4_uint64_t version1;
00073 volatile l4_tracebuffer_entry_t * current_entry;
00075 l4_umword_t logevents[LOG_EVENT_MAX_EVENTS];
00076
00078 l4_umword_t scaler_tsc_to_ns;
00080 l4_umword_t scaler_tsc_to_us;
00082 l4_umword_t scaler_ns_to_tsc;
00083
00085 volatile l4_umword_t cnt_context_switch;
00087 volatile l4_umword_t cnt_addr_space_switch;
00089 volatile l4_umword_t cnt_shortcut_failed;
00091 volatile l4_umword_t cnt_shortcut_success;
00093 volatile l4_umword_t cnt_irq;
00095 volatile l4_umword_t cnt_ipc_long;
00097 volatile l4_umword_t cnt_page_fault;
00100 volatile l4_umword_t cnt_io_fault;
00102 volatile l4_umword_t cnt_task_create;
00104 volatile l4_umword_t cnt_schedule;
00108 volatile l4_umword_t cnt_iobmap_tlb_flush;
00109
00110 } l4_tracebuffer_status_t;
00111
00118 L4_INLINE l4_tracebuffer_status_t *
00119 fiasco_tbuf_get_status(void);
00120
00127 L4_INLINE l4_addr_t
00128 fiasco_tbuf_get_status_phys(void);
00129
00137 L4_INLINE l4_umword_t
00138 fiasco_tbuf_log(const char *text);
00139
00151 L4_INLINE l4_umword_t
00152 fiasco_tbuf_log_3val(const char *text, unsigned v1, unsigned v2, unsigned v3);
00153
00161 L4_INLINE l4_umword_t
00162 fiasco_tbuf_log_binary(const unsigned char *data);
00163
00168 L4_INLINE void
00169 fiasco_tbuf_clear(void);
00170
00175 L4_INLINE void
00176 fiasco_tbuf_dump(void);
00177
00181 L4_INLINE void
00182 fiasco_timer_disable(void);
00183
00188 L4_INLINE void
00189 fiasco_timer_enable(void);
00190
00191
00192
00193
00194
00195 L4_INLINE l4_tracebuffer_status_t *
00196 fiasco_tbuf_get_status(void)
00197 {
00198 l4_tracebuffer_status_t *tbuf;
00199 asm("int $3; cmpb $29, %%al" : "=a" (tbuf) : "0" (0));
00200 return tbuf;
00201 }
00202
00203 L4_INLINE l4_addr_t
00204 fiasco_tbuf_get_status_phys(void)
00205 {
00206 l4_addr_t tbuf_phys;
00207 asm("int $3; cmpb $29, %%al" : "=a" (tbuf_phys) : "0" (5));
00208 return tbuf_phys;
00209 }
00210
00211 L4_INLINE l4_umword_t
00212 fiasco_tbuf_log(const char *text)
00213 {
00214 l4_umword_t offset;
00215 asm volatile("int $3; cmpb $29, %%al"
00216 : "=a" (offset)
00217 : "a" (1), "d" (text));
00218 return offset;
00219 }
00220
00221 L4_INLINE l4_umword_t
00222 fiasco_tbuf_log_3val(const char *text, unsigned v1, unsigned v2, unsigned v3)
00223 {
00224 l4_umword_t offset;
00225 asm volatile("int $3; cmpb $29, %%al"
00226 : "=a" (offset)
00227 : "a" (4), "d" (text), "c" (v1), "S" (v2), "D" (v3));
00228 return offset;
00229 }
00230
00231 L4_INLINE void
00232 fiasco_tbuf_clear(void)
00233 {
00234 asm volatile("int $3; cmpb $29, %%al" : : "a" (2));
00235 }
00236
00237 L4_INLINE void
00238 fiasco_tbuf_dump(void)
00239 {
00240 asm volatile("int $3; cmpb $29, %%al" : : "a" (3));
00241 }
00242
00243 L4_INLINE void
00244 fiasco_timer_disable(void)
00245 {
00246 asm volatile("int $3; cmpb $29, %%al" : : "a" (6));
00247 }
00248
00249 L4_INLINE void
00250 fiasco_timer_enable(void)
00251 {
00252 asm volatile("int $3; cmpb $29, %%al" : : "a" (7));
00253 }
00254
00255 L4_INLINE l4_umword_t
00256 fiasco_tbuf_log_binary(const unsigned char *data)
00257 {
00258 l4_umword_t offset;
00259 asm volatile("int $3; cmpb $29, %%al"
00260 : "=a" (offset)
00261 : "a" (8), "d" (data));
00262 return offset;
00263 }
00264
00265 #endif
00266