Re: Kernel stack....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 10 Sep 2001, Raghava Raju wrote:

> 
> 
> Hi,
> 
>       1) I want to know what exactly is the structure
> of kernel stack. Is it some thing like bss,data,text?
> 
>       2) I want to access kernel stack(in kernel
> mode). So I am using  kernel stack pointer provided in
> thread_struct. So how to access different areas(.i.e 
> data,text)  in kernel stack.
> 
> 
>        Any pointers will be helpful.
> 
>    Please mail me as I did't subscribe.
>    vraghava_raju@yahoo.com
> 
>      Thank you.
>      Raj. 

I am assuming that you want to know how parameters loaded on the
stack are passed to called procedures, i.e., the offset. I assume
that you know that the kernel stack is just like a user stack and
you don't actually manipulate it directly.

Given:
	procedure(one, two, three);
where one, two, and three are values of any size up to the length
of a register..

The called procedure gets the values as:

	0x04(%esp) = one
	0x08(%esp) = two
	0x0c(%esp) = three

If, and only if, no registers are saved on the called procedure's
stack. If some register(s) have been saved, the parameters are
offset by the length of the register(s)...

proc:	pushl	%ebx
	pushl	%ecx
	pushl	%edx
	pushl	%edi			# 4 * 4 = 0ffset 16
	movl	0x14(%esp), %ebx	# One
	movl	0x18(%esp), %ecx	# Two
	movl	0x1c(%esp), %edx	# Three


Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

    I was going to compile a list of innovations that could be
    attributed to Microsoft. Once I realized that Ctrl-Alt-Del
    was handled in the BIOS, I found that there aren't any.


-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux