Subversion Repositories shark

Rev

Rev 1063 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1063 tullio 1
 
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
498 giacomo 19
#include <FTrace_chunk.h>
20
#include <FTrace_OSD.h>
21
#include <FTrace_types.h>
22
 
550 giacomo 23
#include <FTrace_udp.h>
24
 
498 giacomo 25
#include <kernel/kern.h>
26
#include <stdlib.h>
27
 
28
SYS_FLAGS FTracef;
29
 
30
extern FTrace_Chunk_Ptr ActualChunk;
532 giacomo 31
extern void *OSD_current_pointer;
498 giacomo 32
 
1027 tullio 33
/**
34
 * This flag keeps track of the current chunk sending action.
35
 * It is 1 if the output is still ongoing.
36
 * It is reset to 0 if the output is finished.
37
 */
38
int chunk_sending = 0;
39
 
40
/**
41
 * Pointer to the function that actually perform the chunk send.
42
 */
43
void (*FTrace_internal_send_chunk)(FTrace_Chunk_Ptr) = NULL;
44
 
45
/**
46
 * Initializes the poiter to the function for actually sending the chunk.
47
 */
48
void FTrace_set_internal_chunk_sender(void (*ptr)(FTrace_Chunk_Ptr)) {
49
        FTrace_internal_send_chunk = ptr;
50
}
51
 
52
/**
53
 * This function is called before starting the chunck sending.
54
 */
55
void FTrace_chunck_output_start() {
56
        chunk_sending = 1;
57
}
58
 
59
/**
60
 * This function is called after the chunck has been entirely sent.
61
 */
62
void FTrace_chunck_output_end() {
63
        chunk_sending = 0;
64
}
65
 
66
 
498 giacomo 67
void FTrace_fsave()
68
{
69
 
563 giacomo 70
  __asm__("cpuid\n\t":::"eax","ebx","ecx","edx");
498 giacomo 71
  FTracef = kern_fsave();
72
 
73
}
74
 
75
void FTrace_frestore()
76
{
563 giacomo 77
  __asm__("cpuid\n\t":::"eax","ebx","ecx","edx");                                                                            
498 giacomo 78
  kern_frestore(FTracef);
79
 
80
}
81
 
82
void FTrace_lock()
83
{
84
 
85
}
86
 
87
void FTrace_unlock()
88
{
89
 
90
}
91
 
92
void *FTrace_malloc(int size)
93
{
94
 
95
  return malloc(size);
96
 
97
}
98
 
99
void FTrace_free(void *ptr)
100
{
101
 
102
  free(ptr);
103
 
104
}
105
 
106
int FTrace_OSD_init()
107
{
108
 
109
  return 0;
110
 
111
}
112
 
501 giacomo 113
/* OSD_pointers
532 giacomo 114
 
534 giacomo 115
   00 - Actual Chunk Position
116
   04 - Actual Chunk Start
117
   08 - Actual Chunk Size
118
   12 - Actual Chunk Emergency Size
119
   16 - Actual Chunk Flags
501 giacomo 120
 
534 giacomo 121
   20 - Next Chunk OSD Pointer
501 giacomo 122
 
123
*/
124
 
125
int FTrace_OSD_chunk_init(FTrace_Chunk_Ptr c, int size, int emergency_size, FTrace_flags flags)
498 giacomo 126
{
127
 
532 giacomo 128
  *(DWORD *)(c->osd) = (DWORD)(c->osd + FTRACE_OSD_CHUNK_HEAD);
501 giacomo 129
  *(DWORD *)(c->osd + 4) = (DWORD)(c->osd + FTRACE_OSD_CHUNK_HEAD);
534 giacomo 130
  *(DWORD *)(c->osd + 8) = (DWORD)(c->size);
131
  *(DWORD *)(c->osd + 12) = (DWORD)(c->emergency_size);
132
  *(DWORD *)(c->osd + 16) = (DWORD)(c->flags);
133
  *(DWORD *)(c->osd + 20) = 0;
501 giacomo 134
 
498 giacomo 135
  return 0;
136
 
137
}
138
 
139
/* OSD Chunk Link */
532 giacomo 140
int FTrace_OSD_chunk_link(FTrace_Chunk_Ptr a, FTrace_Chunk_Ptr b)
498 giacomo 141
{
142
 
534 giacomo 143
  *(DWORD *)(a->osd + 20) = (DWORD)(b->osd);
498 giacomo 144
 
145
  return 0;
146
 
147
}
148
 
503 giacomo 149
int FTrace_OSD_update_chunk_flags(FTrace_Chunk_Ptr c)
150
{
151
 
534 giacomo 152
  *(DWORD *)(c->osd + 16) = (DWORD)(c->flags);
503 giacomo 153
 
154
  return 0;
155
 
156
}
157
 
498 giacomo 158
int FTrace_OSD_compress_chunk(int number, void *temp_data, int *data_size)
159
{
160
 
161
  return 0;
162
 
163
}
164
 
1027 tullio 165
int FTrace_OSD_send_chunk(FTrace_Chunk_Ptr c, int osd_flag) {
498 giacomo 166
 
1027 tullio 167
  // Tool: send the chunk using the selected method
168
  if (FTrace_internal_send_chunk != NULL)
169
        FTrace_internal_send_chunk(c);
552 giacomo 170
 
1027 tullio 171
 
172
  struct timespec t;
173
  t.tv_sec = 2;
174
  t.tv_nsec = 0;
175
  //cprintf("Chunk sending");   // Tool: DEBUG
176
  while(chunk_sending) {
177
        //cprintf(".");   // Tool: DEBUG
178
        nanosleep(&t,NULL);
179
  }
180
  //cprintf("\n");   // Tool: DEBUG
550 giacomo 181
 
498 giacomo 182
  return 0;
183
}
184
 
534 giacomo 185
int FTrace_OSD_chunk_dump(FTrace_Chunk_Ptr c)
186
{
498 giacomo 187
 
534 giacomo 188
  FTrace_printf("Position : %x\n",*(int *)(c->osd));
189
  FTrace_printf("Start    : %x\n",*(int *)(c->osd+4));
190
  FTrace_printf("Size     : %d\n",*(int *)(c->osd+8));
191
  FTrace_printf("Em-Size  : %d\n",*(int *)(c->osd+12));
192
  FTrace_printf("Flags    : %x\n",*(int *)(c->osd+16));
193
  FTrace_printf("Next     : %x\n\n",*(int *)(c->osd+20));
194
 
195
  return 0;
196
 
197
}
198
 
199