Pergunta

I am a very newer on assembly language. Recently I'm trying to use assembly to control the timer of PowerPC Booke architecture. The content of control is to enable, disable and setTime to interrupt the CPU. I absolutely have no idea how to write these assembly language. Is there any PowerPC assembly expert who can help me or at least give me some hits?

Regards Sijia Li

Foi útil?

Solução

For any newbie in PowerPC assembly, I suggest a good approach is:

a. find out what are the basic opcodes:

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.aixassem/doc/alangref/ppc_instr.htm

b. Google for resources on PowerPC assembly samples:

http://www.ibm.com/developerworks/library/l-ppc/

http://www.csd.uwo.ca/~mburrel/stuff/ppc-asm.html

c. Download Linux kernel and go direct to the "arch/powerpc" subdirectory: this is where all the PowerPC hardware-specific logic in Linux kernel is implemented - majority in C and some in assembly. For example, the hardware logic for timer (as per your question) - starting from arch/powerpc subdirectory:

./include/asm/reg_booke.h:
#define SPRN_PIT    0x3DB   /* Programmable Interval Timer */
#define SPRN_TSR    0x150   /* Timer Status Register */
#define SPRN_TCR    0x154   /* Timer Control Register */
#define SPRN_TSR    0x3D8   /* Timer Status Register */
#define SPRN_TCR    0x3DA   /* Timer Control Register */
#define CCR1_TCS    0x00000080 /* Timer Clock Select */
#define DBCR0_FT    0x00000001  /* Freeze Timers on debug event */
#define DBCR0_FT    0x00000001  /* Freeze Timers on debug event */
#define DBCR_FT     0x00040000  /* Freeze Timers on Debug Event */

And for self-education, the comments fields are highly educational eg:

 include/asm/time.h:

 /* Accessor functions for the decrementer register.
 * The 4xx doesn't even have a decrementer.  I tried to use the
 * generic timer interrupt code, which seems OK, with the 4xx PIT
 * in auto-reload mode.  The problem is PIT stops counting when it
 * hits zero.  If it would wrap, we could use it just like a decrementer.
 */
static inline unsigned int get_dec(void)
{
#if defined(CONFIG_40x)
        return (mfspr(SPRN_PIT));
#else
        return (mfspr(SPRN_DEC));
#endif
}

/*
 * Note: Book E and 4xx processors differ from other PowerPC processors
 * in when the decrementer generates its interrupt: on the 1 to 0
 * transition for Book E/4xx, but on the 0 to -1 transition for others.
 */
static inline void set_dec(int val)
{

And the kernel source should have the source codes that meet your requirements of setting/enabling/disabling the timer.

d. Beginning to feel the technical difficulties? Then you will need to read up more technical notes, eg, Universities lectures notes related to PowerPC:

https://www.google.com.sg/search?q=powerpc+timer+filetype%3Appt

e. Datasheet related to PowerPC (mainly at Motorola/AMCC and Freescale website) should be your last choice, as they are highly technical and not easy to digest:

https://www.google.com.sg/search?q=powerpc+datasheet+site%3Afreescale.com

and in particular this is your BookE architecture user guide:

http://www.freescale.com/files/32bit/doc/user_guide/BOOK_EUM.pdf (timer concept covered in chap 8).

Have fun.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top