MOS Source Code
Loading...
Searching...
No Matches
ap_entry.c
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#define pr_fmt(fmt) "ap_entry: " fmt
4
6
8#include "mos/syslog/printk.h"
10#include "mos/x86/cpu/cpu.h"
14
15static bool aps_blocked = true;
16
18{
20 aps_blocked = false;
21}
22
24{
25 MOS_UNUSED(arg);
26
27#if !MOS_CONFIG(MOS_SMP)
28 pr_info("SMP not enabled, halting AP");
30#endif
31
32 while (aps_blocked)
33 __asm__ volatile("pause");
34
38
39 // enable paging
41
45
46 const u8 processor_id = platform_current_cpu_id();
47 pr_dinfo2(x86_startup, "AP %u started", processor_id);
48
49 const u8 lapic_id = lapic_get_id();
50 if (lapic_id != processor_id)
51 pr_warn("LAPIC ID mismatch: LAPIC_ID: %u != PROCESSOR_ID: %u", lapic_id, processor_id);
52
53 current_cpu->mm_context = platform_info->kernel_mm;
54 current_cpu->id = lapic_id;
55
58}
static bool aps_blocked
Definition ap_entry.c:15
void platform_ap_entry(u64 arg)
Definition ap_entry.c:23
void x86_unblock_aps(void)
Definition ap_entry.c:17
should_inline u8 lapic_get_id(void)
Definition apic.h:45
void lapic_enable(void)
Definition lapic.c:136
void platform_halt_cpu(void)
Definition mm.c:65
#define MOS_ASSERT(cond)
Definition assert.h:14
void x86_cpu_initialise_caps(void)
Definition cpu.c:20
void x86_cpu_setup_xsave_area(void)
Definition cpu.c:37
void x86_init_percpu_gdt()
Definition descriptors.c:59
void x86_init_percpu_tss()
Definition descriptors.c:86
void x86_init_percpu_idt(void)
Definition idt.c:36
#define MOS_UNUSED(x)
Definition mos_global.h:64
#define current_cpu
Definition platform.h:29
#define pr_warn(fmt,...)
Definition printk.h:38
#define pr_info(fmt,...)
Definition printk.h:35
#define pr_dinfo2(feat, fmt,...)
Definition printk.h:27
mos_platform_info_t *const platform_info
void platform_switch_mm(const mm_context_t *new_mm)
u32 platform_current_cpu_id()
void enter_scheduler(void)
Enter the scheduler and switch to the next thread.
Definition schedule.c:67
mm_context_t * kernel_mm
Definition platform.h:118
unsigned long long u64
Definition types.h:23
unsigned char u8
Definition types.h:19
void x86_setup_lapic_timer()