Page 2 of 2

Re:IRQ stop after multi-tasking

Posted: Sat Oct 01, 2005 6:09 pm
by GLneo
this is my stack struct:

Code: Select all

typedef struct stack_data
{
   unsigned int gs;
   unsigned int fs;
   unsigned int es;
   unsigned int ds;
   unsigned int edi;
   unsigned int esi;
   unsigned int ebp;
   unsigned int esp;
   unsigned int ebx;
   unsigned int edx;
   unsigned int ecx;
   unsigned int eax;
   unsigned int eip;
   unsigned int cs;
   unsigned int eflags;
}stack_data_t;
and this is my push and pop:

Code: Select all

_task_timer:
    pushad
    push ds
    push es
    push fs
    push gs
    mov ax, 0x10
    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax
;    cli
    push esp
    mov eax, _task_timer_c
    call eax
;    sti
    pop esp
    mov esp, eax
    pop gs
    pop fs
    pop es
    pop ds
    popad
    iret

Re:IRQ stop after multi-tasking

Posted: Sat Oct 01, 2005 7:33 pm
by Cjmovie

Code: Select all

_task_timer:
    pushad
    push ds
    push es
    push fs
    push gs
    mov ax, 0x10
    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax
;    cli
    push esp
    mov eax, _task_timer_c
    call eax
;    sti
    pop esp
    mov esp, eax
    pop gs
    pop fs
    pop es
    pop ds
    popad
    iret
Either I'm an idiot, or you're putting the address of _task_timer_c into esp....

Re:IRQ stop after multi-tasking

Posted: Sat Oct 01, 2005 7:57 pm
by GLneo
it looks that way but gcc should return value in EAX...hopefully :(

Re:IRQ stop after multi-tasking

Posted: Sun Oct 02, 2005 12:10 am
by Colonel Kernel
Cjmovie wrote:Either I'm an idiot, or you're putting the address of _task_timer_c into esp....
For those who missed the other thread... _task_timer_c returns the address of the stack to switch to, or the address of the current stack if no task switch should occur.

Re:IRQ stop after multi-tasking

Posted: Sun Oct 02, 2005 7:47 am
by GLneo
but how do i know it ends up in eax, is there a switch i can use???

Re:IRQ stop after multi-tasking

Posted: Sun Oct 02, 2005 8:03 am
by AR
GCC uses EAX as the return value, it's part of the calling convention.

Re:IRQ stop after multi-tasking

Posted: Mon Oct 03, 2005 5:54 am
by GLneo
well, like i sayed i can switch a few times like this:

Code: Select all

asm("int $33");
so i know it is not my switcher, and even when i do a test that prints sup and EOI and ret it stops after one???
ok here is the entier test:

Code: Select all

void tester()
{
     puts("sup");
     outport(0x20, 0x20);
}

Code: Select all

set_a_idt(32, (unsigned)tester, 0x08, 0x8E);

Code: Select all

void set_a_idt(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags)
{
    idt[num].base_lo = (base & 0xFFFF);
    idt[num].base_hi = (base >> 16) & 0xFFFF;
    idt[num].sel = sel;
    idt[num].always0 = 0;
    idt[num].flags = flags;
}
and that only works once, i know my IDT's are good

p.s. does the cpu push any values after a IRQ that could corupt my stack???

Re:IRQ stop after multi-tasking

Posted: Mon Oct 03, 2005 6:17 am
by AR
Try printing the hex value of EFLAGS in the ISR, look for 0x200 being off (Interrupts). What code does the CPU wait on, is there a CLI there?