Page 1 of 1
first task enabling question
Posted: Wed May 27, 2009 4:36 am
by kop99
Hi, everybody...
I'm trying to implement of multitasking now.
And I already read intel manuals and searched a lot of OSDev post.
So I have a little picture of multitasking.
But I have some question.
if after all initializing(gdt, idt, pm, page, etc), I load valid tss using "ltr" asm command,
then first task was starting that point?
And if anyone know the url or source code about first task enabling and software multitasking, please let me know.....
Thanks for your reguards
Re: first task enabling question
Posted: Wed May 27, 2009 8:57 am
by Combuster
Define "first task", then know the answer
Re: first task enabling question
Posted: Wed May 27, 2009 7:13 pm
by kop99
If I want to enable the single task or multitasking, the first thing is maybe the initialization of tss.
Then I've initialized tss, and load that to tr register.
Following is my code.
tss structure...
Code: Select all
#pragma pack(push, 1)
typedef struct tss {
WORD ptl;
WORD rsv1;
DWORD esp0;
WORD ss0;
WORD rsv2;
DWORD esp1;
WORD ss1;
WORD rsv3;
DWORD esp2;
WORD ss2;
WORD rsv4;
DWORD cr3;
DWORD eip;
DWORD eflags;
DWORD eax;
DWORD ecx;
DWORD edx;
DWORD ebx;
DWORD esp;
DWORD ebp;
DWORD esi;
DWORD edi;
WORD es;
WORD rsv5;
WORD cs;
WORD rsv6;
WORD ss;
WORD rsv7;
WORD ds;
WORD rsv8;
WORD fs;
WORD rsv9;
WORD gs;
WORD rsv10;
WORD ldtss;
WORD rsv11;
WORD trsv;
WORD iomba;
} tss;
#pragma pack(pop)
tss load with ltr command...
Code: Select all
tss task0;
void init_tss(tss *ptss)
{
ptss->esp0 = get_esp();
ptss->ss0 = __KERNEL_DS;
ptss->cr3 = get_cr3();
ptss->es = __KERNEL_DS;
ptss->ds = __KERNEL_DS;
ptss->fs = __KERNEL_DS;
ptss->gs = __KERNEL_DS;
ptss->ss = __KERNEL_DS;
ptss->cs = __KERNEL_CS;
ptss->ldtss = 0;
ptss->trsv = 0xFFFF;
}
void init_task()
{
init_tss(&task0);
set_gdt_table_entry(5, (DWORD)&task0, sizeof(task0),
GDT_ACC_TSSPRESENT | GDT_ACC_TSSTYPE, GDT_ATT_DEFBIT);
load_tr((WORD)0x28);
while (1);
}
in asm file...
Code: Select all
_load_tr:
push ebp
mov ebp, esp
push eax
mov ax, word [ss:ebp + 8]
ltr ax
pop eax
pop ebp
retn
and it works fine without no fault or error....
But then, is that success of task enabling?
So, What is the first task?
Re: first task enabling question
Posted: Thu May 28, 2009 1:48 am
by kop99
I'm going to implement software multitasking...
But I don't have clear picture of it.
So any software multitasking tutorial, code, or implementation spec is very helpful...
Please tell me, where to start.......