public static DescriptorTableEntry CreateTSS(TaskStateSegment *tss) { var seg = Create(false, (uint)tss, Core.TaskStateSegment.EntrySize); seg.SystemDescriptor_Type = InactiveTask; return(seg); }
public static void SetupUserMode(Addr tssAddr) { KernelMessage.WriteLine("Setup GDT UserMode"); if (KConfig.UseTaskStateSegment) { TssAddr = tssAddr; TssTable = (TaskStateSegmentTable *)tssAddr; TssTable->Clear(); TssTable->AdressOfEntries = TssAddr + TaskStateSegmentTable.StructSize; } if (KConfig.UseTaskStateSegment) { // 9 - TSS Tss = AddTSS(); //tss->esp0 = kernelStackPointer; Tss->SS0 = 0x10; Tss->Trace_bitmap = 0xdfff; KernelMessage.WriteLine("Addr of tss: {0:X8}", (uint)Tss); var tssEntry = DescriptorTableEntry.CreateTSS(Tss); tssEntry.PriviligeRing = 0; tssEntry.TSS_AVL = true; tssEntry.Present = true; GdtTable->AddEntry(tssEntry); } Flush(); if (KConfig.UseTaskStateSegment) { KernelMessage.WriteLine("LoadTaskRegister..."); //LoadTaskRegister(); //Debug, for breakpoint //clockTicks++; //DebugFunction1(); } KernelMessage.WriteLine("Done"); }
public static void SetupUserMode(Addr tssAddr) { KernelMessage.WriteLine("Setup GDT UserMode"); if (KConfig.UseTaskStateSegment) { TssAddr = tssAddr; TssTable = (TaskStateSegmentTable *)tssAddr; TssTable->Clear(); TssTable->AdressOfEntries = TssAddr + TaskStateSegmentTable.StructSize; } //code segment var codeEntry = DescriptorTableEntry.CreateCode(0, 0xFFFFFFFF); codeEntry.CodeSegment_Readable = true; codeEntry.PriviligeRing = 3; codeEntry.Present = true; codeEntry.AddressMode = DescriptorTableEntry.EAddressMode.Bits32; codeEntry.CodeSegment_Confirming = false; GdtTable->AddEntry(codeEntry); //data segment var dataEntry = DescriptorTableEntry.CreateData(0, 0xFFFFFFFF); dataEntry.DataSegment_Writable = true; dataEntry.PriviligeRing = 3; dataEntry.Present = true; dataEntry.AddressMode = DescriptorTableEntry.EAddressMode.Bits32; GdtTable->AddEntry(dataEntry); if (KConfig.UseTaskStateSegment) { //TSS Tss = AddTSS(); //tss->esp0 = kernelStackPointer; Tss->SS0 = 0x10; Tss->Trace_bitmap = 0xdfff; KernelMessage.WriteLine("Addr of tss: {0:X8}", (uint)Tss); var tssEntry = DescriptorTableEntry.CreateTSS(Tss); tssEntry.PriviligeRing = 0; tssEntry.TSS_AVL = true; tssEntry.Present = true; GdtTable->AddEntry(tssEntry); } Flush(); if (KConfig.UseTaskStateSegment) { KernelMessage.WriteLine("LoadTaskRegister..."); //LoadTaskRegister(); //Debug, for breakpoint //clockTicks++; //DebugFunction1(); } KernelMessage.WriteLine("Done"); }