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
5
#include "
mos/x86/cpu/ap_entry.h
"
6
7
#include "
mos/platform/platform.h
"
8
#include "
mos/syslog/printk.h
"
9
#include "
mos/tasks/schedule.h
"
10
#include "
mos/x86/cpu/cpu.h
"
11
#include "
mos/x86/descriptors/descriptors.h
"
12
#include "
mos/x86/interrupt/apic.h
"
13
#include "
mos/x86/x86_platform.h
"
14
15
static
bool
aps_blocked
=
true
;
16
17
void
x86_unblock_aps
(
void
)
18
{
19
MOS_ASSERT
(
aps_blocked
);
20
aps_blocked
=
false
;
21
}
22
23
void
platform_ap_entry
(
u64
arg)
24
{
25
MOS_UNUSED
(arg);
26
27
#if !MOS_CONFIG(MOS_SMP)
28
pr_info
(
"SMP not enabled, halting AP"
);
29
platform_halt_cpu
();
30
#endif
31
32
while
(
aps_blocked
)
33
__asm__
volatile
(
"pause"
);
34
35
x86_init_percpu_gdt
();
36
x86_init_percpu_tss
();
37
x86_init_percpu_idt
();
38
39
// enable paging
40
platform_switch_mm
(
platform_info
->
kernel_mm
);
41
42
x86_cpu_initialise_caps
();
43
x86_cpu_setup_xsave_area
();
44
lapic_enable
();
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
56
x86_setup_lapic_timer
();
57
enter_scheduler
();
58
}
aps_blocked
static bool aps_blocked
Definition
ap_entry.c:15
platform_ap_entry
void platform_ap_entry(u64 arg)
Definition
ap_entry.c:23
x86_unblock_aps
void x86_unblock_aps(void)
Definition
ap_entry.c:17
ap_entry.h
apic.h
lapic_get_id
should_inline u8 lapic_get_id(void)
Definition
apic.h:45
lapic_enable
void lapic_enable(void)
Definition
lapic.c:136
platform_halt_cpu
void platform_halt_cpu(void)
Definition
mm.c:65
MOS_ASSERT
#define MOS_ASSERT(cond)
Definition
assert.h:14
x86_cpu_initialise_caps
void x86_cpu_initialise_caps(void)
Definition
cpu.c:20
x86_cpu_setup_xsave_area
void x86_cpu_setup_xsave_area(void)
Definition
cpu.c:37
x86_init_percpu_gdt
void x86_init_percpu_gdt()
Definition
descriptors.c:59
x86_init_percpu_tss
void x86_init_percpu_tss()
Definition
descriptors.c:86
descriptors.h
x86_init_percpu_idt
void x86_init_percpu_idt(void)
Definition
idt.c:36
MOS_UNUSED
#define MOS_UNUSED(x)
Definition
mos_global.h:64
platform.h
current_cpu
#define current_cpu
Definition
platform.h:29
printk.h
pr_warn
#define pr_warn(fmt,...)
Definition
printk.h:38
pr_info
#define pr_info(fmt,...)
Definition
printk.h:35
pr_dinfo2
#define pr_dinfo2(feat, fmt,...)
Definition
printk.h:27
platform_info
mos_platform_info_t *const platform_info
Definition
riscv64_platform.c:15
platform_switch_mm
void platform_switch_mm(const mm_context_t *new_mm)
Definition
riscv64_platform_api.c:137
platform_current_cpu_id
u32 platform_current_cpu_id()
Definition
riscv64_platform_api.c:41
schedule.h
enter_scheduler
void enter_scheduler(void)
Enter the scheduler and switch to the next thread.
Definition
schedule.c:67
mos_platform_info_t::kernel_mm
mm_context_t * kernel_mm
Definition
platform.h:118
u64
unsigned long long u64
Definition
types.h:23
u8
unsigned char u8
Definition
types.h:19
cpu.h
x86_platform.h
x86_setup_lapic_timer
void x86_setup_lapic_timer()
Definition
x86_platform.c:86
kernel
arch
x86_64
cpu
ap_entry.c
Generated on Sun Sep 1 2024 18:22:52 for MOS Source Code by
1.12.0