Beispiel #1
0
        private static void InitDrivers()
        {
            // Register drivers who depend on scheduling and resource management.
            DebugStub.WriteLine("--- Registering Drivers ---------------------------");
            Console.WriteLine("Registering Non-HAL Drivers.");
            // register the metadata-based drivers
            IoSystem.RegisterDrivers();
            ARM_PROGRESS("Kernel!061");

            // register the internal kernel drivers
            Devices.RegisterInternalDrivers();
            ARM_PROGRESS("Kernel!062");
#if DEBUG
            // and output the results
            IoSystem.Dump(false);
#endif
            DebugStub.WriteLine("--- Activating Devices ----------------------------");
            // now do device initialization
            IoSystem.ActivateDrivers();
            ARM_PROGRESS("Kernel!063");
#if DEBUG
            // and output the results
            // IoSystem.Dump(true);
#endif
        }
Beispiel #2
0
        private static void FinalizeServices()
        {
            ARM_PROGRESS("Kernel!075");
            Tracing.Log(Tracing.Audit, "Shutting down AP processors");
            Processor.StopApProcessors();

            Tracing.Log(Tracing.Audit, "Shutting down I/O system");
            Console.WriteLine("Shutting down I/O system");
            IoSystem.Finalize();

            Tracing.Log(Tracing.Audit, "Interrupts OFF.");
            Processor.DisableInterrupts();

            Tracing.Log(Tracing.Audit, "Shutting down scheduler");
            Console.WriteLine("Shutting down scheduler");
            for (int i = 0; i < Processor.processorTable.Length; i++)
            {
                Processor p = Processor.processorTable[i];
                if (p != null)
                {
                    Console.WriteLine("  cpu {0}: {1} context switches, {2} interrupts", i, p.NumContextSwitches, p.NumInterrupts);
                }
            }

            // Finalize the scheduler
            scheduler.Finalize();

            // We should turn off interrupts here!
            Platform.ReleaseResources();
            PEImage.Finalize();

            DebugStub.WriteLine("Kernel Exiting [{0}]",
                                __arglist(bootReturnCode));
        }
Beispiel #3
0
        // Now that we use metadata, this only registers drivers that do not run
        // in separate processes.  All external processes are registered through
        // the IoSystem.Initialize() code.
        public static void RegisterInternalDrivers()
        {
            // PCI Bus
            IoSystem.RegisterKernelDriver(
                typeof(PciBusResources),
                new IoDeviceCreate(PciBusResources.DeviceCreate));

            // nForce4 LPC Bridge
            IoSystem.RegisterKernelDriver(
                typeof(NvPciLpcResources),
                new IoDeviceCreate(NvPciLpcResources.DeviceCreate));

            // Legacy PC IDE bus
            IoSystem.RegisterKernelDriver(
                typeof(LegacyIdeBus),
                new IoDeviceCreate(LegacyIdeBus.DeviceCreate));

            // nForce4 IDE bus
            IoSystem.RegisterKernelDriver(
                typeof(NvIdeBus),
                new IoDeviceCreate(NvIdeBus.DeviceCreate));

            // Tyan motherboard IDE bus
            IoSystem.RegisterKernelDriver(
                typeof(TyanIdeBus),
                new IoDeviceCreate(TyanIdeBus.DeviceCreate));
        }
Beispiel #4
0
 public void ConnectToMasterIoSystem(IoSystem aIoSystem)
 {
     if (aIoSystem != null)
     {
         FirstPnNetworkInterfaces[0].IoConnectors[0].ConnectToIoSystem(aIoSystem);
     }
 }
        public static async Task <IoSystemLevel> Create(IoSystem iosystem, SubnetLevel subnetLevel)
        {
            var ret = new IoSystemLevel(iosystem, subnetLevel);
            await ret.PopulateIoSystemLvl().ConfigureAwait(false);

            return(ret);
        }
Beispiel #6
0
        public void SwitchIoSystem(Subnet aSubnet, IoSystem aIoSystem)
        {
            int i = 0;

            foreach (NetworkInterface networkInterface in FirstPnNetworkInterfaces)
            {
                try
                {
                    networkInterface.Nodes[0].DisconnectFromSubnet();
                }
                catch
                {
                }
                if (aSubnet != null)
                {
                    networkInterface.Nodes[0].ConnectToSubnet(aSubnet);
                    if (aIoSystem != null)
                    {
                        if ((networkInterface.IoConnectors.Count > 0))
                        {
                            networkInterface.IoConnectors[0].ConnectToIoSystem(aIoSystem);
                            //Service.SetAttribute(networkInterface.IoConnectors[0], PnDeviceNumberOfFirstPnNetworkInterfaces[i]);
                            if ((PnDeviceNumberOfFirstPnNetworkInterfaces[i]?.Value ?? null) != null)
                            {
                                networkInterface.IoConnectors[0].SetAttribute(PnDeviceNumberOfFirstPnNetworkInterfaces[i].Name, PnDeviceNumberOfFirstPnNetworkInterfaces[i].Value);
                            }
                        }
                    }
                }
                i++;
            }
        }
Beispiel #7
0
        public async Task <string> UpdateIoSystemName()
        {
            // at some point it will be wiser to add a reference to subnet in Network Device Item constructor
            // then this functions will become super simple and always right.
            // this is good for now.
            IoSystemName = null;

            // this will not work correctly if it needs second ioconnector or something.
            if (itemLevel != NetworkDeviceItemLevel.IoSystem)
            {
                return(this.IoSystemName);                                              //null
            }
            await Task.Run(() =>
            {
                NetworkInterface itf = ((IEngineeringServiceProvider)deviceItem).GetService <NetworkInterface>();

                if (itf.IoConnectors.Count != 0)
                {
                    IoSystem ioSystem = itf.IoConnectors[0].ConnectedToIoSystem;
                    // the fact that I need that ?? means some devices classified as ioSystem level are not in iosystem.
                    // most likely it's broken cause I hardcoded 0. I will think a bit more about it.
                    this.IoSystemName = ioSystem?.Name;// ?? null;
                }
                else if (itf.IoControllers.Count == 1)
                {
                    IoSystem ioSystem = itf.IoControllers[0].IoSystem;
                    this.IoSystemName = ioSystem?.Name;// ?? null;
                }
            });

            return(IoSystemName);
        }
