This is the main handler:
Code: Select all
void syscall(struct regs *r)
{
int opcode = r->eax;
int operand1 = r->ebx;
int operand2 = r->ecx;
switch(opcode)
{
case SYSCALL_PUTCHAR: // 1
putch(operand1);
break;
case SYSCALL_REBOOT:
raise_signal(SIGNAL_DOREBOOT);
break;
case SYSCALL_MORE_MEMORY:
{
ptr_t *ret_addr = (ptr_t*)((void*)operand2);
*ret_addr = (ptr_t)sbrk(operand1);
}
break;
default:
break;
}
}
Code: Select all
void make_syscall(int syscall_code, int param1, int param2)
{
__asm__ __volatile__ ("movl %0,%%eax" : : "m" (syscall_code));
__asm__ __volatile__ ("movl %0,%%ebx" : : "m" (param1));
__asm__ __volatile__ ("movl %0,%%ecx" : : "m" (param2));
__asm__ __volatile__ ("int $0x80");
}
Code: Select all
void putchar(char c)
{
make_syscall(1,c,0);
}
Code: Select all
void putchar(char c)
{
putch(c);
make_syscall(1,c,0);
}
Does anyone have any idea about this problem?
Thanks a lot,
Enrico[/code]