From: "Wang, Baojun" <wangbj@dslab.lzu.edu.cn>
To: Chetan Nanda <chetannanda@gmail.com>, linux-mips@linux-mips.org
Subject: Re: understanding head.S
Date: Thu, 05 Jun 2008 19:15:24 +0800 [thread overview]
Message-ID: <1212664525.24330.22.camel@localhost.dslab> (raw)
In-Reply-To: <7f245da80806050302m6b449e6m1f84dc7ef7efff46@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]
在 2008-06-05四的 15:32 +0530,Chetan Nanda写道:
> Hi All,
> I was reading the boot code for MIPS.
> in head.S file before jumping to 'start_kernel' it calculate the stack
> pointer address as follow:
>
> "
> PTR_LA $28, init_thread_union
> PTR_ADDIU sp, $28, _THREAD_SIZE - 32
make sp point to the stack top so that we can allocate stack space
later, -32 is a reserved area for local variable, saved GPR, arguments
(function stack frame).. due to the abi
> set_saved_sp sp, t0, t1
set_saved_sp is defined (as a assembler macro) in
include/asm-mips/stackframe.h (if you're using vim, I think it will be
easy to use vim with cscope..)
> PTR_SUBU sp, 4 * SZREG # init stack pointer
SZREG is defined to the general purpose register size, it is 32bit in
MIPS32 and 64bit in MIPS64, so the last line allocates 16/32 bytes to
build a stack frame.. You could refer to the MIPS ABI if you need
further information (the kernel don't follow the standard ABI all the
time though..)
>
> Can anyone please explains me this 4 lines of code?
> Why ' _THREAD_SIZE - 32' is added in 'sp' ?
> What 'set_saved_sp' will do ?
> and then why we subtract '4 * SZREG' from 'sp' ?
>
> Please hep me to understand this code better.
>
> Thanks,
> Chetan Nanda
>
--
Wang, Baojun Lanzhou University
Distributed & Embedded System Lab http://dslab.lzu.edu.cn
School of Information Science and Engeneering wangbj@dslab.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: 197 bytes --]
next prev parent reply other threads:[~2008-06-05 11:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-05 10:02 understanding head.S Chetan Nanda
2008-06-05 11:15 ` Wang, Baojun [this message]
2008-06-06 1:24 ` David VomLehn
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=1212664525.24330.22.camel@localhost.dslab \
--to=wangbj@dslab.lzu.edu.cn \
--cc=chetannanda@gmail.com \
--cc=linux-mips@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.