IRQ stop after multi-tasking

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
GLneo

Re:IRQ stop after multi-tasking

Post 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
Cjmovie

Re:IRQ stop after multi-tasking

Post 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....
GLneo

Re:IRQ stop after multi-tasking

Post by GLneo »

it looks that way but gcc should return value in EAX...hopefully :(
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:IRQ stop after multi-tasking

Post 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.
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
GLneo

Re:IRQ stop after multi-tasking

Post by GLneo »

but how do i know it ends up in eax, is there a switch i can use???
AR

Re:IRQ stop after multi-tasking

Post by AR »

GCC uses EAX as the return value, it's part of the calling convention.
GLneo

Re:IRQ stop after multi-tasking

Post 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???
AR

Re:IRQ stop after multi-tasking

Post 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?
Post Reply