diff options
author | Jarkko Sakkinen <jarkko.sakkinen@intel.com> | 2012-05-08 14:22:25 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2012-05-08 14:41:48 -0400 |
commit | b3266bd6ff52efb9e57c7fbfff4c8f7363dfaab3 (patch) | |
tree | 66f16447ee345e21372fe0fe35b987b16c8061c0 /arch/x86/realmode | |
parent | 433de739bbc22a5b2c87602116566ce27e3b4cab (diff) |
x86, realmode: realmode.bin infrastructure
Create realmode.bin and realmode.relocs files. Piggy
pack them into relocatable object that will be included
into .init.data section of the main kernel image.
The first file includes binary image of the real-mode code.
The latter file includes all relocations. The layout of the
binary image is specified in realmode.lds.S. The makefile
generates pa_ prefixed symbols for each exported global.
These are used in 32-bit code and in realmode header to
define symbols that need to be relocated.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@intel.com>
Link: http://lkml.kernel.org/r/1336501366-28617-3-git-send-email-jarkko.sakkinen@intel.com
Originally-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/realmode')
-rw-r--r-- | arch/x86/realmode/Makefile | 20 | ||||
-rw-r--r-- | arch/x86/realmode/rm/.gitignore | 3 | ||||
-rw-r--r-- | arch/x86/realmode/rm/Makefile | 63 | ||||
-rw-r--r-- | arch/x86/realmode/rm/header.S | 16 | ||||
-rw-r--r-- | arch/x86/realmode/rm/realmode.lds.S | 68 | ||||
-rw-r--r-- | arch/x86/realmode/rmpiggy.S | 18 |
6 files changed, 188 insertions, 0 deletions
diff --git a/arch/x86/realmode/Makefile b/arch/x86/realmode/Makefile new file mode 100644 index 000000000000..f22a4f8d99d6 --- /dev/null +++ b/arch/x86/realmode/Makefile | |||
@@ -0,0 +1,20 @@ | |||
1 | # | ||
2 | # arch/x86/realmode/Makefile | ||
3 | # | ||
4 | # This file is subject to the terms and conditions of the GNU General Public | ||
5 | # License. See the file "COPYING" in the main directory of this archive | ||
6 | # for more details. | ||
7 | # | ||
8 | # | ||
9 | |||
10 | subdir- := rm | ||
11 | |||
12 | obj-y += rmpiggy.o | ||
13 | |||
14 | $(obj)/rmpiggy.o: $(obj)/rm/realmode.relocs $(obj)/rm/realmode.bin | ||
15 | |||
16 | $(obj)/rm/realmode.bin: FORCE | ||
17 | $(Q)$(MAKE) $(build)=$(obj)/rm $@ | ||
18 | |||
19 | $(obj)/rm/realmode.relocs: FORCE | ||
20 | $(Q)$(MAKE) $(build)=$(obj)/rm $@ | ||
diff --git a/arch/x86/realmode/rm/.gitignore b/arch/x86/realmode/rm/.gitignore new file mode 100644 index 000000000000..b6ed3a2555cb --- /dev/null +++ b/arch/x86/realmode/rm/.gitignore | |||
@@ -0,0 +1,3 @@ | |||
1 | pasyms.h | ||
2 | realmode.lds | ||
3 | realmode.relocs | ||
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile new file mode 100644 index 000000000000..7c3f202cbccf --- /dev/null +++ b/arch/x86/realmode/rm/Makefile | |||
@@ -0,0 +1,63 @@ | |||
1 | # | ||
2 | # arch/x86/realmode/Makefile | ||
3 | # | ||
4 | # This file is subject to the terms and conditions of the GNU General Public | ||
5 | # License. See the file "COPYING" in the main directory of this archive | ||
6 | # for more details. | ||
7 | # | ||
8 | # | ||
9 | |||
10 | subdir- := wakeup | ||
11 | |||
12 | always := realmode.bin | ||
13 | |||
14 | realmode-y += header.o | ||
15 | |||
16 | targets += $(realmode-y) | ||
17 | |||
18 | REALMODE_OBJS = $(addprefix $(obj)/,$(realmode-y)) | ||
19 | |||
20 | sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p' | ||
21 | |||
22 | quiet_cmd_pasyms = PASYMS $@ | ||
23 | cmd_pasyms = $(NM) $(filter-out FORCE,$^) | \ | ||
24 | sed $(sed-pasyms) | sort | uniq > $@ | ||
25 | |||
26 | $(obj)/pasyms.h: $(REALMODE_OBJS) FORCE | ||
27 | $(call if_changed,pasyms) | ||
28 | |||
29 | $(obj)/realmode.lds: $(obj)/pasyms.h | ||
30 | |||
31 | LDFLAGS_realmode.elf := --emit-relocs -T | ||
32 | CPPFLAGS_realmode.lds += -P -C -I$(obj) | ||
33 | |||
34 | $(obj)/realmode.elf: $(obj)/realmode.lds $(REALMODE_OBJS) FORCE | ||
35 | $(call if_changed,ld) | ||
36 | |||
37 | OBJCOPYFLAGS_realmode.bin := -O binary | ||
38 | |||
39 | $(obj)/realmode.bin: $(obj)/realmode.elf | ||
40 | $(call if_changed,objcopy) | ||
41 | |||
42 | quiet_cmd_relocs = RELOCS $@ | ||
43 | cmd_relocs = scripts/x86-relocs --realmode $< > $@ | ||
44 | $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE | ||
45 | $(call if_changed,relocs) | ||
46 | |||
47 | # --------------------------------------------------------------------------- | ||
48 | |||
49 | # How to compile the 16-bit code. Note we always compile for -march=i386, | ||
50 | # that way we can complain to the user if the CPU is insufficient. | ||
51 | KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ \ | ||
52 | -DDISABLE_BRANCH_PROFILING \ | ||
53 | -Wall -Wstrict-prototypes \ | ||
54 | -march=i386 -mregparm=3 \ | ||
55 | -include $(srctree)/$(src)/../../boot/code16gcc.h \ | ||
56 | -fno-strict-aliasing -fomit-frame-pointer \ | ||
57 | $(call cc-option, -ffreestanding) \ | ||
58 | $(call cc-option, -fno-toplevel-reorder,\ | ||
59 | $(call cc-option, -fno-unit-at-a-time)) \ | ||
60 | $(call cc-option, -fno-stack-protector) \ | ||
61 | $(call cc-option, -mpreferred-stack-boundary=2) | ||
62 | KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ | ||
63 | GCOV_PROFILE := n | ||
diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S new file mode 100644 index 000000000000..7be17f2c65a3 --- /dev/null +++ b/arch/x86/realmode/rm/header.S | |||
@@ -0,0 +1,16 @@ | |||
1 | /* | ||
2 | * Real-mode blob header; this should match realmode.h and be | ||
3 | * readonly; for mutable data instead add pointers into the .data | ||
4 | * or .bss sections as appropriate. | ||
5 | */ | ||
6 | |||
7 | #include <linux/linkage.h> | ||
8 | #include <asm/page_types.h> | ||
9 | |||
10 | .section ".header", "a" | ||
11 | |||
12 | ENTRY(real_mode_header) | ||
13 | .long pa_text_start | ||
14 | .long pa_ro_end | ||
15 | .long pa_end | ||
16 | END(real_mode_header) | ||
diff --git a/arch/x86/realmode/rm/realmode.lds.S b/arch/x86/realmode/rm/realmode.lds.S new file mode 100644 index 000000000000..c5b8a4f31ba3 --- /dev/null +++ b/arch/x86/realmode/rm/realmode.lds.S | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * realmode.lds.S | ||
3 | * | ||
4 | * Linker script for the real-mode code | ||
5 | */ | ||
6 | |||
7 | #include <asm/page_types.h> | ||
8 | |||
9 | #undef i386 | ||
10 | |||
11 | OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") | ||
12 | OUTPUT_ARCH(i386) | ||
13 | |||
14 | SECTIONS | ||
15 | { | ||
16 | real_mode_seg = 0; | ||
17 | |||
18 | . = 0; | ||
19 | .header : { | ||
20 | pa_real_mode_base = .; | ||
21 | *(.header) | ||
22 | } | ||
23 | |||
24 | . = ALIGN(4); | ||
25 | .rodata : { | ||
26 | *(.rodata) | ||
27 | *(.rodata.*) | ||
28 | } | ||
29 | |||
30 | . = ALIGN(PAGE_SIZE); | ||
31 | .text : { | ||
32 | pa_text_start = .; | ||
33 | *(.text) | ||
34 | *(.text.*) | ||
35 | } | ||
36 | |||
37 | .text32 : { | ||
38 | *(.text32) | ||
39 | *(.text32.*) | ||
40 | pa_ro_end = .; | ||
41 | } | ||
42 | |||
43 | . = ALIGN(PAGE_SIZE); | ||
44 | .data : { | ||
45 | *(.data) | ||
46 | *(.data.*) | ||
47 | } | ||
48 | |||
49 | . = ALIGN(128); | ||
50 | .bss : { | ||
51 | *(.bss*) | ||
52 | } | ||
53 | |||
54 | /* End signature for integrity checking */ | ||
55 | . = ALIGN(4); | ||
56 | .signature : { | ||
57 | *(.signature) | ||
58 | pa_end = .; | ||
59 | } | ||
60 | |||
61 | /DISCARD/ : { | ||
62 | *(.note*) | ||
63 | *(.debug*) | ||
64 | *(.eh_frame*) | ||
65 | } | ||
66 | |||
67 | #include "pasyms.h" | ||
68 | } | ||
diff --git a/arch/x86/realmode/rmpiggy.S b/arch/x86/realmode/rmpiggy.S new file mode 100644 index 000000000000..6047d7f604cf --- /dev/null +++ b/arch/x86/realmode/rmpiggy.S | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * Wrapper script for the realmode binary as a transport object | ||
3 | * before copying to low memory. | ||
4 | */ | ||
5 | #include <linux/linkage.h> | ||
6 | #include <asm/page_types.h> | ||
7 | |||
8 | .section ".init.data","aw" | ||
9 | |||
10 | .balign PAGE_SIZE | ||
11 | |||
12 | ENTRY(real_mode_blob) | ||
13 | .incbin "arch/x86/realmode/rm/realmode.bin" | ||
14 | END(real_mode_blob) | ||
15 | |||
16 | ENTRY(real_mode_relocs) | ||
17 | .incbin "arch/x86/realmode/rm/realmode.relocs" | ||
18 | END(real_mode_relocs) | ||