00001
00002
00003
00004
00005
00006
00007
00008
00020
00021
00022 #ifndef _NLIBC_CONFREG_H
00023 #define _NLIBC_CONFREG_H
00024
00025 #include <nlibc.h>
00026 #include <inttypes.h>
00027 #include <confregs.h>
00028
00029
00030
00032 typedef struct {
00033 vector unsigned clkcnt;
00034 vector unsigned runcnt;
00035 vector unsigned comstr;
00036 vector unsigned memstr;
00037 } clockcnt_t;
00038
00040 clockcnt_t __cc_ref = { 0, 0, 0, 0 };
00041
00042
00056
00057
00058 #if !defined(__cflow_processed) || defined(_uses_cc_get_confreg_h)
00059 inline void cc_get(clockcnt_t* cnt)
00060 {
00061 register clockcnt_t rcnt;
00062
00063 asm("\tctr %0 %1\n" : "=r" (rcnt.clkcnt) : "I" (_CR_CLKCNT));
00064 asm("\tctr %0 %1\n" : "=r" (rcnt.runcnt) : "I" (_CR_RUNCNT));
00065 asm("\tctr %0 %1\n" : "=r" (rcnt.comstr) : "I" (_CR_COMSTR));
00066 asm("\tctr %0 %1\n" : "=r" (rcnt.memstr) : "I" (_CR_MEMSTR));
00067
00068 where (cnt != NULL)
00069 *cnt = rcnt;
00070 }
00071 #endif
00072
00073
00074
00087
00088
00089 #if !defined(__cflow_processed) || defined(_uses_cc_reset_confreg_h)
00090 inline void cc_reset()
00091 {
00092 register clockcnt_t rcnt;
00093
00094 asm("\tctr %0 %1\n" : "=r" (rcnt.clkcnt) : "I" (_CR_CLKCNT));
00095 asm("\tctr %0 %1\n" : "=r" (rcnt.runcnt) : "I" (_CR_RUNCNT));
00096 asm("\tctr %0 %1\n" : "=r" (rcnt.comstr) : "I" (_CR_COMSTR));
00097 asm("\tctr %0 %1\n" : "=r" (rcnt.memstr) : "I" (_CR_MEMSTR));
00098
00099 __cc_ref = rcnt;
00100 }
00101 #endif
00102
00103
00104
00122
00123
00124 #if !defined(__cflow_processed) || defined(_uses_cc_clk_confreg_h)
00125 inline unsigned cc_clk(const clockcnt_t* cnt)
00126 {
00127 register vector unsigned c;
00128
00129 c = cnt->clkcnt - __cc_ref.clkcnt;
00130
00131 return c.lo;
00132 }
00133 #endif
00134
00135
00136
00154
00155
00156 #if !defined(__cflow_processed) || defined(_uses_cc_run_confreg_h)
00157 inline unsigned cc_run(const clockcnt_t* cnt)
00158 {
00159 register vector unsigned c;
00160
00161 c = cnt->runcnt - __cc_ref.runcnt;
00162
00163 return c.lo;
00164 }
00165 #endif
00166
00167
00168
00186
00187
00188 #if !defined(__cflow_processed) || defined(_uses_cc_qwait_confreg_h)
00189 inline unsigned cc_qwait(const clockcnt_t* cnt)
00190 {
00191 register vector unsigned c;
00192
00193 c = (cnt->comstr & 0x00000000ffffffffULL) -
00194 (__cc_ref.comstr & 0x00000000ffffffffULL);
00195
00196 return c.lo;
00197 }
00198 #endif
00199
00200
00201
00219
00220
00221 #if !defined(__cflow_processed) || defined(_uses_cc_nbusy_confreg_h)
00222 inline unsigned cc_nbusy(const clockcnt_t* cnt)
00223 {
00224 register vector unsigned c;
00225
00226 c = ((cnt->comstr & 0xffffffff00000000ULL) >> 32) -
00227 ((__cc_ref.comstr & 0xffffffff00000000ULL) >> 32);
00228
00229 return c.lo;
00230 }
00231 #endif
00232
00233
00234
00252
00253
00254 #if !defined(__cflow_processed) || defined(_uses_cc_mbusy_confreg_h)
00255 inline uint64_t cc_mbusy(const clockcnt_t* cnt)
00256 {
00257 register vector unsigned c;
00258
00259 c = (cnt->memstr & 0x00000000ffffffffULL) -
00260 (__cc_ref.memstr & 0x00000000ffffffffULL);
00261
00262 return c.lo;
00263 }
00264 #endif
00265
00266
00267
00285
00286
00287 #if !defined(__cflow_processed) || defined(_uses_cc_mwait_confreg_h)
00288 inline uint64_t cc_mwait(const clockcnt_t* cnt)
00289 {
00290 register vector unsigned c;
00291
00292 c = ((cnt->memstr & 0xffffffff00000000ULL) >> 32) -
00293 ((__cc_ref.memstr & 0xffffffff00000000ULL) >> 32);
00294
00295 return c.lo;
00296 }
00297 #endif
00298
00299 #endif