Skip to content

Commit

Permalink
[ARM] Fix decompressor serial IO to give CRLF not LFCR
Browse files Browse the repository at this point in the history
As per the corresponding change to the serial drivers, arrange
for ARM decompressors to give CRLF.  Move the common putstr code
into misc.c such that machines only need to supply "putc" and
"flush" functions.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Russell King authored and Russell King committed Mar 28, 2006
1 parent 3747b36 commit a081568
Show file tree
Hide file tree
Showing 24 changed files with 187 additions and 289 deletions.
28 changes: 18 additions & 10 deletions arch/arm/boot/compressed/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,32 @@ unsigned int __machine_arch_type;

#include <linux/string.h>

#include <asm/arch/uncompress.h>

#ifdef STANDALONE_DEBUG
#define putstr printf
#endif
#else

#ifdef CONFIG_DEBUG_ICEDCC
#define putstr icedcc_putstr
#define putc icedcc_putc
static void putstr(const char *ptr);

#include <linux/compiler.h>
#include <asm/arch/uncompress.h>

#ifdef CONFIG_DEBUG_ICEDCC
extern void icedcc_putc(int ch);
#define putc(ch) icedcc_putc(ch)
#define flush() do { } while (0)
#endif

static void
icedcc_putstr(const char *ptr)
static void putstr(const char *ptr)
{
for (; *ptr != '\0'; ptr++) {
icedcc_putc(*ptr);
char c;

while ((c = *ptr++) != '\0') {
if (c == '\n')
putc('\r');
putc(c);
}

flush();
}

#endif
Expand Down
23 changes: 11 additions & 12 deletions include/asm-arm/arch-aaec2000/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define UART(x) (*(volatile unsigned long *)(serial_port + (x)))

static void putstr( const char *s )
static void putc(int c)
{
unsigned long serial_port;
do {
Expand All @@ -28,17 +28,16 @@ static void putstr( const char *s )
return;
} while (0);

for (; *s; s++) {
/* wait for space in the UART's transmitter */
while ((UART(UART_SR) & UART_SR_TxFF));
/* send the character out. */
UART(UART_DR) = *s;
/* if a LF, also do CR... */
if (*s == 10) {
while ((UART(UART_SR) & UART_SR_TxFF));
UART(UART_DR) = 13;
}
}
/* wait for space in the UART's transmitter */
while ((UART(UART_SR) & UART_SR_TxFF))
barrier();

/* send the character out. */
UART(UART_DR) = c;
}

static inline void flush(void)
{
}

#define arch_decomp_setup()
Expand Down
23 changes: 12 additions & 11 deletions include/asm-arm/arch-at91rm9200/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,22 @@
*
* This does not append a newline
*/
static void putstr(const char *s)
static void putc(int c)
{
void __iomem *sys = (void __iomem *) AT91_BASE_SYS; /* physical address */

while (!(__raw_readl(sys + AT91_DBGU_SR) & AT91_DBGU_TXRDY))
barrier();
__raw_writel(c, sys + AT91_DBGU_THR);
}

static inline void flush(void)
{
void __iomem *sys = (void __iomem *) AT91_BASE_SYS; /* physical address */

while (*s) {
while (!(__raw_readl(sys + AT91_DBGU_SR) & AT91_DBGU_TXRDY)) { barrier(); }
__raw_writel(*s, sys + AT91_DBGU_THR);
if (*s == '\n') {
while (!(__raw_readl(sys + AT91_DBGU_SR) & AT91_DBGU_TXRDY)) { barrier(); }
__raw_writel('\r', sys + AT91_DBGU_THR);
}
s++;
}
/* wait for transmission to complete */
while (!(__raw_readl(sys + AT91_DBGU_SR) & AT91_DBGU_TXEMPTY)) { barrier(); }
while (!(__raw_readl(sys + AT91_DBGU_SR) & AT91_DBGU_TXEMPTY))
barrier();
}

#define arch_decomp_setup()
Expand Down
18 changes: 5 additions & 13 deletions include/asm-arm/arch-cl7500/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,19 @@
*
* Copyright (C) 1999, 2000 Nexus Electronics Ltd.
*/

#define BASE 0x03010000
#define SERBASE (BASE + (0x2f8 << 2))

static __inline__ void putc(char c)
static inline void putc(char c)
{
while (!(*((volatile unsigned int *)(SERBASE + 0x14)) & 0x20));
while (!(*((volatile unsigned int *)(SERBASE + 0x14)) & 0x20))
barrier();

*((volatile unsigned int *)(SERBASE)) = c;
}

/*
* This does not append a newline
*/
static void putstr(const char *s)
static inline void flush(void)
{
while (*s) {
putc(*s);
if (*s == '\n')
putc('\r');
s++;
}
}

static __inline__ void arch_decomp_setup(void)
Expand Down
21 changes: 7 additions & 14 deletions include/asm-arm/arch-clps711x/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#undef CLPS7111_BASE
#define CLPS7111_BASE CLPS7111_PHYS_BASE

#define barrier() __asm__ __volatile__("": : :"memory")
#define __raw_readl(p) (*(unsigned long *)(p))
#define __raw_writel(v,p) (*(unsigned long *)(p) = (v))

Expand All @@ -40,21 +39,15 @@
/*
* This does not append a newline
*/
static void putstr(const char *s)
static inline void putc(int c)
{
char c;

while ((c = *s++) != '\0') {
while (clps_readl(SYSFLGx) & SYSFLG_UTXFF)
barrier();
clps_writel(c, UARTDRx);
while (clps_readl(SYSFLGx) & SYSFLG_UTXFF)
barrier();
clps_writel(c, UARTDRx);
}

if (c == '\n') {
while (clps_readl(SYSFLGx) & SYSFLG_UTXFF)
barrier();
clps_writel('\r', UARTDRx);
}
}
static inline void flush(void)
{
while (clps_readl(SYSFLGx) & SYSFLG_UBUSY)
barrier();
}
Expand Down
47 changes: 24 additions & 23 deletions include/asm-arm/arch-ebsa110/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,34 @@
* published by the Free Software Foundation.
*/

#include <linux/serial_reg.h>

#define SERIAL_BASE ((unsigned char *)0xfe000be0)

/*
* This does not append a newline
*/
static void putstr(const char *s)
static inline void putc(int c)
{
unsigned char v, *base = SERIAL_BASE;

do {
v = base[UART_LSR << 2];
barrier();
} while (!(v & UART_LSR_THRE));

base[UART_TX << 2] = c;
}

static inline void flush(void)
{
unsigned long tmp1, tmp2;
__asm__ __volatile__(
"ldrb %0, [%2], #1\n"
" teq %0, #0\n"
" beq 3f\n"
"1: strb %0, [%3]\n"
"2: ldrb %1, [%3, #0x14]\n"
" and %1, %1, #0x60\n"
" teq %1, #0x60\n"
" bne 2b\n"
" teq %0, #'\n'\n"
" moveq %0, #'\r'\n"
" beq 1b\n"
" ldrb %0, [%2], #1\n"
" teq %0, #0\n"
" bne 1b\n"
"3: ldrb %1, [%3, #0x14]\n"
" and %1, %1, #0x60\n"
" teq %1, #0x60\n"
" bne 3b"
: "=&r" (tmp1), "=&r" (tmp2)
: "r" (s), "r" (0xf0000be0) : "cc");
unsigned char v, *base = SERIAL_BASE;

do {
v = base[UART_LSR << 2];
barrier();
} while ((v & (UART_LSR_TEMT|UART_LSR_THRE)) !=
(UART_LSR_TEMT|UART_LSR_THRE));
}

/*
Expand Down
16 changes: 4 additions & 12 deletions include/asm-arm/arch-ebsa285/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,20 @@
#define DC21285_BASE ((volatile unsigned int *)0x42000160)
#define SER0_BASE ((volatile unsigned char *)0x7c0003f8)

static __inline__ void putc(char c)
static inline void putc(char c)
{
if (machine_is_netwinder()) {
while ((SER0_BASE[5] & 0x60) != 0x60);
while ((SER0_BASE[5] & 0x60) != 0x60)
barrier();
SER0_BASE[0] = c;
} else {
while (DC21285_BASE[6] & 8);
DC21285_BASE[0] = c;
}
}

/*
* This does not append a newline
*/
static void putstr(const char *s)
static inline void flush(void)
{
while (*s) {
putc(*s);
if (*s == '\n')
putc('\r');
s++;
}
}

/*
Expand Down
10 changes: 2 additions & 8 deletions include/asm-arm/arch-ep93xx/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void __raw_writel(unsigned int value, unsigned int ptr)
#define PHYS_UART1_FLAG 0x808c0018
#define UART1_FLAG_TXFF 0x20

static __inline__ void putc(char c)
static inline void putc(int c)
{
int i;

Expand All @@ -49,14 +49,8 @@ static __inline__ void putc(char c)
__raw_writeb(c, PHYS_UART1_DATA);
}

static void putstr(const char *s)
static inline void flush(void)
{
while (*s) {
putc(*s);
if (*s == '\n')
putc('\r');
s++;
}
}


Expand Down
24 changes: 11 additions & 13 deletions include/asm-arm/arch-h720x/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@
#define LSR 0x14
#define TEMPTY 0x40

static void putstr(const char *s)
static inline void putc(int c)
{
char c;
volatile unsigned char *p = (volatile unsigned char *)(IO_PHYS+0x20000);

while ( (c = *s++) != '\0') {
/* wait until transmit buffer is empty */
while((p[LSR] & TEMPTY) == 0x0);
/* write next character */
*p = c;

if(c == '\n') {
while((p[LSR] & TEMPTY) == 0x0);
*p = '\r';
}
}
/* wait until transmit buffer is empty */
while((p[LSR] & TEMPTY) == 0x0)
barrier();

/* write next character */
*p = c;
}

static inline void flush(void)
{
}

/*
Expand Down
21 changes: 7 additions & 14 deletions include/asm-arm/arch-imx/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
*
* This does not append a newline
*/
static void
putstr(const char *s)
static void putc(int c)
{
unsigned long serial_port;

Expand All @@ -54,20 +53,14 @@ putstr(const char *s)
return;
} while(0);

while (*s) {
while ( !(UART(USR2) & USR2_TXFE) )
barrier();
while (!(UART(USR2) & USR2_TXFE))
barrier();

UART(TXR) = *s;

if (*s == '\n') {
while ( !(UART(USR2) & USR2_TXFE) )
barrier();
UART(TXR) = c;
}

UART(TXR) = '\r';
}
s++;
}
static inline void flush(void)
{
}

/*
Expand Down
Loading

0 comments on commit a081568

Please sign in to comment.