diff options
author | Yoshinori Sato <ysato@users.sourceforge.jp> | 2015-05-10 20:26:40 +0300 |
---|---|---|
committer | Yoshinori Sato <ysato@users.sourceforge.jp> | 2015-06-23 07:35:52 +0300 |
commit | 06706c96ed753f952e53fa9840fb38852d2fe37e (patch) | |
tree | b0c870e788d6f94d608d4b18d3fa9c002b2252fe /arch/h8300 | |
parent | df2078b8daa7bb15cc8e3f791389b9f44e12bb25 (diff) | |
download | linux-06706c96ed753f952e53fa9840fb38852d2fe37e.tar.xz |
h8300: compressed image support
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Diffstat (limited to 'arch/h8300')
-rw-r--r-- | arch/h8300/boot/Makefile | 26 | ||||
-rw-r--r-- | arch/h8300/boot/compressed/Makefile | 37 | ||||
-rw-r--r-- | arch/h8300/boot/compressed/head.S | 48 | ||||
-rw-r--r-- | arch/h8300/boot/compressed/misc.c | 74 | ||||
-rw-r--r-- | arch/h8300/boot/compressed/vmlinux.lds | 32 | ||||
-rw-r--r-- | arch/h8300/boot/compressed/vmlinux.scr | 9 |
6 files changed, 226 insertions, 0 deletions
diff --git a/arch/h8300/boot/Makefile b/arch/h8300/boot/Makefile new file mode 100644 index 000000000000..2f6393a5da57 --- /dev/null +++ b/arch/h8300/boot/Makefile @@ -0,0 +1,26 @@ +# arch/h8300/boot/Makefile + +targets := vmlinux.srec vmlinux.bin zImage +subdir- := compressed + +OBJCOPYFLAGS_vmlinux.srec := -Osrec +OBJCOPYFLAGS_vmlinux.bin := -Obinary +OBJCOPYFLAGS_zImage := -O binary -R .note -R .comment -R .stab -R .stabstr -S + +UIMAGE_LOADADDR = $(CONFIG_RAMBASE) +UIMAGE_ENTRYADDR = $(shell /bin/bash -c 'printf "0x%08x" \ + $$[$(CONFIG_RAMBASE) + $(CONFIG_OFFSET)]') + +$(obj)/vmlinux.srec $(obj)/vmlinux.bin: vmlinux FORCE + $(call if_changed,objcopy) + +$(obj)/zImage: $(obj)/compressed/vmlinux FORCE + $(call if_changed,objcopy) + +$(obj)/compressed/vmlinux: FORCE + $(Q)$(MAKE) $(build)=$(obj)/compressed $@ + +$(obj)/uImage.bin: $(obj)/vmlinux.bin + $(call if_changed,uimage,none) + +CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec arch/$(ARCH)/uImage.bin diff --git a/arch/h8300/boot/compressed/Makefile b/arch/h8300/boot/compressed/Makefile new file mode 100644 index 000000000000..87d03b7ee97e --- /dev/null +++ b/arch/h8300/boot/compressed/Makefile @@ -0,0 +1,37 @@ +# +# linux/arch/sh/boot/compressed/Makefile +# +# create a compressed vmlinux image from the original vmlinux +# + +targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o + +OBJECTS = $(obj)/head.o $(obj)/misc.o + +# +# IMAGE_OFFSET is the load offset of the compression loader +# Assign dummy values if these 2 variables are not defined, +# in order to suppress error message. +# +CONFIG_MEMORY_START ?= 0x00400000 +CONFIG_BOOT_LINK_OFFSET ?= 0x00140000 +IMAGE_OFFSET := $(shell printf "0x%08x" $$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET)))) + +LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) +LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup $(obj)/vmlinux.lds + +$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE + $(call if_changed,ld) + @: + +$(obj)/vmlinux.bin: vmlinux FORCE + $(call if_changed,objcopy) + +$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE + $(call if_changed,gzip) + +LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T +OBJCOPYFLAGS := -O binary + +$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE + $(call if_changed,ld) diff --git a/arch/h8300/boot/compressed/head.S b/arch/h8300/boot/compressed/head.S new file mode 100644 index 000000000000..74c0d8cc40ba --- /dev/null +++ b/arch/h8300/boot/compressed/head.S @@ -0,0 +1,48 @@ +/* + * linux/arch/h8300/boot/compressed/head.S + * + * Copyright (C) 2006 Yoshinori Sato + */ + +#include <linux/linkage.h> + + .section .text..startup,"ax" + .global startup +startup: + mov.l er0, er4 + mov.l er0, sp + mov.l #__sbss, er0 + mov.l #__ebss, er1 + sub.l er0, er1 + shlr er1 + shlr er1 + sub.l er2, er2 +1: + mov.l er2, @er0 + adds #4, er0 + dec.l #1, er1 + bne 1b + jsr @decompress_kernel + mov.l er4, er0 + jmp @0x400000 + + .align 9 +fake_headers_as_bzImage: + .word 0 + .ascii "HdrS" ; header signature + .word 0x0202 ; header version number (>= 0x0105) + ; or else old loadlin-1.5 will fail) + .word 0 ; default_switch + .word 0 ; SETUPSEG + .word 0x1000 + .word 0 ; pointing to kernel version string + .byte 0 ; = 0, old one (LILO, Loadlin, + ; 0xTV: T=0 for LILO + ; V = version + .byte 1 ; Load flags bzImage=1 + .word 0x8000 ; size to move, when setup is not + .long 0x100000 ; 0x100000 = default for big kernel + .long 0 ; address of loaded ramdisk image + .long 0 ; its size in bytes + + .end diff --git a/arch/h8300/boot/compressed/misc.c b/arch/h8300/boot/compressed/misc.c new file mode 100644 index 000000000000..704274127c07 --- /dev/null +++ b/arch/h8300/boot/compressed/misc.c @@ -0,0 +1,74 @@ +/* + * arch/h8300/boot/compressed/misc.c + * + * This is a collection of several routines from gzip-1.0.3 + * adapted for Linux. + * + * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 + * + * Adapted for h8300 by Yoshinori Sato 2006 + */ + +#include <asm/uaccess.h> + +/* + * gzip declarations + */ + +#define OF(args) args +#define STATIC static + +#undef memset +#undef memcpy +#define memzero(s, n) memset((s), (0), (n)) + +extern int _end; +static unsigned long free_mem_ptr; +static unsigned long free_mem_end_ptr; + +extern char input_data[]; +extern int input_len; +static unsigned char *output; + +#define HEAP_SIZE 0x10000 + +#include "../../../../lib/decompress_inflate.c" + +void *memset(void *s, int c, size_t n) +{ + int i; + char *ss = (char *)s; + + for (i = 0; i < n; i++) + ss[i] = c; + return s; +} + +void *memcpy(void *dest, const void *src, size_t n) +{ + int i; + char *d = (char *)dest, *s = (char *)src; + + for (i = 0; i < n; i++) + d[i] = s[i]; + return dest; +} + +static void error(char *x) +{ + + while (1) + ; /* Halt */ +} + +#define STACK_SIZE (4096) +long user_stack[STACK_SIZE]; +long *stack_start = &user_stack[STACK_SIZE]; + +void decompress_kernel(void) +{ + free_mem_ptr = (unsigned long)&_end; + free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; + + decompress(input_data, input_len, NULL, NULL, output, NULL, error); +} diff --git a/arch/h8300/boot/compressed/vmlinux.lds b/arch/h8300/boot/compressed/vmlinux.lds new file mode 100644 index 000000000000..a0a3a0ed54ef --- /dev/null +++ b/arch/h8300/boot/compressed/vmlinux.lds @@ -0,0 +1,32 @@ +SECTIONS +{ + .text : + { + __stext = . ; + __text = .; + *(.text..startup) + *(.text) + __etext = . ; + } + + .rodata : + { + *(.rodata) + } + .data : + + { + __sdata = . ; + ___data_start = . ; + *(.data.*) + } + .bss : + { + . = ALIGN(0x4) ; + __sbss = . ; + *(.bss*) + . = ALIGN(0x4) ; + __ebss = . ; + __end = . ; + } +} diff --git a/arch/h8300/boot/compressed/vmlinux.scr b/arch/h8300/boot/compressed/vmlinux.scr new file mode 100644 index 000000000000..a084903603fe --- /dev/null +++ b/arch/h8300/boot/compressed/vmlinux.scr @@ -0,0 +1,9 @@ +SECTIONS +{ + .data : { + input_len = .; + LONG(input_data_end - input_data) input_data = .; + *(.data) + input_data_end = .; + } +} |