Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a533374 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'for-linus' of git://www.jni.nu/cris

* 'for-linus' of git://www.jni.nu/cris:
  [CRISv10] Clean up compressed/misc.c
  [CRISv10] Correct whitespace damage.
  [CRIS] Correct definition of subdirs for install_headers.
  [CRIS] Correct image makefiles to allow using a separate OBJ-directory.
  [CRIS] Build fixes for compressed and rescue images for v10 and v32:
  It looks at least odd to apply spin_unlock to a mutex.
  cris: compile fixes for 2.6.26-rc5
parents fb6624eb d17ffb4c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
# arch/cris/arch-v10/boot/Makefile
#

OBJCOPY = objcopy-cris
OBJCOPYFLAGS = -O binary --remove-section=.bss

subdir- := compressed rescue
+3 −11
Original line number Diff line number Diff line
@@ -2,12 +2,10 @@
# arch/cris/arch-v10/boot/compressed/Makefile
#

CC = gcc-cris -melf $(LINUXINCLUDE)
ccflags-y += -O2
LD = ld-cris
ldflags-y += -T $(obj)/decompress.ld
asflags-y += $(LINUXINCLUDE)
ccflags-y += -O2 $(LINUXINCLUDE)
ldflags-y += -T $(srctree)/$(obj)/decompress.ld
OBJECTS = $(obj)/head.o $(obj)/misc.o
OBJCOPY = objcopy-cris
OBJCOPYFLAGS = -O binary --remove-section=.bss

quiet_cmd_image = BUILD   $@
@@ -21,12 +19,6 @@ $(obj)/decompress.o: $(OBJECTS) FORCE
$(obj)/decompress.bin: $(obj)/decompress.o FORCE
	$(call if_changed,objcopy)

$(obj)/head.o: $(obj)/head.S .config
	@$(CC) -D__ASSEMBLY__ -traditional -c $< -o $@

$(obj)/misc.o: $(obj)/misc.c .config
	@$(CC) -D__KERNEL__ -c $< -o $@

$(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE
	$(call if_changed,image)

+2 −1
Original line number Diff line number Diff line
OUTPUT_FORMAT(elf32-us-cris)
/* OUTPUT_FORMAT(elf32-us-cris) */
OUTPUT_FORMAT(elf32-cris)

MEMORY 
	{
+49 −49
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

	;; Exported symbols

	.globl	_input_data
	.globl	input_data


	.text
@@ -26,7 +26,7 @@

;; We need to initialze DRAM registers before we start using the DRAM

	cmp.d	RAM_INIT_MAGIC, r8	; Already initialized?
	cmp.d	RAM_INIT_MAGIC, $r8	; Already initialized?
	beq	dram_init_finished
	nop

@@ -36,56 +36,56 @@ dram_init_finished:

	;; Initiate the PA and PB ports

	move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DATA, r0
	move.b   r0, [R_PORT_PA_DATA]
	move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
	move.b   $r0, [R_PORT_PA_DATA]

	move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DIR, r0
	move.b   r0, [R_PORT_PA_DIR]
	move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
	move.b   $r0, [R_PORT_PA_DIR]

	move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DATA, r0
	move.b   r0, [R_PORT_PB_DATA]
	move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
	move.b   $r0, [R_PORT_PB_DATA]

	move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DIR, r0
	move.b   r0, [R_PORT_PB_DIR]
	move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
	move.b   $r0, [R_PORT_PB_DIR]

	;; Setup the stack to a suitably high address.
	;; We assume 8 MB is the minimum DRAM in an eLinux
	;; product and put the sp at the top for now.

	move.d	0x40800000, sp
	move.d	0x40800000, $sp

	;; Figure out where the compressed piggyback image is
	;; in the flash (since we wont try to copy it to DRAM
	;; before unpacking). It is at _edata, but in flash.
	;; Use (_edata - basse) as offset to the current PC.

basse:	move.d	pc, r5
	and.d	0x7fffffff, r5	; strip any non-cache bit
	subq	2, r5		; compensate for the move.d pc instr
	move.d	r5, r0		; save for later - flash address of 'basse'
	add.d	_edata, r5
	sub.d	basse, r5	; r5 = flash address of '_edata'
basse:	move.d	$pc, $r5
	and.d	0x7fffffff, $r5	; strip any non-cache bit
	subq	2, $r5		; compensate for the move.d $pc instr
	move.d	$r5, $r0		; save for later - flash address of 'basse'
	add.d	_edata, $r5
	sub.d	basse, $r5	; $r5 = flash address of '_edata'

	;; Copy text+data to DRAM

	move.d	basse, r1	; destination
	move.d	_edata, r2	; end destination
1:	move.w	[r0+], r3
	move.w	r3, [r1+]
	cmp.d	r2, r1
	move.d	basse, $r1	; destination
	move.d	_edata, $r2	; end destination
1:	move.w	[$r0+], $r3
	move.w	$r3, [$r1+]
	cmp.d	$r2, $r1
	bcs	1b
	nop

	move.d	r5, [_input_data] ; for the decompressor
	move.d	$r5, [input_data] ; for the decompressor


	;; Clear the decompressors BSS (between _edata and _end)

	moveq	0, r0
	move.d	_edata, r1
	move.d	_end, r2
1:	move.w	r0, [r1+]
	cmp.d	r2, r1
	moveq	0, $r0
	move.d	_edata, $r1
	move.d	_end, $r2
1:	move.w	$r0, [$r1+]
	cmp.d	$r2, $r1
	bcs	1b
	nop

@@ -95,15 +95,15 @@ basse: move.d pc, r5
	move.d	_cmd_line_addr, $r12
	move.d  $r11, [$r12]

	;; Do the decompression and save compressed size in _inptr
	;; Do the decompression and save compressed size in inptr

	jsr	_decompress_kernel
	jsr	decompress_kernel

	;; Put start address of root partition in r9 so the kernel can use it
	;; Put start address of root partition in $r9 so the kernel can use it
	;; when mounting from flash

	move.d	[_input_data], r9	; flash address of compressed kernel
	add.d	[_inptr], r9		; size of compressed kernel
	move.d	[input_data], $r9	; flash address of compressed kernel
	add.d	[inptr], $r9		; size of compressed kernel

	;; Restore command line magic and address.
	move.d  _cmd_line_magic, $r10
@@ -112,12 +112,12 @@ basse: move.d pc, r5
	move.d  [$r11], $r11

	;; Enter the decompressed kernel
	move.d	RAM_INIT_MAGIC, r8	; Tell kernel that DRAM is initialized
	move.d	RAM_INIT_MAGIC, $r8	; Tell kernel that DRAM is initialized
	jump	0x40004000	; kernel is linked to this address

	.data

_input_data:
input_data:
	.dword	0		; used by the decompressor
_cmd_line_magic:
	.dword 0
+77 −67
Original line number Diff line number Diff line
@@ -30,12 +30,10 @@
#define STATIC static

void *memset(void *s, int c, size_t n);
void* memcpy(void* __dest, __const void* __src,
	     size_t __n);
void *memcpy(void *__dest, __const void *__src, size_t __n);

#define memzero(s, n)     memset((s), 0, (n))


typedef unsigned char  uch;
typedef unsigned short ush;
typedef unsigned long  ulg;
@@ -62,16 +60,31 @@ static unsigned outcnt = 0; /* bytes in output buffer */
#define ENCRYPTED    0x20 /* bit 5 set: file is encrypted */
#define RESERVED     0xC0 /* bit 6,7:   reserved */

#define get_byte() inbuf[inptr++]	
#define get_byte() (inbuf[inptr++])

/* Diagnostic functions */
#ifdef DEBUG
#  define Assert(cond,msg) {if(!(cond)) error(msg);}
#  define Assert(cond, msg) do { \
		if (!(cond)) \
			error(msg); \
	} while (0)
#  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 ;}
#  define Tracev(x) do { \
		if (verbose) \
			fprintf x; \
	} while (0)
