MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / main

Function main

tests/system_test/main.cpp:276–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276auto main(int argc, const char** argv) -> int {
277 per_cpu::PerCpuArraySingleton::create();
278 per_cpu::GetCurrentCore() = per_cpu::PerCpu(cpu_io::GetCurrentCoreId());
279
280 ArchInit(argc, argv);
281 MemoryInit();
282 InterruptInit(argc, argv);
283 DeviceInit();
284 FileSystemInit();
285
286 TaskManagerSingleton::create();
287 TaskManagerSingleton::instance().InitCurrentCore();
288
289 TimerInit();
290
291 WakeUpOtherCores();
292
293 DumpStack();
294
295 klog::Info("Hello SimpleKernel");
296
297 for (size_t i = 0; i < kTestCount; ++i) {
298 test_results[i].name = test_cases[i].name;
299 test_results[i].status = TestThreadStatus::kPending;
300 test_results[i].exit_code = -1;
301 test_results[i].pid = 0;
302 }
303
304 // Phase 1: SMP 测试同步运行(需要跨核屏障协调,必须在调度器启动前完成)
305 size_t expected_cores = BasicInfoSingleton::instance().core_count - 1;
306 klog::Info("[RUNNER] Waiting for {} secondary core(s) to initialize...",
307 expected_cores);
308 while (g_cores_ready.load(std::memory_order_acquire) < expected_cores) {
309 cpu_io::Pause();
310 }
311 klog::Info("[RUNNER] All cores ready, starting SMP tests");
312
313 for (size_t i = 0; i < kTestCount; ++i) {
314 if (!test_cases[i].is_smp_test) {
315 continue;
316 }
317 auto& result = test_results[i];
318 result.status = TestThreadStatus::kRunning;
319
320 klog::Info("[SMP] Running: {}", test_cases[i].name);
321 bool smp_passed = test_cases[i].func();
322
323 result.exit_code = smp_passed ? 0 : 1;
324 result.status =
325 smp_passed ? TestThreadStatus::kPassed : TestThreadStatus::kFailed;
326
327 klog::Info("[SMP] Finished: {} — {}", test_cases[i].name,
328 smp_passed ? "PASS" : "FAIL");
329 }
330
331 auto runner = kstd::make_unique<TaskControlBlock>("test_runner", 10,
332 test_runner_entry, nullptr);
333 TaskManagerSingleton::instance().AddTask(std::move(runner));

Callers 1

_startFunction · 0.70

Calls 15

GetCurrentCoreFunction · 0.85
PerCpuClass · 0.85
GetCurrentCoreIdFunction · 0.85
MemoryInitFunction · 0.85
DeviceInitFunction · 0.85
FileSystemInitFunction · 0.85
InfoFunction · 0.85
PauseFunction · 0.85
AddTaskMethod · 0.80
ScheduleMethod · 0.80
ArchInitFunction · 0.50
InterruptInitFunction · 0.50

Tested by

no test coverage detected