TSS初始化需要在GDT初始化完成后进行。
相关:
TR
(LTR (load task register) and STR (store task register))
TSS使用GDT的内容
描述符的类型设置不可为忙,任务是不能嵌套的。
s_tssDesc->type = 0x09;
/* Load the task register */
__asm__ __volatile__ (
"ltr %0"
:
: "a" (s_tssSelector)
);
TSS基本结构,保护了任务运行的所有内容。
/* Stacks for privilege levels. esp0/ss0 specifies the kernel stack. */
ulong_t esp0;
ushort_t ss0;
ushort_t reserved2;
ulong_t esp1;
ushort_t ss1;
ushort_t reserved3;
ulong_t esp2;
ushort_t ss2;
ushort_t reserved4;
/* Page directory register. */
ulong_t cr3;
/* General processor registers. */
ulong_t eip;
ulong_t eflags;
ulong_t eax;
ulong_t ecx;
ulong_t edx;
ulong_t ebx;
ulong_t esp;
ulong_t ebp;
ulong_t esi;
ulong_t edi;
/* Segment registers and padding. */
ushort_t es;
ushort_t reserved5;
ushort_t cs;
ushort_t reserved6;
ushort_t ss;
ushort_t reserved7;
ushort_t ds;
ushort_t reserved8;
ushort_t fs;
ushort_t reserved9;
ushort_t gs;
ushort_t reserved10;
/* GDT selector for the LDT descriptor. */
ushort_t ldt;
ushort_t reserved11;
/*
* The debug trap bit causes a debug exception upon a switch
* to the task specified by this TSS.
*/
uint_t debugTrap : 1;
uint_t reserved12 : 15;
/* Offset in the TSS specifying where the io map is located. */
ushort_t ioMapBase;
};
通过描述符设置TSS内容。
TSS描述符的基地址对应TSS的基地址,长度对应TSS的长度。
这样以后可以通过该描述符访问到TSS内容。
上述结构的最后位图说明该Task可以使用的IO情况。