Rev 188 | Rev 206 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 188 | Rev 194 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | # |
1 | # |
2 | # Copyright (C) 2001-2004 Jakub Jermar |
2 | # Copyright (C) 2001-2004 Ondrej Palkovsky |
3 | # All rights reserved. |
3 | # All rights reserved. |
4 | # |
4 | # |
5 | # Redistribution and use in source and binary forms, with or without |
5 | # Redistribution and use in source and binary forms, with or without |
6 | # modification, are permitted provided that the following conditions |
6 | # modification, are permitted provided that the following conditions |
7 | # are met: |
7 | # are met: |
Line 24... | Line 24... | ||
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 |
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. |
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | # |
27 | # |
28 | 28 | ||
- | 29 | #define __ASM__ |
|
- | 30 | ||
- | 31 | #include <arch/mm/page.h> |
|
29 | #include <arch/mm/ptl.h> |
32 | #include <arch/mm/ptl.h> |
- | 33 | #include <arch/pm.h> |
|
30 | 34 | ||
31 | #define START_STACK 0x7c00 |
35 | #define START_STACK 0x7c00 |
32 | #define START_STACK_64 $0xffffffff80007c00 |
36 | #define START_STACK_64 $0xffffffff80007c00 |
33 | 37 | ||
34 | # |
38 | # |
Line 49... | Line 53... | ||
49 | movw %ax,%ss # initialize stack segment register |
53 | movw %ax,%ss # initialize stack segment register |
50 | movl START_STACK,%esp # initialize stack pointer |
54 | movl START_STACK,%esp # initialize stack pointer |
51 | 55 | ||
52 | # call memmap_arch_init |
56 | # call memmap_arch_init |
53 | 57 | ||
54 | mov $0x80000000, %eax |
58 | movl $0x80000000, %eax |
55 | cpuid |
59 | cpuid |
56 | cmp $0x80000000, %eax # any function > 80000000h? |
60 | cmp $0x80000000, %eax # any function > 80000000h? |
57 | jbe no_long_mode |
61 | jbe no_long_mode |
58 | mov $0x80000001, %eax # Extended function code 80000001 |
62 | movl $0x80000001, %eax # Extended function code 80000001 |
59 | cpuid |
63 | cpuid |
60 | bt $29, %edx # Test if long mode is supported. |
64 | bt $29, %edx # Test if long mode is supported. |
61 | jnc no_long_mode |
65 | jnc no_long_mode |
62 | 66 | ||
63 | # Load gdtr, idtr |
67 | # Load gdtr, idtr |
Line 66... | Line 70... | ||
66 | 70 | ||
67 | movl %cr0,%eax |
71 | movl %cr0,%eax |
68 | orl $0x1,%eax |
72 | orl $0x1,%eax |
69 | movl %eax,%cr0 # switch to protected mode |
73 | movl %eax,%cr0 # switch to protected mode |
70 | 74 | ||
71 | jmpl $40, $now_in_prot |
75 | jmpl $selector(KTEXT32_DES), $now_in_prot |
72 | 76 | ||
73 | no_long_mode: |
77 | no_long_mode: |
74 | 1: |
78 | 1: |
75 | jmp 1b |
79 | jmp 1b |
76 | 80 | ||
77 | # Protected 16-bit. We want to reuse the code-seg descriptor, |
81 | # Protected 16-bit. We want to reuse the code-seg descriptor, |
78 | # the Default operand size must not be 1 when entering long mode |
82 | # the Default operand size must not be 1 when entering long mode |
79 | now_in_prot: |
83 | now_in_prot: |
80 | # Set up stack & data descriptors |
84 | # Set up stack & data descriptors |
81 | movw $16, %ax |
85 | movw $selector(KDATA_DES), %ax |
82 | movw %ax, %ds |
86 | movw %ax, %ds |
83 | movw %ax, %fs |
87 | movw %ax, %fs |
84 | movw %ax, %gs |
88 | movw %ax, %gs |
85 | movw %ax, %ss |
89 | movw %ax, %ss |
86 | 90 | ||
Line 104... | Line 108... | ||
104 | movl %cr0, %eax |
108 | movl %cr0, %eax |
105 | btsl $31, %eax |
109 | btsl $31, %eax |
106 | movl %eax, %cr0 |
110 | movl %eax, %cr0 |
107 | 111 | ||
108 | # At this point we are in compatibility mode |
112 | # At this point we are in compatibility mode |
109 | jmpl $8, $start64 |
113 | jmpl $selector(KTEXT_DES), $start64 |
110 | 114 | ||
111 | .code64 |
115 | .code64 |
112 | start64: |
116 | start64: |
113 | movq START_STACK_64, %rsp |
117 | movq START_STACK_64, %rsp |
114 | 118 | ||
Line 147... | Line 151... | ||
147 | .fill 510,8,0 |
151 | .fill 510,8,0 |
148 | .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT) |
152 | .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT) |
149 | 153 | ||
150 | .global gdtr_inst |
154 | .global gdtr_inst |
151 | gdtr_inst: |
155 | gdtr_inst: |
152 | .word 7*8 # GDT_ITEMS * 8 |
156 | .word selector(GDT_ITEMS) |
153 | .long gdt + 0x80000000 |
157 | .long KA2PA(gdt) |
154 | 158 | ||
155 | .global idtr_inst |
159 | .global idtr_inst |
156 | idtr_inst: |
160 | idtr_inst: |
157 | .word 0 |
161 | .word 0 |
158 | .long idt + 0x80000000 |
162 | .long KA2PA(idt) |