aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshinori Sato <ysato@users.sourceforge.jp>2015-05-10 13:26:40 -0400
committerYoshinori Sato <ysato@users.sourceforge.jp>2015-06-23 00:35:52 -0400
commit06706c96ed753f952e53fa9840fb38852d2fe37e (patch)
treeb0c870e788d6f94d608d4b18d3fa9c002b2252fe
parentdf2078b8daa7bb15cc8e3f791389b9f44e12bb25 (diff)
h8300: compressed image support
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
-rw-r--r--arch/h8300/boot/Makefile26
-rw-r--r--arch/h8300/boot/compressed/Makefile37
-rw-r--r--arch/h8300/boot/compressed/head.S48
-rw-r--r--arch/h8300/boot/compressed/misc.c74
-rw-r--r--arch/h8300/boot/compressed/vmlinux.lds32
-rw-r--r--arch/h8300/boot/compressed/vmlinux.scr9
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 @@
1# arch/h8300/boot/Makefile
2
3targets := vmlinux.srec vmlinux.bin zImage
4subdir- := compressed
5
6OBJCOPYFLAGS_vmlinux.srec := -Osrec
7OBJCOPYFLAGS_vmlinux.bin := -Obinary
8OBJCOPYFLAGS_zImage := -O binary -R .note -R .comment -R .stab -R .stabstr -S
9
10UIMAGE_LOADADDR = $(CONFIG_RAMBASE)
11UIMAGE_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
26CLEAN_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 @@
1#
2# linux/arch/sh/boot/compressed/Makefile
3#
4# create a compressed vmlinux image from the original vmlinux
5#
6
7targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
8
9OBJECTS = $(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#
16CONFIG_MEMORY_START ?= 0x00400000
17CONFIG_BOOT_LINK_OFFSET ?= 0x00140000
18IMAGE_OFFSET := $(shell printf "0x%08x" $$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET))))
19
20LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
21LDFLAGS_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
33LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T
34OBJCOPYFLAGS := -O binary
35
36$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
37 $(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 @@
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
11startup:
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
201:
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
30fake_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
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 @@
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
25extern int _end;
26static unsigned long free_mem_ptr;
27static unsigned long free_mem_end_ptr;
28
29extern char input_data[];
30extern int input_len;
31static unsigned char *output;
32
33#define HEAP_SIZE 0x10000
34
35#include "../../../../lib/decompress_inflate.c"
36
37void *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
47void *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
57static void error(char *x)
58{
59
60 while (1)
61 ; /* Halt */
62}
63
64#define STACK_SIZE (4096)
65long user_stack[STACK_SIZE];
66long *stack_start = &user_stack[STACK_SIZE];
67
68void 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}
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 @@
1SECTIONS
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}
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 @@
1SECTIONS
2{
3 .data : {
4 input_len = .;
5 LONG(input_data_end - input_data) input_data = .;
6 *(.data)
7 input_data_end = .;
8 }
9}