[Prev][Next][Index][Thread]
Re: Problems coding a scheduler
I don't know what else you might have done wrong but this certainly won't
work more than once. You need some kind of assembly language prolog and
epilog to save and restore the CPU registers. I have include the code I
use below, it saves the general purpose registers ("pusha"), then the
segment registers, loads the correct selector for kernel mode into the
segment registers and then calls a generalized interrupt dispatcher. The
epilog sends an EOI to the PIC (actually in KiInterruptDispatch) and
restores the registers saved in the prolog.
VOID KiInterruptDispatch(ULONG irq)
{
....
outb(0x20,0x20);
if (irq >= 8)
{
outb(0xa0,0x20);
}
}
#define IRQ_HANDLER_FIRST(x,y) \
void irq_handler_##y (void); \
__asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \
"pusha\n\t" \
"pushl %ds\n\t" \
"pushl %es\n\t" \
"movw $"STR(KERNEL_DS)",%ax\n\t" \
"movw %ax,%ds\n\t" \
"movw %ax,%es\n\t" \
"pushl $"##x"\n\t" \
"call _KiInterruptDispatch\n\t"\
"popl %eax\n\t" \
"popl %es\n\t" \
"popl %ds\n\t" \
"popa\n\t" \
"iret\n\t")
IRQ_HANDLER_FIRST ("0",0);
IRQ_HANDLER_FIRST ("1",1);
IRQ_HANDLER_FIRST ("2",2);
IRQ_HANDLER_FIRST ("3",3);
IRQ_HANDLER_FIRST ("4",4);
IRQ_HANDLER_FIRST ("5",5);
IRQ_HANDLER_FIRST ("6",6);
IRQ_HANDLER_FIRST ("7",7);
On Sat, Apr 10, 1999 at 10:46:11AM +0100, Imobac Exposito (alu1360)-Vicente Cruz (alu1345) - Fresnadillo Perez (alu1364) wrote:
> void scheduler(void){
>
> printf("Scheduling...\n");
> asm("iret");
> }
>
References:
- Problems coding a scheduler
- From: "Imobac Exposito (alu1360)-Vicente Cruz (alu1345) - Fresnadillo Perez (alu1364)" <mkernel@csi.ull.es>