cc-haxe/src/kernel/Init.hx

45 lines
968 B
Haxe
Raw Normal View History

2022-02-21 00:50:19 +00:00
package kernel;
2023-03-20 00:15:07 +00:00
import kernel.log.Log;
2022-04-10 23:00:23 +00:00
import kernel.turtle.Turtle;
2022-02-24 18:47:27 +00:00
import haxe.MainLoop;
import kernel.net.Routing;
2022-02-21 16:46:38 +00:00
import cc.OS;
2022-12-19 20:06:23 +00:00
import lib.Debug;
2022-02-21 00:50:19 +00:00
import kernel.ui.WindowManager;
import kernel.peripherals.Peripherals.Peripheral;
import kernel.net.Net;
class Init {
2022-02-21 14:35:37 +00:00
public static function initKernel() {
// Init singeltons here because haxe is confused about the order to create them.
2023-03-20 00:15:07 +00:00
Log.instance = new Log();
2022-02-21 14:35:37 +00:00
KernelEvents.instance = new KernelEvents();
Peripheral.instance = new Peripheral();
2022-02-21 00:50:19 +00:00
2022-02-21 14:35:37 +00:00
WindowManager.instance = new WindowManager();
2023-01-30 02:14:54 +00:00
MainTerm.instance = new MainTerm();
2022-02-24 18:47:27 +00:00
2022-04-10 23:00:23 +00:00
if (Turtle.isTurtle()){
Turtle.instance = new Turtle();
}
2022-02-24 18:47:27 +00:00
Routing.instance = new Routing();
2022-02-21 14:35:37 +00:00
Net.instance = new Net();
2022-02-21 16:46:38 +00:00
// Register default terminate handler
KernelEvents.instance.onTerminate.handle(_->{
OS.reboot();
});
2022-02-21 14:35:37 +00:00
Debug.printBuildInfo();
2022-02-24 18:47:27 +00:00
2022-03-01 11:59:23 +00:00
Routing.instance.init();
MainLoop.add(()->{
KernelEvents.instance.startEventLoop();
});
2022-02-21 14:35:37 +00:00
}
2022-02-21 00:50:19 +00:00
}