/// <summary> /// Sets up the GDT table and entries /// </summary> public static void Setup(Addr addr) { KernelMessage.Write("Setup GDT..."); gdtTableAddress = addr; table = (DescriptorTable *)gdtTableAddress; table->Clear(); table->AdressOfEntries = gdtTableAddress + DescriptorTable.StructSize; //Null segment var nullEntry = DescriptorTableEntry.CreateNullDescriptor(); table->AddEntry(nullEntry); //code segment var codeEntry = DescriptorTableEntry.CreateCode(0, 0xFFFFFFFF); codeEntry.CodeSegment_Readable = true; codeEntry.PriviligeRing = 0; codeEntry.Present = true; codeEntry.AddressMode = DescriptorTableEntry.EAddressMode.Bits32; codeEntry.Granularity = true; table->AddEntry(codeEntry); //data segment var dataEntry = DescriptorTableEntry.CreateData(0, 0xFFFFFFFF); dataEntry.DataSegment_Writable = true; dataEntry.PriviligeRing = 0; dataEntry.Present = true; dataEntry.AddressMode = DescriptorTableEntry.EAddressMode.Bits32; dataEntry.Granularity = true; table->AddEntry(dataEntry); Flush(); KernelMessage.WriteLine("Done"); }
public void SetEntry(ushort index, DescriptorTableEntry source) { Assert.InRange(index, Length); //DescriptorTableEntry.CopyTo(&source, entries + index); entries[index] = source; }
public void AddEntry(DescriptorTableEntry source) { Length++; SetEntry((ushort)(Length - 1), source); }