When setting up hardware multi-tasking, I set up TSS in GDT and give TSS.ldtr = 0. Bochs quits with message: fetch_raw_descriptor: LDTR.valid=0. Do I need to set up LDT as well?
Here's the source where I set up the TSS.
.
.
int i;
lldt(0);
// gdt is set up somewhere in my asm codes. I reserved
// space for TSS in advace.
set_gdt_entry (&gdt[6], 0, sizeof(TSS), ACC_TSS|ACC_P, 0);
task_sels[0] = 0x30; //48;
/* 0x38 -- TSS for task1() */
set_gdt_entry (&gdt[7], 0, sizeof(TSS), ACC_TSS|ACC_P, 0);
task_sels[1] = 0x38; //56;
/* 0x38 -- TSS for task2() */
set_gdt_entry (&gdt[8], 0, sizeof(TSS), ACC_TSS|ACC_P, 0);
task_sels[2] = 0x40; //64;
for (i=0;i<3;i++) {
tss.trace = 0;
tss.io_map_addr = sizeof(TSS); /* I/O map just after the TSS */
tss.ldtr = 0; /* ldtr=0 */
tss.fs = tss.gs = 0; /* fs=gs=0 */
tss.ss = 0x10+8*i;
tss.ds=tss.es=get_ds(); /* ds=es=ss = data segment */
tss.cs = get_cs();
tss.eflags = 0x202L; /* interrupts are enabled */
tss[i].esp = (word)&task_stack[i]; /* sp points to task stack top */
}
tss[1].eip = (word)&task1; /* cs:eip point to task1() */
tss[1].eip = (word)&task2; /* cs:eip point to task2() */
tss[2].eip = (word)&task3; /* cs:eip point to task3() */
/* load the TR register */
ltr (task_sels[0]);
.
. :-\
Multi-tasking -- LDT and TSS
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Multi-tasking -- LDT and TSS
normally, you don't need to set up and LDT as long as you don't reference local (TI=1) selectors.
I fear you're facing an invalid segment register loading (some garbage like 0x1234 into DS, ...) and this selector refers to an inexistant local table.
I fear you're facing an invalid segment register loading (some garbage like 0x1234 into DS, ...) and this selector refers to an inexistant local table.