MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / KernelProcess

Function KernelProcess

Kernel/src/kernel.cpp:42–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42void KernelProcess(){
43 if(progressBuffer)
44 Video::DrawBitmapImage(videoMode.width/2 + 24*1, videoMode.height/2 + 292/2 + 48, 24, 24, progressBuffer);
45
46 NVMe::Initialize();
47 USB::XHCIController::Initialize();
48 ATA::Init();
49 AHCI::Init();
50
51 if(progressBuffer)
52 Video::DrawBitmapImage(videoMode.width/2 + 24 * 2, videoMode.height/2 + 292/2 + 48, 24, 24, progressBuffer);
53
54 ServiceFS::Initialize();
55
56 if(progressBuffer)
57 Video::DrawBitmapImage(videoMode.width/2 + 24 * 3, videoMode.height/2 + 292/2 + 48, 24, 24, progressBuffer);
58
59 Log::Info("Loading Init Process...");
60 FsNode* initFsNode = nullptr;
61 char* argv[] = {"init.lef"};
62 int envc = 1;
63 char* envp[] = {"PATH=/initrd", nullptr};
64
65 if(HAL::useKCon || !(initFsNode = fs::ResolvePath("/system/lemon/init.lef"))){ // Attempt to start fterm
66 initFsNode = fs::ResolvePath("/initrd/fterm.lef");
67
68 if(!initFsNode){ // Shit has really hit the fan and fterm is not on the ramdisk
69 const char* panicReasons[]{
70 "Failed to load either init task (init.lef) or fterm (fterm.lef)!"
71 };
72 KernelPanic(panicReasons,1);
73 }
74 }
75
76 void* initElf = (void*)kmalloc(initFsNode->size);
77 fs::Read(initFsNode, 0, initFsNode->size, (uint8_t*)initElf);
78
79 process_t* initProc = Scheduler::CreateELFProcess(initElf, 1, argv, envc, envp);
80
81 strcpy(initProc->workingDir, "/");
82 strcpy(initProc->name, "Init");
83
84 Log::Write("OK");
85
86 if(FsNode* node = fs::ResolvePath("/system/lemon")){
87 fs::volumes->add_back(new fs::LinkVolume(node, "etc")); // Very hacky and cheap workaround for /etc/localtime
88 }
89
90 /*Network::InitializeDrivers();
91 Network::InitializeConnections();*/
92
93 Scheduler::EndProcess(Scheduler::GetCurrentProcess());
94
95 for(;;) {
96 GetCPULocal()->currentThread->state = ThreadStateBlocked;
97 Scheduler::Yield();
98 }
99}

Callers

nothing calls this directly

Calls 15

InfoFunction · 0.85
ResolvePathFunction · 0.85
KernelPanicFunction · 0.85
kmallocFunction · 0.85
CreateELFProcessFunction · 0.85
strcpyFunction · 0.85
EndProcessFunction · 0.85
GetCurrentProcessFunction · 0.85
GetCPULocalFunction · 0.85
DrawBitmapImageFunction · 0.70
InitializeFunction · 0.70
WriteFunction · 0.70

Tested by

no test coverage detected