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

Function SMPEntry

Kernel/src/arch/x86_64/smp.cpp:39–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37 CPU* cpus[256];
38 unsigned processorCount = 1;
39 tss_t tss1 __attribute__((aligned(16)));
40
41 void SMPEntry(uint16_t id){
42 CPU* cpu = cpus[id];
43 cpu->currentThread = nullptr;
44 cpu->runQueueLock = 0;
45 SetCPULocal(cpu);
46
47 cpu->gdt = Memory::KernelAllocate4KPages(1);//kmalloc(GDT64Pointer64.limit + 1); // Account for the 1 subtracted from limit
48 Memory::KernelMapVirtualMemory4K(Memory::AllocatePhysicalMemoryBlock(), (uintptr_t)cpu->gdt, 1);
49 memcpy(cpu->gdt, (void*)GDT64Pointer64.base, GDT64Pointer64.limit + 1); // Make a copy of the GDT
50 cpu->gdtPtr = {.limit = GDT64Pointer64.limit, .base = (uint64_t)cpu->gdt};
51
52 asm volatile("lgdt (%%rax)" :: "a"(&cpu->gdtPtr));
53
54 idt_flush();
55
56 TSS::InitializeTSS(&cpu->tss, cpu->gdt);
57
58 APIC::Local::Enable();
59
60 cpu->runQueue = new FastList<thread_t*>();
61
62 doneInit = true;
63
64 asm("sti");
65
66 for(;;);
67 }
68
69 void PrepareTrampoline(){
70 memcpy((void*)SMP_TRAMPOLINE_ENTRY, &_binary_smptrampoline_bin_start, ((uint64_t)&_binary_smptrampoline_bin_size));

Callers

nothing calls this directly

Calls 7

SetCPULocalFunction · 0.85
KernelAllocate4KPagesFunction · 0.85
KernelMapVirtualMemory4KFunction · 0.85
memcpyFunction · 0.85
InitializeTSSFunction · 0.85
EnableFunction · 0.85

Tested by

no test coverage detected