source: mainline/kernel/arch/ia32/src/smp/ap.S@ e98f1c3e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since e98f1c3e was e98f1c3e, checked in by Martin Decky <martin@…>, 9 years ago

cstyle (no change in functionality)

  • Property mode set to 100644
File size: 2.9 KB
Line 
1#
2# Copyright (c) 2001-2004 Jakub Jermar
3# Copyright (c) 2005-2006 Martin Decky
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# - Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# - Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution.
15# - The name of the author may not be used to endorse or promote products
16# derived from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29
30/*
31 * Init code for application processors.
32 */
33
34#include <abi/asmtool.h>
35#include <arch/boot/boot.h>
36#include <arch/boot/memmap.h>
37#include <arch/mm/page.h>
38#include <arch/pm.h>
39#include <arch/cpu.h>
40#include <arch/context_struct.h>
41
42.section K_TEXT_START, "ax"
43
44#ifdef CONFIG_SMP
45
46KTEXT=8
47KDATA=16
48
49/*
50 * This piece of code is real-mode and is meant to be aligned at 4K boundary.
51 * The requirement for such an alignment comes from MP Specification's
52 * STARTUP IPI requirements.
53 */
54
55.align 4096
56SYMBOL(unmapped_ap_boot)
57.code16
58 cli
59 xorw %ax, %ax
60 movw %ax, %ds
61
62 /* initialize Global Descriptor Table register */
63 lgdtl ap_gdtr
64
65 /* switch to protected mode */
66 movl %cr0, %eax
67 orl $CR0_PE, %eax
68 movl %eax, %cr0
69 jmpl $KTEXT, $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
70
71jump_to_kernel:
72.code32
73 movw $KDATA, %ax
74 movw %ax, %ds
75 movw %ax, %es
76 movw %ax, %ss
77 movl $KA2PA(ctx), %eax /* KA2PA((uintptr_t) &ctx) */
78 movl CONTEXT_OFFSET_SP(%eax), %esp
79 leal KA2PA(0)(%esp), %esp /* KA2PA(ctx.sp) */
80
81 /*
82 * Map kernel and turn paging on.
83 * We assume that when using SMP, PSE is always available
84 */
85 call map_kernel_pse
86
87 addl $PA2KA(0), %esp /* PA2KA(ctx.sp) */
88
89 /* create the first stack frame */
90 pushl $0
91 movl %esp, %ebp
92
93 jmpl $KTEXT, $main_ap
94
95#endif /* CONFIG_SMP */
96
97
98.section K_DATA_START, "aw", @progbits
99
100#ifdef CONFIG_SMP
101
102SYMBOL(unmapped_ap_gdtr)
103 .word 0
104 .long 0
105
106#endif /* CONFIG_SMP */
Note: See TracBrowser for help on using the repository browser.