internal static void ParseMpTables() { UIntPtr mpFloat = GetMpFloatBase(); if (mpFloat == UIntPtr.Zero) { DebugStub.Print("MP Floating Pointer Structure not found.\n"); return; } mpFloatRegion = IoMemory.MapPhysicalMemory(mpFloat, new UIntPtr(16), true, false); FloatingPointer = MpFloatingPointer.Parse(mpFloatRegion); if (FloatingPointer == null) { DebugStub.Print("Failed to parse MP Floating Pointer " + "Structure.\n"); return; } if (FloatingPointer.MpConfTablePresent) { mpConfTableRegion = IoMemory.MapPhysicalMemory( new UIntPtr(FloatingPointer.ConfTableBase), new UIntPtr(0x2c), true, false); DebugStub.Print("Found MP Conf Table\n"); ConfTable = MpConfTable.Parse(mpConfTableRegion); if (ConfTable == null) { DebugStub.Print("Failed to parse MP Configuration table.\n"); } IoMemory mpResourceRegion = IoMemory.MapPhysicalMemory( new UIntPtr(FloatingPointer.ConfTableBase + 0x2c), new UIntPtr(ConfTable.BaseTableLength - 0x2c), true, false); DebugStub.Print("Parsing MP Conf Table Resources\n"); MpResources.Parse(mpResourceRegion, ConfTable.BaseTableLength - 0x2c, ConfTable.EntryCount); } else { DebugStub.Print("MP Configuration table not present.\n"); DebugStub.Print("MP Floating Pointer features: " + "{0:x8} {1:x8} {2:x8} {3:x8} {4:x8}\n", __arglist( FloatingPointer.Feature[0], FloatingPointer.Feature[1], FloatingPointer.Feature[2], FloatingPointer.Feature[3], FloatingPointer.Feature[4])); } }
internal void Initialize(byte baseVector) { DebugStub.Assert(255 - baseVector >= 48); this.baseVector = baseVector; Write(ApicOffset.LvtTimer, LvtFlags.Masked); Write(ApicOffset.LvtThermalSensor, LvtFlags.Masked); Write(ApicOffset.LvtPerfCounts, LvtFlags.Masked); Write(ApicOffset.LvtError, LvtFlags.Masked); Write(ApicOffset.SpuriousIntVector, 0xdfu); // set task priority to 0 so that it can // receive all interrupts from IPI // Write(ApicOffset.TaskPriority, 0x20u); Write(ApicOffset.TaskPriority, 0); Write(ApicOffset.LvtLint0, LvtFlags.Masked); Write(ApicOffset.LvtLint1, LvtFlags.Masked); SetId((byte)Processor.GetCurrentProcessorId()); if (this.IsBsp) { InitializeRouteableEntries(); InitializeMpResourceEntries(); } // Enable in s/w SetEnabled(true); // Enable in h/w Isa.WriteMsr(ApicMSR, Isa.ReadMsr(ApicMSR) | (1 << 11)); // Watch out for the uniprocessor case where the // FloatingPointer may be null. MpFloatingPointer floatingPointer = MpResources.FloatingPointer; if (floatingPointer != null && floatingPointer.ImcrPresent && this.IsBsp) { IoPort addrPort = new IoPort(ImcrAddressPort, 1, Access.Write); IoPort dataPort = new IoPort(ImcrDataPort, 1, Access.Write); addrPort.Write8(ImcrAddressSelect); dataPort.Write8(ImcrDataApic); } Write(ApicOffset.LvtLint0, LvtFlags.Level | LvtFlags.ExtInt); Write(ApicOffset.LvtLint1, LvtFlags.NMI | 0x02); for (int z = 0; z <= maxIrq; z++) { byte m = IrqToInterrupt((byte)z); byte n = InterruptToIrq(m); DebugStub.Assert((byte)z == n); } }
internal static MpFloatingPointer Parse(IoMemory region) { uint signature = region.Read32(0); if (signature != Signature) { return(null); } int length = region.Read8(8) * 16; if (length != 16) { return(null); } byte checksum = 0; for (int i = 0; i < length; i++) { checksum += region.Read8((int)i); } if (checksum != 0) { return(null); } MpFloatingPointer m = new MpFloatingPointer(); m.ConfTableBase = region.Read32(4); m.Revision = region.Read8(9); m.Feature = new byte [5]; for (int i = 0; i < m.Feature.Length; i++) { m.Feature[i] = region.Read8(0xb + i); } return(m); }