aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boot/compressed
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sh/boot/compressed
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/sh/boot/compressed')
-rw-r--r--arch/sh/boot/compressed/Makefile41
-rw-r--r--arch/sh/boot/compressed/head.S120
-rw-r--r--arch/sh/boot/compressed/install.sh56
-rw-r--r--arch/sh/boot/compressed/misc.c240
-rw-r--r--arch/sh/boot/compressed/vmlinux.scr9
5 files changed, 466 insertions, 0 deletions
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
new file mode 100644
index 000000000000..75a6876bf6c6
--- /dev/null
+++ b/arch/sh/boot/compressed/Makefile
@@ -0,0 +1,41 @@
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
8EXTRA_AFLAGS := -traditional
9
10OBJECTS = $(obj)/head.o $(obj)/misc.o
11
12ifdef CONFIG_SH_STANDARD_BIOS
13OBJECTS += $(obj)/../../kernel/sh_bios.o
14endif
15
16#
17# IMAGE_OFFSET is the load offset of the compression loader
18# Assign dummy values if these 2 variables are not defined,
19# in order to suppress error message.
20#
21CONFIG_MEMORY_START ?= 0x0c000000
22CONFIG_BOOT_LINK_OFFSET ?= 0x00800000
23IMAGE_OFFSET := $(shell printf "0x%8x" $$[0x80000000+$(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET)])
24
25LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup -T $(obj)/../../kernel/vmlinux.lds
26
27$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o FORCE
28 $(call if_changed,ld)
29 @:
30
31$(obj)/vmlinux.bin: vmlinux FORCE
32 $(call if_changed,objcopy)
33
34$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
35 $(call if_changed,gzip)
36
37LDFLAGS_piggy.o := -r --format binary --oformat elf32-sh-linux -T
38OBJCOPYFLAGS += -R .empty_zero_page
39
40$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
41 $(call if_changed,ld)
diff --git a/arch/sh/boot/compressed/head.S b/arch/sh/boot/compressed/head.S
new file mode 100644
index 000000000000..88db04d325fb
--- /dev/null
+++ b/arch/sh/boot/compressed/head.S
@@ -0,0 +1,120 @@
1/*
2 * linux/arch/sh/boot/compressed/head.S
3 *
4 * Copyright (C) 1999 Stuart Menefy
5 * Copyright (C) 2003 SUGIOKA Toshinobu
6 */
7
8.text
9
10#include <linux/config.h>
11#include <linux/linkage.h>
12
13 .global startup
14startup:
15 /* Load initial status register */
16 mov.l init_sr, r1
17 ldc r1, sr
18
19 /* Move myself to proper location if necessary */
20 mova 1f, r0
21 mov.l 1f, r2
22 cmp/eq r2, r0
23 bt clear_bss
24 sub r0, r2
25 mov.l bss_start_addr, r0
26 mov #0xe0, r1
27 and r1, r0 ! align cache line
28 mov.l text_start_addr, r3
29 mov r0, r1
30 sub r2, r1
313:
32 mov.l @r1, r4
33 mov.l @(4,r1), r5
34 mov.l @(8,r1), r6
35 mov.l @(12,r1), r7
36 mov.l @(16,r1), r8
37 mov.l @(20,r1), r9
38 mov.l @(24,r1), r10
39 mov.l @(28,r1), r11
40 mov.l r4, @r0
41 mov.l r5, @(4,r0)
42 mov.l r6, @(8,r0)
43 mov.l r7, @(12,r0)
44 mov.l r8, @(16,r0)
45 mov.l r9, @(20,r0)
46 mov.l r10, @(24,r0)
47 mov.l r11, @(28,r0)
48#ifdef CONFIG_CPU_SH4
49 ocbwb @r0
50#endif
51 cmp/hi r3, r0
52 add #-32, r0
53 bt/s 3b
54 add #-32, r1
55 mov.l 2f, r0
56 jmp @r0
57 nop
58
59 .align 2
601: .long 1b
612: .long clear_bss
62text_start_addr:
63 .long startup
64
65 /* Clear BSS */
66clear_bss:
67 mov.l end_addr, r1
68 mov.l bss_start_addr, r2
69 mov #0, r0
70l1:
71 mov.l r0, @-r1
72 cmp/eq r1,r2
73 bf l1
74
75 /* Set the initial pointer. */
76 mov.l init_stack_addr, r0
77 mov.l @r0, r15
78
79 /* Decompress the kernel */
80 mov.l decompress_kernel_addr, r0
81 jsr @r0
82 nop
83
84 /* Jump to the start of the decompressed kernel */
85 mov.l kernel_start_addr, r0
86 jmp @r0
87 nop
88
89 .align 2
90bss_start_addr:
91 .long __bss_start
92end_addr:
93 .long _end
94init_sr:
95 .long 0x400000F0 /* Privileged mode, Bank=0, Block=0, IMASK=0xF */
96init_stack_addr:
97 .long stack_start
98decompress_kernel_addr:
99 .long decompress_kernel
100kernel_start_addr:
101 .long _text+0x1000
102
103 .align 9
104fake_headers_as_bzImage:
105 .word 0
106 .ascii "HdrS" ! header signature
107 .word 0x0202 ! header version number (>= 0x0105)
108 ! or else old loadlin-1.5 will fail)
109 .word 0 ! default_switch
110 .word 0 ! SETUPSEG
111 .word 0x1000
112 .word 0 ! pointing to kernel version string
113 .byte 0 ! = 0, old one (LILO, Loadlin,
114 ! 0xTV: T=0 for LILO
115 ! V = version
116 .byte 1 ! Load flags bzImage=1
117 .word 0x8000 ! size to move, when setup is not
118 .long 0x100000 ! 0x100000 = default for big kernel
119 .long 0 ! address of loaded ramdisk image
120 .long 0 # its size in bytes
diff --git a/arch/sh/boot/compressed/install.sh b/arch/sh/boot/compressed/install.sh
new file mode 100644
index 000000000000..90589f0fec12
--- /dev/null
+++ b/arch/sh/boot/compressed/install.sh
@@ -0,0 +1,56 @@
1#!/bin/sh
2#
3# arch/sh/boot/install.sh
4#
5# This file is subject to the terms and conditions of the GNU General Public
6# License. See the file "COPYING" in the main directory of this archive
7# for more details.
8#
9# Copyright (C) 1995 by Linus Torvalds
10#
11# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
12# Adapted from code in arch/i386/boot/install.sh by Russell King
13# Adapted from code in arch/arm/boot/install.sh by Stuart Menefy
14#
15# "make install" script for sh architecture
16#
17# Arguments:
18# $1 - kernel version
19# $2 - kernel image file
20# $3 - kernel map file
21# $4 - default install path (blank if root directory)
22#
23
24# User may have a custom install script
25
26if [ -x /sbin/installkernel ]; then
27 exec /sbin/installkernel "$@"
28fi
29
30if [ "$2" = "zImage" ]; then
31# Compressed install
32 echo "Installing compressed kernel"
33 if [ -f $4/vmlinuz-$1 ]; then
34 mv $4/vmlinuz-$1 $4/vmlinuz.old
35 fi
36
37 if [ -f $4/System.map-$1 ]; then
38 mv $4/System.map-$1 $4/System.old
39 fi
40
41 cat $2 > $4/vmlinuz-$1
42 cp $3 $4/System.map-$1
43else
44# Normal install
45 echo "Installing normal kernel"
46 if [ -f $4/vmlinux-$1 ]; then
47 mv $4/vmlinux-$1 $4/vmlinux.old
48 fi
49
50 if [ -f $4/System.map ]; then
51 mv $4/System.map $4/System.old
52 fi
53
54 cat $2 > $4/vmlinux-$1
55 cp $3 $4/System.map
56fi
diff --git a/arch/sh/boot/compressed/misc.c b/arch/sh/boot/compressed/misc.c
new file mode 100644
index 000000000000..211e9110074f
--- /dev/null
+++ b/arch/sh/boot/compressed/misc.c
@@ -0,0 +1,240 @@
1/*
2 * arch/sh/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 SH by Stuart Menefy, Aug 1999
10 *
11 * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
12 */
13
14#include <linux/config.h>
15#include <asm/uaccess.h>
16#ifdef CONFIG_SH_STANDARD_BIOS
17#include <asm/sh_bios.h>
18#endif
19
20/*
21 * gzip declarations
22 */
23
24#define OF(args) args
25#define STATIC static
26
27#undef memset
28#undef memcpy
29#define memzero(s, n) memset ((s), 0, (n))
30
31typedef unsigned char uch;
32typedef unsigned short ush;
33typedef unsigned long ulg;
34
35#define WSIZE 0x8000 /* Window size must be at least 32k, */
36 /* and a power of two */
37
38static uch *inbuf; /* input buffer */
39static uch window[WSIZE]; /* Sliding window buffer */
40
41static unsigned insize = 0; /* valid bytes in inbuf */
42static unsigned inptr = 0; /* index of next byte to be processed in inbuf */
43static unsigned outcnt = 0; /* bytes in output buffer */
44
45/* gzip flag byte */
46#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
47#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
48#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
49#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
50#define COMMENT 0x10 /* bit 4 set: file comment present */
51#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
52#define RESERVED 0xC0 /* bit 6,7: reserved */
53
54#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
55
56/* Diagnostic functions */
57#ifdef DEBUG
58# define Assert(cond,msg) {if(!(cond)) error(msg);}
59# define Trace(x) fprintf x
60# define Tracev(x) {if (verbose) fprintf x ;}
61# define Tracevv(x) {if (verbose>1) fprintf x ;}
62# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
63# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
64#else
65# define Assert(cond,msg)
66# define Trace(x)
67# define Tracev(x)
68# define Tracevv(x)
69# define Tracec(c,x)
70# define Tracecv(c,x)
71#endif
72
73static int fill_inbuf(void);
74static void flush_window(void);
75static void error(char *m);
76static void gzip_mark(void **);
77static void gzip_release(void **);
78
79extern char input_data[];
80extern int input_len;
81
82static long bytes_out = 0;
83static uch *output_data;
84static unsigned long output_ptr = 0;
85
86static void *malloc(int size);
87static void free(void *where);
88static void error(char *m);
89static void gzip_mark(void **);
90static void gzip_release(void **);
91
92int puts(const char *);
93
94extern int _text; /* Defined in vmlinux.lds.S */
95extern int _end;
96static unsigned long free_mem_ptr;
97static unsigned long free_mem_end_ptr;
98
99#define HEAP_SIZE 0x10000
100
101#include "../../../../lib/inflate.c"
102
103static void *malloc(int size)
104{
105 void *p;
106
107 if (size <0) error("Malloc error");
108 if (free_mem_ptr == 0) error("Memory error");
109
110 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
111
112 p = (void *)free_mem_ptr;
113 free_mem_ptr += size;
114
115 if (free_mem_ptr >= free_mem_end_ptr)
116 error("Out of memory");
117
118 return p;
119}
120
121static void free(void *where)
122{ /* Don't care */
123}
124
125static void gzip_mark(void **ptr)
126{
127 *ptr = (void *) free_mem_ptr;
128}
129
130static void gzip_release(void **ptr)
131{
132 free_mem_ptr = (long) *ptr;
133}
134
135#ifdef CONFIG_SH_STANDARD_BIOS
136size_t strlen(const char *s)
137{
138 int i = 0;
139
140 while (*s++)
141 i++;
142 return i;
143}
144
145int puts(const char *s)
146{
147 int len = strlen(s);
148 sh_bios_console_write(s, len);
149 return len;
150}
151#else
152int puts(const char *s)
153{
154 /* This should be updated to use the sh-sci routines */
155 return 0;
156}
157#endif
158
159void* memset(void* s, int c, size_t n)
160{
161 int i;
162 char *ss = (char*)s;
163
164 for (i=0;i<n;i++) ss[i] = c;
165 return s;
166}
167
168void* memcpy(void* __dest, __const void* __src,
169 size_t __n)
170{
171 int i;
172 char *d = (char *)__dest, *s = (char *)__src;
173
174 for (i=0;i<__n;i++) d[i] = s[i];
175 return __dest;
176}
177
178/* ===========================================================================
179 * Fill the input buffer. This is called only when the buffer is empty
180 * and at least one byte is really needed.
181 */
182static int fill_inbuf(void)
183{
184 if (insize != 0) {
185 error("ran out of input data");
186 }
187
188 inbuf = input_data;
189 insize = input_len;
190 inptr = 1;
191 return inbuf[0];
192}
193
194/* ===========================================================================
195 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
196 * (Used for the decompressed data only.)
197 */
198static void flush_window(void)
199{
200 ulg c = crc; /* temporary variable */
201 unsigned n;
202 uch *in, *out, ch;
203
204 in = window;
205 out = &output_data[output_ptr];
206 for (n = 0; n < outcnt; n++) {
207 ch = *out++ = *in++;
208 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
209 }
210 crc = c;
211 bytes_out += (ulg)outcnt;
212 output_ptr += (ulg)outcnt;
213 outcnt = 0;
214}
215
216static void error(char *x)
217{
218 puts("\n\n");
219 puts(x);
220 puts("\n\n -- System halted");
221
222 while(1); /* Halt */
223}
224
225#define STACK_SIZE (4096)
226long user_stack [STACK_SIZE];
227long* stack_start = &user_stack[STACK_SIZE];
228
229void decompress_kernel(void)
230{
231 output_data = 0;
232 output_ptr = (unsigned long)&_text+0x20001000;
233 free_mem_ptr = (unsigned long)&_end;
234 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
235
236 makecrc();
237 puts("Uncompressing Linux... ");
238 gunzip();
239 puts("Ok, booting the kernel.\n");
240}
diff --git a/arch/sh/boot/compressed/vmlinux.scr b/arch/sh/boot/compressed/vmlinux.scr
new file mode 100644
index 000000000000..1ed9d791f863
--- /dev/null
+++ b/arch/sh/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}