Subversion Repositories HelenOS-historic

Rev

Rev 1246 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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