add some trace apis
This commit is contained in:
parent
20249fdcf1
commit
d41a3656aa
26
am/amtrace.h
26
am/amtrace.h
|
@ -1,7 +1,29 @@
|
|||
#ifndef __AMTRACE_H__
|
||||
#define __AMTRACE_H__
|
||||
|
||||
void _trace_on();
|
||||
void _trace_off();
|
||||
struct _Trace {
|
||||
uint8_t cpu;
|
||||
uint8_t type;
|
||||
uint16_t length;
|
||||
char payload[];
|
||||
} __attribute__((packed));
|
||||
typedef struct _Trace _Trace;
|
||||
|
||||
// ========================= trace components ========================
|
||||
|
||||
#define _TRACE_IOE 0x00000001
|
||||
#define _TRACE_ASYE 0x00000002
|
||||
#define _TRACE_PTE 0x00000004
|
||||
#define _TRACE_MPE 0x00000008
|
||||
|
||||
// =========================== trace points ==========================
|
||||
|
||||
#define _TRACE_CALL 0x00010000
|
||||
#define _TRACE_RET 0x00020000
|
||||
#define _TRACE_FUNC (_TRACE_CALL | _TRACE_RET)
|
||||
#define _TRACE_ALL 0xffffffff
|
||||
|
||||
void _trace_on(uint32_t flags);
|
||||
void _trace_off(uint32_t flags);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
extern volatile uint32_t *lapic;
|
||||
extern int ncpu;
|
||||
extern volatile int trace_on;
|
||||
extern volatile uint32_t trace_flags;
|
||||
|
||||
void lapic_eoi();
|
||||
void lapic_init();
|
||||
|
@ -60,4 +60,15 @@ void vec14();
|
|||
void vecsys();
|
||||
void irqall();
|
||||
|
||||
static inline int traced() {
|
||||
#ifdef EXT
|
||||
uint32_t flags = trace_flags;
|
||||
if ( (flags & _TRACE_##EXT) && // the extension is being traced
|
||||
1) {
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include <am-x86.h>
|
||||
|
||||
volatile int trace_on = 0;
|
||||
volatile uint32_t trace_flags = 0;
|
||||
|
||||
void _trace_on() {
|
||||
_atomic_xchg(&trace_on, 1);
|
||||
void _trace_on(uint32_t flags) {
|
||||
// TODO: multiprocessor safety
|
||||
trace_flags |= flags;
|
||||
}
|
||||
|
||||
void _trace_off() {
|
||||
_atomic_xchg(&trace_on, 0);
|
||||
void _trace_off(uint32_t flags) {
|
||||
trace_flags &= ~flags;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <am.h>
|
||||
#include <amdev.h>
|
||||
#include <amtrace.h>
|
||||
#include <klib.h>
|
||||
|
||||
_Context *uctx;
|
||||
|
@ -61,6 +62,7 @@ uint8_t code[] = {
|
|||
uint8_t kstk[4096];
|
||||
|
||||
int main() {
|
||||
_trace_on(_TRACE_ALL);
|
||||
st = (uintptr_t)_heap.start;
|
||||
_ioe_init();
|
||||
_asye_init(handler);
|
||||
|
|
Loading…
Reference in New Issue