Do I need a TSS?
Posted: Tue Apr 10, 2007 9:03 pm
I've setup a working multitasking system, one that would be expected of a microkernel. Basically, each process is a structure:
On initialization it's setup like so:
I had tried to initialize a stack but that didn't work (*stackSpace-- = whatever...).
Now, when I try to run a real mode program Bochs crashes. The log at the time of failure is like so:
The problem is, I don't have any TSS whatsoever, and haven't needed one. Can anyone explain this? I can post code if you need it.
Code: Select all
// process structure
typedef struct tagPROCESS {
struct regs myregs;
int stackstart;
int status;
char name[64];
} PROCESS;
Code: Select all
// setup the registers and other data for the process
ProcessList[i].myregs.eip = addr;
ProcessList[i].myregs.esp = (unsigned int) stackSpace;
ProcessList[i].myregs.ebp = 0;
ProcessList[i].myregs.eax = 0;
ProcessList[i].myregs.ebx = 0;
ProcessList[i].myregs.ecx = 0;
ProcessList[i].myregs.edx = 0;
ProcessList[i].myregs.edi = 0;
ProcessList[i].myregs.esi = 0;
ProcessList[i].myregs.cs = 0x08;
ProcessList[i].myregs.ds = 0x10;
ProcessList[i].myregs.es = 0x10;
ProcessList[i].myregs.fs = 0x10;
ProcessList[i].myregs.gs = 0x10;
ProcessList[i].myregs.ss = 0x10;
if( isRealMode == 1 )
{
ProcessList[i].myregs.eflags = EFLAGS_VM | EFLAGS_IOPL0 | EFLAGS_IF | 0x20; // v8086 mode
}
else
{
ProcessList[i].myregs.eflags = 0x0202;
}
ProcessList[i].myregs.useresp = (unsigned int) stackSpace;
Now, when I try to run a real mode program Bochs crashes. The log at the time of failure is like so:
Code: Select all
00203256766e[CPU0 ] allow_io(): TR doesn't point to a valid 32bit TSS
00203256766p[CPU0 ] >>PANIC<< get_SS_ESP_from_TSS: TR is bogus type (3)
00203256766i[SYS ] Last time is 1176260980
00203256766i[CPU0 ] v8086 mode
00203256766i[CPU0 ] CS.d_b = 16 bit
00203256766i[CPU0 ] SS.d_b = 16 bit
00203256766i[CPU0 ] | EAX=00008744 EBX=00000000 ECX=0000a3fe EDX=000000f0
00203256766i[CPU0 ] | ESP=0020b5aa EBP=00000000 ESI=00001ff0 EDI=00000002
00203256766i[CPU0 ] | IOPL=0 id vip vif ac VM RF nt of df IF tf SF zf af PF cf
00203256766i[CPU0 ] | SEG selector base limit G D
00203256766i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00203256766i[CPU0 ] | CS:0008( 0001| 0| 3) 00000080 0000ffff 0 0
00203256766i[CPU0 ] | DS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00203256766i[CPU0 ] | SS:0010( 0002| 0| 3) 00000100 0000ffff 0 0
00203256766i[CPU0 ] | ES:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00203256766i[CPU0 ] | FS:7ade( 0002| 0| 3) 0007ade0 0000ffff 0 0
00203256766i[CPU0 ] | GS:000a( 0002| 0| 3) 000000a0 0000ffff 0 0
00203256766i[CPU0 ] | EIP=00001f8a (00001f8a)
00203256766i[CPU0 ] | CR0=0x00000011 CR1=0 CR2=0x00000000
00203256766i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00203256766i[CPU0 ] >> insb byte ptr es:[di], dx : 656C
00203256766i[ ] restoring default signal behavior
00203256766i[CTRL ] quit_sim called with exit code 1