Subversion Repositories HelenOS

Rev

Rev 2071 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2071 Rev 2703
Line 1... Line 1...
1
#
1
#
2
# Copyright (c) 2001-2004 Jakub Jermar
2
# Copyright (c) 2008 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
Line 43... Line 43...
43
#ifdef CONFIG_SMP
43
#ifdef CONFIG_SMP
44
 
44
 
45
.global unmapped_ap_boot
45
.global unmapped_ap_boot
46
 
46
 
47
# This piece of code is real-mode and is meant to be alligned at 4K boundary.
47
# This piece of code is real-mode and is meant to be alligned at 4K boundary.
48
# The requirement for such an alignment comes from MP Specification's STARTUP IPI
48
# The requirement for such an alignment comes from MP Specification's STARTUP
49
# requirements.
49
# IPI requirements.
50
 
50
 
51
.align 4096
51
.align 4096
52
unmapped_ap_boot:
52
unmapped_ap_boot:
53
.code16
53
.code16
54
	cli
54
	cli
Line 57... Line 57...
57
 
57
 
58
	lgdtl ap_gdtr		# initialize Global Descriptor Table register
58
	lgdtl ap_gdtr		# initialize Global Descriptor Table register
59
	
59
	
60
	movl %cr0, %eax
60
	movl %cr0, %eax
61
	orl $1, %eax
61
	orl $1, %eax
62
	movl %eax, %cr0				# switch to protected mode
62
	movl %eax, %cr0		# switch to protected mode
63
	jmpl $gdtselector(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
63
	jmpl $gdtselector(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
64
	
64
	
65
jump_to_kernel:
65
jump_to_kernel:
66
.code32
66
.code32
67
	movw $gdtselector(KDATA_DES), %ax
67
	movw $gdtselector(KDATA_DES), %ax
Line 80... Line 80...
80
 
80
 
81
	leal ptl_0, %eax
81
	leal ptl_0, %eax
82
	movl %eax, %cr3
82
	movl %eax, %cr3
83
	
83
	
84
	# Enable long mode
84
	# Enable long mode
85
	movl $EFER_MSR_NUM, %ecx   # EFER MSR number
85
	movl $EFER_MSR_NUM, %ecx	# EFER MSR number
86
	rdmsr                   # Read EFER
86
	rdmsr				# Read EFER
87
	btsl $AMD_LME_FLAG, %eax            # Set LME=1
87
	btsl $AMD_LME_FLAG, %eax	# Set LME=1
88
	wrmsr                   # Write EFER
88
	wrmsr				# Write EFER
89
	
89
	
90
	# Enable paging to activate long mode (set CR0.PG=1)
90
	# Enable paging to activate long mode (set CR0.PG=1)
91
	movl %cr0, %eax
91
	movl %cr0, %eax
92
	btsl $31, %eax
92
	btsl $31, %eax
93
	movl %eax, %cr0
93
	movl %eax, %cr0
Line 105... Line 105...
105
.section K_DATA_START, "aw", @progbits
105
.section K_DATA_START, "aw", @progbits
106
 
106
 
107
#ifdef CONFIG_SMP
107
#ifdef CONFIG_SMP
108
 
108
 
109
.global unmapped_ap_gdtr
109
.global unmapped_ap_gdtr
110
 
-
 
111
unmapped_ap_gdtr:
110
unmapped_ap_gdtr:
112
	.word 0
111
	.word 0
113
	.long 0
112
	.long 0
114
 
113
 
115
#endif /* CONFIG_SMP */
114
#endif /* CONFIG_SMP */