diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1998-03-17 22:05:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1998-03-17 22:05:47 +0000 |
commit | 27cfca1ec98e91261b1a5355d10a8996464b63af (patch) | |
tree | 8e895a53e372fa682b4c0a585b9377d67ed70d0e /arch/arm/boot | |
parent | 6a76fb7214c477ccf6582bd79c5b4ccc4f9c41b1 (diff) |
Look Ma' what I found on my harddisk ...
o New faster syscalls for 2.1.x, too
o Upgrade to 2.1.89.
Don't try to run this. It's flaky as hell. But feel free to debug ...
Diffstat (limited to 'arch/arm/boot')
-rw-r--r-- | arch/arm/boot/Makefile | 35 | ||||
-rw-r--r-- | arch/arm/boot/compressed/Makefile | 33 | ||||
-rw-r--r-- | arch/arm/boot/compressed/Makefile.debug | 16 | ||||
-rw-r--r-- | arch/arm/boot/compressed/head-nexuspci.S | 95 | ||||
-rw-r--r-- | arch/arm/boot/compressed/head.S | 124 | ||||
-rw-r--r-- | arch/arm/boot/compressed/misc.c | 308 | ||||
-rw-r--r-- | arch/arm/boot/install.sh | 61 |
7 files changed, 672 insertions, 0 deletions
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile new file mode 100644 index 000000000..e6050bf13 --- /dev/null +++ b/arch/arm/boot/Makefile @@ -0,0 +1,35 @@ +# +# arch/arm/boot/Makefile +# +# This file is subject to the terms and conditions of the GNU General Public +# License. See the file "COPYING" in the main directory of this archive +# for more details. +# +# Copyright (C) 1995, 1996 Russell King +# + +SYSTEM =$(TOPDIR)/vmlinux + +Image: $(CONFIGURE) $(SYSTEM) + $(OBJCOPY) $(SYSTEM) $@ + +zImage: $(CONFIGURE) compressed/vmlinux + $(OBJCOPY) compressed/vmlinux $@ + +compressed/vmlinux: $(TOPDIR)/vmlinux dep + @$(MAKE) -C compressed vmlinux + +install: $(CONFIGURE) Image + sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) Image $(TOPDIR)/System.map "$(INSTALL_PATH)" + +zinstall: $(CONFIGURE) zImage + sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)" + +tools/build: tools/build.c + $(HOSTCC) $(HOSTCFLAGS) -o $@ $< -I$(TOPDIR)/include + +clean: + rm -f Image zImage tools/build + @$(MAKE) -C compressed clean + +dep: diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile new file mode 100644 index 000000000..8e49f5dd0 --- /dev/null +++ b/arch/arm/boot/compressed/Makefile @@ -0,0 +1,33 @@ +# +# linux/arch/arm/boot/compressed/Makefile +# +# create a compressed vmlinuz image from the original vmlinux +# +# With this config, max compressed image size = 640k +# Uncompressed image size = 1.3M (text+data) + +SYSTEM =$(TOPDIR)/vmlinux +HEAD =$(COMPRESSED_HEAD) +OBJS =$(HEAD) misc.o $(COMPRESSED_EXTRA) +CFLAGS =-O2 -DSTDC_HEADERS $(CFLAGS_PROC) +ARFLAGS =rc + +all: vmlinux + +vmlinux: piggy.o $(OBJS) + $(LD) $(ZLINKFLAGS) -o vmlinux $(OBJS) piggy.o + +$(HEAD): $(HEAD:.o=.S) + $(CC) -traditional -DLOADADDR=$(ZRELADDR) -c $(HEAD:.o=.S) + +piggy.o: $(SYSTEM) + tmppiggy=_tmp_$$$$piggy; \ + rm -f $$tmppiggy $$tmppiggy.gz $$tmppiggy.lnk; \ + $(OBJCOPY) $(SYSTEM) $$tmppiggy; \ + gzip -f -9 < $$tmppiggy > $$tmppiggy.gz; \ + echo "SECTIONS { .data : { input_len = .; LONG(input_data_end - input_data) input_data = .; *(.data) input_data_end = .; }}" > $$tmppiggy.lnk; \ + $(LD) -m elf_arm -r -o piggy.o -b binary $$tmppiggy.gz -b elf32-arm -T $$tmppiggy.lnk; \ + rm -f $$tmppiggy $$tmppiggy.gz $$tmppiggy.lnk; + +clean:; rm -f vmlinux core + diff --git a/arch/arm/boot/compressed/Makefile.debug b/arch/arm/boot/compressed/Makefile.debug new file mode 100644 index 000000000..3c87b0569 --- /dev/null +++ b/arch/arm/boot/compressed/Makefile.debug @@ -0,0 +1,16 @@ +# +# linux/arch/arm/boot/compressed/Makefile +# +# create a compressed vmlinux image from the original vmlinux +# + +COMPRESSED_EXTRA=../../lib/ll_char_wr.o +OBJECTS=misc-debug.o $(COMPRESSED_EXTRA) + +CFLAGS=-D__KERNEL__ -O2 -DSTDC_HEADERS -DSTANDALONE_DEBUG -Wall -I../../../../include -c + +test-gzip: piggy.o $(OBJECTS) + $(CC) -o $@ $(OBJECTS) piggy.o + +misc-debug.o: misc.c + $(CC) $(CFLAGS) -o $@ misc.c diff --git a/arch/arm/boot/compressed/head-nexuspci.S b/arch/arm/boot/compressed/head-nexuspci.S new file mode 100644 index 000000000..92840fbda --- /dev/null +++ b/arch/arm/boot/compressed/head-nexuspci.S @@ -0,0 +1,95 @@ +/* + * linux/arch/arm/boot/compressed/head-nexuspci.S + * + * Copyright (C) 1996 Philip Blundell + */ + +#define ARM_CP p15 +#define ARM610_REG_CONTROL cr1 +#define ARM_REG_ZERO cr0 + + .text + +start: b skip1 + b go_uncompress + b go_uncompress + b go_uncompress + b go_uncompress + b go_uncompress + b go_uncompress + b go_uncompress + b go_uncompress + b go_uncompress +skip1: mov sp, #0x40000000 + add sp, sp, #0x200000 + mov r2, #0x20000000 + mov r1, #0x1a + str r1, [r2] + + MOV r0, #0x30 + MCR ARM_CP, 0, r0, ARM610_REG_CONTROL, ARM_REG_ZERO + + mov r2, #0x10000000 + + mov r1, #42 + strb r1, [r2, #8] + + mov r1, #48 + strb r1, [r2, #8] + + mov r1, #16 + strb r1, [r2, #8] + + mov r1, #0x93 + strb r1, [r2, #0] + mov r1, #0x17 + strb r1, [r2, #0] + + mov r1, #0xbb + strb r1, [r2, #0x4] + + mov r1, #0x78 + strb r1, [r2, #0x10] + + mov r1, #160 + strb r1, [r2, #0x8] + + mov r1, #5 + strb r1, [r2, #0x8] + + mov r0, #0x50 + bl _ll_write_char + + mov r4, #0x40000000 + mov r1, #0x00200000 + add r4, r4, r1 +copylp: + ldr r3, [r1] + str r3, [r4, r1] + subs r1, r1, #4 + bne copylp + + add pc, r4, #0x28 + + +/* + * Uncompress the kernel + */ +go_uncompress: + mov r0, #0x40000000 + add r0, r0, #0x300000 + bl _decompress_kernel + + mov r0, #0x40000000 + add r1, r0, #0x300000 + mov r2, #0x100000 + +clp2: ldr r3, [r1, r2] + str r3, [r0, r2] + subs r2, r2, #4 + bne clp2 + + mov r2, #0x40000000 + mov r0, #0 + mov r1, #3 + add pc, r2, #0x20 @ call via EXEC entry diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S new file mode 100644 index 000000000..98853511b --- /dev/null +++ b/arch/arm/boot/compressed/head.S @@ -0,0 +1,124 @@ +/* + * linux/arch/arm/boot/compressed/head.S + * + * Copyright (C) 1996,1997,1998 Russell King + */ +#include <linux/linkage.h> + + .text +/* + * sort out different calling conventions + */ + .align + .globl _start +_start: +start: mov r0, r0 + mov r0, r0 + mov r0, r0 + mov r0, r0 + mov r0, r0 + mov r0, r0 + mov r0, r0 + mov r0, r0 + teq r0, #0 + beq 2f + mov r4, #0x02000000 + add r4, r4, #0x7C000 + mov r3, #0x4000 + sub r3, r3, #4 +1: ldmia r0!, {r5 - r12} + stmia r4!, {r5 - r12} + subs r3, r3, #32 + bpl 1b +2: adr r2, LC0 + ldmia r2, {r2, r3, r4, r5, r6, sp} + add r2, r2, #3 + add r3, r3, #3 + add sp, sp, #3 + bic r2, r2, #3 + bic r3, r3, #3 + bic sp, sp, #3 + adr r7, start + sub r6, r7, r6 +/* + * Relocate pointers + */ + add r2, r2, r6 + add r3, r3, r6 + add r5, r5, r6 + add sp, sp, r6 +/* + * Clear zero-init + */ + mov r6, #0 +1: str r6, [r2], #4 + cmp r2, r3 + blt 1b + str r1, [r5] @ save architecture +/* + * Uncompress the kernel + */ + mov r1, #0x8000 + add r2, r2, r1, lsl #1 @ Add 64k for malloc + sub r1, r1, #1 + add r2, r2, r1 + bic r5, r2, r1 @ decompress kernel to after end of the compressed + mov r0, r5 + bl SYMBOL_NAME(decompress_kernel) + add r0, r0, #7 + bic r2, r0, #7 +/* + * Now move the kernel to the correct location (r5 -> r4, len r0) + */ + mov r0, r4 @ r0 = start of real kernel + mov r1, r5 @ r1 = start of kernel image + add r3, r5, r2 @ r3 = end of kernel + adr r4, movecode + adr r5, movecodeend +1: ldmia r4!, {r6 - r12, lr} + stmia r3!, {r6 - r12, lr} + cmp r4, r5 + blt 1b + mrc p15, 0, r5, c0, c0 + eor r5, r5, #0x44 << 24 + eor r5, r5, #0x01 << 16 + eor r5, r5, #0xa1 << 8 + movs r5, r5, lsr #4 + mov r5, #0 + mcreq p15, 0, r5, c7, c5, 0 @ flush I cache + ldr r5, LC0 + 12 @ get architecture + ldr r5, [r5] + add pc, r1, r2 @ Call move code + +/* + * r0 = length, r1 = to, r2 = from + */ +movecode: add r3, r1, r2 + mov r4, r0 +1: ldmia r1!, {r6 - r12, lr} + stmia r0!, {r6 - r12, lr} + cmp r1, r3 + blt 1b + mrc p15, 0, r0, c0, c0 + eor r0, r0, #0x44 << 24 + eor r0, r0, #0x01 << 16 + eor r0, r0, #0xa1 << 8 + movs r0, r0, lsr #4 + mov r0, #0 + mcreq p15, 0, r0, c7, c5, 0 @ flush I cache + mov r1, r5 @ call kernel correctly + mov pc, r4 @ call via EXEC entry +movecodeend: + +LC0: .word SYMBOL_NAME(_edata) + .word SYMBOL_NAME(_end) + .word LOADADDR + .word SYMBOL_NAME(architecture) + .word start + .word SYMBOL_NAME(user_stack)+4096 + .align + + .bss +SYMBOL_NAME(architecture): + .space 4 + .align diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c new file mode 100644 index 000000000..181583b75 --- /dev/null +++ b/arch/arm/boot/compressed/misc.c @@ -0,0 +1,308 @@ +/* + * 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 + * + * Modified for ARM Linux by Russell King + */ + +#include <asm/uaccess.h> +#include <asm/arch/uncompress.h> +#include <asm/proc/uncompress.h> + +#ifdef STANDALONE_DEBUG +#define puts printf +#endif + +#define __ptr_t void * + +/* + * Optimised C version of memzero for the ARM. + */ +extern __inline__ __ptr_t __memzero (__ptr_t s, size_t n) +{ + union { void *vp; unsigned long *ulp; unsigned char *ucp; } u; + int i; + + u.vp = s; + + for (i = n >> 5; i > 0; i--) { + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + } + + if (n & 1 << 4) { + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + } + + if (n & 1 << 3) { + *u.ulp++ = 0; + *u.ulp++ = 0; + } + + if (n & 1 << 2) + *u.ulp++ = 0; + + if (n & 1 << 1) { + *u.ucp++ = 0; + *u.ucp++ = 0; + } + + if (n & 1) + *u.ucp++ = 0; + return s; +} + +#define memzero(s,n) __memzero(s,n) + +extern __inline__ __ptr_t memcpy(__ptr_t __dest, __const __ptr_t __src, + size_t __n) +{ + int i = 0; + unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src; + + for (i = __n >> 3; i > 0; i--) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } + + if (__n & 1 << 2) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } + + if (__n & 1 << 1) { + *d++ = *s++; + *d++ = *s++; + } + + if (__n & 1) + *d++ = *s++; + + return __dest; +} + +/* + * gzip delarations + */ +#define OF(args) args +#define STATIC static + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + +#define WSIZE 0x8000 /* Window size must be at least 32k, */ + /* and a power of two */ + +static uch *inbuf; /* input buffer */ +static uch window[WSIZE]; /* Sliding window buffer */ + +static unsigned insize; /* valid bytes in inbuf */ +static unsigned inptr; /* index of next byte to be processed in inbuf */ +static unsigned outcnt; /* bytes in output buffer */ + +/* gzip flag byte */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ +#define RESERVED 0xC0 /* bit 6,7: reserved */ + +#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) + +/* Diagnostic functions */ +#ifdef DEBUG +# define Assert(cond,msg) {if(!(cond)) error(msg);} +# define Trace(x) fprintf x +# define Tracev(x) {if (verbose) fprintf x ;} +# define Tracevv(x) {if (verbose>1) fprintf x ;} +# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} +# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + +static int fill_inbuf(void); +static void flush_window(void); +static void error(char *m); +static void gzip_mark(void **); +static void gzip_release(void **); + +extern char input_data[]; +extern int input_len; + +static uch *output_data; +static ulg output_ptr; +static ulg bytes_out = 0; + +static void *malloc(int size); +static void free(void *where); +static void error(char *m); +static void gzip_mark(void **); +static void gzip_release(void **); + +static void puts(const char *); + +extern int end; +static ulg free_mem_ptr; +static ulg free_mem_ptr_end; + +#define HEAP_SIZE 0x2000 + +#include "../../../../lib/inflate.c" + +#ifndef STANDALONE_DEBUG +static void *malloc(int size) +{ + void *p; + + if (size <0) error("Malloc error\n"); + if (free_mem_ptr <= 0) error("Memory error\n"); + + free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */ + + p = (void *)free_mem_ptr; + free_mem_ptr += size; + + if (free_mem_ptr >= free_mem_ptr_end) + error("Out of memory"); + return p; +} + +static void free(void *where) +{ /* gzip_mark & gzip_release do the free */ +} + +static void gzip_mark(void **ptr) +{ + *ptr = (void *) free_mem_ptr; +} + +static void gzip_release(void **ptr) +{ + free_mem_ptr = (long) *ptr; +} +#else +static void gzip_mark(void **ptr) +{ +} + +static void gzip_release(void **ptr) +{ +} +#endif + +/* =========================================================================== + * Fill the input buffer. This is called only when the buffer is empty + * and at least one byte is really needed. + */ +int fill_inbuf() +{ + if (insize != 0) + error("ran out of input data\n"); + + inbuf = input_data; + insize = input_len; + inptr = 1; + return inbuf[0]; +} + +/* =========================================================================== + * Write the output window window[0..outcnt-1] and update crc and bytes_out. + * (Used for the decompressed data only.) + */ +void flush_window() +{ + ulg c = crc; + unsigned n; + uch *in, *out, ch; + + in = window; + out = &output_data[output_ptr]; + for (n = 0; n < outcnt; n++) { + ch = *out++ = *in++; + c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); + } + crc = c; + bytes_out += (ulg)outcnt; + output_ptr += (ulg)outcnt; + outcnt = 0; +} + +static void error(char *x) +{ + int ptr; + + puts("\n\n"); + puts(x); + puts("\n\n -- System halted"); + + while(1); /* Halt */ +} + +#define STACK_SIZE (4096) + +ulg user_stack [STACK_SIZE]; + +#ifndef STANDALONE_DEBUG + +ulg decompress_kernel(ulg output_start) +{ + free_mem_ptr = (ulg)&end; + free_mem_ptr_end = output_start; + + proc_decomp_setup (); + arch_decomp_setup (); + + output_data = (uch *)output_start; /* Points to kernel start */ + + makecrc(); + puts("Uncompressing Linux..."); + gunzip(); + puts("done.\nNow booting the kernel\n"); + return output_ptr; +} +#else + +char output_buffer[1500*1024]; + +int main() +{ + output_data = output_buffer; + + makecrc(); + puts("Uncompressing Linux..."); + gunzip(); + puts("done.\n"); + return 0; +} +#endif + diff --git a/arch/arm/boot/install.sh b/arch/arm/boot/install.sh new file mode 100644 index 000000000..133eae430 --- /dev/null +++ b/arch/arm/boot/install.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# +# arch/arm/boot/install.sh +# +# This file is subject to the terms and conditions of the GNU General Public +# License. See the file "COPYING" in the main directory of this archive +# for more details. +# +# Copyright (C) 1995 by Linus Torvalds +# +# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin +# Adapted from code in arch/i386/boot/install.sh by Russell King +# +# "make install" script for arm architecture +# +# Arguments: +# $1 - kernel version +# $2 - kernel image file +# $3 - kernel map file +# $4 - default install path (blank if root directory) +# + +# User may have a custom install script + +if [ -x /sbin/installkernel ]; then + exec /sbin/installkernel "$@" +fi + +if [ "$2" = "zImage" ]; then +# Compressed install + echo "Installing compressed kernel" + if [ -f $4/vmlinuz-$1 ]; then + mv $4/vmlinuz-$1 $4/vmlinuz.old + fi + + if [ -f $4/System.map-$1 ]; then + mv $4/System.map-$1 $4/System.old + fi + + cat $2 > $4/vmlinuz-$1 + cp $3 $4/System.map-$1 +else +# Normal install + echo "Installing normal kernel" + if [ -f $4/vmlinux-$1 ]; then + mv $4/vmlinux-$1 $4/vmlinux.old + fi + + if [ -f $4/System.map ]; then + mv $4/System.map $4/System.old + fi + + cat $2 > $4/vmlinux-$1 + cp $3 $4/System.map +fi + +if [ -x /sbin/loadmap ]; then + /sbin/loadmap --rdev /dev/ima +else + echo "You have to install it yourself" +fi |