linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Wang, Baojun" <wangbj@lzu.edu.cn>
To: ppc-dev <linuxppc-dev@ozlabs.org>
Cc: Nicholas McGuire <der.herr@hofr.at>
Subject: Is it possible to call a C function in transfer_to_handler(arch/ppc/kernel/entry.S)?
Date: Mon, 28 May 2007 17:30:35 +0800	[thread overview]
Message-ID: <380406375.32007@eyou.net> (raw)
Message-ID: <200705281730.39257.wangbj@lzu.edu.cn> (raw)

[-- Attachment #1: Type: text/plain, Size: 1885 bytes --]

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@lzu.edu.cn
Tianshui South Road 222. Lanzhou 730000                     .P.R.China
Tel:+86-931-8912025                                Fax:+86-931-8912022

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2007-05-28  9:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200705281730.39257.wangbj@lzu.edu.cn>
2007-05-28  9:30 ` Wang, Baojun [this message]
2007-05-28 15:25   ` Is it possible to call a C function in transfer_to_handler(arch/ppc/kernel/entry.S)? Nicholas Mc Guire
2007-05-28 11:28 ` Paul Mackerras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=380406375.32007@eyou.net \
    --to=wangbj@lzu.edu.cn \
    --cc=der.herr@hofr.at \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).