Problem passing arguments from asm to C code...
Posted: Fri Feb 13, 2004 12:00 am
Hey, I have a bit of a problem with my asm interrupt handler entry point calling the c function and passing it appropriate values.
I thought I was doing it just fine... each entry pushes a 0, and then a int number (unless there should be an error code) But it pushes these and then jumps to a point in the asm code which cli's and then calls the c function.
Using simics, I have a copy of the stack as it stands, after doing a keyboard interrupt. (Keep in mind this is AMD64 code, all stack pushs/pops are 64-bit)
rsp = 0x80000f88
rbp = 0x80000fa8
showing from 0x80000f88 and going up
0x10175b <- Return Address 0x80000f88
0x80000ff8 <- Stack Pointer 0x80000f90
0x1a <- ?? 0x80000f98
0 <- ?? 0x80000fa0
0x80000ff8 <- Stack Pointer 0x80000fa8
0x102222 <- ?? Some Address 0x80000fb0
0x21 <- The Number I want 0x80000fb8
0 <- The Error Code 0x80000fc0
Okay, my int handler entry point looks like this:
ioapic_01:
pushq $0x0
pushq $0x21
jmp asm_int_handler
The generic function for all interrupts
-------------------------------------------
asm_int_handler:
cli
call interrupt_handler
sti
iretq
interrupt_handler looks like this
------------------------------------------
void interrupt_handler(unsigned long error_code, unsigned long interrupt_number)
{
unsigned long cr2_value;
asm("hlt");
// Other code that doesn't matter right now
All I want is to get the correct info..
Any ideas?
Thanks in advance
I thought I was doing it just fine... each entry pushes a 0, and then a int number (unless there should be an error code) But it pushes these and then jumps to a point in the asm code which cli's and then calls the c function.
Using simics, I have a copy of the stack as it stands, after doing a keyboard interrupt. (Keep in mind this is AMD64 code, all stack pushs/pops are 64-bit)
rsp = 0x80000f88
rbp = 0x80000fa8
showing from 0x80000f88 and going up
0x10175b <- Return Address 0x80000f88
0x80000ff8 <- Stack Pointer 0x80000f90
0x1a <- ?? 0x80000f98
0 <- ?? 0x80000fa0
0x80000ff8 <- Stack Pointer 0x80000fa8
0x102222 <- ?? Some Address 0x80000fb0
0x21 <- The Number I want 0x80000fb8
0 <- The Error Code 0x80000fc0
Okay, my int handler entry point looks like this:
ioapic_01:
pushq $0x0
pushq $0x21
jmp asm_int_handler
The generic function for all interrupts
-------------------------------------------
asm_int_handler:
cli
call interrupt_handler
sti
iretq
interrupt_handler looks like this
------------------------------------------
void interrupt_handler(unsigned long error_code, unsigned long interrupt_number)
{
unsigned long cr2_value;
asm("hlt");
// Other code that doesn't matter right now
All I want is to get the correct info..
Any ideas?
Thanks in advance