Changeset a35b458 in mainline for kernel/arch/amd64/src/boot/multiboot2.S
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/boot/multiboot2.S
r3061bc1 ra35b458 47 47 .long multiboot2_header_end - multiboot2_header_start 48 48 .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_HEADER_ARCH_I386 + (multiboot2_header_end - multiboot2_header_start)) 49 49 50 50 /* Information request tag */ 51 51 .align 8 … … 61 61 #endif 62 62 tag_info_req_end: 63 63 64 64 /* Address tag */ 65 65 .align 8 … … 73 73 .long 0 74 74 tag_address_end: 75 75 76 76 /* Entry address tag */ 77 77 .align 8 … … 82 82 .long multiboot2_image_start 83 83 tag_entry_address_end: 84 84 85 85 /* Flags tag */ 86 86 .align 8 … … 91 91 .long MULTIBOOT2_FLAGS_CONSOLE 92 92 tag_flags_end: 93 93 94 94 #ifdef CONFIG_FB 95 95 /* Framebuffer tag */ … … 104 104 tag_framebuffer_end: 105 105 #endif 106 106 107 107 /* Module alignment tag */ 108 108 .align 8 … … 113 113 .long 0 114 114 tag_module_align_end: 115 115 116 116 /* Tag terminator */ 117 117 .align 8 … … 126 126 cli 127 127 cld 128 128 129 129 /* Initialize stack pointer */ 130 130 movl $START_STACK, %esp 131 131 132 132 /* 133 133 * Initialize Global Descriptor Table and … … 136 136 lgdtl bootstrap_gdtr 137 137 lidtl bootstrap_idtr 138 138 139 139 /* Kernel data + stack */ 140 140 movw $GDT_SELECTOR(KDATA_DES), %cx … … 142 142 movw %cx, %ds 143 143 movw %cx, %ss 144 144 145 145 /* 146 146 * Simics seems to remove hidden part of GS on entering user mode … … 150 150 movw %cx, %fs 151 151 movw %cx, %gs 152 152 153 153 jmpl $GDT_SELECTOR(KTEXT32_DES), $multiboot2_meeting_point 154 154 multiboot2_meeting_point: 155 155 156 156 /* 157 157 * Protected 32-bit. We want to reuse the code-seg descriptor, 158 158 * the Default operand size must not be 1 when entering long mode. 159 159 */ 160 160 161 161 /* Save multiboot arguments */ 162 162 movl %eax, multiboot_eax 163 163 movl %ebx, multiboot_ebx 164 164 165 165 movl $(INTEL_CPUID_EXTENDED), %eax 166 166 cpuid 167 167 cmp $(INTEL_CPUID_EXTENDED), %eax 168 168 ja extended_cpuid_supported 169 170 jmp pm_error_halt 171 169 170 jmp pm_error_halt 171 172 172 extended_cpuid_supported: 173 173 174 174 movl $(AMD_CPUID_EXTENDED), %eax 175 175 cpuid 176 176 bt $(AMD_EXT_LONG_MODE), %edx 177 177 jc long_mode_supported 178 179 jmp pm_error_halt 180 178 179 jmp pm_error_halt 180 181 181 long_mode_supported: 182 182 183 183 bt $(AMD_EXT_NOEXECUTE), %edx 184 184 jc noexecute_supported 185 186 jmp pm_error_halt 187 185 186 jmp pm_error_halt 187 188 188 noexecute_supported: 189 189 190 190 movl $(INTEL_CPUID_STANDARD), %eax 191 191 cpuid 192 192 bt $(INTEL_FXSAVE), %edx 193 193 jc fx_supported 194 195 jmp pm_error_halt 196 194 195 jmp pm_error_halt 196 197 197 fx_supported: 198 198 199 199 bt $(INTEL_SSE2), %edx 200 200 jc sse2_supported 201 202 jmp pm_error_halt 203 201 202 jmp pm_error_halt 203 204 204 sse2_supported: 205 205 206 206 /* 207 207 * Enable 64-bit page translation entries - CR4.PAE = 1. 208 208 * Paging is not enabled until after long mode is enabled. 209 209 */ 210 210 211 211 movl %cr4, %eax 212 212 orl $CR4_PAE, %eax 213 213 movl %eax, %cr4 214 214 215 215 /* Set up paging tables */ 216 216 leal ptl_0, %eax 217 217 movl %eax, %cr3 218 218 219 219 /* Enable long mode */ 220 220 movl $AMD_MSR_EFER, %ecx … … 222 222 orl $AMD_LME, %eax /* set LME = 1 */ 223 223 wrmsr 224 224 225 225 /* Enable paging to activate long mode (set CR0.PG = 1) */ 226 226 movl %cr0, %eax 227 227 orl $CR0_PG, %eax 228 228 movl %eax, %cr0 229 229 230 230 /* At this point we are in compatibility mode */ 231 231 jmpl $GDT_SELECTOR(KTEXT_DES), $start64 … … 240 240 241 241 start64: 242 242 243 243 /* 244 244 * Long mode. 245 245 */ 246 246 247 247 movq $(PA2KA(START_STACK)), %rsp 248 248 249 249 /* Create the first stack frame */ 250 250 pushq $0 251 251 movq %rsp, %rbp 252 252 253 253 /* Call amd64_pre_main(multiboot_eax, multiboot_ebx) */ 254 254 movl multiboot_eax, %edi 255 255 movl multiboot_ebx, %esi 256 256 257 257 #ifdef MEMORY_MODEL_large 258 258 movabsq $amd64_pre_main, %rax … … 261 261 callq amd64_pre_main 262 262 #endif 263 263 264 264 /* Call main_bsp() */ 265 265 #ifdef MEMORY_MODEL_large … … 269 269 callq main_bsp 270 270 #endif 271 271 272 272 /* Not reached */ 273 273 cli
Note:
See TracChangeset
for help on using the changeset viewer.