Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

h8300: compressed image support

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

+226
+26
arch/h8300/boot/Makefile
··· 1 + # arch/h8300/boot/Makefile 2 + 3 + targets := vmlinux.srec vmlinux.bin zImage 4 + subdir- := compressed 5 + 6 + OBJCOPYFLAGS_vmlinux.srec := -Osrec 7 + OBJCOPYFLAGS_vmlinux.bin := -Obinary 8 + OBJCOPYFLAGS_zImage := -O binary -R .note -R .comment -R .stab -R .stabstr -S 9 + 10 + UIMAGE_LOADADDR = $(CONFIG_RAMBASE) 11 + UIMAGE_ENTRYADDR = $(shell /bin/bash -c 'printf "0x%08x" \ 12 + $$[$(CONFIG_RAMBASE) + $(CONFIG_OFFSET)]') 13 + 14 + $(obj)/vmlinux.srec $(obj)/vmlinux.bin: vmlinux FORCE 15 + $(call if_changed,objcopy) 16 + 17 + $(obj)/zImage: $(obj)/compressed/vmlinux FORCE 18 + $(call if_changed,objcopy) 19 + 20 + $(obj)/compressed/vmlinux: FORCE 21 + $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 22 + 23 + $(obj)/uImage.bin: $(obj)/vmlinux.bin 24 + $(call if_changed,uimage,none) 25 + 26 + CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec arch/$(ARCH)/uImage.bin
+37
arch/h8300/boot/compressed/Makefile
··· 1 + # 2 + # linux/arch/sh/boot/compressed/Makefile 3 + # 4 + # create a compressed vmlinux image from the original vmlinux 5 + # 6 + 7 + targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o 8 + 9 + OBJECTS = $(obj)/head.o $(obj)/misc.o 10 + 11 + # 12 + # IMAGE_OFFSET is the load offset of the compression loader 13 + # Assign dummy values if these 2 variables are not defined, 14 + # in order to suppress error message. 15 + # 16 + CONFIG_MEMORY_START ?= 0x00400000 17 + CONFIG_BOOT_LINK_OFFSET ?= 0x00140000 18 + IMAGE_OFFSET := $(shell printf "0x%08x" $$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET)))) 19 + 20 + LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) 21 + LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup $(obj)/vmlinux.lds 22 + 23 + $(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE 24 + $(call if_changed,ld) 25 + @: 26 + 27 + $(obj)/vmlinux.bin: vmlinux FORCE 28 + $(call if_changed,objcopy) 29 + 30 + $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE 31 + $(call if_changed,gzip) 32 + 33 + LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T 34 + OBJCOPYFLAGS := -O binary 35 + 36 + $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE 37 + $(call if_changed,ld)
+48
arch/h8300/boot/compressed/head.S
··· 1 + /* 2 + * linux/arch/h8300/boot/compressed/head.S 3 + * 4 + * Copyright (C) 2006 Yoshinori Sato 5 + */ 6 + 7 + #include <linux/linkage.h> 8 + 9 + .section .text..startup,"ax" 10 + .global startup 11 + startup: 12 + mov.l er0, er4 13 + mov.l er0, sp 14 + mov.l #__sbss, er0 15 + mov.l #__ebss, er1 16 + sub.l er0, er1 17 + shlr er1 18 + shlr er1 19 + sub.l er2, er2 20 + 1: 21 + mov.l er2, @er0 22 + adds #4, er0 23 + dec.l #1, er1 24 + bne 1b 25 + jsr @decompress_kernel 26 + mov.l er4, er0 27 + jmp @0x400000 28 + 29 + .align 9 30 + fake_headers_as_bzImage: 31 + .word 0 32 + .ascii "HdrS" ; header signature 33 + .word 0x0202 ; header version number (>= 0x0105) 34 + ; or else old loadlin-1.5 will fail) 35 + .word 0 ; default_switch 36 + .word 0 ; SETUPSEG 37 + .word 0x1000 38 + .word 0 ; pointing to kernel version string 39 + .byte 0 ; = 0, old one (LILO, Loadlin, 40 + ; 0xTV: T=0 for LILO 41 + ; V = version 42 + .byte 1 ; Load flags bzImage=1 43 + .word 0x8000 ; size to move, when setup is not 44 + .long 0x100000 ; 0x100000 = default for big kernel 45 + .long 0 ; address of loaded ramdisk image 46 + .long 0 ; its size in bytes 47 + 48 + .end
+74
arch/h8300/boot/compressed/misc.c
··· 1 + /* 2 + * arch/h8300/boot/compressed/misc.c 3 + * 4 + * This is a collection of several routines from gzip-1.0.3 5 + * adapted for Linux. 6 + * 7 + * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 8 + * 9 + * Adapted for h8300 by Yoshinori Sato 2006 10 + */ 11 + 12 + #include <asm/uaccess.h> 13 + 14 + /* 15 + * gzip declarations 16 + */ 17 + 18 + #define OF(args) args 19 + #define STATIC static 20 + 21 + #undef memset 22 + #undef memcpy 23 + #define memzero(s, n) memset((s), (0), (n)) 24 + 25 + extern int _end; 26 + static unsigned long free_mem_ptr; 27 + static unsigned long free_mem_end_ptr; 28 + 29 + extern char input_data[]; 30 + extern int input_len; 31 + static unsigned char *output; 32 + 33 + #define HEAP_SIZE 0x10000 34 + 35 + #include "../../../../lib/decompress_inflate.c" 36 + 37 + void *memset(void *s, int c, size_t n) 38 + { 39 + int i; 40 + char *ss = (char *)s; 41 + 42 + for (i = 0; i < n; i++) 43 + ss[i] = c; 44 + return s; 45 + } 46 + 47 + void *memcpy(void *dest, const void *src, size_t n) 48 + { 49 + int i; 50 + char *d = (char *)dest, *s = (char *)src; 51 + 52 + for (i = 0; i < n; i++) 53 + d[i] = s[i]; 54 + return dest; 55 + } 56 + 57 + static void error(char *x) 58 + { 59 + 60 + while (1) 61 + ; /* Halt */ 62 + } 63 + 64 + #define STACK_SIZE (4096) 65 + long user_stack[STACK_SIZE]; 66 + long *stack_start = &user_stack[STACK_SIZE]; 67 + 68 + void decompress_kernel(void) 69 + { 70 + free_mem_ptr = (unsigned long)&_end; 71 + free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; 72 + 73 + decompress(input_data, input_len, NULL, NULL, output, NULL, error); 74 + }
+32
arch/h8300/boot/compressed/vmlinux.lds
··· 1 + SECTIONS 2 + { 3 + .text : 4 + { 5 + __stext = . ; 6 + __text = .; 7 + *(.text..startup) 8 + *(.text) 9 + __etext = . ; 10 + } 11 + 12 + .rodata : 13 + { 14 + *(.rodata) 15 + } 16 + .data : 17 + 18 + { 19 + __sdata = . ; 20 + ___data_start = . ; 21 + *(.data.*) 22 + } 23 + .bss : 24 + { 25 + . = ALIGN(0x4) ; 26 + __sbss = . ; 27 + *(.bss*) 28 + . = ALIGN(0x4) ; 29 + __ebss = . ; 30 + __end = . ; 31 + } 32 + }
+9
arch/h8300/boot/compressed/vmlinux.scr
··· 1 + SECTIONS 2 + { 3 + .data : { 4 + input_len = .; 5 + LONG(input_data_end - input_data) input_data = .; 6 + *(.data) 7 + input_data_end = .; 8 + } 9 + }