alexfru wrote:Do you use one TSS for more than one task? Are those real tasks from the CPU's point of view or do you try to reuse and update your single TSS?
I use the TSS for only 1 task at a time, i describe that a little later here in my answer
alexfru wrote:If you reuse a TSS, remember about the "busy" bit. You can't switch to a task that has this bit already set to 1.
But, this busy bit is only relevant if there are multiple tasks using the same TSS, right?
alexfru wrote:Do you know/remember that switching to a task simply makes the task continue whatever it was doing when it was last switched from and that the task must essentially be a loop as it has no way to be called at a predefined entry point or returned from unlike a regular subroutine or ISR?
Yes..
Brendan wrote:This looked quite messed up to me. Any task may switch between protected mode an virtual8086 mode, and you do not need a specific task for virtual8086 mode.
The thing is, in my kernel all processes run in ring 0. Therefore my scheduler only switches between ring 0 and vm86 tasks. I know that I don't specifically need a process for vm86 mode, but I thought it would be the cleanest solution..
Brendan wrote:This is done with an "IRET" that includes a CPL=0 to CPL=3 privilege level switch and causes the "real mode compatible" segment registers to be loaded.
That's what my scheduler does when switching to a Vm86 task. It first sets that tasks kernel stack into the TSS as ESP0 and then returns this address to my asm stub that pops off the registers and does an iret.
The IRET then does a switch to the virtual 8086 mode and the BIOS function is executing its code. Then, when this task causes a GPF, my GPF handler checks if the last task was a v86-task, if so it calls a routine to handle the GPF. This routine handler handles the faulty opcode, and everytime an INT is done I count up a variable. Everytime an IRET is called, i count this variable down, and if the variable is 0 when IRET occurs, I know that the BIOS function is done and I can quit the process.
As I currently only have 1 task using the TSS at all, this shouldn't be the problem..
Another thing - the interrupt descriptors that I have in my IDT apply to ring 0, but do they also work for ring 3 tasks? The vm86 task is a ring 3 task, and if the interrupt handlers (should) only work for ring 0 (and QEMU still lets them work for some reason...) that could be bad^^
thanks a lot so far ^-^
EDIT: if i set the idt descriptors to DPL 3, bochs gives me:
Code: Select all
stackPrefetch(4): access [0xfffffffc] > SS.limit [0x0fffffff]
interrupt(): gate descriptor is not valid sys seg (vector=0x08)