aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mn10300/boot
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-02-08 07:19:31 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:30 -0500
commitb920de1b77b72ca9432ac3f97edb26541e65e5dd (patch)
tree40fa9be1470e929c47927dea7eddf184c0204229 /arch/mn10300/boot
parentef3d534754f31fed9c3b976fee1ece1b3bc38282 (diff)
mn10300: add the MN10300/AM33 architecture to the kernel
Add architecture support for the MN10300/AM33 CPUs produced by MEI to the kernel. This patch also adds board support for the ASB2303 with the ASB2308 daughter board, and the ASB2305. The only processor supported is the MN103E010, which is an AM33v2 core plus on-chip devices. [akpm@linux-foundation.org: nuke cvs control strings] Signed-off-by: Masakazu Urade <urade.masakazu@jp.panasonic.com> Signed-off-by: Koichi Yasutake <yasutake.koichi@jp.panasonic.com> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/mn10300/boot')
-rw-r--r--arch/mn10300/boot/.gitignore1
-rw-r--r--arch/mn10300/boot/Makefile28
-rw-r--r--arch/mn10300/boot/compressed/Makefile22
-rw-r--r--arch/mn10300/boot/compressed/head.S86
-rw-r--r--arch/mn10300/boot/compressed/misc.c429
-rw-r--r--arch/mn10300/boot/compressed/misc.h18
-rw-r--r--arch/mn10300/boot/compressed/vmlinux.lds9
-rw-r--r--arch/mn10300/boot/install.sh67
-rw-r--r--arch/mn10300/boot/tools/build.c190
9 files changed, 850 insertions, 0 deletions
diff --git a/arch/mn10300/boot/.gitignore b/arch/mn10300/boot/.gitignore
new file mode 100644
index 000000000000..b6718de23693
--- /dev/null
+++ b/arch/mn10300/boot/.gitignore
@@ -0,0 +1 @@
zImage
diff --git a/arch/mn10300/boot/Makefile b/arch/mn10300/boot/Makefile
new file mode 100644
index 000000000000..36c9caf8ea0a
--- /dev/null
+++ b/arch/mn10300/boot/Makefile
@@ -0,0 +1,28 @@
1# MN10300 kernel compressor and wrapper
2#
3# Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
4# Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5# Written by David Howells (dhowells@redhat.com)
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public Licence
9# as published by the Free Software Foundation; either version
10# 2 of the Licence, or (at your option) any later version.
11#
12
13targets := vmlinux.bin zImage
14
15subdir- := compressed
16
17# ---------------------------------------------------------------------------
18
19
20$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
21 $(call if_changed,objcopy)
22 @echo 'Kernel: $@ is ready'
23
24$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
25 $(call if_changed,objcopy)
26
27$(obj)/compressed/vmlinux: FORCE
28 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
diff --git a/arch/mn10300/boot/compressed/Makefile b/arch/mn10300/boot/compressed/Makefile
new file mode 100644
index 000000000000..08a95e171685
--- /dev/null
+++ b/arch/mn10300/boot/compressed/Makefile
@@ -0,0 +1,22 @@
1#
2# Create a compressed vmlinux image from the original vmlinux
3#
4
5targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
6
7LDFLAGS_vmlinux := -Ttext $(CONFIG_KERNEL_ZIMAGE_BASE_ADDRESS) -e startup_32
8
9$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
10 $(call if_changed,ld)
11 @:
12
13$(obj)/vmlinux.bin: vmlinux FORCE
14 $(call if_changed,objcopy)
15
16$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
17 $(call if_changed,gzip)
18
19LDFLAGS_piggy.o := -r --format binary --oformat elf32-am33lin -T
20
21$(obj)/piggy.o: $(obj)/vmlinux.lds $(obj)/vmlinux.bin.gz FORCE
22 $(call if_changed,ld)
diff --git a/arch/mn10300/boot/compressed/head.S b/arch/mn10300/boot/compressed/head.S
new file mode 100644
index 000000000000..502e1eb56709
--- /dev/null
+++ b/arch/mn10300/boot/compressed/head.S
@@ -0,0 +1,86 @@
1/* Boot entry point for a compressed MN10300 kernel
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11 .section .text
12
13#define DEBUG
14
15#include <linux/linkage.h>
16#include <asm/cpu-regs.h>
17
18 .globl startup_32
19startup_32:
20 # first save off parameters from bootloader
21 mov param_save_area,a0
22 mov d0,(a0)
23 mov d1,(4,a0)
24 mov d2,(8,a0)
25
26 mov sp,a3
27 mov decomp_stack+0x2000-4,a0
28 mov a0,sp
29
30 # invalidate and enable both of the caches
31 mov CHCTR,a0
32 clr d0
33 movhu d0,(a0) # turn off first
34 mov CHCTR_ICINV|CHCTR_DCINV,d0
35 movhu d0,(a0)
36 setlb
37 mov (a0),d0
38 btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy
39 lne
40 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD,d0 # writethru dcache
41 movhu d0,(a0) # enable
42
43 # clear the BSS area
44 mov __bss_start,a0
45 mov _end,a1
46 clr d0
47bssclear:
48 cmp a1,a0
49 bge bssclear_end
50 movbu d0,(a0)
51 inc a0
52 bra bssclear
53bssclear_end:
54
55 # decompress the kernel
56 call decompress_kernel[],0
57
58 # disable caches again
59 mov CHCTR,a0
60 clr d0
61 movhu d0,(a0)
62 setlb
63 mov (a0),d0
64 btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy
65 lne
66
67 mov param_save_area,a0
68 mov (a0),d0
69 mov (4,a0),d1
70 mov (8,a0),d2
71
72 mov a3,sp
73 mov CONFIG_KERNEL_TEXT_ADDRESS,a0
74 jmp (a0)
75
76 .data
77 .align 4
78param_save_area:
79 .rept 3
80 .word 0
81 .endr
82
83 .section .bss
84 .align 4
85decomp_stack:
86 .space 0x2000
diff --git a/arch/mn10300/boot/compressed/misc.c b/arch/mn10300/boot/compressed/misc.c
new file mode 100644
index 000000000000..ded207efc97a
--- /dev/null
+++ b/arch/mn10300/boot/compressed/misc.c
@@ -0,0 +1,429 @@
1/* MN10300 Miscellaneous helper routines for kernel decompressor
2 *
3 * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Modified by David Howells (dhowells@redhat.com)
6 * - Derived from arch/x86/boot/compressed/misc_32.c
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public Licence
10 * as published by the Free Software Foundation; either version
11 * 2 of the Licence, or (at your option) any later version.
12 */
13#include <linux/compiler.h>
14#include <asm/serial-regs.h>
15#include "misc.h"
16
17#ifndef CONFIG_GDBSTUB_ON_TTYSx
18/* display 'Uncompressing Linux... ' messages on ttyS0 or ttyS1 */
19#if 1 /* ttyS0 */
20#define CYG_DEV_BASE 0xA6FB0000
21#else /* ttyS1 */
22#define CYG_DEV_BASE 0xA6FC0000
23#endif
24
25#define CYG_DEV_THR (*((volatile __u8*)(CYG_DEV_BASE + 0x00)))
26#define CYG_DEV_MCR (*((volatile __u8*)(CYG_DEV_BASE + 0x10)))
27#define SIO_MCR_DTR 0x01
28#define SIO_MCR_RTS 0x02
29#define CYG_DEV_LSR (*((volatile __u8*)(CYG_DEV_BASE + 0x14)))
30#define SIO_LSR_THRE 0x20 /* transmitter holding register empty */
31#define SIO_LSR_TEMT 0x40 /* transmitter register empty */
32#define CYG_DEV_MSR (*((volatile __u8*)(CYG_DEV_BASE + 0x18)))
33#define SIO_MSR_CTS 0x10 /* clear to send */
34#define SIO_MSR_DSR 0x20 /* data set ready */
35
36#define LSR_WAIT_FOR(STATE) \
37 do { while (!(CYG_DEV_LSR & SIO_LSR_##STATE)) {} } while (0)
38#define FLOWCTL_QUERY(LINE) \
39 ({ CYG_DEV_MSR & SIO_MSR_##LINE; })
40#define FLOWCTL_WAIT_FOR(LINE) \
41 do { while (!(CYG_DEV_MSR & SIO_MSR_##LINE)) {} } while (0)
42#define FLOWCTL_CLEAR(LINE) \
43 do { CYG_DEV_MCR &= ~SIO_MCR_##LINE; } while (0)
44#define FLOWCTL_SET(LINE) \
45 do { CYG_DEV_MCR |= SIO_MCR_##LINE; } while (0)
46#endif
47
48/*
49 * gzip declarations
50 */
51
52#define OF(args) args
53#define STATIC static
54
55#undef memset
56#undef memcpy
57
58static inline void *memset(const void *s, int c, size_t n)
59{
60 int i;
61 char *ss = (char *) s;
62
63 for (i = 0; i < n; i++)
64 ss[i] = c;
65 return (void *)s;
66}
67
68#define memzero(s, n) memset((s), 0, (n))
69
70static inline void *memcpy(void *__dest, const void *__src, size_t __n)
71{
72 int i;
73 const char *s = __src;
74 char *d = __dest;
75
76 for (i = 0; i < __n; i++)
77 d[i] = s[i];
78 return __dest;
79}
80
81typedef unsigned char uch;
82typedef unsigned short ush;
83typedef unsigned long ulg;
84
85#define WSIZE 0x8000 /* Window size must be at least 32k, and a power of
86 * two */
87
88static uch *inbuf; /* input buffer */
89static uch window[WSIZE]; /* sliding window buffer */
90
91static unsigned insize; /* valid bytes in inbuf */
92static unsigned inptr; /* index of next byte to be processed in inbuf */
93static unsigned outcnt; /* bytes in output buffer */
94
95/* gzip flag byte */
96#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
97#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
98#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
99#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
100#define COMMENT 0x10 /* bit 4 set: file comment present */
101#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
102#define RESERVED 0xC0 /* bit 6,7: reserved */
103
104/* Diagnostic functions */
105#ifdef DEBUG
106# define Assert(cond, msg) { if (!(cond)) error(msg); }
107# define Trace(x) fprintf x
108# define Tracev(x) { if (verbose) fprintf x ; }
109# define Tracevv(x) { if (verbose > 1) fprintf x ; }
110# define Tracec(c, x) { if (verbose && (c)) fprintf x ; }
111# define Tracecv(c, x) { if (verbose > 1 && (c)) fprintf x ; }
112#else
113# define Assert(cond, msg)
114# define Trace(x)
115# define Tracev(x)
116# define Tracevv(x)
117# define Tracec(c, x)
118# define Tracecv(c, x)
119#endif
120
121static int fill_inbuf(void);
122static void flush_window(void);
123static void error(const char *) __attribute__((noreturn));
124static void kputs(const char *);
125
126static inline unsigned char get_byte(void)
127{
128 unsigned char ch = inptr < insize ? inbuf[inptr++] : fill_inbuf();
129
130#if 0
131 char hex[3];
132 hex[0] = ((ch & 0x0f) > 9) ?
133 ((ch & 0x0f) + 'A' - 0xa) : ((ch & 0x0f) + '0');
134 hex[1] = ((ch >> 4) > 9) ?
135 ((ch >> 4) + 'A' - 0xa) : ((ch >> 4) + '0');
136 hex[2] = 0;
137 kputs(hex);
138#endif
139 return ch;
140}
141
142/*
143 * This is set up by the setup-routine at boot-time
144 */
145#define EXT_MEM_K (*(unsigned short *)0x90002)
146#ifndef STANDARD_MEMORY_BIOS_CALL
147#define ALT_MEM_K (*(unsigned long *) 0x901e0)
148#endif
149#define SCREEN_INFO (*(struct screen_info *)0x90000)
150
151static long bytes_out;
152static uch *output_data;
153static unsigned long output_ptr;
154
155
156static void *malloc(int size);
157
158static inline void free(void *where)
159{ /* Don't care */
160}
161
162static unsigned long free_mem_ptr = (unsigned long) &end;
163static unsigned long free_mem_end_ptr = (unsigned long) &end + 0x90000;
164
165static inline void gzip_mark(void **ptr)
166{
167 kputs(".");
168 *ptr = (void *) free_mem_ptr;
169}
170
171static inline void gzip_release(void **ptr)
172{
173 free_mem_ptr = (unsigned long) *ptr;
174}
175
176#define INPLACE_MOVE_ROUTINE 0x1000
177#define LOW_BUFFER_START 0x2000
178#define LOW_BUFFER_END 0x90000
179#define LOW_BUFFER_SIZE (LOW_BUFFER_END - LOW_BUFFER_START)
180#define HEAP_SIZE 0x3000
181static int high_loaded;
182static uch *high_buffer_start /* = (uch *)(((ulg)&end) + HEAP_SIZE)*/;
183
184static char *vidmem = (char *)0xb8000;
185static int lines, cols;
186
187#include "../../../../lib/inflate.c"
188
189static void *malloc(int size)
190{
191 void *p;
192
193 if (size < 0)
194 error("Malloc error\n");
195 if (!free_mem_ptr)
196 error("Memory error\n");
197
198 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
199
200 p = (void *) free_mem_ptr;
201 free_mem_ptr += size;
202
203 if (free_mem_ptr >= free_mem_end_ptr)
204 error("\nOut of memory\n");
205
206 return p;
207}
208
209static inline void scroll(void)
210{
211 int i;
212
213 memcpy(vidmem, vidmem + cols * 2, (lines - 1) * cols * 2);
214 for (i = (lines - 1) * cols * 2; i < lines * cols * 2; i += 2)
215 vidmem[i] = ' ';
216}
217
218static inline void kputchar(unsigned char ch)
219{
220#ifdef CONFIG_MN10300_UNIT_ASB2305
221 while (SC0STR & SC01STR_TBF)
222 continue;
223
224 if (ch == 0x0a) {
225 SC0TXB = 0x0d;
226 while (SC0STR & SC01STR_TBF)
227 continue;
228 }
229
230 SC0TXB = ch;
231
232#else
233 while (SC1STR & SC01STR_TBF)
234 continue;
235
236 if (ch == 0x0a) {
237 SC1TXB = 0x0d;
238 while (SC1STR & SC01STR_TBF)
239 continue;
240 }
241
242 SC1TXB = ch;
243
244#endif
245}
246
247static void kputs(const char *s)
248{
249#ifdef CONFIG_DEBUG_DECOMPRESS_KERNEL
250#ifndef CONFIG_GDBSTUB_ON_TTYSx
251 char ch;
252
253 FLOWCTL_SET(DTR);
254
255 while (*s) {
256 LSR_WAIT_FOR(THRE);
257
258 ch = *s++;
259 if (ch == 0x0a) {
260 CYG_DEV_THR = 0x0d;
261 LSR_WAIT_FOR(THRE);
262 }
263 CYG_DEV_THR = ch;
264 }
265
266 FLOWCTL_CLEAR(DTR);
267#else
268
269 for (; *s; s++)
270 kputchar(*s);
271
272#endif
273#endif /* CONFIG_DEBUG_DECOMPRESS_KERNEL */
274}
275
276/* ===========================================================================
277 * Fill the input buffer. This is called only when the buffer is empty
278 * and at least one byte is really needed.
279 */
280static int fill_inbuf()
281{
282 if (insize != 0)
283 error("ran out of input data\n");
284
285 inbuf = input_data;
286 insize = input_len;
287 inptr = 1;
288 return inbuf[0];
289}
290
291/* ===========================================================================
292 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
293 * (Used for the decompressed data only.)
294 */
295static void flush_window_low(void)
296{
297 ulg c = crc; /* temporary variable */
298 unsigned n;
299 uch *in, *out, ch;
300
301 in = window;
302 out = &output_data[output_ptr];
303 for (n = 0; n < outcnt; n++) {
304 ch = *out++ = *in++;
305 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
306 }
307 crc = c;
308 bytes_out += (ulg)outcnt;
309 output_ptr += (ulg)outcnt;
310 outcnt = 0;
311}
312
313static void flush_window_high(void)
314{
315 ulg c = crc; /* temporary variable */
316 unsigned n;
317 uch *in, ch;
318 in = window;
319 for (n = 0; n < outcnt; n++) {
320 ch = *output_data++ = *in++;
321 if ((ulg) output_data == LOW_BUFFER_END)
322 output_data = high_buffer_start;
323 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
324 }
325 crc = c;
326 bytes_out += (ulg)outcnt;
327 outcnt = 0;
328}
329
330static void flush_window(void)
331{
332 if (high_loaded)
333 flush_window_high();
334 else
335 flush_window_low();
336}
337
338static void error(const char *x)
339{
340 kputs("\n\n");
341 kputs(x);
342 kputs("\n\n -- System halted");
343
344 while (1)
345 /* Halt */;
346}
347
348#define STACK_SIZE (4096)
349
350long user_stack[STACK_SIZE];
351
352struct {
353 long *a;
354 short b;
355} stack_start = { &user_stack[STACK_SIZE], 0 };
356
357void setup_normal_output_buffer(void)
358{
359#ifdef STANDARD_MEMORY_BIOS_CALL
360 if (EXT_MEM_K < 1024)
361 error("Less than 2MB of memory.\n");
362#else
363 if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < 1024)
364 error("Less than 2MB of memory.\n");
365#endif
366 output_data = (char *) 0x100000; /* Points to 1M */
367}
368
369struct moveparams {
370 uch *low_buffer_start;
371 int lcount;
372 uch *high_buffer_start;
373 int hcount;
374};
375
376void setup_output_buffer_if_we_run_high(struct moveparams *mv)
377{
378 high_buffer_start = (uch *)(((ulg) &end) + HEAP_SIZE);
379#ifdef STANDARD_MEMORY_BIOS_CALL
380 if (EXT_MEM_K < (3 * 1024))
381 error("Less than 4MB of memory.\n");
382#else
383 if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < (3 * 1024))
384 error("Less than 4MB of memory.\n");
385#endif
386 mv->low_buffer_start = output_data = (char *) LOW_BUFFER_START;
387 high_loaded = 1;
388 free_mem_end_ptr = (long) high_buffer_start;
389 if (0x100000 + LOW_BUFFER_SIZE > (ulg) high_buffer_start) {
390 high_buffer_start = (uch *)(0x100000 + LOW_BUFFER_SIZE);
391 mv->hcount = 0; /* say: we need not to move high_buffer */
392 } else {
393 mv->hcount = -1;
394 }
395 mv->high_buffer_start = high_buffer_start;
396}
397
398void close_output_buffer_if_we_run_high(struct moveparams *mv)
399{
400 mv->lcount = bytes_out;
401 if (bytes_out > LOW_BUFFER_SIZE) {
402 mv->lcount = LOW_BUFFER_SIZE;
403 if (mv->hcount)
404 mv->hcount = bytes_out - LOW_BUFFER_SIZE;
405 } else {
406 mv->hcount = 0;
407 }
408}
409
410#undef DEBUGFLAG
411#ifdef DEBUGFLAG
412int debugflag;
413#endif
414
415int decompress_kernel(struct moveparams *mv)
416{
417#ifdef DEBUGFLAG
418 while (!debugflag)
419 barrier();
420#endif
421
422 output_data = (char *) CONFIG_KERNEL_TEXT_ADDRESS;
423
424 makecrc();
425 kputs("Uncompressing Linux... ");
426 gunzip();
427 kputs("Ok, booting the kernel.\n");
428 return 0;
429}
diff --git a/arch/mn10300/boot/compressed/misc.h b/arch/mn10300/boot/compressed/misc.h
new file mode 100644
index 000000000000..da921cd172fb
--- /dev/null
+++ b/arch/mn10300/boot/compressed/misc.h
@@ -0,0 +1,18 @@
1/* Internal definitions for the MN10300 kernel decompressor
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12extern int end;
13
14/*
15 * vmlinux.lds
16 */
17extern char input_data[];
18extern int input_len;
diff --git a/arch/mn10300/boot/compressed/vmlinux.lds b/arch/mn10300/boot/compressed/vmlinux.lds
new file mode 100644
index 000000000000..a084903603fe
--- /dev/null
+++ b/arch/mn10300/boot/compressed/vmlinux.lds
@@ -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}
diff --git a/arch/mn10300/boot/install.sh b/arch/mn10300/boot/install.sh
new file mode 100644
index 000000000000..072951c83976
--- /dev/null
+++ b/arch/mn10300/boot/install.sh
@@ -0,0 +1,67 @@
1#!/bin/sh
2#
3# arch/mn10300/boot/install -c.sh
4#
5# This file is subject to the terms and conditions of the GNU General Public
6# Licence. 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#
13# "make install -c" script for i386 architecture
14#
15# Arguments:
16# $1 - kernel version
17# $2 - kernel image file
18# $3 - kernel map file
19# $4 - default install -c path (blank if root directory)
20# $5 - boot rom file
21#
22
23# User may have a custom install -c script
24
25rm -fr $4/../usr/include/linux $4/../usr/include/asm
26install -c -m 0755 $2 $4/vmlinuz
27install -c -m 0755 $5 $4/boot.rom
28install -c -m 0755 -d $4/../usr/include/linux
29cd $TOPDIR/include/linux
30for i in `find . -maxdepth 1 -name '*.h' -print`; do
31 install -c -m 0644 $i $4/../usr/include/linux
32done
33install -c -m 0755 -d $4/../usr/include/linux/byteorder
34cd $TOPDIR/include/linux/byteorder
35for i in `find . -name '*.h' -print`; do
36 install -c -m 0644 $i $4/../usr/include/linux/byteorder
37done
38install -c -m 0755 -d $4/../usr/include/linux/lockd
39cd $TOPDIR/include/linux/lockd
40for i in `find . -name '*.h' -print`; do
41 install -c -m 0644 $i $4/../usr/include/linux/lockd
42done
43install -c -m 0755 -d $4/../usr/include/linux/netfilter_ipv4
44cd $TOPDIR/include/linux/netfilter_ipv4
45for i in `find . -name '*.h' -print`; do
46 install -c -m 0644 $i $4/../usr/include/linux/netfilter_ipv4
47done
48install -c -m 0755 -d $4/../usr/include/linux/nfsd
49cd $TOPDIR/include/linux/nfsd
50for i in `find . -name '*.h' -print`; do
51 install -c -m 0644 $i $4/../usr/include/linux/nfsd/$i
52done
53install -c -m 0755 -d $4/../usr/include/linux/raid
54cd $TOPDIR/include/linux/raid
55for i in `find . -name '*.h' -print`; do
56 install -c -m 0644 $i $4/../usr/include/linux/raid
57done
58install -c -m 0755 -d $4/../usr/include/linux/sunrpc
59cd $TOPDIR/include/linux/sunrpc
60for i in `find . -name '*.h' -print`; do
61 install -c -m 0644 $i $4/../usr/include/linux/sunrpc
62done
63install -c -m 0755 -d $4/../usr/include/asm
64cd $TOPDIR/include/asm
65for i in `find . -name '*.h' -print`; do
66 install -c -m 0644 $i $4/../usr/include/asm
67done
diff --git a/arch/mn10300/boot/tools/build.c b/arch/mn10300/boot/tools/build.c
new file mode 100644
index 000000000000..4f552ead0f8e
--- /dev/null
+++ b/arch/mn10300/boot/tools/build.c
@@ -0,0 +1,190 @@
1/*
2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 1997 Martin Mares
4 */
5
6/*
7 * This file builds a disk-image from three different files:
8 *
9 * - bootsect: exactly 512 bytes of 8086 machine code, loads the rest
10 * - setup: 8086 machine code, sets up system parm
11 * - system: 80386 code for actual system
12 *
13 * It does some checking that all files are of the correct type, and
14 * just writes the result to stdout, removing headers and padding to
15 * the right amount. It also writes some system data to stderr.
16 */
17
18/*
19 * Changes by tytso to allow root device specification
20 * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
21 * Cross compiling fixes by Gertjan van Wingerde, July 1996
22 * Rewritten by Martin Mares, April 1997
23 */
24
25#include <stdio.h>
26#include <string.h>
27#include <stdlib.h>
28#include <stdarg.h>
29#include <sys/types.h>
30#include <sys/stat.h>
31#include <sys/sysmacros.h>
32#include <unistd.h>
33#include <fcntl.h>
34#include <asm/boot.h>
35
36#define DEFAULT_MAJOR_ROOT 0
37#define DEFAULT_MINOR_ROOT 0
38
39/* Minimal number of setup sectors (see also bootsect.S) */
40#define SETUP_SECTS 4
41
42uint8_t buf[1024];
43int fd;
44int is_big_kernel;
45
46__attribute__((noreturn))
47void die(const char *str, ...)
48{
49 va_list args;
50 va_start(args, str);
51 vfprintf(stderr, str, args);
52 fputc('\n', stderr);
53 exit(1);
54}
55
56void file_open(const char *name)
57{
58 fd = open(name, O_RDONLY, 0);
59 if (fd < 0)
60 die("Unable to open `%s': %m", name);
61}
62
63__attribute__((noreturn))
64void usage(void)
65{
66 die("Usage: build [-b] bootsect setup system [rootdev] [> image]");
67}
68
69int main(int argc, char **argv)
70{
71 unsigned int i, c, sz, setup_sectors;
72 uint32_t sys_size;
73 uint8_t major_root, minor_root;
74 struct stat sb;
75
76 if (argc > 2 && !strcmp(argv[1], "-b")) {
77 is_big_kernel = 1;
78 argc--, argv++;
79 }
80 if ((argc < 4) || (argc > 5))
81 usage();
82 if (argc > 4) {
83 if (!strcmp(argv[4], "CURRENT")) {
84 if (stat("/", &sb)) {
85 perror("/");
86 die("Couldn't stat /");
87 }
88 major_root = major(sb.st_dev);
89 minor_root = minor(sb.st_dev);
90 } else if (strcmp(argv[4], "FLOPPY")) {
91 if (stat(argv[4], &sb)) {
92 perror(argv[4]);
93 die("Couldn't stat root device.");
94 }
95 major_root = major(sb.st_rdev);
96 minor_root = minor(sb.st_rdev);
97 } else {
98 major_root = 0;
99 minor_root = 0;
100 }
101 } else {
102 major_root = DEFAULT_MAJOR_ROOT;
103 minor_root = DEFAULT_MINOR_ROOT;
104 }
105 fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
106
107 file_open(argv[1]);
108 i = read(fd, buf, sizeof(buf));
109 fprintf(stderr, "Boot sector %d bytes.\n", i);
110 if (i != 512)
111 die("Boot block must be exactly 512 bytes");
112 if (buf[510] != 0x55 || buf[511] != 0xaa)
113 die("Boot block hasn't got boot flag (0xAA55)");
114 buf[508] = minor_root;
115 buf[509] = major_root;
116 if (write(1, buf, 512) != 512)
117 die("Write call failed");
118 close(fd);
119
120 /* Copy the setup code */
121 file_open(argv[2]);
122 for (i = 0; (c = read(fd, buf, sizeof(buf))) > 0; i += c)
123 if (write(1, buf, c) != c)
124 die("Write call failed");
125 if (c != 0)
126 die("read-error on `setup'");
127 close(fd);
128
129 /* Pad unused space with zeros */
130 setup_sectors = (i + 511) / 512;
131 /* for compatibility with ancient versions of LILO. */
132 if (setup_sectors < SETUP_SECTS)
133 setup_sectors = SETUP_SECTS;
134 fprintf(stderr, "Setup is %d bytes.\n", i);
135 memset(buf, 0, sizeof(buf));
136 while (i < setup_sectors * 512) {
137 c = setup_sectors * 512 - i;
138 if (c > sizeof(buf))
139 c = sizeof(buf);
140 if (write(1, buf, c) != c)
141 die("Write call failed");
142 i += c;
143 }
144
145 file_open(argv[3]);
146 if (fstat(fd, &sb))
147 die("Unable to stat `%s': %m", argv[3]);
148 sz = sb.st_size;
149 fprintf(stderr, "System is %d kB\n", sz / 1024);
150 sys_size = (sz + 15) / 16;
151 /* 0x28000*16 = 2.5 MB, conservative estimate for the current maximum */
152 if (sys_size > (is_big_kernel ? 0x28000 : DEF_SYSSIZE))
153 die("System is too big. Try using %smodules.",
154 is_big_kernel ? "" : "bzImage or ");
155 if (sys_size > 0xffff)
156 fprintf(stderr,
157 "warning: kernel is too big for standalone boot "
158 "from floppy\n");
159 while (sz > 0) {
160 int l, n;
161
162 l = (sz > sizeof(buf)) ? sizeof(buf) : sz;
163 n = read(fd, buf, l);
164 if (n != l) {
165 if (n < 0)
166 die("Error reading %s: %m", argv[3]);
167 else
168 die("%s: Unexpected EOF", argv[3]);
169 }
170 if (write(1, buf, l) != l)
171 die("Write failed");
172 sz -= l;
173 }
174 close(fd);
175
176 /* Write sizes to the bootsector */
177 if (lseek(1, 497, SEEK_SET) != 497)
178 die("Output: seek failed");
179 buf[0] = setup_sectors;
180 if (write(1, buf, 1) != 1)
181 die("Write of setup sector count failed");
182 if (lseek(1, 500, SEEK_SET) != 500)
183 die("Output: seek failed");
184 buf[0] = (sys_size & 0xff);
185 buf[1] = ((sys_size >> 8) & 0xff);
186 if (write(1, buf, 2) != 2)
187 die("Write of image length failed");
188
189 return 0;
190}