anytime try to get return value its wrong.
most of this is based on a tutorial for the same in 32bit (im using 64bit) dont remember where i found it but it worked fine when i was working with 32 bits
this is the function called from user app to use syscall:
Code: Select all
#define DEFN_SYSCALL1(fn, num, P1) \
uint64_t fn(P1 p1) \
{ \
uint64_t a; \
asm volatile("int $0x80" : "=a" (a) : "D" (num), "S" ((uint64_t)p1)); \
return a; \
}
Code: Select all
void syscall_handler(registers_t reg)
{
if (reg.rdi >= num_syscalls)
return;
void *location = syscalls[reg.rdi];
asm volatile (" \
mov %1, %%r8; \
mov %2, %%rcx; \
mov %3, %%rdx; \
mov %4, %%rsi; \
mov %5, %%rdi; \
call *%6; \
" : "=a" (reg.rax) : "r" (reg.r9), "r" (reg.r8), "r" (reg.rcx), "r" (reg.rdx), "r" (reg.rsi), "r" (location));
}
this just creates a syscall with desired function name
DEFN_SYSCALL1(sys_get_pages, 11, const char*);
then this should get a pointer to a block of memory but always gets 0xB (should be around 0x600000)
void *mem = sys_get_pages(16);
sorry if its really obvious but iv been fighting with this for months
and if you need any other code ill be glad to post it
also not sure if this matters but using qemu for testing