Well, this is already being done by:
Code: Select all
mov [_gdt8 + 5], byte 0x8b ; set busy bit
and
Code: Select all
mov [_gdt6 + 5], byte 0x8b ; set busy bit
If it would be that, I'll get an invalid TSS, which is not happening.
386 programer's reference says about IRET:
Code: Select all
ELSE (*PROTECTED MODE*)
IF VM = 1
..
ELSE
IF NT = 1
THEN GOTO TASK-RETURN; // I HAVE FLAG 0x400 set
ELSE
...
FI;
FI;
...
TASK-RETURN:
Examine Back Link Selector in TSS addressed by the current task
register:
Must specify global in the local/global bit, else #TS(new TSS selector);
Index must be within GDT limits, else #TS(new TSS selector);
AR byte must specify TSS, else #TS(new TSS selector);
New TSS must be busy, else #TS(new TSS selector);
TSS must be present, else #NP(new TSS selector);
SWITCH-TASKS without nesting to TSS specified by back link selector;
Mark the task just abandoned as NOT BUSY;
Instruction pointer must be within code segment limit ELSE #GP(0);
I don't get any "Invalid TSS" or GPF so all checks pass...
It also says on section 7.6.2 Modifying Task Linkages:
Any modification of the linkage order of tasks should be accomplished only
by software that can be trusted to correctly update the back-link and the
busy-bit. Such changes may be needed to resume an interrupted task before
the task that interrupted it. Trusted software that removes a task from the
back-link chain must follow one of the following policies:
1. First change the back-link field in the TSS of the interrupting task,
then clear the busy-bit in the TSS descriptor of the task removed from
the list.
2. Ensure that no interrupts occur between updating the back-link chain
and the busy bit.
Code: Select all
So I added this:
lea eax, [_irq0_task]
mov [eax], dword 0x30
mov [_gdt8 + 5], byte 0x8b ; set busy bit
mov [_gdt6 + 5], byte 0x89 ; clear current task busy bit
jmp resch2
resch1:
lea eax, [_irq0_task]
mov [eax], dword 0x20
mov [_gdt6 + 5], byte 0x8b ; set busy bit
mov [_gdt8 + 5], byte 0x89 ; clear current task busy bit
..but it still goes on running the previous task , not the next one "in schedule" by tampering the TSS back-link selector field.
I checked every single line with my own debug routines... there's nothing to do on the stack as with interrupt gates. I dumped the stack and it's clear and empty. All I got were the parameters I pushed myself for the dumpMem proc