[U-Boot] Microblaze changes

Hi,
I am sending some Microblaze changes.
Thanks for your comments, Michal

Use inline functions instead of macros because of typechecking.
Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/include/asm/io.h | 33 +++++++++++++++++++++++++++------ 1 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h index 7e190d1..a35700e 100644 --- a/arch/microblaze/include/asm/io.h +++ b/arch/microblaze/include/asm/io.h @@ -46,14 +46,35 @@ #define outl(x, addr) ((void) writel (x, addr))
/* Some #definitions to keep strange Xilinx code happy */ -#define in_8(addr) readb (addr) -#define in_be16(addr) readw (addr) -#define in_be32(addr) readl (addr) +extern inline int in_8(volatile unsigned char *addr) +{ + return readb(addr); +} + +extern inline int in_be16(volatile unsigned short *addr) +{ + return readw(addr); +}
-#define out_8(addr,x ) outb (x,addr) -#define out_be16(addr,x ) outw (x,addr) -#define out_be32(addr,x ) outl (x,addr) +extern inline int in_be32(volatile unsigned int *addr) +{ + return readl(addr); +}
+extern inline void out_8(volatile unsigned char *addr, char val) +{ + outb (val, addr); +} + +extern inline void out_be16(volatile unsigned short *addr, short val) +{ + outw (val, addr); +} + +extern inline void out_be32(volatile unsigned int *addr, int val) +{ + outl (val, addr); +}
#define inb_p(port) inb((port)) #define outb_p(val, port) outb((val), (port))

Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/lib/board.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c index d97543b..5510c12 100644 --- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -68,6 +68,7 @@ typedef int (init_fnc_t) (void); init_fnc_t *init_sequence[] = { env_init, serial_init, + console_init_f, #ifdef CONFIG_SYS_GPIO_0 gpio_init, #endif

Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/lib/board.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c index 5510c12..ab1cbab 100644 --- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -84,6 +84,10 @@ init_fnc_t *init_sequence[] = { NULL, };
+unsigned long monitor_flash_len; +extern char *__end; +extern char *__text_start; + void board_init (void) { bd_t *bd; @@ -105,6 +109,8 @@ void board_init (void) bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
+ monitor_flash_len = __end - __text_start; + /* * The Malloc area is immediately below the monitor copy in DRAM * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off

Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/lib/board.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c index ab1cbab..e8f4c5b 100644 --- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -167,6 +167,12 @@ void board_init (void) /* Initialize stdio devices */ stdio_init ();
+ /* Initialize the jump table for applications */ + jumptable_init (); + + /* Initialize the console (after the relocation and devices init) */ + console_init_r (); + if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); }

Based on ARM unaligned.h.
Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/include/asm/unaligned.h | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/microblaze/include/asm/unaligned.h b/arch/microblaze/include/asm/unaligned.h index 785c2e9..faf1b02 100644 --- a/arch/microblaze/include/asm/unaligned.h +++ b/arch/microblaze/include/asm/unaligned.h @@ -1,16 +1,16 @@ #ifndef _ASM_MICROBLAZE_UNALIGNED_H #define _ASM_MICROBLAZE_UNALIGNED_H
-#ifdef __KERNEL__ - -/* - * The Microblaze can do unaligned accesses itself in big endian mode. - */ -#include <linux/unaligned/access_ok.h> +#include <linux/unaligned/le_byteshift.h> +#include <linux/unaligned/be_byteshift.h> #include <linux/unaligned/generic.h>
-#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +#ifdef __MICROBLAZEEL__ +# define get_unaligned __get_unaligned_le +# define put_unaligned __put_unaligned_le +#else +# define get_unaligned __get_unaligned_be +# define put_unaligned __put_unaligned_be +#endif
-#endif /* __KERNEL__ */ #endif /* _ASM_MICROBLAZE_UNALIGNED_H */

Setup bootfile.
Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/lib/board.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c index e8f4c5b..c00d96b 100644 --- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -187,6 +187,10 @@ void board_init (void) uchar enetaddr[6]; eth_getenv_enetaddr("ethaddr", enetaddr); printf("MAC: %pM\n", enetaddr); + + if ((s = getenv ("bootfile")) != NULL) { + copy_filename (BootFile, s, sizeof (BootFile)); + } #endif
/* main_loop */

Forget to remove debug code.
Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/cpu/start.S | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 93a9efd..d3370c4 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -46,8 +46,6 @@ _start: addik r6, r0, 0x2 /* BIG/LITTLE endian offset */ swi r6, r0, 0 lbui r10, r0, 0 - swi r6, r0, 0x40 - swi r10, r0, 0x50
/* add opcode instruction for 32bit jump - 2 instruction imm & brai*/ addi r6, r0, 0xb0000000 /* hex b000 opcode imm */

