Is it possible to call a C function in transfer_to_handler(arch/ppc/kernel/entry.S)?

Wang, Baojun wangbj at lzu.edu.cn
Mon May 28 19:30:35 EST 2007


hi, list

  I'm sorry to ask this topic in this mailling list. I've spend more than 2 
days try to add a C function call in transfer_to_handler(in 
arch/ppc/kernel/entry.S) like this:

/* cut from arch/ppc/kernel/entry.S */
transfer_to_handler:
        stw     r2,GPR2(r11)
        stw     r12,_NIP(r11)
        stw     r9,_MSR(r11)
        andi.   r2,r9,MSR_PR
        mfctr   r12
        mfspr   r2,SPRN_XER
        stw     r12,_CTR(r11)
        stw     r2,_XER(r11)
        mfspr   r12,SPRN_SPRG3
        addi    r2,r12,-THREAD
        tovirt(r2,r2)                   /* set r2 to current */
        beq     2f                      /* if from user, fix up THREAD.regs */
#if 1	/* this is add by me */
        stwu    r1, -16(r1)
        mflr    r0
        stw     r0, 20(r1)
        bl      emulate_iret
        lwz     r0, 20(r1)
        mtlr    r0
        addi    r1, r1, 16
#endif
        addi    r11,r1,STACK_FRAME_OVERHEAD
        stw     r11,PT_REGS(r12)


The function prolog is taken from a userspace program. this code freeze the 
system after prints out `emulate_iret' (The only thing function emulate_iret 
do is print that message). 

I read the source code from head_44x.S to entry.S, sounds like all registers 
(r0-r32, and even more such as _LINK, _CTR, etc..) are being saved, does that 
mean I shouldn't call any C function in transfer_to_handler()? Is there 
something tricky (or is it possible) to add a C function call? 

Thanks in advance!

regards

-- 
Wang, Baojun                                        Lanzhou University
Distributed & Embedded System Lab              http://dslab.lzu.edu.cn
School of Information Science and Engeneering        wangbj at lzu.edu.cn
Tianshui South Road 222. Lanzhou 730000                     .P.R.China
Tel:+86-931-8912025                                Fax:+86-931-8912022
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20070528/ed6add78/attachment.pgp>


More information about the Linuxppc-dev mailing list