![]() This routine basically does some error checking on the value of the NR_identifier, it then looks up the address in _sys_call_table and transfers execution to that address.Ĭontrol transfers to the function set up previously as the handler for the particular system call. Orl $(CF_MASK),EFLAGS(%esp) # set carry to indicate error Movl %eax,EAX(%esp) # save the return value Movl %edx,dbgreg6(%ebx) # save current hardware debugging status Specifically, control goes to the _system_call() function defined in linux/arch/i386/entry.S:Īndl $~CF_MASK,EFLAGS(%esp) # clear carry - assume no errors Currently there are 140 (as of 1.2.13) system calls in Linux with the ability to handle 256. The kernel file linux/include/linux/unistd.h file contains definitions of the unique identifiaction values for each call. This call basically sets up the stack to pass the parameters. ![]() The processor is still in user mode at this point. This macro expands to create the full assembly call of the system call. #define _syscall1(type,name,type1,arg1) \ For chdir(), the call with 1 argument is used: There is a macro defined for each possible number of arguments to the system call (generally). This is a generic name referring to one of several macros defined in include/asm/unistd.h. The library call results in a call to the syscallX macro. #define function_alias(name, _name, type, args, defun) \Īsm(".stabs \"" "_" #alias "\",11,0,0,0\n"\Īll these macros do is match the symbols with those used in the call to syscallX. The function_alias() call is an assembler macro defined in /usr/include/gnu-stabs.h: The source for this call is contained in libc/io/chdir.c:įunction_alias(chdir, _chdir, int, (path), This call to chdir() links to the compiled library libc. The user program calls the function as listed in the man pages. We will use the chdir() system call as an example.Ĭhdir changes the current directory to that specified in It will give insight into adding a system call to the kernel. This will be a walk through the entire system call process. Sched_init() (in linux/kernel/sched.c) sets up the vector 0x80Ĭall to the macro set_system_gate (0x80, &system _call). This function sets up the interrupt vector with the addresses of the handler When the kernel is set up enough (see bootup procedures) With enough space for jump addresses for all the system calls (256). Linux uses exception 0x80 (instruction: int 80)for system calls. This means that the user can set the location of exceptionsģ3-255. Many exceptions are called maskable interrupts or programmedĮxceptions. To a location defined in the interrupt vector. The x86 has four execution modes: ring0 through ring3. divide by zero) or by a thrown exception. These force a context switch.Įxceptions are software interrupts. The x86 processors have two mechanisms for interrupting the execution return from system call ( ret_from_sys_call ).transfer control to system call function (through lookup in _sys_call_table).The Wayback Machine - Linux System Calls Quick Overview
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |