package kernel; import kernel.binstore.BinStore; import kernel.gps.INS; import kernel.fs.FS; import kernel.gps.GPS; import kernel.log.Log; import kernel.turtle.Turtle; import haxe.MainLoop; import kernel.net.Routing; import cc.OS; import lib.Debug; import kernel.ui.WindowManager; import kernel.peripherals.Peripherals.Peripheral; import kernel.net.Net; class Init { @:allow(kernel.KernelEvents) private static var mainEvent:MainEvent; public static function initKernel() { // Init singeltons here because haxe is confused about the order to create them. Log.instance = new Log(); KernelEvents.instance = new KernelEvents(); Peripheral.instance = new Peripheral(); WindowManager.instance = new WindowManager(); MainTerm.instance = new MainTerm(); BinStore.instance = new BinStore(); if (Turtle.isTurtle()){ Turtle.instance = new Turtle(); } Routing.instance = new Routing(); Net.instance = new Net(); GPS.instance = new GPS(); INS.instance = new INS(); // Register default terminate handler KernelEvents.instance.onTerminate.handle(_->{ OS.reboot(); }); Debug.printBuildInfo(); Routing.instance.init(); if (!FS.exists("/var/ns")) { FS.makeDir("/var/ns"); } Init.mainEvent = MainLoop.add(()->{ KernelEvents.instance.startEventLoop(); }); } }