But now i have a little question:
When I switch to the Ring3 Task, I get an Error like this:
Code: Select all
get_SS_ESP_from_TSS: TR is bogus type (3)
This is the Code for initializing a dummy TSS.
Code: Select all
void set_tss(void)
{
unsigned long base = (unsigned long)&v86_task;
unsigned long limit = base + sizeof(tss_t);
unsigned short trace = 5<<3;
memset(&v86_task, 0, sizeof(tss_t));
v86_task.bitmap = (u16int)sizeof(tss_t);
v86_task.ss0 = KERNEL_DATA_SEL;
gdt_set_gate(5, base, limit, /*0x89*/0xE9, 0x67);
asm ( "ltr %%ax"::"a"(trace) );
gdt_flush();
}
Code: Select all
u32int switch_task(u32int OldEsp)
{
// Initialise return_esp with the old esp
u32int return_esp = OldEsp;
if(current_process == NULL)
{
if(head_process == NULL)
{
return_esp = OldEsp;
}
else
{
if(head_process->first == NULL && head_process->last == NULL)
{
return_esp = OldEsp;
}
else
{
current_process = head_process->first;
if(current_process->data->thread.v86 == 1)
{
memcpy(&v86_task, current_process->data->thread.v86_tss, sizeof(tss_t));
return_esp = current_process->data->thread.esp3;
}
else
{
return_esp = current_process->data->thread.esp0;
}
}
}
}
else
{
if(current_process->data->thread.v86 == 1)
{
current_process->data->thread.esp3 = OldEsp;
}
else
{
current_process->data->thread.esp0 = OldEsp;
}
if(current_process->next == NULL)
{
if(current_process->data->thread.v86 == 1)
{
memcpy(current_process->data->thread.v86_tss, &v86_task, sizeof(tss_t));
}
current_process = head_process->first;
if(current_process->data->thread.v86 == 1)
{
memcpy(&v86_task, current_process->data->thread.v86_tss, sizeof(tss_t));
return_esp = current_process->data->thread.esp3;
}
else
{
return_esp = current_process->data->thread.esp0;
}
}
else
{
if(current_process->data->thread.v86 == 1)
{
memcpy(current_process->data->thread.v86_tss, &v86_task, sizeof(tss_t));
}
current_process = current_process->next;
if(current_process->data->thread.v86 == 1)
{
memcpy(&v86_task, current_process->data->thread.v86_tss, sizeof(tss_t));
return_esp = current_process->data->thread.esp3;
}
else
{
return_esp = current_process->data->thread.esp0;
}
}
}
return(return_esp);
}
greetings
Christian

