source: mainline/arch/amd64/src/smp/ap.S@ 46d26ee

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 46d26ee was 2ccd275, checked in by Jakub Jermar <jakub@…>, 20 years ago

Changes in build system.
For .S targets, always do -DASM.
Remove unnecessary #define ASM from various *.S files.
At the end of build, generate disassembler dump for kernel.raw.

ia64 work.
Better General Exception handler.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1#
2# Copyright (C) 2001-2004 Jakub Jermar
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29#
30# Init code for application processors.
31#
32
33#include <arch/boot/boot.h>
34#include <arch/pm.h>
35#include <arch/cpu.h>
36#include <arch/cpuid.h>
37#include <arch/mm/page.h>
38
39.section K_TEXT_START_2, "ax"
40
41#ifdef CONFIG_SMP
42
43.global ap_boot
44
45# This piece of code is real-mode and is meant to be alligned at 4K boundary.
46# The requirement for such an alignment comes from MP Specification's STARTUP IPI
47# requirements.
48
49.align 4096
50ap_boot:
51.code16
52 cli
53 xorw %ax, %ax
54 movw %ax, %ds
55
56 lgdt real_bootstrap_gdtr_boot # initialize Global Descriptor Table register
57
58 movl %cr0, %eax
59 orl $1, %eax
60 movl %eax, %cr0 # switch to protected mode
61
62 jmpl $gdtselector(KTEXT32_DES), $now_in_prot
63
64.code32
65now_in_prot:
66 movw $gdtselector(KDATA_DES), %ax
67 movw %ax, %ds
68 movw %ax, %ss
69
70
71 # Enable 64-bit page transaltion entries - CR4.PAE = 1.
72 # Paging is not enabled until after long mode is enabled
73 movl %cr4, %eax
74 btsl $5, %eax
75 movl %eax, %cr4
76
77 # Set up NEW paging tables, that are
78 # already moved BOOT_OFFSET up
79 leal ptl_0+BOOT_OFFSET, %eax
80 movl %eax, %cr3
81
82 # Enable long mode
83 movl $EFER_MSR_NUM, %ecx # EFER MSR number
84 rdmsr # Read EFER
85 btsl $AMD_LME_FLAG, %eax # Set LME=1
86 wrmsr # Write EFER
87
88 # Enable paging to activate long mode (set CR0.PG=1)
89 movl %cr0, %eax
90 btsl $31, %eax
91 movl %eax, %cr0
92
93 # At this point we are in compatibility mode
94 jmpl $gdtselector(KTEXT_DES), $start64
95
96.code64
97start64:
98 movq (ctx), %rsp
99 call main_ap # never returns
100
101
102#endif /* CONFIG_SMP */
Note: See TracBrowser for help on using the repository browser.