For example: Setup reset vectors if reset address is setup. Setup user exception vector if user exception is enabled
Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/cpu/start.S | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index d3370c4..34b07d8 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -30,6 +30,12 @@ .text .global _start _start: + /* reserve registers: + * r10: Stores little/big endian offset for vectors + * r2: Stores imm opcode + * r3: Stores brai opcode + */ + mts rmsr, r0 /* disable cache */ addi r1, r0, CONFIG_SYS_INIT_SP_OFFSET addi r1, r1, -4 /* Decrement SP to top of memory */ @@ -47,21 +53,15 @@ _start: swi r6, r0, 0 lbui r10, r0, 0
- /* add opcode instruction for 32bit jump - 2 instruction imm & brai*/ - addi r6, r0, 0xb0000000 /* hex b000 opcode imm */ - swi r6, r0, 0x0 /* reset address */ - swi r6, r0, 0x8 /* user vector exception */ - swi r6, r0, 0x10 /* interrupt */ - swi r6, r0, 0x20 /* hardware exception */ - - addi r6, r0, 0xb8080000 /* hew b808 opcode brai*/ - swi r6, r0, 0x4 /* reset address */ - swi r6, r0, 0xC /* user vector exception */ - swi r6, r0, 0x14 /* interrupt */ - swi r6, r0, 0x24 /* hardware exception */ + /* add opcode instruction for 32bit jump - 2 instruction imm & brai */ + addi r2, r0, 0xb0000000 /* hex b000 opcode imm */ + addi r3, r0, 0xb8080000 /* hew b808 opcode brai */
#ifdef CONFIG_SYS_RESET_ADDRESS /* reset address */ + swi r2, r0, 0x0 /* reset address - imm opcode */ + swi r3, r0, 0x4 /* reset address - brai opcode */ + addik r6, r0, CONFIG_SYS_RESET_ADDRESS sw r6, r1, r0 lhu r7, r1, r0 @@ -88,6 +88,9 @@ _start:
#ifdef CONFIG_SYS_USR_EXCEP /* user_vector_exception */ + swi r2, r0, 0x8 /* user vector exception - imm opcode */ + swi r3, r0, 0xC /* user vector exception - brai opcode */ + addik r6, r0, _exception_handler sw r6, r1, r0 /* @@ -119,6 +122,9 @@ _start:
#ifdef CONFIG_SYS_INTC_0 /* interrupt_handler */ + swi r2, r0, 0x10 /* interrupt - imm opcode */ + swi r3, r0, 0x14 /* interrupt - brai opcode */ + addik r6, r0, _interrupt_handler sw r6, r1, r0 lhu r7, r1, r10 @@ -129,6 +135,9 @@ _start: #endif
/* hardware exception */ + swi r2, r0, 0x20 /* hardware exception - imm opcode */ + swi r3, r0, 0x24 /* hardware exception - brai opcode */ + addik r6, r0, _hw_exception_handler sw r6, r1, r0 lhu r7, r1, r10

Use one memory space to detect little/big endian platforms. The first unused address(0x28) is used instead 0x0 address (reset vectors). Detection rewrited reset vector setup from first stage bootloader.
Workflow: 1. Store 0x28 to r7 2. Do little/big endian test 3. Restore r7 to 0x28
Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/cpu/start.S | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 34b07d8..97dd757 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -50,8 +50,10 @@ _start: * 4b) BIG endian - r10 contains 0x0 because 0x2 offset is on addr 0x3 */ addik r6, r0, 0x2 /* BIG/LITTLE endian offset */ - swi r6, r0, 0 - lbui r10, r0, 0 + lwi r7, r0, 0x28 + swi r6, r0, 0x28 /* used first unused MB vector */ + lbui r10, r0, 0x28 /* used first unused MB vector */ + swi r7, r0, 0x28
/* add opcode instruction for 32bit jump - 2 instruction imm & brai */ addi r2, r0, 0xb0000000 /* hex b000 opcode imm */

- Remove code copying - Reset address is setup from first stage bootloader - Support reset vector setup on little endian
Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/cpu/start.S | 25 +++++-------------------- 1 files changed, 5 insertions(+), 20 deletions(-)
diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 97dd757..492ad93 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -66,26 +66,11 @@ _start:
addik r6, r0, CONFIG_SYS_RESET_ADDRESS sw r6, r1, r0 - lhu r7, r1, r0 - shi r7, r0, 0x2 - shi r6, r0, 0x6 -/* - * Copy U-Boot code to CONFIG_SYS_TEXT_BASE - * solve problem with sbrk_base - */ -#if (CONFIG_SYS_RESET_ADDRESS != CONFIG_SYS_TEXT_BASE) - addi r4, r0, __end - addi r5, r0, __text_start - rsub r4, r5, r4 /* size = __end - __text_start */ - addi r6, r0, CONFIG_SYS_RESET_ADDRESS /* source address */ - addi r7, r0, 0 /* counter */ -4: - lw r8, r6, r7 - sw r8, r5, r7 - addi r7, r7, 0x4 - cmp r8, r4, r7 - blti r8, 4b -#endif + lhu r7, r1, r10 + rsubi r8, r10, 0x2 + sh r7, r0, r8 + rsubi r8, r10, 0x6 + sh r6, r0, r8 #endif
#ifdef CONFIG_SYS_USR_EXCEP

