diff options
author | Richard Braun <rbraun@sceen.net> | 2012-10-10 21:18:28 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2012-10-10 21:18:28 +0200 |
commit | e2955084048dac30b081b62ba27d0282079dd01a (patch) | |
tree | 82cfe89dc0ea9725ff3e972e6189d1070023b385 | |
parent | cceb9712ab7e66fb64d07cd575d5a743e86e2972 (diff) |
x86: rework the linker script
Merge the .boot section into the .init section, and set the .init
section at physical addresses.
-rw-r--r-- | arch/x86/machine/biosmem.c | 32 | ||||
-rw-r--r-- | arch/x86/machine/boot.c | 18 | ||||
-rw-r--r-- | arch/x86/machine/boot.h | 14 | ||||
-rw-r--r-- | arch/x86/machine/boot_asm.S | 4 | ||||
-rw-r--r-- | arch/x86/machine/pmap.c | 5 | ||||
-rw-r--r-- | arch/x86/x15.lds.S | 55 | ||||
-rw-r--r-- | kern/init.h | 13 | ||||
-rw-r--r-- | vm/vm_kmem.h | 1 |
8 files changed, 55 insertions, 87 deletions
diff --git a/arch/x86/machine/biosmem.c b/arch/x86/machine/biosmem.c index c761a772..430d6462 100644 --- a/arch/x86/machine/biosmem.c +++ b/arch/x86/machine/biosmem.c @@ -66,21 +66,21 @@ struct biosmem_map_entry { * based on the mem_lower and mem_upper multiboot fields. */ static struct biosmem_map_entry biosmem_map[BIOSMEM_MAX_MAP_SIZE * 2] - __bootdata; + __initdata; /* * Number of valid entries in the BIOS memory map table. */ -static unsigned int biosmem_map_size __bootdata; +static unsigned int biosmem_map_size __initdata; /* * Boundaries of the simple bootstrap heap. */ -static unsigned long biosmem_heap_start __bootdata; -static unsigned long biosmem_heap_free __bootdata; -static unsigned long biosmem_heap_end __bootdata; +static unsigned long biosmem_heap_start __initdata; +static unsigned long biosmem_heap_free __initdata; +static unsigned long biosmem_heap_end __initdata; -static void __boot +static void __init biosmem_map_build(const struct multiboot_info *mbi) { struct multiboot_mmap_entry *mb_entry, *mb_end; @@ -104,7 +104,7 @@ biosmem_map_build(const struct multiboot_info *mbi) biosmem_map_size = entry - start; } -static void __boot +static void __init biosmem_map_build_simple(const struct multiboot_info *mbi) { struct biosmem_map_entry *entry; @@ -122,7 +122,7 @@ biosmem_map_build_simple(const struct multiboot_info *mbi) biosmem_map_size = 2; } -static void __boot +static void __init biosmem_find_boot_data_update(unsigned long min, unsigned long *start, unsigned long *end, const void *data_start, const void *data_end) @@ -146,7 +146,7 @@ biosmem_find_boot_data_update(unsigned long min, unsigned long *start, * * If no boot data was found, 0 is returned, and the end address isn't set. */ -static unsigned long __boot +static unsigned long __init biosmem_find_boot_data(const struct multiboot_info *mbi, unsigned long min, unsigned long max, unsigned long *endp) { @@ -156,7 +156,7 @@ biosmem_find_boot_data(const struct multiboot_info *mbi, unsigned long min, start = max; - biosmem_find_boot_data_update(min, &start, &end, &_boot, + biosmem_find_boot_data_update(min, &start, &end, &_init, (void *)BOOT_VTOP(&_end)); if ((mbi->flags & MULTIBOOT_LOADER_CMDLINE) && (mbi->cmdline != NULL)) @@ -185,7 +185,7 @@ biosmem_find_boot_data(const struct multiboot_info *mbi, unsigned long min, return start; } -static void __boot +static void __init biosmem_setup_allocator(struct multiboot_info *mbi) { unsigned long heap_start, heap_end, max_heap_start, max_heap_end; @@ -226,7 +226,7 @@ biosmem_setup_allocator(struct multiboot_info *mbi) biosmem_heap_end = max_heap_end; } -static size_t __boot +static size_t __init biosmem_strlen(const char *s) { size_t i; @@ -239,7 +239,7 @@ biosmem_strlen(const char *s) return i; } -static void __boot +static void __init biosmem_save_cmdline_sizes(struct multiboot_info *mbi) { struct multiboot_module *mod; @@ -255,7 +255,7 @@ biosmem_save_cmdline_sizes(struct multiboot_info *mbi) } } -void __boot +void __init biosmem_bootstrap(struct multiboot_info *mbi) { if (mbi->flags & MULTIBOOT_LOADER_MMAP) @@ -271,7 +271,7 @@ biosmem_bootstrap(struct multiboot_info *mbi) biosmem_setup_allocator(mbi); } -void * __boot +void * __init biosmem_bootalloc(unsigned int nr_pages) { unsigned long free, page; @@ -597,7 +597,7 @@ biosmem_find_reserved_area(vm_phys_t min, vm_phys_t max, vm_phys_t start, end = end; start = max; - biosmem_find_reserved_area_update(min, &start, &end, (unsigned long)&_boot, + biosmem_find_reserved_area_update(min, &start, &end, (unsigned long)&_init, BOOT_VTOP(&_end)); biosmem_find_reserved_area_update(min, &start, &end, biosmem_heap_start, biosmem_heap_end); diff --git a/arch/x86/machine/boot.c b/arch/x86/machine/boot.c index ea864cd6..9df4451d 100644 --- a/arch/x86/machine/boot.c +++ b/arch/x86/machine/boot.c @@ -42,17 +42,17 @@ #define INIT_VGACHARS (80 * 25) #define INIT_VGACOLOR 0x7 -char boot_stack[BOOT_STACK_SIZE] __aligned(8) __bootdata; -char boot_ap_stack[BOOT_STACK_SIZE] __aligned(8) __bootdata; -unsigned long boot_ap_id __bootdata; -unsigned long boot_ap_stack_addr __bootdata; +char boot_stack[BOOT_STACK_SIZE] __aligned(8) __initdata; +char boot_ap_stack[BOOT_STACK_SIZE] __aligned(8) __initdata; +unsigned long boot_ap_id __initdata; +unsigned long boot_ap_stack_addr __initdata; /* * Copy of the multiboot data passed by the boot loader. */ -static struct multiboot_info boot_mbi __bootdata; +static struct multiboot_info boot_mbi __initdata; -void __boot +void __init boot_panic(const char *msg) { uint16_t *ptr, *end; @@ -79,7 +79,7 @@ boot_panic(const char *msg) /* Never reached */ } -pmap_pte_t * __boot +pmap_pte_t * __init boot_setup_paging(uint32_t eax, const struct multiboot_info *mbi) { pmap_pte_t *pdir, *ptps, *pte, *id_pte; @@ -129,7 +129,7 @@ boot_setup_paging(uint32_t eax, const struct multiboot_info *mbi) } /* Map the kernel */ - kern_start = (unsigned long)&_boot; + kern_start = (unsigned long)&_init; for (i = kern_start; i < kern_end; i += PAGE_SIZE) ptps[vm_page_atop(i)] = i | PMAP_PTE_WRITE | PMAP_PTE_PRESENT; @@ -148,7 +148,7 @@ boot_setup_paging(uint32_t eax, const struct multiboot_info *mbi) #endif /* PAE */ } -pmap_pte_t * __boot +pmap_pte_t * __init boot_ap_setup_paging(void) { #ifdef PAE diff --git a/arch/x86/machine/boot.h b/arch/x86/machine/boot.h index 4c7efb54..757f1370 100644 --- a/arch/x86/machine/boot.h +++ b/arch/x86/machine/boot.h @@ -60,20 +60,6 @@ #define BOOT_VTOP(addr) ((unsigned long)(addr) - KERNEL_OFFSET) /* - * Functions and data used before paging is enabled must be part of the .boot - * and .bootdata sections respectively, so that they use physical addresses. - * Once paging is enabled, their access relies on the kernel identity mapping. - */ -#define __boot __section(".boot") -#define __bootdata __section(".bootdata") - -/* - * Boundaries of the .boot section. - */ -extern char _boot; -extern char _eboot; - -/* * Stack used to bootstrap the kernel. */ extern char boot_stack[BOOT_STACK_SIZE]; diff --git a/arch/x86/machine/boot_asm.S b/arch/x86/machine/boot_asm.S index e8d10697..e46eedb5 100644 --- a/arch/x86/machine/boot_asm.S +++ b/arch/x86/machine/boot_asm.S @@ -29,7 +29,7 @@ #define BOOT_MP_ADDR_PTOT(addr) (BOOT_MP_TRAMPOLINE_ADDR + (addr) \ - boot_mp_trampoline) -.section .boothdr, "wax" +.section .init.hdr, "wax" /* * Multiboot header. @@ -110,8 +110,6 @@ ENTRY(_start) */ END(_start) -.section .boot, "wax" - DATA(boot_gdtr) .word (8 * 3) .long boot_gdt diff --git a/arch/x86/machine/pmap.c b/arch/x86/machine/pmap.c index d5c5224c..6681bc68 100644 --- a/arch/x86/machine/pmap.c +++ b/arch/x86/machine/pmap.c @@ -23,7 +23,6 @@ #include <lib/macros.h> #include <lib/stddef.h> #include <lib/string.h> -#include <machine/boot.h> #include <machine/cpu.h> #include <machine/pmap.h> #include <vm/vm_kmem.h> @@ -35,13 +34,13 @@ * Kernel page directory. */ pmap_pte_t pmap_kpdir[PMAP_NR_PDT * PMAP_PTE_PER_PT] __aligned(PAGE_SIZE) - __bootdata; + __initdata; #ifdef PAE /* * Kernel page directory pointer table. */ -pmap_pte_t pmap_kpdpt[PMAP_NR_PDT] __aligned(sizeof(pmap_kpdpt)) __bootdata; +pmap_pte_t pmap_kpdpt[PMAP_NR_PDT] __aligned(sizeof(pmap_kpdpt)) __initdata; #endif /* PAE */ /* diff --git a/arch/x86/x15.lds.S b/arch/x86/x15.lds.S index d5c3bff1..5861fc5e 100644 --- a/arch/x86/x15.lds.S +++ b/arch/x86/x15.lds.S @@ -13,12 +13,12 @@ ENTRY(_start) #define __ASSEMBLY__ -#include <kern/param.h> #include <machine/boot.h> +#include <machine/param.h> PHDRS { - boot PT_LOAD FLAGS(7); + /* Flags are actually similar to classic Unix permissions */ init PT_LOAD FLAGS(7); text PT_LOAD FLAGS(5); rodata PT_LOAD FLAGS(4); @@ -28,66 +28,47 @@ PHDRS SECTIONS { . = BOOT_OFFSET; + _init = .; - .boot ALIGN(PAGE_SIZE): { - _boot = .; - *(.boothdr) - *(.boot) - *(.bootdata) - _eboot = .; - } : boot - - . += KERNEL_OFFSET; - - .init ALIGN(PAGE_SIZE): AT(ADDR(.init) - KERNEL_OFFSET) { - _init = .; - *(.init) - _einit = .; + .init ALIGN(PAGE_SIZE): { + *(.init.hdr) + *(.init.text) + *(.init.data) } : init - .initrodata ALIGN(8): AT(ADDR(.initrodata) - KERNEL_OFFSET) { - _initrodata = .; - *(.initrodata) - _einitrodata = .; - } : init + . = ALIGN(PAGE_SIZE); + _einit = .; - .initdata ALIGN(8): AT(ADDR(.initdata) - KERNEL_OFFSET) { - _initdata = .; - *(.initdata) - _einitdata = .; - } : init + . += KERNEL_OFFSET; + _text = .; .text ALIGN(PAGE_SIZE): AT(ADDR(.text) - KERNEL_OFFSET) { - _text = .; *(.text) - _etext = .; } : text + . = ALIGN(PAGE_SIZE); + _rodata = .; + .rodata ALIGN(PAGE_SIZE): AT(ADDR(.rodata) - KERNEL_OFFSET) { - _rodata = .; *(.rodata) - _erodata = .; } : rodata .notes ALIGN(8): AT(ADDR(.notes) - KERNEL_OFFSET) { - _notes = .; *(.note.*) - _enotes = .; } : rodata + . = ALIGN(PAGE_SIZE); + _data = .; + .data ALIGN(PAGE_SIZE): AT(ADDR(.data) - KERNEL_OFFSET) { - _data = .; *(.data) - _edata = .; } : data .bss ALIGN(8): AT(ADDR(.bss) - KERNEL_OFFSET) { - _bss = .; *(.bss) *(COMMON) - . = ALIGN(PAGE_SIZE); - _ebss = .; } : data + . = ALIGN(PAGE_SIZE); _end = .; } diff --git a/kern/init.h b/kern/init.h index a3128d75..e9762724 100644 --- a/kern/init.h +++ b/kern/init.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Richard Braun. + * Copyright (c) 2010, 2012 Richard Braun. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,13 @@ * These sections should contain code and data which can be discarded once * kernel initialization is done. */ -#define __init __section(".init") -#define __initrodata __section(".initrodata") -#define __initdata __section(".initdata") +#define __init __section(".init.text") +#define __initdata __section(".init.data") + +/* + * Boundaries of the .init section. + */ +extern char _init; +extern char _einit; #endif /* _KERN_INIT_H */ diff --git a/vm/vm_kmem.h b/vm/vm_kmem.h index e23ab9bd..d4984e8e 100644 --- a/vm/vm_kmem.h +++ b/vm/vm_kmem.h @@ -26,7 +26,6 @@ extern char _text; extern char _rodata; extern char _data; -extern char _bss; extern char _end; /* |