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

Function kmain

Kernel/src/kernel.cpp:115–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114extern "C"
115[[noreturn]] void kmain(multiboot2_info_header_t* mb_info){
116 HAL::Init(mb_info);
117
118 fs::Initialize();
119
120 InitializeConstructors(); // Call global constructors
121
122 Log::LateInitialize();
123 Log::EnableBuffer();
124
125 DeviceManager::InitializeBasicDevices();
126
127 videoMode = Video::GetVideoMode();
128
129 Memory::InitializeSharedMemory();
130
131 if(debugLevelMisc >= DebugLevelVerbose){
132 Log::Info("Video Resolution: %dx%dx%d", videoMode.width, videoMode.height, videoMode.bpp);
133 }
134
135 if(videoMode.height < 600)
136 Log::Warning("Small Resolution, it is recommended to use a higher resoulution if possible.");
137 if(videoMode.bpp != 32)
138 Log::Warning("Unsupported Colour Depth expect issues.");
139
140 Video::DrawRect(0, 0, videoMode.width, videoMode.height, 0, 0, 0);
141
142 Log::Info("Used RAM: %d MB", Memory::usedPhysicalBlocks * 4096 / 1024 / 1024);
143
144 Log::Info("Initializing Ramdisk...");
145
146 fs::tar::TarVolume* tar = new fs::tar::TarVolume(HAL::bootModules[0].base, HAL::bootModules[0].size, "initrd");
147 fs::volumes->add_back(tar);
148 fs::volumes->add_back(new fs::LinkVolume(tar, "lib"));
149 Log::Write("OK");
150
151 assert(fs::GetRoot());
152 FsNode* initrd = fs::FindDir(fs::GetRoot(), "initrd");
153 FsNode* splashFile = nullptr;
154
155 if(initrd){
156 if((splashFile = fs::FindDir(initrd,"splash.bmp"))){
157 uint32_t size = splashFile->size;
158 uint8_t* buffer = (uint8_t*)kmalloc(size);
159 if(fs::Read(splashFile, 0, size, buffer))
160 Video::DrawBitmapImage(videoMode.width/2 - 620/2, videoMode.height/2 - 150/2, 621, 150, buffer);
161 } else Log::Warning("Could not load splash image");
162
163 if((splashFile = fs::FindDir(initrd,"pbar.bmp"))){
164 uint32_t size = splashFile->size;
165 progressBuffer = (uint8_t*)kmalloc(size);
166 if(fs::Read(splashFile, 0, size, progressBuffer)){
167 Video::DrawBitmapImage(videoMode.width/2 - 24*4, videoMode.height/2 + 292/2 + 48, 24, 24, progressBuffer);
168 Video::DrawBitmapImage(videoMode.width/2 - 24*3, videoMode.height/2 + 292/2 + 48, 24, 24, progressBuffer);
169 }
170 } else Log::Warning("Could not load progress bar image");
171 } else {
172 Log::Warning("Failed to find initrd!");

Callers

nothing calls this directly

Calls 15

InitializeConstructorsFunction · 0.85
LateInitializeFunction · 0.85
EnableBufferFunction · 0.85
InitializeBasicDevicesFunction · 0.85
GetVideoModeFunction · 0.85
InitializeSharedMemoryFunction · 0.85
InfoFunction · 0.85
WarningFunction · 0.85
GetRootFunction · 0.85
kmallocFunction · 0.85
InitializeFunction · 0.70
DrawRectFunction · 0.70

Tested by

no test coverage detected