[Prev][Next][Index][Thread]

Re: How make an interrupt gate?



My guess is that the compiler is generating you a stack frame, involving
pushing %ebp onto the stack, and when you execute the 'iret', the stack
frame is not unwound, thus you are not using the correct return values. As
there are no local variables, compiling with -fomit-frame-pointer might
save the code, as %ebp will not be saved on the stack.

The GPF is because your code 'returns' to where %ebp is pointing, which is
probably not executable.

You're best off using a pure assembly based stub, or using the oskit
supplied ones.

Christian

--
    /"\
    \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL 
     X                           - AGAINST MS ATTACHMENTS
    / \

On Thu, 3 Feb 2000, Mohmod Taghizade wrote:

>hi every body,
>	I want to put a interrupt gate in IDT, I dont like using
>	oskit stub for it. I did it, 
>	but in interrupt hadnler after asm("iret"), i got a trap_dump
>	because of trap 13(#GPF).
>	whats the problem?
>regards,
>--taghi
>---------------------------------------- here is my source.
>#include <stdio.h>
>#include <oskit/machine/base_cpu.h>
>#include <oskit/x86/pmode.h>
>#include <oskit/x86/base_gdt.h>
>#include <oskit/x86/proc_reg.h>
>#include <oskit/x86/base_idt.h>
>#include <oskit/debug.h>
>#include <oskit/x86/pio.h>
>#include <oskit/x86/pc/pit.h>
>#include <oskit/x86/eflags.h>
>#include <oskit/x86/pc/base_irq.h>
>#include <oskit/x86/base_trap.h>
>#include <oskit/x86/trap.h>
>#include <oskit/clientos.h>
>	
>CODE32
>void delay(void) {
>	unsigned int i,j, k;
>	for (i = 0; i < 30000; ++i)
>		for (j = 0; j < 500; ++j)
>			k = k +1;
>}
>/*
>	interrupt hadnler.
>*/
>void timer(void)
>{
>	printf("in interrupt timer. \n");
>	outb(0x20, 0x20);
>/* &&&&&&&&&&&& I got a trap dump after running this instruction */B
>	asm ("iret");
>}
>
>void main (void) {
>	
>	oskit_clientos_init();
>
>	osenv_intr_disable();
>	base_gdt_init();
>	base_gdt_load();
>	base_idt_load();
>	base_irq_init();
>
>	fill_descriptor(&base_gdt[USER_CS / 8],
>			0x00000000, 0xffffffff,
>			ACC_PL_U | ACC_CODE_R, SZ_32);
>	fill_descriptor(&base_gdt[USER_DS / 8],
>			0x00000000, 0xffffffff,
>			ACC_PL_U | ACC_DATA_W, SZ_32);
>
>	fill_gate(&base_idt[32+ 0], (unsigned)timer, KERNEL_CS, 
>		ACC_INTR_GATE | ACC_PL_K, 0);
>
>	pit_init(100);
>
>	osenv_irq_enable(0);
>	osenv_intr_enable();   
>	while (1) {
>		delay();	
>		printf("Main program \n");
>	}
>	return;
>}
>	
>
>


References: