[1141c1a] | 1 | #
|
---|
[ee7e6ace] | 2 | # Copyright (C) 2005 Ondrej Palkovsky
|
---|
[42edee68] | 3 | # Copyright (C) 2006 Martin Decky
|
---|
[1141c1a] | 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 |
|
---|
[46d26ee] | 30 | #include <arch/boot/boot.h>
|
---|
| 31 | #include <arch/boot/memmap.h>
|
---|
[8fc0d455] | 32 | #include <arch/mm/page.h>
|
---|
[6f878b7] | 33 | #include <arch/mm/ptl.h>
|
---|
[8fc0d455] | 34 | #include <arch/pm.h>
|
---|
[89344d85] | 35 | #include <arch/cpu.h>
|
---|
[c4b3e3e] | 36 | #include <arch/cpuid.h>
|
---|
[1141c1a] | 37 |
|
---|
[8725fb4] | 38 | #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE)
|
---|
[c4b3e3e] | 39 |
|
---|
[874e312a] | 40 | .section K_TEXT_START, "ax"
|
---|
[46d26ee] | 41 |
|
---|
[8ccec3c1] | 42 | .code32
|
---|
| 43 | .align 4
|
---|
[46d26ee] | 44 | .global multiboot_image_start
|
---|
[8ccec3c1] | 45 | multiboot_header:
|
---|
| 46 | .long MULTIBOOT_HEADER_MAGIC
|
---|
| 47 | .long MULTIBOOT_HEADER_FLAGS
|
---|
| 48 | .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum
|
---|
[8725fb4] | 49 | .long multiboot_header
|
---|
| 50 | .long unmapped_ktext_start
|
---|
[8ccec3c1] | 51 | .long 0
|
---|
| 52 | .long 0
|
---|
[8725fb4] | 53 | .long multiboot_image_start
|
---|
[8ccec3c1] | 54 |
|
---|
| 55 | multiboot_image_start:
|
---|
[46d26ee] | 56 | movl $START_STACK, %esp # initialize stack pointer
|
---|
| 57 | lgdt bootstrap_gdtr # initialize Global Descriptor Table register
|
---|
[1a67595] | 58 |
|
---|
| 59 | movw $gdtselector(KDATA_DES), %cx
|
---|
| 60 | movw %cx, %es
|
---|
| 61 | movw %cx, %ds # kernel data + stack
|
---|
| 62 | movw %cx, %ss
|
---|
[65640fef] | 63 | # Simics seems to remove hidden part of GS on entering user mode
|
---|
| 64 | # when _visible_ part of GS does not point to user-mode segment
|
---|
| 65 | movw $gdtselector(UDATA_DES), %cx
|
---|
| 66 | movw %cx, %fs
|
---|
| 67 | movw %cx, %gs
|
---|
[1a67595] | 68 |
|
---|
[46d26ee] | 69 | jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point
|
---|
[1a67595] | 70 | multiboot_meeting_point:
|
---|
| 71 |
|
---|
[46d26ee] | 72 | movl %eax, grub_eax # save parameters from GRUB
|
---|
| 73 | movl %ebx, grub_ebx
|
---|
| 74 |
|
---|
[de07bcf] | 75 | #ifdef CONFIG_FB
|
---|
| 76 | mov $vesa_init,%esi;
|
---|
| 77 | mov $VESA_INIT_SEGMENT<<4,%edi;
|
---|
| 78 | mov $e_vesa_init-vesa_init,%ecx;
|
---|
| 79 | cld;
|
---|
| 80 | rep movsb;
|
---|
| 81 |
|
---|
| 82 | mov $VESA_INIT_SEGMENT<<4,%edi;
|
---|
| 83 | call *%edi;
|
---|
| 84 | mov %esi,KA2PA(vesa_ph_addr);
|
---|
| 85 | mov %di,KA2PA(vesa_height);
|
---|
| 86 | shr $16,%edi;
|
---|
| 87 | mov %di,KA2PA(vesa_width);
|
---|
| 88 | mov %bx,KA2PA(vesa_scanline);
|
---|
| 89 | shr $16,%ebx;
|
---|
| 90 | mov %bx,KA2PA(vesa_bpp);
|
---|
| 91 | #endif
|
---|
| 92 |
|
---|
[8725fb4] | 93 | # Protected 32-bit. We want to reuse the code-seg descriptor,
|
---|
| 94 | # the Default operand size must not be 1 when entering long mode
|
---|
| 95 |
|
---|
[42edee68] | 96 | movl $0x80000000, %eax
|
---|
| 97 | cpuid
|
---|
| 98 | cmp $0x80000000, %eax # any function > 80000000h?
|
---|
| 99 | jbe long_mode_unsupported
|
---|
| 100 | movl $(AMD_CPUID_EXTENDED), %eax # Extended function code 80000001
|
---|
| 101 | cpuid
|
---|
| 102 | bt $29, %edx # Test if long mode is supported.
|
---|
| 103 | jc long_mode_supported
|
---|
| 104 |
|
---|
| 105 | long_mode_unsupported:
|
---|
| 106 | cli
|
---|
| 107 | hlt
|
---|
| 108 |
|
---|
| 109 | long_mode_supported:
|
---|
| 110 |
|
---|
[6f878b7] | 111 | # Enable 64-bit page transaltion entries - CR4.PAE = 1.
|
---|
| 112 | # Paging is not enabled until after long mode is enabled
|
---|
[8725fb4] | 113 |
|
---|
[6f878b7] | 114 | movl %cr4, %eax
|
---|
| 115 | btsl $5, %eax
|
---|
| 116 | movl %eax, %cr4
|
---|
| 117 |
|
---|
| 118 | # Set up paging tables
|
---|
[8725fb4] | 119 |
|
---|
[6f878b7] | 120 | leal ptl_0, %eax
|
---|
| 121 | movl %eax, %cr3
|
---|
[c4b3e3e] | 122 |
|
---|
[6f878b7] | 123 | # Enable long mode
|
---|
[8725fb4] | 124 |
|
---|
| 125 | movl $EFER_MSR_NUM, %ecx # EFER MSR number
|
---|
| 126 | rdmsr # Read EFER
|
---|
| 127 | btsl $AMD_LME_FLAG, %eax # Set LME=1
|
---|
| 128 | wrmsr # Write EFER
|
---|
[c245372b] | 129 |
|
---|
[6f878b7] | 130 | # Enable paging to activate long mode (set CR0.PG=1)
|
---|
[8725fb4] | 131 |
|
---|
[6f878b7] | 132 | movl %cr0, %eax
|
---|
| 133 | btsl $31, %eax
|
---|
| 134 | movl %eax, %cr0
|
---|
[c245372b] | 135 |
|
---|
[6f878b7] | 136 | # At this point we are in compatibility mode
|
---|
[8725fb4] | 137 |
|
---|
[b9e97fb] | 138 | jmpl $gdtselector(KTEXT_DES), $start64
|
---|
[c245372b] | 139 |
|
---|
[6f878b7] | 140 | .code64
|
---|
| 141 | start64:
|
---|
[c4b3e3e] | 142 | movq $(PA2KA(START_STACK)), %rsp
|
---|
[46d26ee] | 143 | movl grub_eax, %eax
|
---|
| 144 | movl grub_ebx, %ebx
|
---|
| 145 |
|
---|
| 146 | cmpl $MULTIBOOT_LOADER_MAGIC, %eax # compare GRUB signature
|
---|
| 147 | je valid_boot
|
---|
| 148 |
|
---|
| 149 | xorl %ecx, %ecx # no memory size or map available
|
---|
| 150 | movl %ecx, e801memorysize
|
---|
| 151 | movl %ecx, e820counter
|
---|
| 152 |
|
---|
| 153 | jmp invalid_boot
|
---|
| 154 |
|
---|
| 155 | valid_boot:
|
---|
| 156 |
|
---|
| 157 | movl (%ebx), %eax # ebx = physical address of struct multiboot_info
|
---|
| 158 |
|
---|
| 159 | bt $0, %eax # mbi->flags[0] (mem_lower, mem_upper valid)
|
---|
| 160 | jc mem_valid
|
---|
| 161 |
|
---|
| 162 | xorl %ecx, %ecx
|
---|
| 163 | jmp mem_invalid
|
---|
| 164 |
|
---|
| 165 | mem_valid:
|
---|
| 166 | movl 4(%ebx), %ecx # mbi->mem_lower
|
---|
| 167 | addl 8(%ebx), %ecx # mbi->mem_upper
|
---|
| 168 |
|
---|
| 169 | mem_invalid:
|
---|
| 170 | movl %ecx, e801memorysize
|
---|
| 171 |
|
---|
[d764ddc] | 172 | bt $3, %eax # mbi->flags[3] (mods_count, mods_addr valid)
|
---|
[46d26ee] | 173 | jc mods_valid
|
---|
| 174 |
|
---|
[6eb103c] | 175 | xorq %rcx, %rcx
|
---|
| 176 | movq %rcx, init
|
---|
[d764ddc] | 177 | jmp mods_end
|
---|
[46d26ee] | 178 |
|
---|
| 179 | mods_valid:
|
---|
[d764ddc] | 180 |
|
---|
| 181 | xorq %rcx, %rcx
|
---|
[46d26ee] | 182 | movl 20(%ebx), %ecx # mbi->mods_count
|
---|
[6eb103c] | 183 | movq %rcx, init
|
---|
[d764ddc] | 184 |
|
---|
[46d26ee] | 185 | cmpl $0, %ecx
|
---|
[d764ddc] | 186 | je mods_end
|
---|
[46d26ee] | 187 |
|
---|
| 188 | movl 24(%ebx), %esi # mbi->mods_addr
|
---|
[d764ddc] | 189 | movq $init, %rdi
|
---|
[46d26ee] | 190 |
|
---|
[d764ddc] | 191 | mods_loop:
|
---|
| 192 |
|
---|
| 193 | xorq %rdx, %rdx
|
---|
| 194 | movl 0(%esi), %edx # mods->mod_start
|
---|
[93165be] | 195 | movq $0xffff800000000000, %r10
|
---|
| 196 | addq %r10, %rdx
|
---|
[6eb103c] | 197 | movq %rdx, 8(%rdi)
|
---|
[d764ddc] | 198 |
|
---|
| 199 | xorq %rdx, %rdx
|
---|
| 200 | movl 4(%esi), %edx
|
---|
| 201 | subl 0(%esi), %edx # mods->mod_end - mods->mod_start
|
---|
[6eb103c] | 202 | movq %rdx, 16(%rdi)
|
---|
[d764ddc] | 203 |
|
---|
| 204 | addl $16, %esi
|
---|
| 205 | addq $16, %rdi
|
---|
| 206 |
|
---|
| 207 | loop mods_loop
|
---|
| 208 |
|
---|
| 209 | mods_end:
|
---|
[46d26ee] | 210 |
|
---|
| 211 | bt $6, %eax # mbi->flags[6] (mmap_length, mmap_addr valid)
|
---|
| 212 | jc mmap_valid
|
---|
| 213 |
|
---|
| 214 | xorl %edx, %edx
|
---|
| 215 | jmp mmap_invalid
|
---|
| 216 |
|
---|
| 217 | mmap_valid:
|
---|
| 218 | movl 44(%ebx), %ecx # mbi->mmap_length
|
---|
| 219 | movl 48(%ebx), %esi # mbi->mmap_addr
|
---|
| 220 | movq $e820table, %rdi
|
---|
| 221 | xorl %edx, %edx
|
---|
| 222 |
|
---|
| 223 | mmap_loop:
|
---|
| 224 | cmpl $0, %ecx
|
---|
| 225 | jle mmap_end
|
---|
| 226 |
|
---|
| 227 | movl 4(%esi), %eax # mmap->base_addr_low
|
---|
| 228 | movl %eax, (%rdi)
|
---|
| 229 |
|
---|
| 230 | movl 8(%esi), %eax # mmap->base_addr_high
|
---|
| 231 | movl %eax, 4(%rdi)
|
---|
| 232 |
|
---|
| 233 | movl 12(%esi), %eax # mmap->length_low
|
---|
| 234 | movl %eax, 8(%rdi)
|
---|
| 235 |
|
---|
| 236 | movl 16(%esi), %eax # mmap->length_high
|
---|
| 237 | movl %eax, 12(%rdi)
|
---|
| 238 |
|
---|
| 239 | movl 20(%esi), %eax # mmap->type
|
---|
| 240 | movl %eax, 16(%rdi)
|
---|
| 241 |
|
---|
| 242 | movl (%esi), %eax # mmap->size
|
---|
| 243 | addl $0x4, %eax
|
---|
| 244 | addl %eax, %esi
|
---|
| 245 | subl %eax, %ecx
|
---|
| 246 | addq $MEMMAP_E820_RECORD_SIZE, %rdi
|
---|
| 247 | incl %edx
|
---|
| 248 | jmp mmap_loop
|
---|
| 249 |
|
---|
| 250 | mmap_end:
|
---|
| 251 |
|
---|
| 252 | mmap_invalid:
|
---|
| 253 | movl %edx, e820counter
|
---|
| 254 |
|
---|
| 255 | invalid_boot:
|
---|
| 256 |
|
---|
[42edee68] | 257 | #ifdef CONFIG_SMP
|
---|
| 258 |
|
---|
| 259 | # copy AP bootstrap routines below 1 MB
|
---|
| 260 |
|
---|
| 261 | movq $BOOT_OFFSET, %rsi
|
---|
| 262 | movq $AP_BOOT_OFFSET, %rdi
|
---|
| 263 | movq $_hardcoded_unmapped_size, %rcx
|
---|
| 264 | cld
|
---|
| 265 | rep movsb
|
---|
| 266 |
|
---|
| 267 | #endif
|
---|
| 268 |
|
---|
[6f878b7] | 269 | call main_bsp # never returns
|
---|
[8725fb4] | 270 |
|
---|
| 271 | cli
|
---|
| 272 | hlt
|
---|
[de07bcf] | 273 |
|
---|
| 274 | #ifdef CONFIG_FB
|
---|
| 275 | .code32
|
---|
| 276 | vesa_init:
|
---|
| 277 | jmp $gdtselector(VESA_INIT_DES),$vesa_init_real-vesa_init;
|
---|
| 278 | .code16
|
---|
| 279 | vesa_init_real:
|
---|
| 280 |
|
---|
| 281 | mov %cr0,%eax;
|
---|
| 282 | and $~1,%eax;
|
---|
| 283 | mov %eax,%cr0;
|
---|
| 284 |
|
---|
| 285 |
|
---|
| 286 | jmp $VESA_INIT_SEGMENT,$vesa_init_real2-vesa_init;
|
---|
| 287 |
|
---|
| 288 | vesa_init_real2:
|
---|
| 289 |
|
---|
| 290 |
|
---|
| 291 | mov %esp,%ebp;
|
---|
| 292 | mov %ss,%cx;
|
---|
| 293 | mov $VESA_INIT_SEGMENT,%bx;
|
---|
| 294 | mov %bx,%ss;
|
---|
| 295 | mov $0x0000fffc,%esp;
|
---|
| 296 | push %ds;
|
---|
| 297 | push %es;
|
---|
| 298 | push %fs;
|
---|
| 299 | push %gs;
|
---|
| 300 | push %ebp;
|
---|
| 301 | push %cx;
|
---|
| 302 |
|
---|
| 303 | mov %bx,%ds;
|
---|
| 304 | mov %bx,%es;
|
---|
| 305 | mov %bx,%fs;
|
---|
| 306 | mov %bx,%gs;
|
---|
| 307 |
|
---|
| 308 |
|
---|
| 309 | mov $vesa_idt-vesa_init,%ebx;
|
---|
| 310 | lidtl (%ebx);
|
---|
| 311 |
|
---|
| 312 | #define VESA_INFO_SIZE 1024
|
---|
| 313 |
|
---|
| 314 | #define VESA_MODE_LIST_PTR_OFFSET 14
|
---|
| 315 | #define VESA_MODE_WIDTH_OFFSET 18
|
---|
| 316 | #define VESA_MODE_HEIGHT_OFFSET 20
|
---|
| 317 | #define VESA_MODE_BPP_OFFSET 25
|
---|
| 318 | #define VESA_MODE_SCANLINE_OFFSET 16
|
---|
| 319 | #define VESA_MODE_PHADDR_OFFSET 40
|
---|
| 320 |
|
---|
| 321 | #define VESA_END_OF_MODES 0xffff
|
---|
| 322 |
|
---|
| 323 | #define VESA_OK 0x4f
|
---|
| 324 |
|
---|
| 325 | #define VESA_GET_INFO 0x4f00
|
---|
| 326 | #define VESA_GET_MODE_INFO 0x4f01
|
---|
| 327 | #define VESA_SET_MODE 0x4f02
|
---|
| 328 |
|
---|
| 329 | #define CONFIG_VESA_BPP_a 255
|
---|
| 330 |
|
---|
| 331 | #if CONFIG_VESA_BPP==24
|
---|
| 332 | #undef CONFIG_VESA_BPP_a
|
---|
| 333 | #define CONFIG_VESA_BPP_a 32
|
---|
| 334 | #endif
|
---|
| 335 |
|
---|
| 336 |
|
---|
| 337 | mov $VESA_GET_INFO,%ax;
|
---|
| 338 | mov $e_vesa_init-vesa_init,%di
|
---|
| 339 | push %di;
|
---|
| 340 | int $0x10;
|
---|
| 341 | pop %di;
|
---|
| 342 | cmp $VESA_OK,%al;
|
---|
| 343 | jnz 0f;
|
---|
| 344 | mov 2+VESA_MODE_LIST_PTR_OFFSET(%di),%si;
|
---|
| 345 | mov %si,%gs;
|
---|
| 346 | mov VESA_MODE_LIST_PTR_OFFSET(%di),%si;
|
---|
| 347 |
|
---|
| 348 | add $VESA_INFO_SIZE,%di;
|
---|
| 349 |
|
---|
| 350 | 1:# Try next mode
|
---|
| 351 | mov %gs:(%si),%cx;
|
---|
| 352 | cmp $VESA_END_OF_MODES,%cx;
|
---|
| 353 | jz 0f;
|
---|
| 354 | inc %si;
|
---|
| 355 | inc %si;
|
---|
| 356 | push %cx;
|
---|
| 357 | push %di;
|
---|
| 358 | push %si;
|
---|
| 359 | mov $VESA_GET_MODE_INFO,%ax;
|
---|
| 360 | int $0x10;
|
---|
| 361 | pop %si;
|
---|
| 362 | pop %di;
|
---|
| 363 | pop %cx;
|
---|
| 364 | cmp $VESA_OK,%al;
|
---|
| 365 | jnz 0f;
|
---|
| 366 |
|
---|
| 367 |
|
---|
| 368 | mov $CONFIG_VESA_WIDTH,%ax;
|
---|
| 369 | cmp VESA_MODE_WIDTH_OFFSET(%di),%ax;
|
---|
| 370 | jnz 1b;
|
---|
| 371 | mov $CONFIG_VESA_HEIGHT,%ax;
|
---|
| 372 | cmp VESA_MODE_HEIGHT_OFFSET(%di),%ax;
|
---|
| 373 | jnz 1b;
|
---|
| 374 | mov $CONFIG_VESA_BPP,%al;
|
---|
| 375 | cmp VESA_MODE_BPP_OFFSET(%di),%al;
|
---|
| 376 | jz 2f;
|
---|
| 377 | mov $CONFIG_VESA_BPP_a,%al;
|
---|
| 378 | cmp VESA_MODE_BPP_OFFSET(%di),%al;
|
---|
| 379 | jnz 1b;
|
---|
| 380 |
|
---|
| 381 | 2:
|
---|
| 382 |
|
---|
| 383 | mov %cx,%bx;
|
---|
| 384 | or $0xC000,%bx;
|
---|
| 385 | push %di;
|
---|
| 386 | mov $VESA_SET_MODE,%ax;
|
---|
| 387 | int $0x10;
|
---|
| 388 | pop %di;
|
---|
| 389 | cmp $VESA_OK,%al;
|
---|
| 390 | jnz 0f;
|
---|
| 391 |
|
---|
| 392 | mov VESA_MODE_PHADDR_OFFSET(%di),%esi;
|
---|
| 393 | mov VESA_MODE_WIDTH_OFFSET(%di),%ax;
|
---|
| 394 | shl $16,%eax;
|
---|
| 395 | mov VESA_MODE_HEIGHT_OFFSET(%di),%ax;
|
---|
| 396 | mov VESA_MODE_BPP_OFFSET(%di),%bl;
|
---|
| 397 | xor %bh,%bh;
|
---|
| 398 | shl $16,%ebx;
|
---|
| 399 | mov VESA_MODE_SCANLINE_OFFSET(%di),%bx;
|
---|
| 400 | mov %eax,%edi;
|
---|
| 401 |
|
---|
| 402 |
|
---|
| 403 |
|
---|
| 404 | 8:
|
---|
| 405 |
|
---|
| 406 | mov %cr0,%eax;
|
---|
| 407 | or $1,%eax;
|
---|
| 408 | mov %eax,%cr0;
|
---|
| 409 |
|
---|
| 410 | jmp 9f;
|
---|
| 411 | 9:
|
---|
| 412 |
|
---|
| 413 | pop %cx;
|
---|
| 414 | pop %ebp;
|
---|
| 415 | pop %gs;
|
---|
| 416 | pop %fs;
|
---|
| 417 | pop %es;
|
---|
| 418 | pop %ds;
|
---|
| 419 | mov %cx,%ss;
|
---|
| 420 | mov %ebp,%esp;
|
---|
| 421 |
|
---|
| 422 | ljmpl $gdtselector(KTEXT32_DES),$(vesa_init_protect-vesa_init+VESA_INIT_SEGMENT<<4);
|
---|
| 423 |
|
---|
[4c89b09] | 424 |
|
---|
| 425 | 0:#Error no Prefered mode found
|
---|
| 426 | mov $0x111,%cx;
|
---|
| 427 | push %di;
|
---|
| 428 | push %cx;
|
---|
| 429 | mov $VESA_GET_MODE_INFO,%ax;
|
---|
| 430 | int $0x10;
|
---|
| 431 | pop %cx;
|
---|
| 432 | pop %di;
|
---|
| 433 | cmp $VESA_OK,%al;
|
---|
| 434 | jnz 1f;
|
---|
| 435 | jz 2b; /* Force relative jump */
|
---|
| 436 |
|
---|
| 437 |
|
---|
| 438 | 1:mov $0x0003,%ax;
|
---|
| 439 | int $0x10;
|
---|
| 440 | mov $0xffffffff,%edi; /* EGA text mode used, because of problems with VESA */
|
---|
| 441 | xor %ax,%ax
|
---|
| 442 | jz 8b; /* Force relative jump */
|
---|
| 443 |
|
---|
| 444 |
|
---|
[de07bcf] | 445 | vesa_init_protect:
|
---|
| 446 | .code32
|
---|
| 447 | ret;
|
---|
| 448 |
|
---|
| 449 |
|
---|
| 450 | vesa_idt:
|
---|
| 451 | .word 0x03ff
|
---|
| 452 | .long 0
|
---|
| 453 | .align 4
|
---|
| 454 | e_vesa_init:
|
---|
| 455 | #endif
|
---|
| 456 |
|
---|
| 457 |
|
---|
[b9e97fb] | 458 |
|
---|
[874e312a] | 459 | .section K_DATA_START, "aw", @progbits
|
---|
[1141c1a] | 460 | .align 4096
|
---|
[b9e97fb] | 461 |
|
---|
[a16bfd0] | 462 | # Identical mapping of first 64MB and the same of -2GB -> 0
|
---|
[6f878b7] | 463 | .global ptl_2
|
---|
| 464 | ptl_2:
|
---|
| 465 | .quad 0x0 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 466 | .quad 0x200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 467 | .quad 0x400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 468 | .quad 0x600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 469 | .quad 0x800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 470 | .quad 0xa00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 471 | .quad 0xc00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 472 | .quad 0xe00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
[a16bfd0] | 473 | .quad 0x1000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 474 | .quad 0x1200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 475 | .quad 0x1400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 476 | .quad 0x1600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 477 | .quad 0x1800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 478 | .quad 0x1a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 479 | .quad 0x1c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 480 | .quad 0x1e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 481 | .quad 0x2000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 482 | .quad 0x2200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 483 | .quad 0x2400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 484 | .quad 0x2600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 485 | .quad 0x2800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 486 | .quad 0x2a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 487 | .quad 0x2c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 488 | .quad 0x2e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 489 | .quad 0x3000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 490 | .quad 0x3200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 491 | .quad 0x3400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 492 | .quad 0x3600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 493 | .quad 0x3800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 494 | .quad 0x3a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 495 | .quad 0x3c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
| 496 | .quad 0x3e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
|
---|
[6f878b7] | 497 |
|
---|
| 498 | .align 4096
|
---|
| 499 | .global ptl_1
|
---|
| 500 | ptl_1:
|
---|
| 501 | .quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
|
---|
| 502 | .fill 509,8,0
|
---|
| 503 | .quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
|
---|
[ae9624e] | 504 | .fill 1,8,0
|
---|
[6f878b7] | 505 |
|
---|
| 506 | .align 4096
|
---|
| 507 | .global ptl_0
|
---|
| 508 | ptl_0:
|
---|
| 509 | .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
|
---|
[93165be] | 510 | .fill 255,8,0
|
---|
| 511 | .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
|
---|
| 512 | .fill 254,8,0
|
---|
[6f878b7] | 513 | .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
|
---|
| 514 |
|
---|
[46d26ee] | 515 | .global bootstrap_gdtr
|
---|
| 516 | bootstrap_gdtr:
|
---|
[1a67595] | 517 | .word gdtselector(GDT_ITEMS)
|
---|
| 518 | .long KA2PA(gdt)
|
---|
[46d26ee] | 519 |
|
---|
| 520 | grub_eax:
|
---|
| 521 | .long 0
|
---|
| 522 |
|
---|
| 523 | grub_ebx:
|
---|
| 524 | .long 0
|
---|