Page 3 of 3

Posted: Fri Mar 28, 2008 12:27 pm
by Pyrofan1
even after adding that code it still doesn't work. As far as i can tell the interrupt is only firing onces
my interrupt handling code

Code: Select all

.type irq0,@function
irq0:
call timer_handler
push $0
push $0
pusha
mov %ds, %eax
push %eax
mov %es, %eax
push %eax
mov %fs, %eax
push %eax
mov %gs, %eax
push %eax
mov %esp, %eax
push %eax
call switch_tasks
mov %eax, %esp
mov $0x20, %al
out %al, $0x20 
pop %eax

pop %eax
pop %eax
pop %eax
pop %eax
popa
add $8, %esp
sti
iret
my timer_handler function

Code: Select all

void timer_handler(void)
{
	ticks++;
	Printf("timer handler\n");
	update_time();
	update_cursor();
}
and my tasking code

Code: Select all

unsigned int switch_tasks(struct REGS *r)
{
	Printf("Task switcher\n");
	if(current_task==MAX_TASKS) current_task=0;

	if(tasks[current_task++].status!=0)
	{
		tasks[current_task].r->eax=r->eax;
		tasks[current_task].r->ebx=r->ebx;
		tasks[current_task].r->ecx=r->ecx;
		tasks[current_task].r->edx=r->edx;
		tasks[current_task].r->esi=r->esi;
		tasks[current_task].r->edi=r->edi;
		tasks[current_task].r->esp=r->esp;
		tasks[current_task].r->ebp=r->ebp;
		tasks[current_task].r->ss=r->ss;
		tasks[current_task].r->cs=r->cs;
		tasks[current_task].r->es=r->es;
		tasks[current_task].r->ds=r->ds;
		tasks[current_task].r->fs=r->fs;
		tasks[current_task].r->gs=r->gs;
		tasks[current_task].r->eip=r->eip;
		tasks[current_task].r->eflags=r->eflags;
		tasks[current_task].r->int_no=r->int_no;
		tasks[current_task].r->err_code=r->err_code;

		current_task++;
	}
	else
	{
		tasks[current_task].r->eax=r->eax;
		tasks[current_task].r->ebx=r->ebx;
		tasks[current_task].r->ecx=r->ecx;
		tasks[current_task].r->edx=r->edx;
		tasks[current_task].r->esi=r->esi;
		tasks[current_task].r->edi=r->edi;
		tasks[current_task].r->esp=r->esp;
		tasks[current_task].r->ebp=r->ebp;
		tasks[current_task].r->ss=r->ss;
		tasks[current_task].r->cs=r->cs;
		tasks[current_task].r->es=r->es;
		tasks[current_task].r->ds=r->ds;
		tasks[current_task].r->fs=r->fs;
		tasks[current_task].r->gs=r->gs;
		tasks[current_task].r->eip=r->eip;
		tasks[current_task].r->eflags=r->eflags;
		tasks[current_task].r->int_no=r->int_no;
		tasks[current_task].r->err_code=r->err_code;

		current_task++;
		while(tasks[current_task].status==0)
		{
			if(current_task==MAX_TASKS) current_task=0;
			else current_task++;
		}

		
	}
	return tasks[current_task].stack;
}

Posted: Fri Mar 28, 2008 1:18 pm
by t0xic
do you have stack setup code anywhere? That is not a proper stack.
Just one field.
*--stack = ...;
*--stack = ...;

tasks[0].stack = stack;
and just do that for every switch. Just scrap your code, use the tutorial code, and modify it from the working model.

Posted: Sun Mar 30, 2008 3:51 am
by Combuster
how about that function call from an interrupt without saving the registers first? :shock: