This Presentation for start_printf#5 at 2014/02/23.
It describes some kernel walk throw guide of Xsyscall/syscall/sys_write source code of NetBSD6.0.1.
https://github.com/start-printf/wiki/wiki.
35. syscallの呼び出し
sys/arch/i386/include/frameasm.h 67~
/*
* These are used on interrupt or trap entry or exit.
*/
#define INTRENTRY ¥
subl $TF_PUSHSIZE,%esp ; ¥ offsetof(struct trapframe, tf_trapno) "sys/arch/i386/i386/genassym.cf"
…
sys/arch/i386/i386/locore.S 67~
IDTVEC(syscall)
…
pushl %sp
call *P_MD_SYSCALL(%edx) # get pointer to syscall() function
…
・INTRENTRYでレジスタをスタックに格納し、引数trapframeを作成して
syscall()関数を呼び出しています。
36. syscallの引数(writeの場合)
sys/arch/i386/include/frame.h 76~
/*
* Exception/Trap Stack Frame
*/
struct trapframe {
uint16_t tf_gs;
uint16_t tf_gs_pad;
uint16_t tf_fs;
uint16_t tf_fs_pad;
uint16_t tf_es;
uint16_t tf_es_pad;
uint16_t tf_ds;
uint16_t tf_ds_pad;
int tf_edi;
int tf_esi;
int tf_ebp;
int tf_ebx;
int tf_edx;
int tf_ecx;
int tf_eax; == 4
int tf_trapno;
/* below portion defined in 386 hardware */
int tf_err;
int tf_eip;
int tf_cs;
int tf_eflags;
/* below used when transitting rings (e.g. user to kernel) */
int tf_esp;
int tf_ss;
/* below used when switching out of VM86 mode */
int tf_vm86_es;
int tf_vm86_ds;
int tf_vm86_fs;
int tf_vm86_gs;
};