Changeset 8725fb4 in mainline
- Timestamp:
- 2006-01-08T18:11:20Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 46d26ee
- Parents:
- 66def8d
- Location:
- arch/amd64
- Files:
-
- 5 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/Makefile.inc
r66def8d r8725fb4 78 78 arch/$(ARCH)/src/fpu_context.c \ 79 79 arch/$(ARCH)/src/boot/boot.S \ 80 arch/$(ARCH)/src/boot/memmap.S \81 80 arch/$(ARCH)/src/pm.c \ 82 81 arch/$(ARCH)/src/context.S \ -
arch/amd64/_link.ld.in
r66def8d r8725fb4 13 13 #include <arch/mm/page.h> 14 14 15 ENTRY(kernel_image_start)16 17 15 SECTIONS { 18 .unmapped BOOT STRAP_OFFSET: AT (BOOTSTRAP_OFFSET) {16 .unmapped BOOT_OFFSET: AT (0) { 19 17 unmapped_ktext_start = .; 20 18 *(K_TEXT_START); 21 *(K_TEXT_START_2);22 19 unmapped_ktext_end = .; 23 20 … … 27 24 } 28 25 29 .mapped (PA2KA(BOOT_OFFSET +BOOTSTRAP_OFFSET)+SIZEOF(.unmapped)) : AT (BOOTSTRAP_OFFSET+SIZEOF(.unmapped)) {26 .mapped (PA2KA(BOOT_OFFSET)+SIZEOF(.unmapped)) : AT (SIZEOF(.unmapped)) { 30 27 ktext_start = .; 31 *(BOOT_DATA);32 28 *(.text); 33 29 ktext_end = .; … … 37 33 *(.rodata*); /* string literals */ 38 34 hardcoded_load_address = .; 39 QUAD(PA2KA(BOOT_OFFSET +BOOTSTRAP_OFFSET));35 QUAD(PA2KA(BOOT_OFFSET)); 40 36 hardcoded_ktext_size = .; 41 37 QUAD(ktext_end - ktext_start + (unmapped_ktext_end - unmapped_ktext_start)); … … 57 53 kdata_end = .; 58 54 } 59 60 _hardcoded_kernel_size = (ktext_end - ktext_start) + (unmapped_ktext_end - unmapped_ktext_start) + (kdata_end - kdata_start) + (unmapped_kdata_end - unmapped_kdata_start);61 62 /* Symbols that need to be accessed both from real mode & long mode */63 /* e820*_boot is real mode (pre-above-1MB-move), e820* is */64 /* kernel mapped above-1MB-physical copied symbol */65 e820table_boot = KA2PA(e820table) - BOOT_OFFSET;66 e820counter_boot = KA2PA(e820counter) - BOOT_OFFSET;67 68 /* real_bootstrap_gdtr is mapped real_bootstrap_gdtr_boot */69 /* It is physically outside of kernel area, we have to access */70 /* it after modification from long mode for booting */71 /* SMP slave processors */72 real_bootstrap_gdtr = PA2KA(real_bootstrap_gdtr_boot);73 55 } -
arch/amd64/include/boot/boot.h
r66def8d r8725fb4 30 30 #define __amd64_BOOT_H__ 31 31 32 #define BOOTSTRAP_OFFSET 0x8000 33 #define BOOT_OFFSET 0x100000 32 #define BOOT_OFFSET 0x108000 33 #define AP_BOOT_OFFSET 0x8000 34 #define BOOT_STACK_SIZE 0x400 34 35 35 36 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 -
arch/amd64/src/boot/boot.S
r66def8d r8725fb4 34 34 #include <arch/boot/boot.h> 35 35 36 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) 36 37 #define START_STACK_64 0xffffffff80007c00 37 38 #39 # This is where we require any SPARTAN-kernel-compatible boot loader40 # to pass control in real mode.41 #42 # Protected mode tables are statically initialised during compile43 # time. So we can just load the respective table registers and44 # switch to protected mode.45 #46 47 #define START_STACK (BOOTSTRAP_OFFSET-0x400)48 38 49 39 .section K_TEXT_START, "ax" 50 .code1651 .global kernel_image_start52 .global multiboot_image_start53 kernel_image_start:54 cli55 xorw %ax,%ax56 movw %ax,%ds57 movw %ax,%es58 movw %ax,%ss # initialize stack segment register59 movl $(START_STACK), %esp # initialize stack pointer60 61 call memmap_arch_init62 63 movl $0x80000000, %eax64 cpuid65 cmp $0x80000000, %eax # any function > 80000000h?66 jbe no_long_mode67 movl $(AMD_CPUID_EXTENDED), %eax # Extended function code 8000000168 cpuid69 bt $29, %edx # Test if long mode is supported.70 jnc no_long_mode71 72 # Load gdtr, idtr73 lgdt real_bootstrap_gdtr_boot74 75 movl %cr0,%eax76 orl $0x1,%eax77 movl %eax,%cr0 # switch to protected mode78 79 jmpl $gdtselector(KTEXT32_DES), $now_in_prot80 81 no_long_mode:82 1:83 jmp 1b84 40 # .code16 41 # .global kernel_image_start 42 # .global multiboot_image_start 43 # kernel_image_start: 44 # cli 45 # xorw %ax,%ax 46 # movw %ax,%ds 47 # movw %ax,%es 48 # movw %ax,%ss # initialize stack segment register 49 # movl $(START_STACK), %esp # initialize stack pointer 50 # 51 # call memmap_arch_init 52 # 53 # movl $0x80000000, %eax 54 # cpuid 55 # cmp $0x80000000, %eax # any function > 80000000h? 56 # jbe no_long_mode 57 # movl $(AMD_CPUID_EXTENDED), %eax # Extended function code 80000001 58 # cpuid 59 # bt $29, %edx # Test if long mode is supported. 60 # jnc no_long_mode 61 # 62 # # Load gdtr, idtr 63 # lgdt real_bootstrap_gdtr_boot 64 # 65 # movl %cr0,%eax 66 # orl $0x1,%eax 67 # movl %eax,%cr0 # switch to protected mode 68 # 69 # jmpl $gdtselector(KTEXT32_DES), $now_in_prot 70 # 71 # no_long_mode: 72 # 1: 73 # jmp 1b 74 # 85 75 .code32 86 76 .align 4 … … 89 79 .long MULTIBOOT_HEADER_FLAGS 90 80 .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum 91 .long multiboot_header + BOOT_OFFSET92 .long unmapped_ktext_start + BOOT_OFFSET81 .long multiboot_header 82 .long unmapped_ktext_start 93 83 .long 0 94 84 .long 0 95 .long multiboot_image_start + BOOT_OFFSET85 .long multiboot_image_start 96 86 97 87 multiboot_image_start: … … 110 100 multiboot_meeting_point: 111 101 112 hlt 113 114 # Protected 32-bit. We want to reuse the code-seg descriptor, 115 # the Default operand size must not be 1 when entering long mode 116 now_in_prot: 117 # Set up stack & data descriptors 118 movw $gdtselector(KDATA_DES), %ax 119 movw %ax, %ds 120 movw %ax, %ss 121 122 movb $0xd1, %al # enable A20 using the keyboard controller 123 outb %al, $0x64 124 movb $0xdf, %al 125 outb %al, $0x60 126 102 # Protected 32-bit. We want to reuse the code-seg descriptor, 103 # the Default operand size must not be 1 when entering long mode 104 105 pushl %ebx # save parameters from GRUB 106 pushl %eax 127 107 128 108 # Enable 64-bit page transaltion entries - CR4.PAE = 1. 129 109 # Paging is not enabled until after long mode is enabled 110 130 111 movl %cr4, %eax 131 112 btsl $5, %eax … … 133 114 134 115 # Set up paging tables 116 135 117 leal ptl_0, %eax 136 118 movl %eax, %cr3 137 119 138 120 # Enable long mode 139 movl $EFER_MSR_NUM, %ecx # EFER MSR number 140 rdmsr # Read EFER 141 btsl $AMD_LME_FLAG, %eax # Set LME=1 142 wrmsr # Write EFER 121 122 movl $EFER_MSR_NUM, %ecx # EFER MSR number 123 rdmsr # Read EFER 124 btsl $AMD_LME_FLAG, %eax # Set LME=1 125 wrmsr # Write EFER 143 126 144 127 # Enable paging to activate long mode (set CR0.PG=1) 128 145 129 movl %cr0, %eax 146 130 btsl $31, %eax … … 148 132 149 133 # At this point we are in compatibility mode 134 150 135 jmpl $gdtselector(KTEXT_DES), $start64 151 136 … … 154 139 movq $(PA2KA(START_STACK)), %rsp 155 140 156 # Copy kernel to higher physical memory157 movq $BOOTSTRAP_OFFSET, %rsi158 movq $BOOTSTRAP_OFFSET + BOOT_OFFSET, %rdi159 movq $_hardcoded_kernel_size, %rcx160 cld161 rep movsb162 163 141 call main_bsp # never returns 164 1: 165 jmp 1b 142 143 cli 144 hlt 166 145 167 146 .section K_DATA_START, "aw", @progbits … … 219 198 .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT) 220 199 221 .global real_bootstrap_gdtr_boot222 real_bootstrap_gdtr_boot:223 .word gdtselector(GDT_ITEMS)224 .long KA2PA(gdt)-BOOT_OFFSET225 226 200 .global protected_bootstrap_gdtr 227 201 protected_bootstrap_gdtr: -
arch/amd64/src/mm/memory_init.c
r66def8d r8725fb4 32 32 #include <print.h> 33 33 34 __u8 e820counter __attribute__ ((section ("BOOT_DATA"))) = 0xff; 35 struct e820memmap_ e820table[MEMMAP_E820_MAX_RECORDS] __attribute__ ((section ("BOOT_DATA"))) ; 34 __u8 e820counter = 0xff; 35 struct e820memmap_ e820table[MEMMAP_E820_MAX_RECORDS]; 36 __u32 e801memorysize; 36 37 37 38 size_t get_memory_size(void)
Note:
See TracChangeset
for help on using the changeset viewer.