RE: Switch from User space to Kernel space.

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

 



The inline assembley code is
making a system call ( int $0x80)
passing system call number (__NR_##name) and argument( arg1) it requires.
The value returned from the system call is obtained in __res variable
a and b denotes eax and ebx registers respectively.
Basically the inline assembly format is like
    asm ( assembler template
              : output operands
              : input operands);
 
 
regards
sanjay
-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx [mailto:kernelnewbies-bounce@xxxxxxxxxxxx]On Behalf Of Dhiman, Gaurav
Sent: Monday, July 26, 2004 10:10 PM
To: kernelnewbies@xxxxxxxxxxxx
Subject: Switch from User space to Kernel space.

 

Can any one tell me what’s going on in following code (esp code in RED color) ?

 

#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
        long __res; \
   &!
nbsp;    __asm__ volatile ("int $0x80" \
        : "=a" (__res) \
        : "" (__NR_##name),"b" ((long)(arg1))); \
        __syscall_return(type,__res); \
}

 

This has been taken from ‘unistd.h’ file in kernel sources. It’s a code which actually creates a stub, so that user process can make a call to system call.

 

My question is for having an access this code (macro) user process or library function used by user program must include this file (‘unistd.h’). Is it like this that this file is included by a library or user program which makes a call to system call. Actually it is the first time that I am studying about how the control switches from user space to kernel space. I want to know exact code which make this switch. I think that its this stub only which allow the control to switch from user space to kernel space.

 

One more thing, Please let me know what does the code in RED color is doing. Its an assembly code, please explain it.

 

Regards,

Gaurav

 



Disclaimer:


This message and any attachment(s) contained here are information that is confidential,proprietary to HCL Technologies and its customers, privileged or otherwise protected by law.The information is solely intended for the individual or the entity it is addressed to. If you are not the intended recipient of this message, you are not authorized to read, forward, print,retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.




[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