diff options
author | Mikael Starvik <mikael.starvik@axis.com> | 2005-07-27 14:44:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-27 19:26:01 -0400 |
commit | 51533b615e605d86154ec1b4e585c8ca1b0b15b7 (patch) | |
tree | 4a6d7d8494d2017632d83624fb71b36031e0e7e5 /arch/cris/arch-v32/boot | |
parent | 5d01e6ce785884a5db5792cd2e5bb36fa82fe23c (diff) |
[PATCH] CRIS update: new subarchitecture v32
New CRIS sub architecture named v32.
From: Dave Jones <davej@redhat.com>
Fix swapped kmalloc args
Signed-off-by: Mikael Starvik <starvik@axis.com>
Signed-off-by: Dave Jones <davej@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/cris/arch-v32/boot')
-rw-r--r-- | arch/cris/arch-v32/boot/Makefile | 14 | ||||
-rw-r--r-- | arch/cris/arch-v32/boot/compressed/Makefile | 41 | ||||
-rw-r--r-- | arch/cris/arch-v32/boot/compressed/README | 25 | ||||
-rw-r--r-- | arch/cris/arch-v32/boot/compressed/decompress.ld | 30 | ||||
-rw-r--r-- | arch/cris/arch-v32/boot/compressed/head.S | 193 | ||||
-rw-r--r-- | arch/cris/arch-v32/boot/compressed/misc.c | 318 | ||||
-rw-r--r-- | arch/cris/arch-v32/boot/rescue/Makefile | 36 | ||||
-rw-r--r-- | arch/cris/arch-v32/boot/rescue/head.S | 39 | ||||
-rw-r--r-- | arch/cris/arch-v32/boot/rescue/rescue.ld | 20 |
9 files changed, 716 insertions, 0 deletions
diff --git a/arch/cris/arch-v32/boot/Makefile b/arch/cris/arch-v32/boot/Makefile new file mode 100644 index 000000000000..26f293ab9617 --- /dev/null +++ b/arch/cris/arch-v32/boot/Makefile | |||
@@ -0,0 +1,14 @@ | |||
1 | # | ||
2 | # arch/cris/arch-v32/boot/Makefile | ||
3 | # | ||
4 | target = $(target_boot_dir) | ||
5 | src = $(src_boot_dir) | ||
6 | |||
7 | zImage: compressed/vmlinuz | ||
8 | |||
9 | compressed/vmlinuz: $(objtree)/vmlinux | ||
10 | @$(MAKE) -f $(src)/compressed/Makefile $(objtree)/vmlinuz | ||
11 | |||
12 | clean: | ||
13 | rm -f zImage tools/build compressed/vmlinux.out | ||
14 | @$(MAKE) -f $(src)/compressed/Makefile clean | ||
diff --git a/arch/cris/arch-v32/boot/compressed/Makefile b/arch/cris/arch-v32/boot/compressed/Makefile new file mode 100644 index 000000000000..9f77eda914ba --- /dev/null +++ b/arch/cris/arch-v32/boot/compressed/Makefile | |||
@@ -0,0 +1,41 @@ | |||
1 | # | ||
2 | # lx25/arch/cris/arch-v32/boot/compressed/Makefile | ||
3 | # | ||
4 | # create a compressed vmlinux image from the original vmlinux files and romfs | ||
5 | # | ||
6 | |||
7 | target = $(target_compressed_dir) | ||
8 | src = $(src_compressed_dir) | ||
9 | |||
10 | CC = gcc-cris -mlinux -march=v32 -I $(TOPDIR)/include | ||
11 | CFLAGS = -O2 | ||
12 | LD = gcc-cris -mlinux -march=v32 -nostdlib | ||
13 | OBJCOPY = objcopy-cris | ||
14 | OBJCOPYFLAGS = -O binary --remove-section=.bss | ||
15 | OBJECTS = $(target)/head.o $(target)/misc.o | ||
16 | |||
17 | # files to compress | ||
18 | SYSTEM = $(objtree)/vmlinux.bin | ||
19 | |||
20 | all: vmlinuz | ||
21 | |||
22 | $(target)/decompress.bin: $(OBJECTS) | ||
23 | $(LD) -T $(src)/decompress.ld -o $(target)/decompress.o $(OBJECTS) | ||
24 | $(OBJCOPY) $(OBJCOPYFLAGS) $(target)/decompress.o $(target)/decompress.bin | ||
25 | |||
26 | $(objtree)/vmlinuz: $(target) piggy.img $(target)/decompress.bin | ||
27 | cat $(target)/decompress.bin piggy.img > $(objtree)/vmlinuz | ||
28 | rm -f piggy.img | ||
29 | cp $(objtree)/vmlinuz $(src) | ||
30 | |||
31 | $(target)/head.o: $(src)/head.S | ||
32 | $(CC) -D__ASSEMBLY__ -c $< -o $@ | ||
33 | |||
34 | # gzip the kernel image | ||
35 | |||
36 | piggy.img: $(SYSTEM) | ||
37 | cat $(SYSTEM) | gzip -f -9 > piggy.img | ||
38 | |||
39 | clean: | ||
40 | rm -f piggy.img $(objtree)/vmlinuz vmlinuz.o decompress.o decompress.bin $(OBJECTS) | ||
41 | |||
diff --git a/arch/cris/arch-v32/boot/compressed/README b/arch/cris/arch-v32/boot/compressed/README new file mode 100644 index 000000000000..e33691d15c57 --- /dev/null +++ b/arch/cris/arch-v32/boot/compressed/README | |||
@@ -0,0 +1,25 @@ | |||
1 | Creation of the self-extracting compressed kernel image (vmlinuz) | ||
2 | ----------------------------------------------------------------- | ||
3 | $Id: README,v 1.1 2003/08/21 09:37:03 johana Exp $ | ||
4 | |||
5 | This can be slightly confusing because it's a process with many steps. | ||
6 | |||
7 | The kernel object built by the arch/etrax100/Makefile, vmlinux, is split | ||
8 | by that makefile into text and data binary files, vmlinux.text and | ||
9 | vmlinux.data. | ||
10 | |||
11 | Those files together with a ROM filesystem can be catted together and | ||
12 | burned into a flash or executed directly at the DRAM origin. | ||
13 | |||
14 | They can also be catted together and compressed with gzip, which is what | ||
15 | happens in this makefile. Together they make up piggy.img. | ||
16 | |||
17 | The decompressor is built into the file decompress.o. It is turned into | ||
18 | the binary file decompress.bin, which is catted together with piggy.img | ||
19 | into the file vmlinuz. It can be executed in an arbitrary place in flash. | ||
20 | |||
21 | Be careful - it assumes some things about free locations in DRAM. It | ||
22 | assumes the DRAM starts at 0x40000000 and that it is at least 8 MB, | ||
23 | so it puts its code at 0x40700000, and initial stack at 0x40800000. | ||
24 | |||
25 | -Bjorn | ||
diff --git a/arch/cris/arch-v32/boot/compressed/decompress.ld b/arch/cris/arch-v32/boot/compressed/decompress.ld new file mode 100644 index 000000000000..3c837feca3ac --- /dev/null +++ b/arch/cris/arch-v32/boot/compressed/decompress.ld | |||
@@ -0,0 +1,30 @@ | |||
1 | /*#OUTPUT_FORMAT(elf32-us-cris) */ | ||
2 | OUTPUT_ARCH (crisv32) | ||
3 | |||
4 | MEMORY | ||
5 | { | ||
6 | dram : ORIGIN = 0x40700000, | ||
7 | LENGTH = 0x00100000 | ||
8 | } | ||
9 | |||
10 | SECTIONS | ||
11 | { | ||
12 | .text : | ||
13 | { | ||
14 | _stext = . ; | ||
15 | *(.text) | ||
16 | *(.rodata) | ||
17 | *(.rodata.*) | ||
18 | _etext = . ; | ||
19 | } > dram | ||
20 | .data : | ||
21 | { | ||
22 | *(.data) | ||
23 | _edata = . ; | ||
24 | } > dram | ||
25 | .bss : | ||
26 | { | ||
27 | *(.bss) | ||
28 | _end = ALIGN( 0x10 ) ; | ||
29 | } > dram | ||
30 | } | ||
diff --git a/arch/cris/arch-v32/boot/compressed/head.S b/arch/cris/arch-v32/boot/compressed/head.S new file mode 100644 index 000000000000..0c55b83b8287 --- /dev/null +++ b/arch/cris/arch-v32/boot/compressed/head.S | |||
@@ -0,0 +1,193 @@ | |||
1 | /* | ||
2 | * Code that sets up the DRAM registers, calls the | ||
3 | * decompressor to unpack the piggybacked kernel, and jumps. | ||
4 | * | ||
5 | * Copyright (C) 1999 - 2003, Axis Communications AB | ||
6 | */ | ||
7 | |||
8 | #include <linux/config.h> | ||
9 | #define ASSEMBLER_MACROS_ONLY | ||
10 | #include <asm/arch/hwregs/asm/reg_map_asm.h> | ||
11 | #include <asm/arch/hwregs/asm/gio_defs_asm.h> | ||
12 | #include <asm/arch/hwregs/asm/config_defs_asm.h> | ||
13 | |||
14 | #define RAM_INIT_MAGIC 0x56902387 | ||
15 | #define COMMAND_LINE_MAGIC 0x87109563 | ||
16 | |||
17 | ;; Exported symbols | ||
18 | |||
19 | .globl input_data | ||
20 | |||
21 | .text | ||
22 | start: | ||
23 | di | ||
24 | |||
25 | ;; Start clocks for used blocks. | ||
26 | move.d REG_ADDR(config, regi_config, rw_clk_ctrl), $r1 | ||
27 | move.d [$r1], $r0 | ||
28 | or.d REG_STATE(config, rw_clk_ctrl, cpu, yes) | \ | ||
29 | REG_STATE(config, rw_clk_ctrl, bif, yes) | \ | ||
30 | REG_STATE(config, rw_clk_ctrl, fix_io, yes), $r0 | ||
31 | move.d $r0, [$r1] | ||
32 | |||
33 | ;; If booting from NAND flash we first have to copy some | ||
34 | ;; data from NAND flash to internal RAM to get the code | ||
35 | ;; that initializes the SDRAM. Lets copy 20 KB. This | ||
36 | ;; code executes at 0x38010000 if booting from NAND and | ||
37 | ;; we are guaranted that at least 0x200 bytes are good so | ||
38 | ;; lets start from there. The first 8192 bytes in the nand | ||
39 | ;; flash is spliced with zeroes and is thus 16384 bytes. | ||
40 | move.d 0x38010200, $r10 | ||
41 | move.d 0x14200, $r11 ; Start offset in NAND flash 0x10200 + 16384 | ||
42 | move.d 0x5000, $r12 ; Length of copy | ||
43 | |||
44 | ;; Before this code the tools add a partitiontable so the PC | ||
45 | ;; has an offset from the linked address. | ||
46 | offset1: | ||
47 | lapcq ., $r13 ; get PC | ||
48 | add.d first_copy_complete-offset1, $r13 | ||
49 | |||
50 | #include "../../lib/nand_init.S" | ||
51 | |||
52 | first_copy_complete: | ||
53 | ;; Initialze the DRAM registers. | ||
54 | cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized? | ||
55 | beq dram_init_finished | ||
56 | nop | ||
57 | |||
58 | #include "../../lib/dram_init.S" | ||
59 | |||
60 | dram_init_finished: | ||
61 | lapcq ., $r13 ; get PC | ||
62 | add.d second_copy_complete-dram_init_finished, $r13 | ||
63 | |||
64 | move.d REG_ADDR(config, regi_config, r_bootsel), $r0 | ||
65 | move.d [$r0], $r0 | ||
66 | and.d REG_MASK(config, r_bootsel, boot_mode), $r0 | ||
67 | cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0 | ||
68 | bne second_copy_complete ; No NAND boot | ||
69 | nop | ||
70 | |||
71 | ;; Copy 2MB from NAND flash to SDRAM (at 2-4MB into the SDRAM) | ||
72 | move.d 0x40204000, $r10 | ||
73 | move.d 0x8000, $r11 | ||
74 | move.d 0x200000, $r12 | ||
75 | ba copy_nand_to_ram | ||
76 | nop | ||
77 | second_copy_complete: | ||
78 | |||
79 | ;; Initiate the PA port. | ||
80 | move.d CONFIG_ETRAX_DEF_GIO_PA_OUT, $r0 | ||
81 | move.d REG_ADDR(gio, regi_gio, rw_pa_dout), $r1 | ||
82 | move.d $r0, [$r1] | ||
83 | |||
84 | move.d CONFIG_ETRAX_DEF_GIO_PA_OE, $r0 | ||
85 | move.d REG_ADDR(gio, regi_gio, rw_pa_oe), $r1 | ||
86 | move.d $r0, [$r1] | ||
87 | |||
88 | ;; Setup the stack to a suitably high address. | ||
89 | ;; We assume 8 MB is the minimum DRAM and put | ||
90 | ;; the SP at the top for now. | ||
91 | |||
92 | move.d 0x40800000, $sp | ||
93 | |||
94 | ;; Figure out where the compressed piggyback image is | ||
95 | ;; in the flash (since we wont try to copy it to DRAM | ||
96 | ;; before unpacking). It is at _edata, but in flash. | ||
97 | ;; Use (_edata - herami) as offset to the current PC. | ||
98 | |||
99 | move.d REG_ADDR(config, regi_config, r_bootsel), $r0 | ||
100 | move.d [$r0], $r0 | ||
101 | and.d REG_MASK(config, r_bootsel, boot_mode), $r0 | ||
102 | cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0 | ||
103 | beq hereami2 | ||
104 | nop | ||
105 | hereami: | ||
106 | lapcq ., $r5 ; get PC | ||
107 | and.d 0x7fffffff, $r5 ; strip any non-cache bit | ||
108 | move.d $r5, $r0 ; save for later - flash address of 'herami' | ||
109 | add.d _edata, $r5 | ||
110 | sub.d hereami, $r5 ; r5 = flash address of '_edata' | ||
111 | move.d hereami, $r1 ; destination | ||
112 | ba 2f | ||
113 | nop | ||
114 | hereami2: | ||
115 | lapcq ., $r5 ; get PC | ||
116 | and.d 0x00ffffff, $r5 ; strip any non-cache bit | ||
117 | move.d $r5, $r6 | ||
118 | or.d 0x40200000, $r6 | ||
119 | move.d $r6, $r0 ; save for later - flash address of 'herami' | ||
120 | add.d _edata, $r5 | ||
121 | sub.d hereami2, $r5 ; r5 = flash address of '_edata' | ||
122 | add.d 0x40200000, $r5 | ||
123 | move.d hereami2, $r1 ; destination | ||
124 | 2: | ||
125 | ;; Copy text+data to DRAM | ||
126 | |||
127 | move.d _edata, $r2 ; end destination | ||
128 | 1: move.w [$r0+], $r3 | ||
129 | move.w $r3, [$r1+] | ||
130 | cmp.d $r2, $r1 | ||
131 | bcs 1b | ||
132 | nop | ||
133 | |||
134 | move.d input_data, $r0 ; for the decompressor | ||
135 | move.d $r5, [$r0] ; for the decompressor | ||
136 | |||
137 | ;; Clear the decompressors BSS (between _edata and _end) | ||
138 | |||
139 | moveq 0, $r0 | ||
140 | move.d _edata, $r1 | ||
141 | move.d _end, $r2 | ||
142 | 1: move.w $r0, [$r1+] | ||
143 | cmp.d $r2, $r1 | ||
144 | bcs 1b | ||
145 | nop | ||
146 | |||
147 | ;; Save command line magic and address. | ||
148 | move.d _cmd_line_magic, $r12 | ||
149 | move.d $r10, [$r12] | ||
150 | move.d _cmd_line_addr, $r12 | ||
151 | move.d $r11, [$r12] | ||
152 | |||
153 | ;; Do the decompression and save compressed size in _inptr | ||
154 | |||
155 | jsr decompress_kernel | ||
156 | nop | ||
157 | |||
158 | ;; Restore command line magic and address. | ||
159 | move.d _cmd_line_magic, $r10 | ||
160 | move.d [$r10], $r10 | ||
161 | move.d _cmd_line_addr, $r11 | ||
162 | move.d [$r11], $r11 | ||
163 | |||
164 | ;; Put start address of root partition in r9 so the kernel can use it | ||
165 | ;; when mounting from flash | ||
166 | move.d input_data, $r0 | ||
167 | move.d [$r0], $r9 ; flash address of compressed kernel | ||
168 | move.d inptr, $r0 | ||
169 | add.d [$r0], $r9 ; size of compressed kernel | ||
170 | cmp.d 0x40200000, $r9 | ||
171 | blo enter_kernel | ||
172 | nop | ||
173 | sub.d 0x40200000, $r9 | ||
174 | add.d 0x4000, $r9 | ||
175 | |||
176 | enter_kernel: | ||
177 | ;; Enter the decompressed kernel | ||
178 | move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized | ||
179 | jump 0x40004000 ; kernel is linked to this address | ||
180 | nop | ||
181 | |||
182 | .data | ||
183 | |||
184 | input_data: | ||
185 | .dword 0 ; used by the decompressor | ||
186 | _cmd_line_magic: | ||
187 | .dword 0 | ||
188 | _cmd_line_addr: | ||
189 | .dword 0 | ||
190 | is_nand_boot: | ||
191 | .dword 0 | ||
192 | |||
193 | #include "../../lib/hw_settings.S" | ||
diff --git a/arch/cris/arch-v32/boot/compressed/misc.c b/arch/cris/arch-v32/boot/compressed/misc.c new file mode 100644 index 000000000000..54644238ed59 --- /dev/null +++ b/arch/cris/arch-v32/boot/compressed/misc.c | |||
@@ -0,0 +1,318 @@ | |||
1 | /* | ||
2 | * misc.c | ||
3 | * | ||
4 | * $Id: misc.c,v 1.8 2005/04/24 18:34:29 starvik Exp $ | ||
5 | * | ||
6 | * This is a collection of several routines from gzip-1.0.3 | ||
7 | * adapted for Linux. | ||
8 | * | ||
9 | * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 | ||
10 | * puts by Nick Holloway 1993, better puts by Martin Mares 1995 | ||
11 | * adoptation for Linux/CRIS Axis Communications AB, 1999 | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | /* where the piggybacked kernel image expects itself to live. | ||
16 | * it is the same address we use when we network load an uncompressed | ||
17 | * image into DRAM, and it is the address the kernel is linked to live | ||
18 | * at by vmlinux.lds.S | ||
19 | */ | ||
20 | |||
21 | #define KERNEL_LOAD_ADR 0x40004000 | ||
22 | |||
23 | #include <linux/config.h> | ||
24 | |||
25 | #include <linux/types.h> | ||
26 | #include <asm/arch/hwregs/reg_rdwr.h> | ||
27 | #include <asm/arch/hwregs/reg_map.h> | ||
28 | #include <asm/arch/hwregs/ser_defs.h> | ||
29 | |||
30 | /* | ||
31 | * gzip declarations | ||
32 | */ | ||
33 | |||
34 | #define OF(args) args | ||
35 | #define STATIC static | ||
36 | |||
37 | void* memset(void* s, int c, size_t n); | ||
38 | void* memcpy(void* __dest, __const void* __src, | ||
39 | size_t __n); | ||
40 | |||
41 | #define memzero(s, n) memset ((s), 0, (n)) | ||
42 | |||
43 | |||
44 | typedef unsigned char uch; | ||
45 | typedef unsigned short ush; | ||
46 | typedef unsigned long ulg; | ||
47 | |||
48 | #define WSIZE 0x8000 /* Window size must be at least 32k, */ | ||
49 | /* and a power of two */ | ||
50 | |||
51 | static uch *inbuf; /* input buffer */ | ||
52 | static uch window[WSIZE]; /* Sliding window buffer */ | ||
53 | |||
54 | unsigned inptr = 0; /* index of next byte to be processed in inbuf | ||
55 | * After decompression it will contain the | ||
56 | * compressed size, and head.S will read it. | ||
57 | */ | ||
58 | |||
59 | static unsigned outcnt = 0; /* bytes in output buffer */ | ||
60 | |||
61 | /* gzip flag byte */ | ||
62 | #define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ | ||
63 | #define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ | ||
64 | #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ | ||
65 | #define ORIG_NAME 0x08 /* bit 3 set: original file name present */ | ||
66 | #define COMMENT 0x10 /* bit 4 set: file comment present */ | ||
67 | #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ | ||
68 | #define RESERVED 0xC0 /* bit 6,7: reserved */ | ||
69 | |||
70 | #define get_byte() inbuf[inptr++] | ||
71 | |||
72 | /* Diagnostic functions */ | ||
73 | #ifdef DEBUG | ||
74 | # define Assert(cond,msg) {if(!(cond)) error(msg);} | ||
75 | # define Trace(x) fprintf x | ||
76 | # define Tracev(x) {if (verbose) fprintf x ;} | ||
77 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | ||
78 | # define Tracec(c,x) {if (verbose && (c)) fprintf x ;} | ||
79 | # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} | ||
80 | #else | ||
81 | # define Assert(cond,msg) | ||
82 | # define Trace(x) | ||
83 | # define Tracev(x) | ||
84 | # define Tracevv(x) | ||
85 | # define Tracec(c,x) | ||
86 | # define Tracecv(c,x) | ||
87 | #endif | ||
88 | |||
89 | static int fill_inbuf(void); | ||
90 | static void flush_window(void); | ||
91 | static void error(char *m); | ||
92 | static void gzip_mark(void **); | ||
93 | static void gzip_release(void **); | ||
94 | |||
95 | extern char *input_data; /* lives in head.S */ | ||
96 | |||
97 | static long bytes_out = 0; | ||
98 | static uch *output_data; | ||
99 | static unsigned long output_ptr = 0; | ||
100 | |||
101 | static void *malloc(int size); | ||
102 | static void free(void *where); | ||
103 | static void error(char *m); | ||
104 | static void gzip_mark(void **); | ||
105 | static void gzip_release(void **); | ||
106 | |||
107 | static void puts(const char *); | ||
108 | |||
109 | /* the "heap" is put directly after the BSS ends, at end */ | ||
110 | |||
111 | extern int _end; | ||
112 | static long free_mem_ptr = (long)&_end; | ||
113 | |||
114 | #include "../../../../../lib/inflate.c" | ||
115 | |||
116 | static void *malloc(int size) | ||
117 | { | ||
118 | void *p; | ||
119 | |||
120 | if (size <0) error("Malloc error"); | ||
121 | |||
122 | free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */ | ||
123 | |||
124 | p = (void *)free_mem_ptr; | ||
125 | free_mem_ptr += size; | ||
126 | |||
127 | return p; | ||
128 | } | ||
129 | |||
130 | static void free(void *where) | ||
131 | { /* Don't care */ | ||
132 | } | ||
133 | |||
134 | static void gzip_mark(void **ptr) | ||
135 | { | ||
136 | *ptr = (void *) free_mem_ptr; | ||
137 | } | ||
138 | |||
139 | static void gzip_release(void **ptr) | ||
140 | { | ||
141 | free_mem_ptr = (long) *ptr; | ||
142 | } | ||
143 | |||
144 | /* decompressor info and error messages to serial console */ | ||
145 | |||
146 | static inline void | ||
147 | serout(const char *s, reg_scope_instances regi_ser) | ||
148 | { | ||
149 | reg_ser_rs_stat_din rs; | ||
150 | reg_ser_rw_dout dout = {.data = *s}; | ||
151 | |||
152 | do { | ||
153 | rs = REG_RD(ser, regi_ser, rs_stat_din); | ||
154 | } | ||
155 | while (!rs.tr_rdy);/* Wait for tranceiver. */ | ||
156 | |||
157 | REG_WR(ser, regi_ser, rw_dout, dout); | ||
158 | } | ||
159 | |||
160 | static void | ||
161 | puts(const char *s) | ||
162 | { | ||
163 | #ifndef CONFIG_ETRAX_DEBUG_PORT_NULL | ||
164 | while (*s) { | ||
165 | #ifdef CONFIG_ETRAX_DEBUG_PORT0 | ||
166 | serout(s, regi_ser0); | ||
167 | #endif | ||
168 | #ifdef CONFIG_ETRAX_DEBUG_PORT1 | ||
169 | serout(s, regi_ser1); | ||
170 | #endif | ||
171 | #ifdef CONFIG_ETRAX_DEBUG_PORT2 | ||
172 | serout(s, regi_ser2); | ||
173 | #endif | ||
174 | #ifdef CONFIG_ETRAX_DEBUG_PORT3 | ||
175 | serout(s, regi_ser3); | ||
176 | #endif | ||
177 | *s++; | ||
178 | } | ||
179 | /* CONFIG_ETRAX_DEBUG_PORT_NULL */ | ||
180 | #endif | ||
181 | } | ||
182 | |||
183 | void* | ||
184 | memset(void* s, int c, size_t n) | ||
185 | { | ||
186 | int i; | ||
187 | char *ss = (char*)s; | ||
188 | |||
189 | for (i=0;i<n;i++) ss[i] = c; | ||
190 | } | ||
191 | |||
192 | void* | ||
193 | memcpy(void* __dest, __const void* __src, | ||
194 | size_t __n) | ||
195 | { | ||
196 | int i; | ||
197 | char *d = (char *)__dest, *s = (char *)__src; | ||
198 | |||
199 | for (i=0;i<__n;i++) d[i] = s[i]; | ||
200 | } | ||
201 | |||
202 | /* =========================================================================== | ||
203 | * Write the output window window[0..outcnt-1] and update crc and bytes_out. | ||
204 | * (Used for the decompressed data only.) | ||
205 | */ | ||
206 | |||
207 | static void | ||
208 | flush_window() | ||
209 | { | ||
210 | ulg c = crc; /* temporary variable */ | ||
211 | unsigned n; | ||
212 | uch *in, *out, ch; | ||
213 | |||
214 | in = window; | ||
215 | out = &output_data[output_ptr]; | ||
216 | for (n = 0; n < outcnt; n++) { | ||
217 | ch = *out++ = *in++; | ||
218 | c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); | ||
219 | } | ||
220 | crc = c; | ||
221 | bytes_out += (ulg)outcnt; | ||
222 | output_ptr += (ulg)outcnt; | ||
223 | outcnt = 0; | ||
224 | } | ||
225 | |||
226 | static void | ||
227 | error(char *x) | ||
228 | { | ||
229 | puts("\n\n"); | ||
230 | puts(x); | ||
231 | puts("\n\n -- System halted\n"); | ||
232 | |||
233 | while(1); /* Halt */ | ||
234 | } | ||
235 | |||
236 | void | ||
237 | setup_normal_output_buffer() | ||
238 | { | ||
239 | output_data = (char *)KERNEL_LOAD_ADR; | ||
240 | } | ||
241 | |||
242 | static inline void | ||
243 | serial_setup(reg_scope_instances regi_ser) | ||
244 | { | ||
245 | reg_ser_rw_xoff xoff; | ||
246 | reg_ser_rw_tr_ctrl tr_ctrl; | ||
247 | reg_ser_rw_rec_ctrl rec_ctrl; | ||
248 | reg_ser_rw_tr_baud_div tr_baud; | ||
249 | reg_ser_rw_rec_baud_div rec_baud; | ||
250 | |||
251 | /* Turn off XOFF. */ | ||
252 | xoff = REG_RD(ser, regi_ser, rw_xoff); | ||
253 | |||
254 | xoff.chr = 0; | ||
255 | xoff.automatic = regk_ser_no; | ||
256 | |||
257 | REG_WR(ser, regi_ser, rw_xoff, xoff); | ||
258 | |||
259 | /* Set baudrate and stopbits. */ | ||
260 | tr_ctrl = REG_RD(ser, regi_ser, rw_tr_ctrl); | ||
261 | rec_ctrl = REG_RD(ser, regi_ser, rw_rec_ctrl); | ||
262 | tr_baud = REG_RD(ser, regi_ser, rw_tr_baud_div); | ||
263 | rec_baud = REG_RD(ser, regi_ser, rw_rec_baud_div); | ||
264 | |||
265 | tr_ctrl.stop_bits = 1; /* 2 stop bits. */ | ||
266 | |||
267 | /* | ||
268 | * The baudrate setup is a bit fishy, but in the end the tranceiver is | ||
269 | * set to 4800 and the receiver to 115200. The magic value is | ||
270 | * 29.493 MHz. | ||
271 | */ | ||
272 | tr_ctrl.base_freq = regk_ser_f29_493; | ||
273 | rec_ctrl.base_freq = regk_ser_f29_493; | ||
274 | tr_baud.div = (29493000 / 8) / 4800; | ||
275 | rec_baud.div = (29493000 / 8) / 115200; | ||
276 | |||
277 | REG_WR(ser, regi_ser, rw_tr_ctrl, tr_ctrl); | ||
278 | REG_WR(ser, regi_ser, rw_tr_baud_div, tr_baud); | ||
279 | REG_WR(ser, regi_ser, rw_rec_ctrl, rec_ctrl); | ||
280 | REG_WR(ser, regi_ser, rw_rec_baud_div, rec_baud); | ||
281 | } | ||
282 | |||
283 | void | ||
284 | decompress_kernel() | ||
285 | { | ||
286 | char revision; | ||
287 | |||
288 | /* input_data is set in head.S */ | ||
289 | inbuf = input_data; | ||
290 | |||
291 | #ifdef CONFIG_ETRAX_DEBUG_PORT0 | ||
292 | serial_setup(regi_ser0); | ||
293 | #endif | ||
294 | #ifdef CONFIG_ETRAX_DEBUG_PORT1 | ||
295 | serial_setup(regi_ser1); | ||
296 | #endif | ||
297 | #ifdef CONFIG_ETRAX_DEBUG_PORT2 | ||
298 | serial_setup(regi_ser2); | ||
299 | #endif | ||
300 | #ifdef CONFIG_ETRAX_DEBUG_PORT3 | ||
301 | serial_setup(regi_ser3); | ||
302 | #endif | ||
303 | |||
304 | setup_normal_output_buffer(); | ||
305 | |||
306 | makecrc(); | ||
307 | |||
308 | __asm__ volatile ("move $vr,%0" : "=rm" (revision)); | ||
309 | if (revision < 32) | ||
310 | { | ||
311 | puts("You need an ETRAX FS to run Linux 2.6/crisv32.\n"); | ||
312 | while(1); | ||
313 | } | ||
314 | |||
315 | puts("Uncompressing Linux...\n"); | ||
316 | gunzip(); | ||
317 | puts("Done. Now booting the kernel.\n"); | ||
318 | } | ||
diff --git a/arch/cris/arch-v32/boot/rescue/Makefile b/arch/cris/arch-v32/boot/rescue/Makefile new file mode 100644 index 000000000000..f668a8198724 --- /dev/null +++ b/arch/cris/arch-v32/boot/rescue/Makefile | |||
@@ -0,0 +1,36 @@ | |||
1 | # | ||
2 | # Makefile for rescue code | ||
3 | # | ||
4 | target = $(target_rescue_dir) | ||
5 | src = $(src_rescue_dir) | ||
6 | |||
7 | CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE) | ||
8 | CFLAGS = -O2 | ||
9 | LD = gcc-cris -mlinux -march=v32 -nostdlib | ||
10 | OBJCOPY = objcopy-cris | ||
11 | OBJCOPYFLAGS = -O binary --remove-section=.bss | ||
12 | |||
13 | all: $(target)/rescue.bin | ||
14 | |||
15 | rescue: rescue.bin | ||
16 | # do nothing | ||
17 | |||
18 | $(target)/rescue.bin: $(target) $(target)/head.o | ||
19 | $(LD) -T $(src)/rescue.ld -o $(target)/rescue.o $(target)/head.o | ||
20 | $(OBJCOPY) $(OBJCOPYFLAGS) $(target)/rescue.o $(target)/rescue.bin | ||
21 | cp -p $(target)/rescue.bin $(objtree) | ||
22 | |||
23 | $(target): | ||
24 | mkdir -p $(target) | ||
25 | |||
26 | $(target)/head.o: $(src)/head.S | ||
27 | $(CC) -D__ASSEMBLY__ -c $< -o $*.o | ||
28 | |||
29 | clean: | ||
30 | rm -f $(target)/*.o $(target)/*.bin | ||
31 | |||
32 | fastdep: | ||
33 | |||
34 | modules: | ||
35 | |||
36 | modules-install: | ||
diff --git a/arch/cris/arch-v32/boot/rescue/head.S b/arch/cris/arch-v32/boot/rescue/head.S new file mode 100644 index 000000000000..61ede5f30f99 --- /dev/null +++ b/arch/cris/arch-v32/boot/rescue/head.S | |||
@@ -0,0 +1,39 @@ | |||
1 | /* $Id: head.S,v 1.4 2004/11/01 16:10:28 starvik Exp $ | ||
2 | * | ||
3 | * This used to be the rescue code but now that is handled by the | ||
4 | * RedBoot based RFL instead. Nothing to see here, move along. | ||
5 | */ | ||
6 | |||
7 | #include <linux/config.h> | ||
8 | #include <asm/arch/hwregs/reg_map_asm.h> | ||
9 | #include <asm/arch/hwregs/config_defs_asm.h> | ||
10 | |||
11 | .text | ||
12 | |||
13 | ;; Start clocks for used blocks. | ||
14 | move.d REG_ADDR(config, regi_config, rw_clk_ctrl), $r1 | ||
15 | move.d [$r1], $r0 | ||
16 | or.d REG_STATE(config, rw_clk_ctrl, cpu, yes) | \ | ||
17 | REG_STATE(config, rw_clk_ctrl, bif, yes) | \ | ||
18 | REG_STATE(config, rw_clk_ctrl, fix_io, yes), $r0 | ||
19 | move.d $r0, [$r1] | ||
20 | |||
21 | ;; Copy 68KB NAND flash to Internal RAM (if NAND boot) | ||
22 | move.d 0x38004000, $r10 | ||
23 | move.d 0x8000, $r11 | ||
24 | move.d 0x11000, $r12 | ||
25 | move.d copy_complete, $r13 | ||
26 | and.d 0x000fffff, $r13 | ||
27 | or.d 0x38000000, $r13 | ||
28 | |||
29 | #include "../../lib/nand_init.S" | ||
30 | |||
31 | ;; No NAND found | ||
32 | move.d CONFIG_ETRAX_PTABLE_SECTOR, $r10 | ||
33 | jump $r10 ; Jump to decompresser | ||
34 | nop | ||
35 | |||
36 | copy_complete: | ||
37 | move.d 0x38000000 + CONFIG_ETRAX_PTABLE_SECTOR, $r10 | ||
38 | jump $r10 ; Jump to decompresser | ||
39 | nop | ||
diff --git a/arch/cris/arch-v32/boot/rescue/rescue.ld b/arch/cris/arch-v32/boot/rescue/rescue.ld new file mode 100644 index 000000000000..42b11aa122b2 --- /dev/null +++ b/arch/cris/arch-v32/boot/rescue/rescue.ld | |||
@@ -0,0 +1,20 @@ | |||
1 | MEMORY | ||
2 | { | ||
3 | flash : ORIGIN = 0x00000000, | ||
4 | LENGTH = 0x00100000 | ||
5 | } | ||
6 | |||
7 | SECTIONS | ||
8 | { | ||
9 | .text : | ||
10 | { | ||
11 | stext = . ; | ||
12 | *(.text) | ||
13 | etext = . ; | ||
14 | } > flash | ||
15 | .data : | ||
16 | { | ||
17 | *(.data) | ||
18 | edata = . ; | ||
19 | } > flash | ||
20 | } | ||