now for some code:
asm switcher (where the problem is(I think))
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
mov eax, _running_stack
mov dword [eax], esp
push eax
call _task_timer_c
pop ebx
test ebx, eax
je noswitch
mov [_running_stack], ebx
cmp dword[ebx], 0x03
jne notss
mov ecx, [_TSS]
mov word [ecx+8], KERNEL_DATA_SEL
mov edx, [ebx+8]
add edx, 4096
mov dword[ecx+4], edx
notss:
mov esp, [ebx]
noswitch:
pop gs
pop fs
pop es
pop ds
popad
iretd
Code: Select all
void start_sys()
{
TSS = (struct tss *)malloc(sizeof(struct tss));
memset((void *)TSS, 0x00, sizeof(struct tss));
set_a_gdt(5, (unsigned int)TSS, sizeof(struct tss)-1, 0x89, 0x00);
ltr(KERNEL_TSS_SEG);
add_process(make_task("NOT_DOING_NOTHIN'_TASK", task0, 0));
running_stack = HEAD->stack;
add_process(make_task("task0", task0, 3));
add_process(make_task("task1", task1, 3));
}
Code: Select all
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;
};
struct tss
{
short backlink, __blh;
int esp0;
short ss0, __ss0h;
int esp1;
short ss1, __ss1h;
int esp2;
short ss2, __ss2h;
int cr3;
int eip;
int eflags;
int eax, ecx, edx, ebx;
int esp, ebp, esi, edi;
short es, __esh;
short cs, __csh;
short ss, __ssh;
short ds, __dsh;
short fs, __fsh;
short gs, __gsh;
short ldt, __ldth;
short trace, bitmap;
}__attribute__((packed));
struct task_data
{
int ring;
struct stack_data *stack;
unsigned int stack_base;
char name[33];
unsigned int ss;
unsigned int kstack;
unsigned int PID;
unsigned int P_PID;
unsigned int time;
unsigned int priority;
unsigned int state;
struct task_data *prev;
};