hw_x86_64: Add syscall helper macros

The macros are used to assign syscall arguments to specific registers.
Using the AMD64 parameter passing convention avoids additional copying of
variables since the C++ function parameters are already in the right
registers.
This commit is contained in:
Adrian-Ken Rueegsegger 2015-02-20 10:34:53 +01:00 committed by Christian Helmuth
parent 3e779e3ca1
commit 04ad1340d5
1 changed files with 32 additions and 0 deletions

View File

@ -17,6 +17,38 @@
using namespace Kernel;
/************************************
** Helper macros for kernel calls **
************************************/
/**
* Assign argument registers according to AMD64 parameter passing
* convention to avoid additional register copy operations.
*/
#define CALL_1_FILL_ARG_REGS \
register Call_arg arg_0_reg asm("rdi") = arg_0;
#define CALL_2_FILL_ARG_REGS \
CALL_1_FILL_ARG_REGS \
register Call_arg arg_1_reg asm("rsi") = arg_1;
#define CALL_3_FILL_ARG_REGS \
CALL_2_FILL_ARG_REGS \
register Call_arg arg_2_reg asm("rdx") = arg_2;
#define CALL_4_FILL_ARG_REGS \
CALL_3_FILL_ARG_REGS \
register Call_arg arg_3_reg asm("rcx") = arg_3;
#define CALL_5_FILL_ARG_REGS \
CALL_4_FILL_ARG_REGS \
register Call_arg arg_4_reg asm("r8") = arg_4;
#define CALL_6_FILL_ARG_REGS \
CALL_5_FILL_ARG_REGS \
register Call_arg arg_5_reg asm("r9") = arg_5;
/******************
** Kernel calls **