Hi I'm writing some interrupt processes.
I'm on Ubuntu 18.04 and using gcc -7.3.0.
Currently I use the following prefix and suffix to pack up my Interrupt Service Routine(without error code):
#define Ent_Int __asm__ __volatile__ ("\
pushq %rax\n\t\
movq %es, %rax\n\t\
pushq %rax\n\t\
movq %ds, %rax\n\t\
pushq %rax\n\t\
pushq %rbx\n\t\
pushq %rcx\n\t\
pushq %rdx\n\t\
pushq %rbp\n\t\
pushq %rdi\n\t\
pushq %rsi\n\t\
pushq %r8\n\t\
pushq %r9\n\t\
pushq %r10\n\t\
pushq %r11\n\t\
pushq %r12\n\t\
pushq %r13\n\t\
pushq %r14\n\t\
pushq %r15\n\t\
movq $0x10, %rdi\n\t\
movq %rdi, %es\n\t\
movq %rdi, %ds\n\t");
#define Ret_Int __asm__ __volatile__ ("\
popq %r15\n\t\
popq %r14\n\t\
popq %r13\n\t\
popq %r12\n\t\
popq %r11\n\t\
popq %r10\n\t\
popq %r9\n\t\
popq %r8\n\t\
popq %rsi\n\t\
popq %rdi\n\t\
popq %rbp\n\t\
popq %rdx\n\t\
popq %rcx\n\t\
popq %rbx\n\t\
popq %rax\n\t\
movq %rax, %ds\n\t\
popq %rax\n\t\
movq %rax, %es\n\t\
popq %rax\n\t\
leave\n\t\
iretq");
And the function looks like this:
void Div_Eorr(Int_Info_No_Err STK)
{
Ent_Int;
color_printk(RED,BLACK,"do_divide_error(0),ERROR_CODE:%#016lx,RSP:%#016lx,RIP:%#016lx\n", 0, STK.RSP, *((unsigned long *)(&STK)-1));
while(1);
Ret_Int;
}
However from OSDEV, I found that attribute((interrupt)) could make life easier.
However when I compile the function, there is an error message:
./OSFiles/Codes/INT.c:288:1: sorry, unimplemented: SSE instructions aren't allowed in interrupt service routine
However, there is no SSE instruction inside of the function. So I would like to ask:
1, How should I correctly compile the ISR
2, How would gcc distinguish INT with/without error code.
Would be really grateful if any one can illustrate what are the detailed differences of compiled assembly with or without interrupt attribute.