Subversion Repositories shark

Rev

Rev 503 | Rev 532 | 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
506 giacomo 20
   40 - Next1 Chunk Flags
21
 
22
   44 - Next1 Chunk Position
23
   48 - Next1 Chunk Start
24
   52 - Next1 Chunk Size
25
   56 - Next1 Chunk Emergency Size
501 giacomo 26
   60 - Next1 Chunk Flags
498 giacomo 27
 
506 giacomo 28
   64 - Fast_Access
29
 
498 giacomo 30
*/
31
 
501 giacomo 32
void FTrace_safe_ipoint(WORD type, WORD par1, DWORD par2)
498 giacomo 33
{
34
 
35
  extern BYTE OSD_pointers[FTRACE_OSD_CHUNK_HEAD];
36
  extern BYTE FTrace_enable;
37
 
501 giacomo 38
  DWORD tsclow, tschigh;
503 giacomo 39
  DWORD next;
40
  DWORD current;
41
  DWORD start;
42
  DWORD size;
43
  DWORD flags;
501 giacomo 44
 
45
  SYS_FLAGS f;
498 giacomo 46
 
503 giacomo 47
  f = ll_fsave();
48
 
501 giacomo 49
  if (FTrace_enable) {
50
 
503 giacomo 51
    next = *(DWORD *)(OSD_pointers);
52
    current = *(DWORD *)(OSD_pointers + next);
53
    start   = *(DWORD *)(OSD_pointers + next + 4);
54
    size    = *(DWORD *)(OSD_pointers + next + 8);
55
    flags   = *(DWORD *)(OSD_pointers + next + 16);
501 giacomo 56
 
503 giacomo 57
    if (current == NULL) {
58
      ll_frestore(f);
59
      return;
60
    }
61
 
501 giacomo 62
    if (type != FTrace_EVT_next_chunk) {
63
 
64
      if ((flags & FTRACE_CHUNK_FLAG_FULL) == FTRACE_CHUNK_FLAG_FULL) {
65
	ll_frestore(f);
66
	return;
67
      }
68
 
69
      /* Cyclical Buffer */
70
      if (current + 16 >= (start + size)) {
71
	if ((flags & 0x0C) == FTRACE_CHUNK_FLAG_CYC) {
72
          current = start;
73
	} else {
503 giacomo 74
	  *(WORD *)(OSD_pointers + next + 16) |= FTRACE_CHUNK_FLAG_FULL;
501 giacomo 75
	  if ((flags & 0x0C) ==  FTRACE_CHUNK_FLAG_JTN) {
76
		*(DWORD *)(OSD_pointers) += 20;
77
		next = *(DWORD *)(OSD_pointers);
78
          }
79
	}
80
      }
81
 
82
      __asm__("cpuid\n\t"
83
              "rdtsc\n\t"
503 giacomo 84
	      : "=a" (tsclow), "=d" (tschigh) : : "ecx","ebx");
501 giacomo 85
 
86
      *(DWORD *)current = (DWORD)(type << 16 | par1);
87
      *(DWORD *)(current + 4) = tschigh;
88
      *(DWORD *)(current + 8) = tsclow;
89
      *(DWORD *)(current + 16) = par2;
90
 
506 giacomo 91
      *(DWORD *)(OSD_pointers + 64) = *(DWORD *)(OSD_pointers + next) = current + 16;
501 giacomo 92
 
93
    } else {
94
 
503 giacomo 95
      *(WORD *)(OSD_pointers + next + 16) |= FTRACE_CHUNK_FLAG_FULL;
96
      *(DWORD *)(OSD_pointers) += 20;
506 giacomo 97
      *(DWORD *)(OSD_pointers + 64) = *(DWORD *)(OSD_pointers + *(DWORD *)(OSD_pointers) + 4); //Fast Access
501 giacomo 98
 
99
    }
100
 
101
  }
102
 
503 giacomo 103
  ll_frestore(f);
104
 
498 giacomo 105
}
106
 
501 giacomo 107
void FTrace_unsafe_ipoint(WORD type, WORD par1)
498 giacomo 108
{
109
 
110
  extern BYTE OSD_pointers[FTRACE_OSD_CHUNK_HEAD];
111
 
112
  __asm__("pushfl\n\t" /* Critical Section */
113
          "cli\n\t"
114
	  "cpuid\n\t"
115
	  "rdtsc\n\t"
501 giacomo 116
	  "movl (%%edi),%%ebx\n\t"
503 giacomo 117
          "movl %%esi,(%%ebx)\n\t"   /* Save TYPE + WORD par1 */
118
          "movl %%edx,4(%%ebx)\n\t"  /* Save TSC HIGH */
119
          "movl %%eax,8(%%ebx)\n\t"  /* Save TSC LOW */
120
	  "movl %%eax,12(%%ebx)\n\t" /* DWORD par2 */
121
	  "addl $16,(%%edi)\n\t"     /* Inc Position */
498 giacomo 122
	  "popfl\n\t"
506 giacomo 123
          :: "D" ((DWORD *)(OSD_pointers+64)), "S" ((type | 0x8000) << 16 | par1));
498 giacomo 124
 
125
}
126