#include <const.h>
#include <arch/i386.h>
#include <arch/mem.h>
#include <kernel/console.h>
#include <kernel/keyboard.h>
#include <kernel/kernel.h>
#include <kernel/speaker.h>
#include <kernel/task.h>
#include <kernel/umalloc.h>
#include <kernel/syscall.h>
Go to the source code of this file.
Data Structures | |||||
struct | syscall_t | ||||
System call entry. More... | |||||
Defines | |||||
#define | SYS_CALL_NR ( sizeof(syscall_table)/sizeof(dword) ) | ||||
Total amount of system calls. | |||||
Typedefs | |||||
typedef syscall_t | syscall_t | ||||
System call entry. | |||||
Functions | |||||
void | syscall_handler (dword *eax, dword *ebp) | ||||
This procedure execute every system call invoked by INT 0x80.
| |||||
Variables | |||||
syscall_t | syscall_table [] | ||||
This is the array of the known system calls. |
Definition in file syscall.c.
|
Total amount of system calls.
|
|
System call entry.
|
|
This procedure execute every system call invoked by INT 0x80.
Copy the stack parameters from the stack pointer of the calling procedure (pointed by Definition at line 60 of file syscall.c.
00061 { 00062 // Function pointer. 00063 size_t (*p)() = (void *)syscall_table[*eax].address; 00064 // How many parameters. 00065 int paramcnt = syscall_table[*eax].paramcnt; 00066 // Start of parameters'address. 00067 size_t *args = (size_t *)(*ebp); 00068 00069 register int i; 00070 00071 // Check if the system call id does not exceed the syscall table. 00072 // NOTE: sycall id is 0-based!!! 00073 if ( *eax < SYS_CALL_NR ) 00074 { 00075 // Pass the parameters to the system call routine. 00076 for( i=paramcnt; i; --i) 00077 __asm__ __volatile__ ("pushl %0" : : "r"(*(args+i-1))); 00078 // Execute the system call. 00079 // The result will be returned into the task's eax register. 00080 *eax = (*p)(); 00081 // Pop elements out of the stack. 00082 __asm__ __volatile__ ("add %0, %%esp" : : "r"(paramcnt*sizeof(size_t))); 00083 } 00084 else 00085 { 00086 // Invalid syscall id! => kill the task. 00087 kprintf("\n\rsyscall: %u", *eax); 00088 error("Invalid system call"); 00089 } 00090 } |
|
Initial value: { { (size_t)&auto_kill, 1 }, { (size_t)&kgetchar, 0 }, { (size_t)&kputchar, 1 }, { (size_t)&keyb_read, 0 }, { (size_t)&umalloc, 1 }, { (size_t)&ufree, 1 }, }
|