About the system Call

28 views
Skip to first unread message

daniel.tian

unread,
Nov 1, 2011, 3:22:26 AM11/1/11
to MV5sim
Hi, guys:
I have some questions about how the syscalls are emulated.
Here is the piece of code from the asm_api.h

unsigned long asm_callsys(unsigned long callnum, unsigned long arg0,
unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned
long arg4)
{
unsigned long retval;
/*
asm volatile( "mov %0, $0\n\t"
".byte 0x60, 0x00, 0x00, 0x04\n\t"
"mov $0, %1\n\t"
:"r="(retval)
:"r"(arg2)
);
*/
asm volatile( ".byte 0x60, 0x00, 0x00, 0x04\n\t"
"mov $0, %0\n\t"
:"r="(retval)
:
);
return retval;
}

ulong asm_get_kernel_handler(ulong contextID)
{
ulong val;
asm volatile( ".byte 0x6a, 0x00, 0x00, 0x04\n\t"
"mov $0, %0\n\t"
:"r="(val)
:
);
return val;
}

What does the "".byte 0x6a, 0x00, 0x00, 0x04\n\t"" mean?

I don't quite understand how the M5/MV5 handle the syscall callback.

Any suggestion is appreciated.

Thanks.
Daniel

Jiayuan Meng

unread,
Nov 1, 2011, 11:38:27 AM11/1/11
to mv5...@googlegroups.com
These bytecodes will reside in the binary file. When the benchmark is
executed by the simulator, the bytecode is interpreted by
src/arch/alpha/isa/decoder.isa. Some bytecodes are "nops" in the
original ISA and is now used by the simulator as "pseudo"
instructions. We can define a pseudo instruction so that it triggers
system calls.

For more details on how the system call is triggered, see slides 29-31
in fractal_lookinside.ppt in
https://sites.google.com/site/mv5sim/file-cabinet. Here we define a
pseudo instruction for triggering system calls, and we can pass the
system call number to specify which system call to trigger. The call
number is the index to the system call table, which is basically a
table of function pointers in the simulator.

Please let me know if you have further questions.

Jiayuan

daniel tian

unread,
Nov 1, 2011, 2:13:14 PM11/1/11
to mv5...@googlegroups.com
Thank you very much.
Reply all
Reply to author
Forward
0 new messages