Mike Frysinger wrote:
On Wednesday, August 31, 2011 04:35:16 Michal Simek wrote:
Based on ARM unaligned.h.
can't you just include asm-generic/unaligned.h ? the ARM peeps are just being lazy at this point :P.
Can.
Thanks, Michal

On Wednesday, August 31, 2011 04:35:15 Michal Simek wrote:
--- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -167,6 +167,12 @@ void board_init (void) /* Initialize stdio devices */ stdio_init ();
- /* Initialize the jump table for applications */
- jumptable_init ();
- /* Initialize the console (after the relocation and devices init) */
- console_init_r ();
- if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); }
your summary doesnt seem to match what you're changing. the two things you're doing here should always be done regardless of netconsole. -mike

Mike Frysinger wrote:
On Wednesday, August 31, 2011 04:35:15 Michal Simek wrote:
--- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -167,6 +167,12 @@ void board_init (void) /* Initialize stdio devices */ stdio_init ();
- /* Initialize the jump table for applications */
- jumptable_init ();
- /* Initialize the console (after the relocation and devices init) */
- console_init_r ();
- if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); }
your summary doesnt seem to match what you're changing. the two things you're doing here should always be done regardless of netconsole.
It is really old patch where the point was to get netconsole work. It is just initialize jumptable and setup correct console.
Fixed.
Thanks, Michal

Dear Michal Simek,
In message 1314779721-1113-5-git-send-email-monstr@monstr.eu you wrote:
Signed-off-by: Michal Simek monstr@monstr.eu
arch/microblaze/lib/board.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c index ab1cbab..e8f4c5b 100644 --- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -167,6 +167,12 @@ void board_init (void) /* Initialize stdio devices */ stdio_init ();
- /* Initialize the jump table for applications */
- jumptable_init ();
- /* Initialize the console (after the relocation and devices init) */
- console_init_r ();
2 x WARNING: space prohibited between function name and open parenthesis '('
Stop review here. Will you please run your patches through ckeckpatch _before_ submitting? Thanks.
Best regards,
Wolfgang Denk

On Wednesday, August 31, 2011 04:35:14 Michal Simek wrote:
+extern char *__end; +extern char *__text_start;
if you're referring to symbols provided by a linker script, you should do: extern char __end[]; -mike

Mike Frysinger wrote:
On Wednesday, August 31, 2011 04:35:14 Michal Simek wrote:
+extern char *__end; +extern char *__text_start;
if you're referring to symbols provided by a linker script, you should do: extern char __end[];
fixed.
Thanks, Michal

Dear Michal Simek,
In message 1314779721-1113-4-git-send-email-monstr@monstr.eu you wrote:
Signed-off-by: Michal Simek monstr@monstr.eu
arch/microblaze/lib/board.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c index 5510c12..ab1cbab 100644 --- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -84,6 +84,10 @@ init_fnc_t *init_sequence[] = { NULL, };
+unsigned long monitor_flash_len; +extern char *__end; +extern char *__text_start;
WARNING: externs should be avoided in .c files
Best regards,
Wolfgang Denk

Dear Michal Simek,
In message 1314779721-1113-2-git-send-email-monstr@monstr.eu you wrote:
Use inline functions instead of macros because of typechecking.
I don't understand the rationale of this change.
-#define in_8(addr) readb (addr) -#define in_be16(addr) readw (addr) -#define in_be32(addr) readl (addr) +extern inline int in_8(volatile unsigned char *addr) +{
- return readb(addr);
+}
What;s the difference wether the type checking occurs for the in_8() call or for the readb() call?
+extern inline int in_be16(volatile unsigned short *addr)
Also, checkpatch says:
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt #106: FILE: arch/microblaze/include/asm/io.h:49: +extern inline int in_8(volatile unsigned char *addr)
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt #111: FILE: arch/microblaze/include/asm/io.h:54: +extern inline int in_be16(volatile unsigned short *addr)
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt #119: FILE: arch/microblaze/include/asm/io.h:59: +extern inline int in_be32(volatile unsigned int *addr)
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt #124: FILE: arch/microblaze/include/asm/io.h:64: +extern inline void out_8(volatile unsigned char *addr, char val)
WARNING: space prohibited between function name and open parenthesis '(' #126: FILE: arch/microblaze/include/asm/io.h:66: + outb (val, addr);
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt #129: FILE: arch/microblaze/include/asm/io.h:69: +extern inline void out_be16(volatile unsigned short *addr, short val)
WARNING: space prohibited between function name and open parenthesis '(' #131: FILE: arch/microblaze/include/asm/io.h:71: + outw (val, addr);
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt #134: FILE: arch/microblaze/include/asm/io.h:74: +extern inline void out_be32(volatile unsigned int *addr, int val)
WARNING: space prohibited between function name and open parenthesis '(' #136: FILE: arch/microblaze/include/asm/io.h:76: + outl (val, addr);
total: 0 errors, 9 warnings, 41 lines checked
Please fix.
Best regards,
Wolfgang Denk
participants (3)
-
Michal Simek
-
Mike Frysinger
-
Wolfgang Denk