Rev 501 | Rev 506 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
498 | giacomo | 1 | #include <FTrace_types.h> |
2 | #include <FTrace_OSD.h> |
||
3 | |||
501 | giacomo | 4 | #include <ll/i386/hw-instr.h> |
5 | |||
498 | giacomo | 6 | /* OSD_pointers |
7 | |||
501 | giacomo | 8 | 00 - Next pointer |
9 | |||
10 | 04 - Actual Chunk Position |
||
498 | giacomo | 11 | 08 - Actual Chunk Start |
501 | giacomo | 12 | 12 - Actual Chunk Size |
13 | 16 - Actual Chunk Emergency Size |
||
14 | 20 - Actual Chunk Flags |
||
498 | giacomo | 15 | |
501 | giacomo | 16 | 24 - Next1 Chunk Position |
17 | 28 - Next1 Chunk Start |
||
18 | 32 - Next1 Chunk Size |
||
19 | 36 - Next1 Chunk Emergency Size |
||
20 | 60 - Next1 Chunk Flags |
||
498 | giacomo | 21 | |
22 | */ |
||
23 | |||
501 | giacomo | 24 | void FTrace_safe_ipoint(WORD type, WORD par1, DWORD par2) |
498 | giacomo | 25 | { |
26 | |||
27 | extern BYTE OSD_pointers[FTRACE_OSD_CHUNK_HEAD]; |
||
28 | extern BYTE FTrace_enable; |
||
29 | |||
501 | giacomo | 30 | DWORD tsclow, tschigh; |
503 | giacomo | 31 | DWORD next; |
32 | DWORD current; |
||
33 | DWORD start; |
||
34 | DWORD size; |
||
35 | DWORD flags; |
||
501 | giacomo | 36 | |
37 | SYS_FLAGS f; |
||
498 | giacomo | 38 | |
503 | giacomo | 39 | f = ll_fsave(); |
40 | |||
501 | giacomo | 41 | if (FTrace_enable) { |
42 | |||
503 | giacomo | 43 | next = *(DWORD *)(OSD_pointers); |
44 | current = *(DWORD *)(OSD_pointers + next); |
||
45 | start = *(DWORD *)(OSD_pointers + next + 4); |
||
46 | size = *(DWORD *)(OSD_pointers + next + 8); |
||
47 | flags = *(DWORD *)(OSD_pointers + next + 16); |
||
501 | giacomo | 48 | |
503 | giacomo | 49 | if (current == NULL) { |
50 | ll_frestore(f); |
||
51 | return; |
||
52 | } |
||
53 | |||
501 | giacomo | 54 | if (type != FTrace_EVT_next_chunk) { |
55 | |||
56 | if ((flags & FTRACE_CHUNK_FLAG_FULL) == FTRACE_CHUNK_FLAG_FULL) { |
||
57 | ll_frestore(f); |
||
58 | return; |
||
59 | } |
||
60 | |||
61 | /* Cyclical Buffer */ |
||
62 | if (current + 16 >= (start + size)) { |
||
63 | if ((flags & 0x0C) == FTRACE_CHUNK_FLAG_CYC) { |
||
64 | current = start; |
||
65 | } else { |
||
503 | giacomo | 66 | *(WORD *)(OSD_pointers + next + 16) |= FTRACE_CHUNK_FLAG_FULL; |
501 | giacomo | 67 | if ((flags & 0x0C) == FTRACE_CHUNK_FLAG_JTN) { |
68 | *(DWORD *)(OSD_pointers) += 20; |
||
69 | next = *(DWORD *)(OSD_pointers); |
||
70 | } |
||
71 | } |
||
72 | } |
||
73 | |||
74 | __asm__("cpuid\n\t" |
||
75 | "rdtsc\n\t" |
||
503 | giacomo | 76 | : "=a" (tsclow), "=d" (tschigh) : : "ecx","ebx"); |
501 | giacomo | 77 | |
78 | *(DWORD *)current = (DWORD)(type << 16 | par1); |
||
79 | *(DWORD *)(current + 4) = tschigh; |
||
80 | *(DWORD *)(current + 8) = tsclow; |
||
81 | *(DWORD *)(current + 16) = par2; |
||
82 | |||
83 | *(DWORD *)(OSD_pointers + next) = current + 16; |
||
84 | |||
85 | } else { |
||
86 | |||
503 | giacomo | 87 | *(WORD *)(OSD_pointers + next + 16) |= FTRACE_CHUNK_FLAG_FULL; |
88 | *(DWORD *)(OSD_pointers) += 20; |
||
501 | giacomo | 89 | |
90 | } |
||
91 | |||
92 | } |
||
93 | |||
503 | giacomo | 94 | ll_frestore(f); |
95 | |||
498 | giacomo | 96 | } |
97 | |||
501 | giacomo | 98 | void FTrace_unsafe_ipoint(WORD type, WORD par1) |
498 | giacomo | 99 | { |
100 | |||
101 | extern BYTE OSD_pointers[FTRACE_OSD_CHUNK_HEAD]; |
||
102 | |||
103 | __asm__("pushfl\n\t" /* Critical Section */ |
||
104 | "cli\n\t" |
||
105 | "cpuid\n\t" |
||
106 | "rdtsc\n\t" |
||
501 | giacomo | 107 | "movl (%%edi),%%ebx\n\t" |
503 | giacomo | 108 | "movl %%esi,(%%ebx)\n\t" /* Save TYPE + WORD par1 */ |
109 | "movl %%edx,4(%%ebx)\n\t" /* Save TSC HIGH */ |
||
110 | "movl %%eax,8(%%ebx)\n\t" /* Save TSC LOW */ |
||
111 | "movl %%eax,12(%%ebx)\n\t" /* DWORD par2 */ |
||
112 | "addl $16,(%%edi)\n\t" /* Inc Position */ |
||
498 | giacomo | 113 | "popfl\n\t" |
503 | giacomo | 114 | :: "D" ((DWORD *)(OSD_pointers+4)), "S" ((type | 0x8000) << 16 | par1)); |
498 | giacomo | 115 | |
116 | } |
||
117 |