From 8f5ae128d9134e4aafbe213894b2f9b138a4643c Mon Sep 17 00:00:00 2001 From: Jesper Nilsson Date: Mon, 30 Jun 2008 23:22:51 +0200 Subject: [PATCH] --- yaml --- r: 102423 b: refs/heads/master c: bd451d5ed206cda4ed0e03fac4e5dece2fd7767f h: refs/heads/master i: 102421: 291ccb13879b036eceaa5c4ddd8bb5f279c1c721 102419: fe25b1f0a823900a0f4e3c42628643c073b42b01 102415: e079e5872abc18f3de861068c3f361bb3737a2cb v: v3 --- [refs] | 2 +- trunk/arch/cris/arch-v10/boot/Makefile | 1 + .../cris/arch-v10/boot/compressed/Makefile | 14 +- .../arch-v10/boot/compressed/decompress.ld | 3 +- .../arch/cris/arch-v10/boot/compressed/head.S | 98 ++++++------ .../arch/cris/arch-v10/boot/compressed/misc.c | 144 ++++++++---------- trunk/arch/cris/arch-v10/boot/rescue/Makefile | 9 +- trunk/arch/cris/arch-v10/drivers/pcf8563.c | 2 +- trunk/arch/cris/arch-v10/kernel/debugport.c | 8 +- trunk/arch/cris/arch-v32/boot/Makefile | 1 + .../cris/arch-v32/boot/compressed/Makefile | 6 +- trunk/arch/cris/arch-v32/boot/rescue/Makefile | 3 +- trunk/arch/cris/arch-v32/drivers/pcf8563.c | 2 +- trunk/include/asm-cris/Kbuild | 5 +- 14 files changed, 152 insertions(+), 146 deletions(-) diff --git a/[refs] b/[refs] index 8bcd4febb2df..467849e03288 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e05f86c13bca8eac80bccd1e86f3e09a7d3ae963 +refs/heads/master: bd451d5ed206cda4ed0e03fac4e5dece2fd7767f diff --git a/trunk/arch/cris/arch-v10/boot/Makefile b/trunk/arch/cris/arch-v10/boot/Makefile index 217203014433..20c83a53caf3 100644 --- a/trunk/arch/cris/arch-v10/boot/Makefile +++ b/trunk/arch/cris/arch-v10/boot/Makefile @@ -2,6 +2,7 @@ # arch/cris/arch-v10/boot/Makefile # +OBJCOPY = objcopy-cris OBJCOPYFLAGS = -O binary --remove-section=.bss subdir- := compressed rescue diff --git a/trunk/arch/cris/arch-v10/boot/compressed/Makefile b/trunk/arch/cris/arch-v10/boot/compressed/Makefile index 08d943ce4be7..4a031cb27eb9 100644 --- a/trunk/arch/cris/arch-v10/boot/compressed/Makefile +++ b/trunk/arch/cris/arch-v10/boot/compressed/Makefile @@ -2,10 +2,12 @@ # arch/cris/arch-v10/boot/compressed/Makefile # -asflags-y += $(LINUXINCLUDE) -ccflags-y += -O2 $(LINUXINCLUDE) -ldflags-y += -T $(srctree)/$(obj)/decompress.ld +CC = gcc-cris -melf $(LINUXINCLUDE) +ccflags-y += -O2 +LD = ld-cris +ldflags-y += -T $(obj)/decompress.ld OBJECTS = $(obj)/head.o $(obj)/misc.o +OBJCOPY = objcopy-cris OBJCOPYFLAGS = -O binary --remove-section=.bss quiet_cmd_image = BUILD $@ @@ -19,6 +21,12 @@ $(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) diff --git a/trunk/arch/cris/arch-v10/boot/compressed/decompress.ld b/trunk/arch/cris/arch-v10/boot/compressed/decompress.ld index e80f4594d543..0b0a14fe6177 100644 --- a/trunk/arch/cris/arch-v10/boot/compressed/decompress.ld +++ b/trunk/arch/cris/arch-v10/boot/compressed/decompress.ld @@ -1,5 +1,4 @@ -/* OUTPUT_FORMAT(elf32-us-cris) */ -OUTPUT_FORMAT(elf32-cris) +OUTPUT_FORMAT(elf32-us-cris) MEMORY { diff --git a/trunk/arch/cris/arch-v10/boot/compressed/head.S b/trunk/arch/cris/arch-v10/boot/compressed/head.S index 981fbae84959..610bdb237553 100644 --- a/trunk/arch/cris/arch-v10/boot/compressed/head.S +++ b/trunk/arch/cris/arch-v10/boot/compressed/head.S @@ -15,77 +15,77 @@ #define COMMAND_LINE_MAGIC 0x87109563 ;; Exported symbols + + .globl _input_data - .globl input_data - - + .text nop di ;; 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 - + #include "../../lib/dram_init.S" - -dram_init_finished: - + +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 @@ -94,16 +94,16 @@ basse: move.d $pc, $r5 move.d $r10, [$r12] 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 - - ;; Put start address of root partition in $r9 so the kernel can use it + jsr _decompress_kernel + + ;; 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 diff --git a/trunk/arch/cris/arch-v10/boot/compressed/misc.c b/trunk/arch/cris/arch-v10/boot/compressed/misc.c index 18e13bce1400..9a43ab19391e 100644 --- a/trunk/arch/cris/arch-v10/boot/compressed/misc.c +++ b/trunk/arch/cris/arch-v10/boot/compressed/misc.c @@ -29,10 +29,12 @@ #define OF(args) args #define STATIC static -void *memset(void *s, int c, size_t n); -void *memcpy(void *__dest, __const void *__src, size_t __n); +void* memset(void* s, int c, size_t n); +void* memcpy(void* __dest, __const void* __src, + size_t __n); + +#define memzero(s, n) memset ((s), 0, (n)) -#define memzero(s, n) memset((s), 0, (n)) typedef unsigned char uch; typedef unsigned short ush; @@ -60,69 +62,57 @@ 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) do { \ - if (!(cond)) \ - error(msg); \ - } while (0) +# define Assert(cond,msg) {if(!(cond)) error(msg);} # define Trace(x) 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) +# 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 Assert(cond,msg) # define Trace(x) # define Tracev(x) # define Tracevv(x) -# define Tracec(c, x) -# define Tracecv(c, 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; /* lives in head.S */ static long bytes_out = 0; static uch *output_data; 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 **); - + 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" 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 */ @@ -152,47 +142,44 @@ static void puts(const char *s) { #ifndef CONFIG_ETRAX_DEBUG_PORT_NULL - while (*s) { + while(*s) { #ifdef CONFIG_ETRAX_DEBUG_PORT0 - while (!(*R_SERIAL0_STATUS & (1 << 5))) ; + while(!(*R_SERIAL0_STATUS & (1 << 5))) ; *R_SERIAL0_TR_DATA = *s++; #endif #ifdef CONFIG_ETRAX_DEBUG_PORT1 - while (!(*R_SERIAL1_STATUS & (1 << 5))) ; + while(!(*R_SERIAL1_STATUS & (1 << 5))) ; *R_SERIAL1_TR_DATA = *s++; #endif #ifdef CONFIG_ETRAX_DEBUG_PORT2 - while (!(*R_SERIAL2_STATUS & (1 << 5))) ; + while(!(*R_SERIAL2_STATUS & (1 << 5))) ; *R_SERIAL2_TR_DATA = *s++; #endif #ifdef CONFIG_ETRAX_DEBUG_PORT3 - while (!(*R_SERIAL3_STATUS & (1 << 5))) ; + while(!(*R_SERIAL3_STATUS & (1 << 5))) ; *R_SERIAL3_TR_DATA = *s++; #endif } #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; + char *ss = (char*)s; - return s; + for (i=0;i> 8); - } - crc = c; - bytes_out += (ulg)outcnt; - output_ptr += (ulg)outcnt; - outcnt = 0; + ulg c = crc; /* temporary variable */ + 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) +static void +error(char *x) { puts("\n\n"); puts(x); puts("\n\n -- System halted\n"); - while (1); /* Halt */ + while(1); /* Halt */ } -void setup_normal_output_buffer(void) +void +setup_normal_output_buffer() { output_data = (char *)KERNEL_LOAD_ADR; } -void decompress_kernel(void) +void +decompress_kernel() { char revision; - + /* input_data is set in head.S */ inbuf = input_data; @@ -268,10 +257,11 @@ void decompress_kernel(void) 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); + while(1); } puts("Uncompressing Linux...\n"); diff --git a/trunk/arch/cris/arch-v10/boot/rescue/Makefile b/trunk/arch/cris/arch-v10/boot/rescue/Makefile index 07688da92708..2e5045b9e19c 100644 --- a/trunk/arch/cris/arch-v10/boot/rescue/Makefile +++ b/trunk/arch/cris/arch-v10/boot/rescue/Makefile @@ -2,9 +2,12 @@ # Makefile for rescue (bootstrap) code # -ccflags-y += -O2 $(LINUXINCLUDE) -asflags-y += $(LINUXINCLUDE) -ldflags-y += -T $(srctree)/$(obj)/rescue.ld +CC = gcc-cris -mlinux $(LINUXINCLUDE) +ccflags-y += -O2 +asflags-y += -traditional +LD = gcc-cris -mlinux -nostdlib +ldflags-y += -T $(obj)/rescue.ld +OBJCOPY = objcopy-cris OBJCOPYFLAGS = -O binary --remove-section=.bss obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o OBJECT := $(obj)/head.o diff --git a/trunk/arch/cris/arch-v10/drivers/pcf8563.c b/trunk/arch/cris/arch-v10/drivers/pcf8563.c index 8769dc914073..52103d16dc6c 100644 --- a/trunk/arch/cris/arch-v10/drivers/pcf8563.c +++ b/trunk/arch/cris/arch-v10/drivers/pcf8563.c @@ -233,7 +233,7 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, if (copy_to_user((struct rtc_time *) arg, &tm, sizeof tm)) { - mutex_unlock(&rtc_lock); + spin_unlock(&rtc_lock); return -EFAULT; } diff --git a/trunk/arch/cris/arch-v10/kernel/debugport.c b/trunk/arch/cris/arch-v10/kernel/debugport.c index 162730eb887b..3dc6e91ba39e 100644 --- a/trunk/arch/cris/arch-v10/kernel/debugport.c +++ b/trunk/arch/cris/arch-v10/kernel/debugport.c @@ -432,10 +432,10 @@ static int dummy_write_room(struct tty_struct *tty) } static const struct tty_operations dummy_ops = { - .open = dummy_open, - .close = dummy_close, - .write = dummy_write, - .write_room = dummy_write_room, + .open = dummy_open, + .close = dummy_close, + .write = dummy_write, + .write_room = dummy_write_room, }; void __init diff --git a/trunk/arch/cris/arch-v32/boot/Makefile b/trunk/arch/cris/arch-v32/boot/Makefile index 99896ad60b30..3f91349c5f12 100644 --- a/trunk/arch/cris/arch-v32/boot/Makefile +++ b/trunk/arch/cris/arch-v32/boot/Makefile @@ -2,6 +2,7 @@ # arch/cris/arch-v32/boot/Makefile # +OBJCOPY = objcopy-cris OBJCOPYFLAGS = -O binary -R .note -R .comment subdir- := compressed rescue diff --git a/trunk/arch/cris/arch-v32/boot/compressed/Makefile b/trunk/arch/cris/arch-v32/boot/compressed/Makefile index d6335f26083b..2c8c2c3039c5 100644 --- a/trunk/arch/cris/arch-v32/boot/compressed/Makefile +++ b/trunk/arch/cris/arch-v32/boot/compressed/Makefile @@ -2,10 +2,14 @@ # arch/cris/arch-v32/boot/compressed/Makefile # +CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE) asflags-y += -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch ccflags-y += -O2 -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch -ldflags-y += -T $(srctree)/$(obj)/decompress.ld +LD = gcc-cris -mlinux -march=v32 -nostdlib +ldflags-y += -T $(obj)/decompress.ld +obj-y = head.o misc.o OBJECTS = $(obj)/head.o $(obj)/misc.o +OBJCOPY = objcopy-cris OBJCOPYFLAGS = -O binary --remove-section=.bss quiet_cmd_image = BUILD $@ diff --git a/trunk/arch/cris/arch-v32/boot/rescue/Makefile b/trunk/arch/cris/arch-v32/boot/rescue/Makefile index 44ae0ad61f90..c0987795dcb7 100644 --- a/trunk/arch/cris/arch-v32/boot/rescue/Makefile +++ b/trunk/arch/cris/arch-v32/boot/rescue/Makefile @@ -7,8 +7,9 @@ ccflags-y += -O2 -I $(srctree)/include/asm/arch/mach/ \ -I $(srctree)/include/asm/arch asflags-y += -I $(srctree)/include/asm/arch/mach/ -I $(srctree)/include/asm/arch LD = gcc-cris -mlinux -march=v32 -nostdlib -ldflags-y += -T $(srctree)/$(obj)/rescue.ld +ldflags-y += -T $(obj)/rescue.ld LDPOSTFLAGS = -lgcc +OBJCOPY = objcopy-cris OBJCOPYFLAGS = -O binary --remove-section=.bss obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o OBJECT := $(obj)/head.o diff --git a/trunk/arch/cris/arch-v32/drivers/pcf8563.c b/trunk/arch/cris/arch-v32/drivers/pcf8563.c index f263ab571221..53db3870ba04 100644 --- a/trunk/arch/cris/arch-v32/drivers/pcf8563.c +++ b/trunk/arch/cris/arch-v32/drivers/pcf8563.c @@ -229,7 +229,7 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, if (copy_to_user((struct rtc_time *) arg, &tm, sizeof tm)) { - mutex_unlock(&rtc_lock); + spin_unlock(&rtc_lock); return -EFAULT; } diff --git a/trunk/include/asm-cris/Kbuild b/trunk/include/asm-cris/Kbuild index b7037d80d461..17455459c43f 100644 --- a/trunk/include/asm-cris/Kbuild +++ b/trunk/include/asm-cris/Kbuild @@ -1,8 +1,7 @@ include include/asm-generic/Kbuild.asm -header-y += arch/ -header-y += arch-v10/ -header-y += arch-v32/ +header-$(CONFIG_ETRAX_ARCH_V10) += arch-v10/ +header-$(CONFIG_ETRAX_ARCH_V32) += arch-v32/ header-y += ethernet.h header-y += rtc.h