8 |
|
|
9 |
|
|
10 |
#define DPRINTF_BUF_SZ 1024 |
#define DPRINTF_BUF_SZ 1024 |
11 |
static void dprintf(char *fmt, ...) |
static void |
12 |
|
dprintf(char *fmt, |
13 |
|
...) |
14 |
{ |
{ |
15 |
va_list args; |
va_list args; |
16 |
char buf[DPRINTF_BUF_SZ]; |
char buf[DPRINTF_BUF_SZ]; |
67 |
#define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax |
#define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax |
68 |
|
|
69 |
// needed for timer.c |
// needed for timer.c |
70 |
static __inline int64_t read_counter() { |
static __inline int64_t |
71 |
|
read_counter() |
72 |
|
{ |
73 |
int64_t ts; |
int64_t ts; |
74 |
uint32_t ts1, ts2; |
uint32_t ts1, ts2; |
75 |
|
|
76 |
__asm { |
__asm { |
77 |
rdtsc |
rdtsc mov ts1, eax mov ts2, edx} |
|
mov ts1, eax |
|
|
mov ts2, edx |
|
|
} |
|
78 |
|
|
79 |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
80 |
|
|
135 |
"r" (&(a)), "m" (a)); |
"r" (&(a)), "m" (a)); |
136 |
#define EMMS() |
#define EMMS() |
137 |
|
|
138 |
static __inline unsigned long get_tbl(void) { |
static __inline unsigned long |
139 |
|
get_tbl(void) |
140 |
|
{ |
141 |
unsigned long tbl; |
unsigned long tbl; |
142 |
asm volatile("mftb %0" : "=r" (tbl)); |
asm volatile("mftb %0" : "=r" (tbl)); |
143 |
|
|
144 |
return tbl; |
return tbl; |
145 |
} |
} |
146 |
static __inline unsigned long get_tbu(void) { |
static __inline unsigned long |
147 |
|
get_tbu(void) |
148 |
|
{ |
149 |
unsigned long tbl; |
unsigned long tbl; |
150 |
asm volatile("mftbu %0" : "=r" (tbl)); |
asm volatile("mftbu %0" : "=r" (tbl)); |
151 |
|
|
152 |
return tbl; |
return tbl; |
153 |
} |
} |
154 |
static __inline int64_t read_counter() { |
static __inline int64_t |
155 |
|
read_counter() |
156 |
|
{ |
157 |
unsigned long tb, tu; |
unsigned long tb, tu; |
158 |
|
|
159 |
do { |
do { |
160 |
tu = get_tbu(); |
tu = get_tbu(); |
161 |
tb = get_tbl(); |
tb = get_tbl(); |
168 |
|
|
169 |
|
|
170 |
// needed for timer.c |
// needed for timer.c |
171 |
static __inline int64_t read_counter() { |
static __inline int64_t |
172 |
|
read_counter() |
173 |
|
{ |
174 |
int64_t ts; |
int64_t ts; |
175 |
uint32_t ts1, ts2; |
uint32_t ts1, ts2; |
176 |
|
|
177 |
__asm__ __volatile__("rdtsc\n\t":"=a"(ts1), "=d"(ts2)); |
__asm__ __volatile__("rdtsc\n\t":"=a"(ts1), |
178 |
|
"=d"(ts2)); |
179 |
|
|
180 |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
181 |
|
|
203 |
|
|
204 |
// rdtsc command most likely not supported, |
// rdtsc command most likely not supported, |
205 |
// so just dummy code here |
// so just dummy code here |
206 |
static __inline int64_t read_counter() { |
static __inline int64_t |
207 |
|
read_counter() |
208 |
|
{ |
209 |
return 0; |
return 0; |
210 |
} |
} |
211 |
|
|
215 |
#endif |
#endif |
216 |
|
|
217 |
#endif // _PORTAB_H_ |
#endif // _PORTAB_H_ |
|
|
|