Beispiel #8
0
        private void CreateAndConnectIOSystem()
        {
            Subnet mySubnet = null;

            foreach (var subnet in MyProject.Subnets)
            {
                mySubnet = subnet;
                SetTextInRichTextBox(Color.Black, $"[{subnet.Name}] is founded");
            }
            foreach (IoSystem ioSystem1 in mySubnet.IoSystems)
            {
                SetTextInRichTextBox(Color.Black, $"[{ioSystem1.Name}] is founded");
            }
            NetworkInterface networkInterface = null;
            IoSystem         ioSystem         = null;

            foreach (Device device in MyProject.Devices)
            {
                foreach (DeviceItem Dev1 in device.DeviceItems)
                {
                    foreach (DeviceItem Dev2 in Dev1.DeviceItems)
                    {
                        if (Dev2.Name == "PROFINET interface_1" || Dev2.Name == "PROFINET interface" || Dev2.Name == "PROFINET Interface_1" || Dev2.Name == "SCALANCE interface_1")
                        {
                            networkInterface = ((IEngineeringServiceProvider)Dev2).GetService <NetworkInterface>();
                            if ((networkInterface.InterfaceOperatingMode & InterfaceOperatingModes.IoController) != 0)
                            {
                                SetTextInRichTextBox(Color.Black, "Bingo IO Controller");
                                IoControllerComposition ioControllers = networkInterface.IoControllers;
                                IoController            ioController  = ioControllers.First();
                                if (ioController.IoSystem != null)
                                {
                                    SetTextInRichTextBox(Color.Blue, $"{ioController.IoSystem.Name} IO system is already connected");
                                }
                                if ((ioController != null) && (ioController.IoSystem == null))
                                {
                                    ioSystem = ioController.CreateIoSystem("");
                                }
                            }
                            if ((networkInterface.InterfaceOperatingMode & InterfaceOperatingModes.IoDevice) != 0)
                            {
                                SetTextInRichTextBox(Color.Black, "Bingo IO Device");
                                IoConnectorComposition ioConnectors = networkInterface.IoConnectors;
                                IoConnector            ioConnector  = ioConnectors.First();
                                if (ioConnector != null)
                                {
                                    ioConnector.ConnectToIoSystem(ioSystem);
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #9
0
 public void CreateNewIoSystem(Subnet aSubnet, string aPrefix)
 {
     try
     {
         //string tempIPaddress = (string)FirstPnNetworkInterfaces[0].Nodes[0].GetAttribute("Address");
         string IoSystemName = FirstPnNetworkInterfaces[0].IoControllers[0].IoSystem.Name;
         FirstPnNetworkInterfaces[0].Nodes[0].DisconnectFromSubnet();
         FirstPnNetworkInterfaces[0].Nodes[0].ConnectToSubnet(aSubnet);
         newIoSystem = FirstPnNetworkInterfaces[0].IoControllers[0].CreateIoSystem(aPrefix + IoSystemName);
         //FirstPnNetworkInterfaces[0].Nodes[0].SetAttribute("Address", tempIPaddress);
     }
     catch (NullReferenceException)
     { }
 }
Beispiel #10
0
 public void ConnectToIoSystem(IoSystem aIoSystem)
 {
     if (aIoSystem != null)
     {
         int i = 0;
         foreach (NetworkInterface networkInterface in FirstPnNetworkInterfaces)
         {
             networkInterface.IoConnectors[0].ConnectToIoSystem(aIoSystem);
             if ((networkInterface.IoConnectors.Count > 0) && (PnDeviceNumberOfFirstPnNetworkInterfaces[i].Value != null))
             {
                 //Service.SetAttribute(networkInterface.IoConnectors[0], PnDeviceNumberOfFirstPnNetworkInterfaces[i]);
                 networkInterface.IoConnectors[0].SetAttribute(PnDeviceNumberOfFirstPnNetworkInterfaces[i].Name, PnDeviceNumberOfFirstPnNetworkInterfaces[i].Value);
             }
             i++;
         }
     }
 }
Beispiel #11
0
        public override void Initialize(Processor processor)
        {
            Cpu thisCpu = (Cpu)Platform.CurrentCpu;

            if (processor.Id == 0)
            {
                InitializeBsp(processor);

                IoSystem.RegisterKernelDriver(
                    typeof(HpetResources),
                    new IoDeviceCreate(Hpet.CreateDevice)
                    );
            }
            else
            {
                InitializeAp(processor);
            }
        }
Beispiel #12
0
        public override void Initialize(Processor rootProcessor)
        {
            DebugStub.Print("HalDevices.Initialize() - ARM\n");

            // PIC
            PnpConfig picConfig
                = (PnpConfig)IoSystem.YieldResources("/arm/ti/3430/INTCPS",
                                                     typeof(Pic));

            pic = new Pic(picConfig);
            pic.Initialize();

            // Timer
            PnpConfig timerConfig
                = (PnpConfig)IoSystem.YieldResources("/arm/ti/3430/GPTIMER1",
                                                     typeof(TimerOmap3430));

            timer = new TimerOmap3430(timerConfig, pic);
            byte timerInterrupt = timer.Initialize();

            // Real-time clock
            clock = new HalClockNull();
            byte clockInterrupt = clock.Initialize();
            bool noisyTimer     = false;

            CalibrateTimers.Run(clock, timer);

            SystemClock.Initialize(clock, TimeSpan.FromHours(8).Ticks);

            rootProcessor.AddPic(pic);

            rootProcessor.AddTimer(timerInterrupt, timer);
            rootProcessor.AddClock(clockInterrupt, clock);

            // ----------------------------------------------------------
            // Add Srat tables to the Processor
            halMemory = new HalMemoryNull();
            ProcessorNode.AddMemory(halMemory);

            timer.Start();

            halScreen      = new HalScreenNull();
            Console.Screen = (HalScreen)halScreen;
        }
Beispiel #13
0
        private static void InitIO(Processor p, XmlNode initConfig, XmlNode driverConfig)
        {
            // obtain the configuration for the namespace service
            // and initialize the namespace service
            ARM_PROGRESS("Kernel!041");
            DirectoryService.Initialize(initConfig);

            Tracing.Log(Tracing.Audit, "IoSystem");
            ARM_PROGRESS("Kernel!042");
            IoSystem.Initialize(driverConfig);

            Tracing.Log(Tracing.Audit, "Registering HAL Drivers.");

            ARM_PROGRESS("Kernel!043");

            Devices.RegisterPnpResources(); // add the root devices

            ARM_PROGRESS("Kernel!044");

            Platform.InitializeHal(p);
        }
        private void SetNetwork(Device device, Subnet subnet, IoSystem ioSystem, string ipAddress, string pnDeviceNameAuto, string pnDeviceName, int PnDeviceNumber)
        {
            foreach (DeviceItem deviceItem in device.DeviceItems[1].DeviceItems)
            {
                if (deviceItem.Name.Contains("PROFINET"))
                {
                    IoConnector ioConnector = deviceItem.GetService <NetworkInterface>().IoConnectors[0];
                    Node        node        = deviceItem.GetService <NetworkInterface>().Nodes[0];

                    node.ConnectToSubnet(subnet);
                    ioConnector.ConnectToIoSystem(ioSystem);
                    node.SetAttribute("Address", ipAddress);
                    ioConnector.SetAttribute("PnDeviceNumber", PnDeviceNumber);

                    if (pnDeviceNameAuto.Equals("False"))
                    {
                        node.SetAttribute("PnDeviceNameAutoGeneration", false);
                        node.SetAttribute("PnDeviceName", pnDeviceName);
                    }
                }
            }
        }
Beispiel #15
0
        public new void Save()
        {
            Device currentDevice = AllDevices[0];

            CentralFSourceAddress_attribue = Service.Get1ValueAndDeviceItemWithAttribute(currentDevice.DeviceItems, "Failsafe_CentralFSourceAddress");
            LowerBoundForFDestinationAddresses_attribues = Service.Get1ValueAndDeviceItemWithAttribute(currentDevice.DeviceItems, "Failsafe_LowerBoundForFDestinationAddresses");
            UpperBoundForFDestinationAddresses_attribues = Service.Get1ValueAndDeviceItemWithAttribute(currentDevice.DeviceItems, "Failsafe_UpperBoundForFDestinationAddresses");
            //xFDestinationAddress_attribues = Service.GetValueAndDeviceItemsWithAttribute(currentDevice.DeviceItems, "Failsafe_FDestinationAddress");

            try
            {
                originalSubnet   = FirstPnNetworkInterfaces[0].Nodes[0].ConnectedSubnet;
                originalIoSystem = FirstPnNetworkInterfaces[0].IoConnectors[0].ConnectedToIoSystem;
            }
            catch (EngineeringTargetInvocationException)
            {
            }
            //GetAll_I_DeviceParnerAdresses();

            plcSoftware = Service.GetPlcSoftware(currentDevice);
            GetAllToConnections();
        }
Beispiel #16
0
        public void XxSwitchIoSystem(Subnet aSubnet, IoSystem aIoSystem, ulong aIpOffset)
        {
            int i = 0;

            foreach (NetworkInterface networkInterface in FirstPnNetworkInterfaces)
            {
                try
                {
                    networkInterface.Nodes[0].DisconnectFromSubnet();
                }
                catch
                {
                }
                if (aSubnet != null)
                {
                    string[] tempIPaddress = ((string)networkInterface.Nodes[0].GetAttribute("Address")).Split('.');
                    networkInterface.Nodes[0].SetAttribute("Address", tempIPaddress[0] + "." + tempIPaddress[1] + "." + (Convert.ToInt32(tempIPaddress[2]) + (uint)aIpOffset) + "." + tempIPaddress[3]); //ip of PLC
                    networkInterface.Nodes[0].ConnectToSubnet(aSubnet);
                    if (aIoSystem != null)
                    {
                        networkInterface.IoConnectors[0].ConnectToIoSystem(aIoSystem);
                        if ((networkInterface.IoConnectors.Count > 0) && (PnDeviceNumberOfFirstPnNetworkInterfaces[i].Value != null))
                        {
                            //PnDeviceNumberOfFirstPnNetworkInterfaces[i].AddToValue(10);
                            //Service.SetAttribute(networkInterface.IoConnectors[0], PnDeviceNumberOfFirstPnNetworkInterfaces[i]);
                            //var x = networkInterface.IoConnectors[0].GetAttribute("PnDeviceNumber");
                            //networkInterface.IoConnectors[0].SetAttribute("PnDeviceNumber", 2);
                            //networkInterface.IoConnectors[0].SetAttribute(PnDeviceNumberOfFirstPnNetworkInterfaces[i].Name, 4);

                            //int tempDeviceNumber = PnDeviceNumberOfFirstPnNetworkInterfaces[i].GetValueAsInt();
                            //networkInterface.IoConnectors[0].SetAttribute(PnDeviceNumberOfFirstPnNetworkInterfaces[i].Name, tempDeviceNumber);
                            networkInterface.IoConnectors[0].SetAttribute(PnDeviceNumberOfFirstPnNetworkInterfaces[i].Name, PnDeviceNumberOfFirstPnNetworkInterfaces[i].Value);
                        }
                    }
                }
                i++;
            }
        }
 private IoSystemLevel(IoSystem iosystem, SubnetLevel subnetLevel)
 {
     this.ioSystem = iosystem;
     IoSystemName  = this.ioSystem.Name;
     SubnetLevel   = subnetLevel;
 }
Beispiel #18
0
        private void InitializeBsp(Processor rootProcessor)
        {
            DebugStub.Print("HalDevicesApic.Initialize()\n");

            pmTimer = AcpiTables.GetPMTimer();

            // Get PIC resources.  Pic is masked by default.
            PnpConfig picConfig
                = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0000", typeof(PicStub));

            pic = new PicStub(picConfig);
            pic.Initialize(PicBaseVector);

            // Parse MP Table and create IO apics
            MpResources.ParseMpTables();
            ioApics = IoApic.CreateIOApics();

            halPic = new Apic(ioApics);
            halPic.Initialize(ApicBaseVector);

            // Apic timer is used to provide one-shot timer interrupts.
            halTimer = new ApicTimer(halPic);
            halTimer.Initialize();

            // Calibrate timers
            Calibrate.CpuCycleCounter(pmTimer);
            Calibrate.ApicTimer(pmTimer, halTimer);

            // Legacy timer is used to time stalls when starting CPUs.
            PnpConfig i8254Config
                = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0100", typeof(Timer8254Apic));

            stallTimer = new Timer8254Apic(i8254Config);

            // Real-time clock
            PnpConfig rtClockConfig
                = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0B00", typeof(RTClockApic));

            rtClock = new RTClockApic(rtClockConfig, halPic);

            // Compose our HalClock from the component clocks we have available
            halClock = new HalClockApic(halPic, rtClock, new PMClock(pmTimer));

            SystemClock.Initialize(halClock, TimeSpan.FromHours(8).Ticks);

            rootProcessor.AddPic(halPic);

            rootProcessor.AddTimer(halTimer.Interrupt, halTimer);
            rootProcessor.AddClock(halClock.Interrupt, halClock);

            InitializeProcessorCount();
            DebugReportProcessors();

            halTimer.Start();

            // Get the screen resources.  Since we have metadata above to
            // declare all fixed resources used by the screen,
            // YieldResources("") will keep the resource tracking correct:

            halScreen      = new HalScreenDirect(IoSystem.YieldResources("", typeof(HalScreen)));
            Console.Screen = (HalScreen)halScreen;

            halPic.DumpState();
            foreach (IoApic ioApic in ioApics)
            {
                ioApic.DumpRedirectionEntries();
            }
            pic.DumpRegisters();
        }
Beispiel #19
0
        public override void Initialize(Processor rootProcessor)
        {
            DebugStub.Print("HalDevices.Initialize() - Legacy\n");

            pmTimer = AcpiTables.GetPMTimer();

            // PIC
            PnpConfig picConfig
                = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0000", typeof(Pic));

            pic = new Pic(picConfig);
            pic.Initialize();

            // Timer
            PnpConfig timerConfig
                = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0100", typeof(Timer8254LegacyPC));

            timer = new Timer8254LegacyPC(timerConfig, pic);
            byte timerInterrupt = timer.Initialize();

            // Real-time clock
            PnpConfig clockConfig
                = (PnpConfig)IoSystem.YieldResources("/pnp/PNP0B00", typeof(RTClockLegacyPC));

            clock = new RTClockLegacyPC(clockConfig, pic, timer);
            byte clockInterrupt = clock.Initialize();

            bool noisyTimer = false;

            if (pmTimer != null)
            {
                noisyTimer = CalibrateTimers.Run(pmTimer, timer);
            }
            else
            {
                CalibrateTimers.Run(clock, timer);
            }

            clock.SetNoisyTimer(noisyTimer);
            clock.Start();

            SystemClock.Initialize(clock, TimeSpan.FromHours(8).Ticks);

            rootProcessor.AddPic(pic);
            rootProcessor.AddTimer(timerInterrupt, timer);
            rootProcessor.AddClock(clockInterrupt, clock);

            // ----------------------------------------------------------
            // Add Srat tables to the Processor
            halMemory = new HalMemorySrat(AcpiTables.GetSrat());
            Processor.AddMemory(halMemory);

            timer.Start();

            // Get the screen resources.  Since we have metadata above to
            // declare all fixed resources used by the screen,
            // YieldResources("") will keep the resource tracking correct:

            halScreen      = new HalScreenDirect(IoSystem.YieldResources("", typeof(HalScreen)));
            Console.Screen = (HalScreen)halScreen;
        }
Beispiel #20
0
        public static void RegisterPnpResources()
        {
            // Register our pseudo bus driver
            PseudoBus pseudo = new PseudoBus();

            IoSystem.AddRootDevice("/pseudobus0", pseudo, pseudo.ReportConfig());

            // : /pnp/PNP0700 : Floppy Controller   : PC Standard
            // : /pnp/PNP0C01 : RAM                 : System Board
            // : /pnp/PNP0A03 : PCI                 : PCI Bus
            // : /pnp/PNP0501 : Generic Serial      : 16550A COM Port
            // : /pnp/PNP0501 : Generic Serial      : 16550A COM Port
            // : /pnp/PNP0400 : AT Parallel         : LPT Port
            // : /pnp/PNP0000 : ISA 8259 PIC        : AT Interrupt Controller
            // : /pnp/PNP0200 : ISA 8237 DMA        : AT DMA Controller
            // : /pnp/PNP0100 : ISA 8254 Timer      : AT Timer
            // : /pnp/PNP0B00 : ISA RTC Controller  : AT RTC
            // : /pnp/PNP0800 : Other               : ???
            // : /pnp/PNP0C02 : Other               : PnP Event Notification
            // : /pnp/PNP0C02 : Other               : PnP Event Notification
            // : /pnp/PNP0C04 : Other               : Math Coprocessor
            // : /pnp/PNP0303 : Keyboard controller : 101/102 Keyboard
            // : /pnp/PNP0F13 : Mouse Controller    : Logitech PS/2 Mouse
            AcpiDevice[] deviceInfo = null;
            AcpiTables.Parse();
#if ACPI_ENABLED
            deviceInfo = AcpiTables.LoadDevices();
#endif // ACPI_ENABLED


            if (deviceInfo != null && deviceInfo.Length > 0)
            {
                AcpiBus !acpi = new AcpiBus(deviceInfo);
                IoSystem.AddRootDevice("/acpi0", acpi, acpi.ReportConfig());
            }
            else
            {
                PnpBios bios = new PnpBios(Resources.GetPnpBiosInfo());

                // in order for IoSystem accounting to work, we need to explicitly
                // tell it what the IoConfig of the root device is:
                IoSystem.AddRootDevice("/pnp0", bios, bios.ReportConfig());
            }

#if VESA_ENABLED
            // Add VESA Device if it exists.
            if (((!)Platform.ThePlatform).VesaBuffer != 0)
            {
                SortedList custom = new SortedList();

                custom.Add("000",
                           new PnpConfig(
                               new String[] { "/pnp/vesa" },
                               new IoRange[] {
                    new IoMemoryRange(
                        Platform.ThePlatform.VesaBuffer,
                        0x300000, Access.ReadWrite)
                }));
                IoSystem.AddDevicesToTree(custom, "/vesa0/", false);
            }
#endif // VESA_ENABLED
        }
Beispiel #21
0
        private static void InitServices()
        {
            InitGCSupport();
            args = GetCommandLine();
            VTable.ParseArgs(args);

            ARM_PROGRESS("Kernel!011");
            InitSchedulerTypes();

            ARM_PROGRESS("Kernel!018");
            Controller.InitializeSystem();
            Tracing.InitializeSystem();

            ARM_PROGRESS("Kernel!019");
            //  Read the profiler settings. The values are assumed in kbytes
            //  convert them to bytes for direct consumption
            ProfilerBufferSize  = (uint)GetIntegerArgument("profiler", 0);
            ProfilerBufferSize *= 1024;

            ARM_PROGRESS("Kernel!020");

            SpinLock.StaticInitialize();

            int cpusLength;
            int cpuCount = GetCpuCount(out cpusLength);

            Processor.InitializeProcessorTable(cpusLength);
            ARM_PROGRESS("Kernel!021");
            Tracing.Log(Tracing.Audit, "processor");
            Processor processor = Processor.EnableProcessor(0);

            PEImage.Initialize();
            ARM_PROGRESS("Kernel!034");

            //  Initialize the sample profiling for the processor
            //  after the initial breakpoint in kd in the call
            //  PEImage.Initialize(). This will allow enabling profiling
            //  from kd, by overwriting the ProfilerBufferSize value
            processor.EnableProfiling();
            ARM_PROGRESS("Kernel!035");
            FlatPages.InitializeMemoryMonitoring();

            // initialize endpoints
            InitType(typeof(Microsoft.Singularity.Channels.EndpointCore));

            // TODO Bug 59: Currently broken, need to review paging build.
//#if PAGING
//            Microsoft.Singularity.Channels.EndpointTrusted.StaticInitialize();
//#endif
            ARM_PROGRESS("Kernel!036");

            // get the system manifest
            IoMemory systemManifest = GetSystemManifest();

            ARM_PROGRESS("Kernel!037");
            XmlReader xmlReader    = new XmlReader(systemManifest);
            XmlNode   xmlData      = xmlReader.Parse();
            XmlNode   manifestRoot = xmlData.GetChild("system");
            XmlNode   initConfig   = manifestRoot.GetChild("initConfig");

            ARM_PROGRESS("Kernel!038");

            PerfCounters.Initialize();
            // need to have processed the manifest before we can call Process initialize
            ARM_PROGRESS("Kernel!039");
            PrincipalImpl.Initialize(initConfig);

            ARM_PROGRESS("Kernel!040");
            Process.Initialize(manifestRoot.GetChild("processConfig"));

            InitIO(processor, initConfig, manifestRoot.GetChild("drivers"));

            InitBootTime();

            ARM_PROGRESS("Kernel!045");
            // From here on, we want lazy type initialization to worry about
            // competing threads.
            VTable.InitializeForMultipleThread();

            ARM_PROGRESS("Kernel!046");
            Console.WriteLine("Running C# Kernel of {0}", GetLinkDate());
            Console.WriteLine();

            // TODO: remove this
            Console.WriteLine("Current time: {0}", SystemClock.GetUtcTime().ToString("r"));
            ARM_PROGRESS("Kernel!047");

            InitScheduling();

            DirectoryService.StartNotificationThread();

            Console.WriteLine("Initializing Shared Heap Walker");
            ProtectionDomain.InitializeSharedHeapWalker();
            ARM_PROGRESS("Kernel!050");

            Console.WriteLine("Initializing Service Thread");
            ServiceThread.Initialize();
            ARM_PROGRESS("Kernel!051");

            GC.EnableHeap();
            GCProfilerLogger.StartProfiling();
            ARM_PROGRESS("Kernel!052");

            Tracing.Log(Tracing.Audit, "Waypoints init");
            Waypoints   = new long[2048];
            WaypointSeq = new int[2048];
            WaypointThd = new int[2048];

            Tracing.Log(Tracing.Audit, "Interrupts ON.");
            Processor.RestoreInterrupts(true);
            ARM_PROGRESS("Kernel!053");

#if ISA_ARM && TEST_GC
            for (int i = 0; i < 1000; i++)
            {
                DebugStub.WriteLine("Iteration {0}", __arglist(i));
                ArrayList a = new ArrayList();
                for (int j = 0; j < 128; j++)
                {
                    int size = 1024 * 1024;
                    a.Add(new byte [size]);
                }
            }
#endif // ISA_ARM

            ARM_PROGRESS("Kernel!054");

            Tracing.Log(Tracing.Audit, "Binder");
            Binder.Initialize(manifestRoot.GetChild("namingConventions"));

#if ISA_ARM
            DebugStub.WriteLine("Exporting local namespace to BSP\n");
            DirectoryService.ExportArmNamespace();
            DebugStub.WriteLine("Export complete...redirecting binder\n");
            Binder.RedirectRootRef();
            DebugStub.WriteLine("Binder redirect complete\n");
#endif

#if false
            Tracing.Log(Tracing.Audit, "Starting Security Service channels");
            PrincipalImpl.Export();
            ARM_PROGRESS("Kernel!055");
#endif
            Tracing.Log(Tracing.Audit, "Creating Root Directory.");

            //This can be moved below
            IoSystem.InitializeDirectoryService();
            ARM_PROGRESS("Kernel!055");

#if false
            // Start User space namespace manager
            Console.WriteLine("Starting Directory Service SIP");
            DirectoryService.StartUserSpaceDirectoryService();
#endif
            ARM_PROGRESS("Kernel!055.5");

#if !ISA_ARM
            Tracing.Log(Tracing.Audit, "Starting Security Service channels");
            PrincipalImpl.Export();
#endif

            ARM_PROGRESS("Kernel!056");

            Console.WriteLine("Initializing system channels");

            // starting channels services
            DebugStub.Print("Initializing Channel Services\n");
            ChannelDeliveryImplService.Initialize();

            ARM_PROGRESS("Kernel!057");
            ConsoleOutput.Initialize();

            ARM_PROGRESS("Kernel!058");

            // Initialize MP after Binder and ConsoleOutput
            // are initialized so there are no
            // initialization races if the additional
            // threads try to use them.
            Tracing.Log(Tracing.Audit, "Starting additional processors");

            // For ABI to ARM support
            MpExecution.Initialize();
            ARM_PROGRESS("Kernel!059");

            mpEndEvent = new ManualResetEvent(false);

            Tracing.Log(Tracing.Audit, "Initializing Volume Manager.");

#if !ISA_ARM
            IoSystem.InitializeVolumeManager();
#endif // ISA_ARM
            ARM_PROGRESS("Kernel!060");

            InitDrivers();

            if (cpuCount > 1)
            {
                unsafe {
                    Console.WriteLine("Enabling {0} cpus out of {1} real cpus\n", cpuCount, Platform.ThePlatform.CpuRealCount);
                }
                Processor.EnableMoreProcessors(cpuCount);
                ARM_PROGRESS("Kernel!064");
            }

            Tracing.Log(Tracing.Audit, "Initializing Service Manager.");
            IoSystem.InitializeServiceManager(manifestRoot.GetChild("serviceConfig"));
            ARM_PROGRESS("Kernel!065");

            InitDiagnostics();

#if !ISA_ARM
            // At this point consider kernel finshed booting
            hasBooted = true;
#endif // ISA_ARM

            Processor.StartSampling();
            ARM_PROGRESS("Kernel!069");

            Microsoft.Singularity.KernelDebugger.KdFilesNamespace.StartNamespaceThread();
            ARM_PROGRESS("Kernel!070");
        }