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
first task enabling question
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: first task enabling question
Define "first task", then know the answer
Re: first task enabling question
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...
tss load with ltr command...
in asm file...
and it works fine without no fault or error....
But then, is that success of task enabling?
So, What is the first task?
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)
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);
}
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
But then, is that success of task enabling?
So, What is the first task?
Re: first task enabling question
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.......
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.......