2005-09-07 14:59:48 -06:00
|
|
|
#ifndef _ASM_POWERPC_TIMEX_H
|
|
|
|
#define _ASM_POWERPC_TIMEX_H
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2005-09-07 14:59:48 -06:00
|
|
|
* PowerPC architecture timex specifications
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/cputable.h>
|
2006-10-19 22:37:05 -06:00
|
|
|
#include <asm/reg.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-10-11 19:39:33 -06:00
|
|
|
#define CLOCK_TICK_RATE 1024000 /* Underlying HZ */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
typedef unsigned long cycles_t;
|
|
|
|
|
|
|
|
static inline cycles_t get_cycles(void)
|
|
|
|
{
|
2005-09-07 14:59:48 -06:00
|
|
|
#ifdef __powerpc64__
|
2006-10-19 22:37:05 -06:00
|
|
|
return mftb();
|
2005-09-07 14:59:48 -06:00
|
|
|
#else
|
2006-10-19 22:37:05 -06:00
|
|
|
cycles_t ret;
|
|
|
|
|
2005-09-07 14:59:48 -06:00
|
|
|
/*
|
|
|
|
* For the "cycle" counter we use the timebase lower half.
|
|
|
|
* Currently only used on SMP.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ret = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
__asm__ __volatile__(
|
2006-10-19 19:47:18 -06:00
|
|
|
"97: mftb %0\n"
|
2005-04-16 16:20:36 -06:00
|
|
|
"99:\n"
|
|
|
|
".section __ftr_fixup,\"a\"\n"
|
2006-10-19 19:47:18 -06:00
|
|
|
".align 2\n"
|
|
|
|
"98:\n"
|
2005-04-16 16:20:36 -06:00
|
|
|
" .long %1\n"
|
|
|
|
" .long 0\n"
|
2006-10-19 19:47:18 -06:00
|
|
|
" .long 97b-98b\n"
|
|
|
|
" .long 99b-98b\n"
|
powerpc: Introduce infrastructure for feature sections with alternatives
The current feature section logic only supports nop'ing out code, this means
if you want to choose at runtime between instruction sequences, one or both
cases will have to execute the nop'ed out contents of the other section, eg:
BEGIN_FTR_SECTION
or 1,1,1
END_FTR_SECTION_IFSET(FOO)
BEGIN_FTR_SECTION
or 2,2,2
END_FTR_SECTION_IFCLR(FOO)
and the resulting code will be either,
or 1,1,1
nop
or,
nop
or 2,2,2
For small code segments this is fine, but for larger code blocks and in
performance criticial code segments, it would be nice to avoid the nops.
This commit starts to implement logic to allow the following:
BEGIN_FTR_SECTION
or 1,1,1
FTR_SECTION_ELSE
or 2,2,2
ALT_FTR_SECTION_END_IFSET(FOO)
and the resulting code will be:
or 1,1,1
or,
or 2,2,2
We achieve this by extending the existing FTR macros. The current feature
section semantic just becomes a special case, ie. if the else case is empty
we nop out the default case.
The key limitation is that the size of the else case must be less than or
equal to the size of the default case. If the else case is smaller the
remainder of the section is nop'ed.
We let the linker put the else case code in with the rest of the text,
so that relative branches from the else case are more likley to link,
this has the disadvantage that we can't free the unused else cases.
This commit introduces the required macro and linker script changes, but
does not enable the patching of the alternative sections.
We also need to update two hand-made section entries in reg.h and timex.h
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-06-23 19:32:54 -06:00
|
|
|
" .long 0\n"
|
|
|
|
" .long 0\n"
|
2005-04-16 16:20:36 -06:00
|
|
|
".previous"
|
|
|
|
: "=r" (ret) : "i" (CPU_FTR_601));
|
|
|
|
return ret;
|
2006-10-19 22:37:05 -06:00
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-09-07 14:59:48 -06:00
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* _ASM_POWERPC_TIMEX_H */
|