[f761f1eb] | 1 | #
|
---|
[df4ed85] | 2 | # Copyright (c) 2001-2004 Jakub Jermar
|
---|
| 3 | # Copyright (c) 2005-2006 Martin Decky
|
---|
[f761f1eb] | 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 |
|
---|
[e0e00d7] | 30 | /*
|
---|
| 31 | * Init code for application processors.
|
---|
| 32 | */
|
---|
[f761f1eb] | 33 |
|
---|
[8844e70] | 34 | #include <abi/asmtool.h>
|
---|
[66def8d] | 35 | #include <arch/boot/boot.h>
|
---|
| 36 | #include <arch/boot/memmap.h>
|
---|
| 37 | #include <arch/mm/page.h>
|
---|
| 38 | #include <arch/pm.h>
|
---|
[57c2a87] | 39 | #include <arch/cpu.h>
|
---|
[4928165] | 40 | #include <arch/context_struct.h>
|
---|
[66def8d] | 41 |
|
---|
| 42 | .section K_TEXT_START, "ax"
|
---|
[f761f1eb] | 43 |
|
---|
[5f85c91] | 44 | #ifdef CONFIG_SMP
|
---|
[f761f1eb] | 45 |
|
---|
| 46 | KTEXT=8
|
---|
| 47 | KDATA=16
|
---|
| 48 |
|
---|
[1b20da0] | 49 | /*
|
---|
[e0e00d7] | 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 | */
|
---|
[f761f1eb] | 54 |
|
---|
| 55 | .align 4096
|
---|
[8844e70] | 56 | SYMBOL(unmapped_ap_boot)
|
---|
[f761f1eb] | 57 | .code16
|
---|
| 58 | cli
|
---|
[f6297e0] | 59 | xorw %ax, %ax
|
---|
| 60 | movw %ax, %ds
|
---|
[f761f1eb] | 61 |
|
---|
[e0e00d7] | 62 | /* initialize Global Descriptor Table register */
|
---|
| 63 | lgdtl ap_gdtr
|
---|
[a35b458] | 64 |
|
---|
[e0e00d7] | 65 | /* switch to protected mode */
|
---|
[f6297e0] | 66 | movl %cr0, %eax
|
---|
[57c2a87] | 67 | orl $CR0_PE, %eax
|
---|
[e0e00d7] | 68 | movl %eax, %cr0
|
---|
[66def8d] | 69 | jmpl $KTEXT, $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
|
---|
[a35b458] | 70 |
|
---|
[f761f1eb] | 71 | jump_to_kernel:
|
---|
| 72 | .code32
|
---|
[f6297e0] | 73 | movw $KDATA, %ax
|
---|
| 74 | movw %ax, %ds
|
---|
| 75 | movw %ax, %es
|
---|
| 76 | movw %ax, %ss
|
---|
[65f3117] | 77 | movl $KA2PA(bootstrap_stack_top), %eax /* KA2PA((uintptr_t) &bootstrap_stack_top) */
|
---|
| 78 | movl (%eax), %esp
|
---|
[e98f1c3e] | 79 | leal KA2PA(0)(%esp), %esp /* KA2PA(ctx.sp) */
|
---|
[f761f1eb] | 80 |
|
---|
[e0e00d7] | 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
|
---|
[a35b458] | 86 |
|
---|
[e98f1c3e] | 87 | addl $PA2KA(0), %esp /* PA2KA(ctx.sp) */
|
---|
[a35b458] | 88 |
|
---|
[e0e00d7] | 89 | /* create the first stack frame */
|
---|
| 90 | pushl $0
|
---|
[bac86377] | 91 | movl %esp, %ebp
|
---|
| 92 |
|
---|
[f6297e0] | 93 | jmpl $KTEXT, $main_ap
|
---|
[f761f1eb] | 94 |
|
---|
[5f85c91] | 95 | #endif /* CONFIG_SMP */
|
---|
[66def8d] | 96 |
|
---|
| 97 |
|
---|
[4e09712] | 98 | .section K_DATA_START, "aw", @progbits
|
---|
[66def8d] | 99 |
|
---|
| 100 | #ifdef CONFIG_SMP
|
---|
| 101 |
|
---|
[8844e70] | 102 | SYMBOL(unmapped_ap_gdtr)
|
---|
[66def8d] | 103 | .word 0
|
---|
| 104 | .long 0
|
---|
| 105 |
|
---|
| 106 | #endif /* CONFIG_SMP */
|
---|