#  define Tracevv(x) do { \
		if (verbose > 1) \
			fprintf x; \
	} while (0)
#  define Tracec(c, x) do { \
		if (verbose && (c)) \
			fprintf x; \
	} while (0)
#  define Tracecv(c, x) do { \
		if (verbose > 1 && (c)) \
			fprintf x; \
	} while (0)
#else
#  define Assert(cond, msg)
#  define Trace(x)
@@ -81,11 +94,8 @@ static unsigned outcnt = 0; /* bytes in output buffer */
#  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;  /* lives in head.S */

@@ -95,7 +105,6 @@ static unsigned long output_ptr = 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 **);

@@ -103,8 +112,8 @@ static void puts(const char *);

/* the "heap" is put directly after the BSS ends, at end */

extern int end;
static long free_mem_ptr = (long)&end;
extern int _end;
static long free_mem_ptr = (long)&_end;

#include "../../../../../lib/inflate.c"

@@ -112,7 +121,8 @@ static void *malloc(int size)
{
	void *p;

	if (size <0) error("Malloc error");
	if (size < 0)
		error("Malloc error");

	free_mem_ptr = (free_mem_ptr + 3) & ~3;	/* Align */

@@ -163,23 +173,26 @@ puts(const char *s)
#endif
}

void*
memset(void* s, int c, size_t n)
void *memset(void *s, int c, size_t n)
{
	int i;
	char *ss = (char *)s;

	for (i=0;i<n;i++) ss[i] = c;
	for (i = 0; i < n; i++)
		ss[i] = c;

	return s;
}

void*
memcpy(void* __dest, __const void* __src,
			    size_t __n)
void *memcpy(void *__dest, __const void *__src, size_t __n)
{
	int i;
	char *d = (char *)__dest, *s = (char *)__src;

	for (i=0;i<__n;i++) d[i] = s[i];
	for (i = 0; i < __n; i++)
		d[i] = s[i];

	return __dest;
}

/* ===========================================================================
@@ -187,8 +200,7 @@ memcpy(void* __dest, __const void* __src,
 * (Used for the decompressed data only.)
 */

static void
flush_window()
static void flush_window(void)
{
	ulg c = crc;         /* temporary variable */
	unsigned n;
@@ -197,7 +209,9 @@ flush_window()
	in = window;
	out = &output_data[output_ptr];
	for (n = 0; n < outcnt; n++) {
	    ch = *out++ = *in++;
		ch = *out = *in;
		out++;
		in++;
		c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
	}
	crc = c;
@@ -206,8 +220,7 @@ flush_window()
	outcnt = 0;
}

static void
error(char *x)
static void error(char *x)
{
	puts("\n\n");
	puts(x);
@@ -216,14 +229,12 @@ error(char *x)
	while (1);	/* Halt */
}

void
setup_normal_output_buffer()
void setup_normal_output_buffer(void)
{
	output_data = (char *)KERNEL_LOAD_ADR;
}

void
decompress_kernel()
void decompress_kernel(void)
{
	char revision;

@@ -257,9 +268,8 @@ decompress_kernel()

	makecrc();

	__asm__ volatile ("move vr,%0" : "=rm" (revision));
	if (revision < 10)
	{
	__asm__ volatile ("move $vr,%0" : "=rm" (revision));
	if (revision < 10) {
		puts("You need an ETRAX 100LX to run linux 2.6\n");
		while (1);
	}
Loading