That looks very helpful Frank... rewriting that code was on my todo list anyway (i still have a few files in my OS that i didnt write from scratch, i'm rewriting them as i feel the need), so i guess it will just be placed at the top.
It seems so obvious now, thank you for explaining, i assumed that the EAX register would be saved as this is the default return register.. silly me =/
anyway, i'll rewrite my ISR routine when i get home, thanks again
inline assembly
Re: inline assembly
grrr still isnt working, can i run through my interpretation of this code? maybe i'm going wrong somewhere
this all seems to make sense, but whatever i do i get an EAX value of 5, and even setting EBX doesn't have an effect... i've spent a long time debugging this but i'm having mental block... it must be something simple, but i cant think what would be ruining this routine
Code: Select all
isr_common_stub:
pusha ; Pushes all registers to stack
mov ax, ds ; puts data segment into AX
push eax ; pushes AX to stack
mov ax, 0x10 ; puts kernel data segment into AX
mov ds, ax ; sets all segments to kernel segment
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp ; put stack pointer in eax
push esp ; push stack pointer to stack (argument for isr_handler)
call isr_handler
pop eax ; get rid of the default return value??
pop eax ; restore userland segment
mov ds, ax ; reassign this to the segment registers
mov es, ax
mov fs, ax
mov gs, ax
popa ; pop all registers (from stack pointer we modified)
add esp, 8 ; do some cleaning up
sti
iret
Re: inline assembly
Are you trying to set EAX by using inline assembly? That won't work because the isr stub restores all registers at the end before the IRET. You need to change the value of EAX by using
That edits the value of EAX on the stack so that when the ISR function returns the new value is poped into the EAX register.
Code: Select all
registers->eax = value;
Re: inline assembly
Code: Select all
__asm__ __volatile__ (" \
push %1; \
push %2; \
push %3; \
push %4; \
push %5; \
call *%6; \
pop %%ebx; \
pop %%ebx; \
pop %%ebx; \
pop %%ebx; \
pop %%ebx; "
: "=a" (ret)
: "r" (regs->edi), "r" (regs->esi), "r" (regs->edx), "r" (regs->ecx), "r" (regs->ebx), "r" (func_addr));
regs->eax = ret;
Re: inline assembly (well... syscalls) [SOLVED]
SOLVED!
i debugged a fair bit and got nowhere, so whilst playing with my code i decided to pass the memory location of the programs stack, and use a pointer to that. worked a charm.
thankyou to frank for the extensive help
i debugged a fair bit and got nowhere, so whilst playing with my code i decided to pass the memory location of the programs stack, and use a pointer to that. worked a charm.
thankyou to frank for the extensive help