source: mainline/kernel/arch/amd64/src/smp/ap.S@ cb7be8f

Last change on this file since cb7be8f was cb7be8f, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update headers in .S files that incorrectly use #-style comments

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2008 Jakub Jermar
3 * SPDX-FileCopyrightText: 2005-2006 Martin Decky
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#
9# Init code for application processors.
10#
11
12#include <abi/asmtool.h>
13#include <arch/boot/boot.h>
14#include <arch/boot/memmap.h>
15#include <arch/mm/page.h>
16#include <arch/pm.h>
17#include <arch/cpu.h>
18#include <arch/cpuid.h>
19#include <arch/context_struct.h>
20
21.section K_TEXT_START, "ax"
22
23#ifdef CONFIG_SMP
24
25# This piece of code is real-mode and is meant to be alligned at 4K boundary.
26# The requirement for such an alignment comes from MP Specification's STARTUP
27# IPI requirements.
28
29.align 4096
30SYMBOL(unmapped_ap_boot)
31.code16
32 cli
33 xorw %ax, %ax
34 movw %ax, %ds
35
36 lgdtl ap_gdtr # initialize Global Descriptor Table register
37
38 movl %cr0, %eax
39 orl $CR0_PE, %eax
40 movl %eax, %cr0 # switch to protected mode
41 jmpl $GDT_SELECTOR(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
42
43jump_to_kernel:
44.code32
45 movw $GDT_SELECTOR(KDATA_DES), %ax
46 movw %ax, %ds
47 movw %ax, %es
48 movw %ax, %ss
49 movw $GDT_SELECTOR(UDATA_DES), %ax
50 movw %ax, %gs
51
52 # Enable 64-bit page translation entries (CR4.PAE = 1).
53 # Paging is not enabled until after long mode is enabled
54
55 movl %cr4, %eax
56 orl $CR4_PAE, %eax
57 movl %eax, %cr4
58
59 leal ptl_0, %eax
60 movl %eax, %cr3
61
62 # Enable long mode
63 movl $AMD_MSR_EFER, %ecx # EFER MSR number
64 rdmsr # Read EFER
65 orl $AMD_LME, %eax # Set LME=1
66 wrmsr # Write EFER
67
68 # Enable paging to activate long mode (set CR0.PG = 1)
69 movl %cr0, %eax
70 orl $CR0_PG, %eax
71 movl %eax, %cr0
72
73 # At this point we are in compatibility mode
74 jmpl $GDT_SELECTOR(KTEXT_DES), $start64 - BOOT_OFFSET + AP_BOOT_OFFSET
75
76.code64
77start64:
78 movabsq $ctx, %rsp
79 movq CONTEXT_OFFSET_SP(%rsp), %rsp
80
81 pushq $0
82 movq %rsp, %rbp
83
84 movabsq $main_ap, %rax
85 callq *%rax # never returns
86
87#endif /* CONFIG_SMP */
88
89.section K_DATA_START, "aw", @progbits
90
91#ifdef CONFIG_SMP
92
93SYMBOL(unmapped_ap_gdtr)
94 .word 0
95 .long 0
96
97#endif /* CONFIG_SMP */
Note: See TracBrowser for help on using the repository browser.