-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parisc: Add core code for self-extracting kernel
Signed-off-by: Helge Deller <deller@gmx.de>
- Loading branch information
Helge Deller
committed
Aug 22, 2017
1 parent
e35a2ce
commit 2f3c7b8
Showing
9 changed files
with
679 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
image | ||
bzImage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Makefile for the linux parisc-specific parts of the boot image creator. | ||
# | ||
|
||
COMPILE_VERSION := __linux_compile_version_id__`hostname | \ | ||
tr -c '[0-9A-Za-z]' '_'`__`date | \ | ||
tr -c '[0-9A-Za-z]' '_'`_t | ||
|
||
ccflags-y := -DCOMPILE_VERSION=$(COMPILE_VERSION) -gstabs -I. | ||
|
||
targets := image | ||
targets += bzImage | ||
subdir- := compressed | ||
|
||
$(obj)/image: vmlinux FORCE | ||
$(call if_changed,objcopy) | ||
|
||
$(obj)/bzImage: $(obj)/compressed/vmlinux FORCE | ||
$(call if_changed,objcopy) | ||
|
||
$(obj)/compressed/vmlinux: FORCE | ||
$(Q)$(MAKE) $(build)=$(obj)/compressed $@ | ||
|
||
install: $(CONFIGURE) $(obj)/bzImage | ||
sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \ | ||
System.map "$(INSTALL_PATH)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sizes.h | ||
vmlinux | ||
vmlinux.lds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# | ||
# linux/arch/parisc/boot/compressed/Makefile | ||
# | ||
# create a compressed self-extracting vmlinux image from the original vmlinux | ||
# | ||
|
||
KCOV_INSTRUMENT := n | ||
GCOV_PROFILE := n | ||
UBSAN_SANITIZE := n | ||
|
||
targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 | ||
targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4 | ||
targets += misc.o piggy.o sizes.h head.o real2.o firmware.o | ||
|
||
KBUILD_CFLAGS := -D__KERNEL__ -O2 -DBOOTLOADER | ||
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING | ||
KBUILD_CFLAGS += $(cflags-y) -fno-delete-null-pointer-checks | ||
KBUILD_CFLAGS += -fno-PIE -mno-space-regs -mdisable-fpregs | ||
ifndef CONFIG_64BIT | ||
KBUILD_CFLAGS += -mfast-indirect-calls | ||
endif | ||
|
||
OBJECTS += $(obj)/head.o $(obj)/real2.o $(obj)/firmware.o $(obj)/misc.o $(obj)/piggy.o | ||
|
||
# LDFLAGS_vmlinux := -X --whole-archive -e startup -T | ||
LDFLAGS_vmlinux := -X -e startup --as-needed -T | ||
$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(LIBGCC) | ||
$(call if_changed,ld) | ||
|
||
sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\|parisc_kernel_start\)$$/\#define SZ\2 0x\1/p' | ||
|
||
quiet_cmd_sizes = GEN $@ | ||
cmd_sizes = $(NM) $< | sed -n $(sed-sizes) > $@ | ||
|
||
$(obj)/sizes.h: vmlinux | ||
$(call if_changed,sizes) | ||
|
||
AFLAGS_head.o += -I$(objtree)/$(obj) -DBOOTLOADER | ||
$(obj)/head.o: $(obj)/sizes.h | ||
|
||
CFLAGS_misc.o += -I$(objtree)/$(obj) | ||
$(obj)/misc.o: $(obj)/sizes.h | ||
|
||
$(obj)/firmware.o: $(obj)/firmware.c | ||
$(obj)/firmware.c: $(srctree)/arch/$(SRCARCH)/kernel/firmware.c | ||
$(call cmd,shipped) | ||
|
||
AFLAGS_real2.o += -DBOOTLOADER | ||
$(obj)/real2.o: $(obj)/real2.S | ||
$(obj)/real2.S: $(srctree)/arch/$(SRCARCH)/kernel/real2.S | ||
$(call cmd,shipped) | ||
|
||
$(obj)/misc.o: $(obj)/sizes.h | ||
|
||
CPPFLAGS_vmlinux.lds += -I$(objtree)/$(obj) -DBOOTLOADER | ||
$(obj)/vmlinux.lds: $(obj)/sizes.h | ||
|
||
OBJCOPYFLAGS_vmlinux.bin := -O binary -R .comment -S | ||
$(obj)/vmlinux.bin: vmlinux | ||
$(call if_changed,objcopy) | ||
|
||
vmlinux.bin.all-y := $(obj)/vmlinux.bin | ||
|
||
suffix-$(CONFIG_KERNEL_GZIP) := gz | ||
suffix-$(CONFIG_KERNEL_BZIP2) := bz2 | ||
suffix-$(CONFIG_KERNEL_LZ4) := lz4 | ||
suffix-$(CONFIG_KERNEL_LZMA) := lzma | ||
suffix-$(CONFIG_KERNEL_LZO) := lzo | ||
suffix-$(CONFIG_KERNEL_XZ) := xz | ||
|
||
$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) | ||
$(call if_changed,gzip) | ||
$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) | ||
$(call if_changed,bzip2) | ||
$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) | ||
$(call if_changed,lz4) | ||
$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) | ||
$(call if_changed,lzma) | ||
$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) | ||
$(call if_changed,lzo) | ||
$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) | ||
$(call if_changed,xzkern) | ||
|
||
LDFLAGS_piggy.o := -r --format binary --oformat $(LD_BFD) -T | ||
$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) | ||
$(call if_changed,ld) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Startup glue code to uncompress the kernel | ||
* | ||
* (C) 2017 Helge Deller <deller@gmx.de> | ||
*/ | ||
|
||
#include <linux/init.h> | ||
#include <linux/linkage.h> | ||
#include <asm/asm-offsets.h> | ||
#include <asm/page.h> | ||
#include <asm/psw.h> | ||
#include <asm/pdc.h> | ||
#include <asm/assembly.h> | ||
#include "sizes.h" | ||
|
||
#define BOOTADDR(x) (x) | ||
|
||
#ifndef CONFIG_64BIT | ||
.import $global$ /* forward declaration */ | ||
#endif /*!CONFIG_64BIT*/ | ||
|
||
__HEAD | ||
|
||
ENTRY(startup) | ||
.level LEVEL | ||
|
||
#define PSW_W_SM 0x200 | ||
#define PSW_W_BIT 36 | ||
|
||
;! nuke the W bit, saving original value | ||
.level 2.0 | ||
rsm PSW_W_SM, %r1 | ||
|
||
.level 1.1 | ||
extrw,u %r1, PSW_W_BIT-32, 1, %r1 | ||
copy %r1, %arg0 | ||
|
||
/* Make sure sr4-sr7 are set to zero for the kernel address space */ | ||
mtsp %r0,%sr4 | ||
mtsp %r0,%sr5 | ||
mtsp %r0,%sr6 | ||
mtsp %r0,%sr7 | ||
|
||
/* Clear BSS */ | ||
|
||
.import _bss,data | ||
.import _ebss,data | ||
|
||
load32 BOOTADDR(_bss),%r3 | ||
load32 BOOTADDR(_ebss),%r4 | ||
ldo FRAME_SIZE(%r4),%sp /* stack at end of bss */ | ||
$bss_loop: | ||
cmpb,<<,n %r3,%r4,$bss_loop | ||
stw,ma %r0,4(%r3) | ||
|
||
/* Initialize the global data pointer */ | ||
loadgp | ||
|
||
/* arg0..arg4 were set by palo. */ | ||
copy %arg1, %r6 /* command line */ | ||
copy %arg2, %r7 /* rd-start */ | ||
copy %arg3, %r8 /* rd-end */ | ||
load32 BOOTADDR(decompress_kernel),%r3 | ||
|
||
#ifdef CONFIG_64BIT | ||
.level LEVEL | ||
ssm PSW_W_SM, %r0 /* set W-bit */ | ||
depdi 0, 31, 32, %r3 | ||
#endif | ||
load32 BOOTADDR(startup_continue), %r2 | ||
bv,n 0(%r3) | ||
|
||
startup_continue: | ||
#ifdef CONFIG_64BIT | ||
.level LEVEL | ||
rsm PSW_W_SM, %r0 /* clear W-bit */ | ||
#endif | ||
|
||
load32 KERNEL_BINARY_TEXT_START, %arg0 /* free mem */ | ||
copy %r6, %arg1 /* command line */ | ||
copy %r7, %arg2 /* rd-start */ | ||
copy %r8, %arg3 /* rd-end */ | ||
|
||
bv,n 0(%ret0) | ||
END(startup) |
Oops, something went wrong.