
to allow it to have base address and other information to simplify the implementation and avoid workarround as done for ns16550 on the omap3 zoom or ppc4xx as example
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- board/MAI/AmigaOneG3SE/video.c | 10 +++--- board/bf527-ezkit/video.c | 4 +- board/bf548-ezkit/video.c | 4 +- board/cm-bf548/video.c | 4 +- board/omap3/zoom2/zoom2_serial.h | 70 +++++++++++++++++++------------------- board/rbc823/kbd.c | 4 +- common/cmd_log.c | 16 ++++++--- common/console.c | 18 +++++----- common/lcd.c | 21 +++++++++-- common/serial.c | 28 +++++++------- common/stdio.c | 58 ++++++++++++++++++++++++------- common/usb_kbd.c | 4 +- cpu/blackfin/jtag-console.c | 8 ++-- cpu/mpc5xxx/serial.c | 24 ++++++------ cpu/mpc8xx/serial.c | 32 +++++++++--------- cpu/mpc8xx/video.c | 6 ++-- cpu/ppc4xx/4xx_uart.c | 24 ++++++------ drivers/input/i8042.c | 4 +- drivers/net/netconsole.c | 10 +++--- drivers/serial/arm_dcc.c | 39 ++++++++++++++------- drivers/serial/serial.c | 12 +++--- drivers/serial/serial_pxa.c | 36 ++++++++++---------- drivers/serial/serial_s3c24x0.c | 12 +++--- drivers/serial/usbtty.c | 8 ++-- drivers/video/cfb_console.c | 6 ++-- include/i8042.h | 4 +- include/stdio_dev.h | 14 ++++---- lib_i386/video.c | 4 +- 28 files changed, 273 insertions(+), 211 deletions(-)
diff --git a/board/MAI/AmigaOneG3SE/video.c b/board/MAI/AmigaOneG3SE/video.c index e24e28b..4827f50 100644 --- a/board/MAI/AmigaOneG3SE/video.c +++ b/board/MAI/AmigaOneG3SE/video.c @@ -46,8 +46,8 @@ unsigned int video_scrolls = 0; #define VIDEO_NAME "vga"
void video_test(void); -void video_putc(char ch); -void video_puts(char *string); +void video_putc(struct stdio_dev *dev, char ch); +void video_puts(struct stdio_dev *dev, char *string); void video_scroll(int rows); void video_banner(void); int video_init(void); @@ -163,7 +163,7 @@ void video_test(void)
}
-void video_putc(char ch) +void video_putc(struct stdio_dev *dev, char ch) { switch(ch) { @@ -224,11 +224,11 @@ void video_scroll(int rows) cursor_col=0; }
-void video_puts(char *string) +void video_puts(struct stdio_dev *dev, char *string) { while (*string) { - video_putc(*string); + video_putc(dev, *string); string++; } } diff --git a/board/bf527-ezkit/video.c b/board/bf527-ezkit/video.c index 0b6b7b2..1c10d04 100644 --- a/board/bf527-ezkit/video.c +++ b/board/bf527-ezkit/video.c @@ -261,11 +261,11 @@ static void dma_bitblit(void *dst, fastimage_t *logo, int x, int y)
}
-void video_putc(const char c) +void video_putc(struct stdio_dev *dev, const char c) { }
-void video_puts(const char *s) +void video_puts(struct stdio_dev *dev, const char *s) { }
diff --git a/board/bf548-ezkit/video.c b/board/bf548-ezkit/video.c index f4f1bec..2d1ca7c 100644 --- a/board/bf548-ezkit/video.c +++ b/board/bf548-ezkit/video.c @@ -271,11 +271,11 @@ static void dma_bitblit(void *dst, fastimage_t *logo, int x, int y)
}
-void video_putc(const char c) +void video_putc(struct stdio_dev *dev, const char c) { }
-void video_puts(const char *s) +void video_puts(struct stdio_dev *dev, const char *s) { }
diff --git a/board/cm-bf548/video.c b/board/cm-bf548/video.c index 49dbe77..f963257 100644 --- a/board/cm-bf548/video.c +++ b/board/cm-bf548/video.c @@ -280,11 +280,11 @@ static void dma_bitblit(void *dst, fastimage_t *logo, int x, int y)
}
-void video_putc(const char c) +void video_putc(struct stdio_dev *dev, const char c) { }
-void video_puts(const char *s) +void video_puts(struct stdio_dev *dev, const char *s) { }
diff --git a/board/omap3/zoom2/zoom2_serial.h b/board/omap3/zoom2/zoom2_serial.h index c963dc2..76a84a4 100644 --- a/board/omap3/zoom2/zoom2_serial.h +++ b/board/omap3/zoom2/zoom2_serial.h @@ -35,41 +35,41 @@ extern int zoom2_debug_board_connected (void); #define N(a) S(quad##a) #define U(a) S(UART##a)
-#define QUAD_INIT(n) \ -int quad_init_##n(void) \ -{ \ - return quad_init_dev(QUAD_BASE_##n); \ -} \ -void quad_setbrg_##n(void) \ -{ \ - quad_setbrg_dev(QUAD_BASE_##n); \ -} \ -void quad_putc_##n(const char c) \ -{ \ - quad_putc_dev(QUAD_BASE_##n, c); \ -} \ -void quad_puts_##n(const char *s) \ -{ \ - quad_puts_dev(QUAD_BASE_##n, s); \ -} \ -int quad_getc_##n(void) \ -{ \ - return quad_getc_dev(QUAD_BASE_##n); \ -} \ -int quad_tstc_##n(void) \ -{ \ - return quad_tstc_dev(QUAD_BASE_##n); \ -} \ -struct stdio_dev zoom2_serial_device##n = \ -{ \ - .name = N(n), \ - .ctlr = U(n), \ - .start = quad_init_##n, \ - .setbrg = quad_setbrg_##n, \ - .getc = quad_getc_##n, \ - .tstc = quad_tstc_##n, \ - .putc = quad_putc_##n, \ - .puts = quad_puts_##n, \ +#define QUAD_INIT(n) \ +int quad_init_##n(struct stdio_dev *dev) \ +{ \ + return quad_init_dev(QUAD_BASE_##n); \ +} \ +void quad_setbrg_##n(struct stdio_dev *dev) \ +{ \ + quad_setbrg_dev(QUAD_BASE_##n); \ +} \ +void quad_putc_##n(struct stdio_dev *dev, const char c) \ +{ \ + quad_putc_dev(QUAD_BASE_##n, c); \ +} \ +void quad_puts_##n(struct stdio_dev *dev, const char *s)\ +{ \ + quad_puts_dev(QUAD_BASE_##n, s); \ +} \ +int quad_getc_##n(struct stdio_dev *dev) \ +{ \ + return quad_getc_dev(QUAD_BASE_##n); \ +} \ +int quad_tstc_##n(struct stdio_dev *dev) \ +{ \ + return quad_tstc_dev(QUAD_BASE_##n); \ +} \ +struct stdio_dev zoom2_serial_device##n = \ +{ \ + .name = N(n), \ + .ctlr = U(n), \ + .start = quad_init_##n, \ + .setbrg = quad_setbrg_##n, \ + .getc = quad_getc_##n, \ + .tstc = quad_tstc_##n, \ + .putc = quad_putc_##n, \ + .puts = quad_puts_##n, \ };
#endif /* ZOOM2_SERIAL_H */ diff --git a/board/rbc823/kbd.c b/board/rbc823/kbd.c index 853cbde..d404362 100644 --- a/board/rbc823/kbd.c +++ b/board/rbc823/kbd.c @@ -205,7 +205,7 @@ void smc1_putc(const char c) } }
-int smc1_getc(void) +int smc1_getc(struct stdio_dev *dev) { volatile cbd_t *rbdf; volatile unsigned char *buf; @@ -231,7 +231,7 @@ int smc1_getc(void) return(c); }
-int smc1_tstc(void) +int smc1_tstc(struct stdio_dev *dev) { volatile cbd_t *rbdf; volatile smc_uart_t *up; diff --git a/common/cmd_log.c b/common/cmd_log.c index 3653fe1..b1803dc 100644 --- a/common/cmd_log.c +++ b/common/cmd_log.c @@ -49,8 +49,9 @@ DECLARE_GLOBAL_DATA_PTR;
/* Local prototypes */ -static void logbuff_putc (const char c); -static void logbuff_puts (const char *s); +static void stdio_logbuff_putc (struct stdio_dev *dev, const char c); +static void stdio_logbuff_puts (struct stdio_dev *dev, const char *s); +static void logbuff_putc (const char c) static int logbuff_printk(const char *line);
static char buf[1024]; @@ -151,14 +152,19 @@ int drv_logbuff_init (void) strcpy (logdev.name, "logbuff"); logdev.ext = 0; /* No extensions */ logdev.flags = DEV_FLAGS_OUTPUT; /* Output only */ - logdev.putc = logbuff_putc; /* 'putc' function */ - logdev.puts = logbuff_puts; /* 'puts' function */ + logdev.putc = stdio_logbuff_putc; /* 'putc' function */ + logdev.puts = stdio_logbuff_puts; /* 'puts' function */
rc = stdio_register (&logdev);
return (rc == 0) ? 1 : rc; }
+static void stdio_logbuff_putc (struct stdio_dev *dev, const char c) +{ + logbuff_putc(c); +} + static void logbuff_putc (const char c) { char buf[2]; @@ -167,7 +173,7 @@ static void logbuff_putc (const char c) logbuff_printk (buf); }
-static void logbuff_puts (const char *s) +static void stdio_logbuff_puts (struct stdio_dev *dev, const char *s) { logbuff_printk (s); } diff --git a/common/console.c b/common/console.c index 867c12c..af59b58 100644 --- a/common/console.c +++ b/common/console.c @@ -61,7 +61,7 @@ static int console_setfile(int file, struct stdio_dev * dev) case stderr: /* Start new device */ if (dev->start) { - error = dev->start(); + error = dev->start(dev); /* If it's not started dont use it */ if (error < 0) break; @@ -111,7 +111,7 @@ static int console_getc(int file) unsigned char ret;
/* This is never called with testcdev == NULL */ - ret = tstcdev->getc(); + ret = tstcdev->getc(tstcdev); tstcdev = NULL; return ret; } @@ -125,7 +125,7 @@ static int console_tstc(int file) for (i = 0; i < cd_count[file]; i++) { dev = console_devices[file][i]; if (dev->tstc != NULL) { - ret = dev->tstc(); + ret = dev->tstc(dev); if (ret > 0) { tstcdev = dev; disable_ctrlc(0); @@ -146,7 +146,7 @@ static void console_putc(int file, const char c) for (i = 0; i < cd_count[file]; i++) { dev = console_devices[file][i]; if (dev->putc != NULL) - dev->putc(c); + dev->putc(dev, c); } }
@@ -158,7 +158,7 @@ static void console_puts(int file, const char *s) for (i = 0; i < cd_count[file]; i++) { dev = console_devices[file][i]; if (dev->puts != NULL) - dev->puts(s); + dev->puts(dev, s); } }
@@ -174,22 +174,22 @@ static inline void console_doenv(int file, struct stdio_dev *dev) #else static inline int console_getc(int file) { - return stdio_devices[file]->getc(); + return stdio_devices[file]->getc(stdio_devices[file]); }
static inline int console_tstc(int file) { - return stdio_devices[file]->tstc(); + return stdio_devices[file]->tstc(stdio_devices[file]); }
static inline void console_putc(int file, const char c) { - stdio_devices[file]->putc(c); + stdio_devices[file]->putc(stdio_devices[file], c); }
static inline void console_puts(int file, const char *s) { - stdio_devices[file]->puts(s); + stdio_devices[file]->puts(stdio_devices[file], s); }
static inline void console_printdevs(int file) diff --git a/common/lcd.c b/common/lcd.c index dc8fea6..6da4f9d 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -69,6 +69,7 @@ #endif
DECLARE_GLOBAL_DATA_PTR; +struct stdio_dev lcddev;
ulong lcd_setmem (ulong addr);
@@ -76,6 +77,9 @@ static void lcd_drawchars (ushort x, ushort y, uchar *str, int count); static inline void lcd_puts_xy (ushort x, ushort y, uchar *s); static inline void lcd_putc_xy (ushort x, ushort y, uchar c);
+static void dev_lcd_putc (struct stdio_dev *dev, const char c); +static void dev_lcd_puts (struct stdio_dev *dev, const char *s); + static int lcd_init (void *lcdbase);
static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]); @@ -162,6 +166,11 @@ static inline void console_newline (void)
void lcd_putc (const char c) { + dev_lcd_putc(&lcddev, c); +} + +static void dev_lcd_putc (struct stdio_dev *dev, const char c) +{ if (!lcd_is_enabled) { serial_putc(c); return; @@ -201,13 +210,18 @@ void lcd_putc (const char c)
void lcd_puts (const char *s) { + dev_lcd_puts(&lcddev, s); +} + +static void dev_lcd_puts (struct stdio_dev *dev, const char *s) +{ if (!lcd_is_enabled) { serial_puts (s); return; }
while (*s) { - lcd_putc (*s++); + dev_lcd_putc (dev, *s++); } }
@@ -343,7 +357,6 @@ static void test_pattern (void)
int drv_lcd_init (void) { - struct stdio_dev lcddev; int rc;
lcd_base = (void *)(gd->fb_base); @@ -358,8 +371,8 @@ int drv_lcd_init (void) strcpy (lcddev.name, "lcd"); lcddev.ext = 0; /* No extensions */ lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */ - lcddev.putc = lcd_putc; /* 'putc' function */ - lcddev.puts = lcd_puts; /* 'puts' function */ + lcddev.putc = dev_lcd_putc; /* 'putc' function */ + lcddev.puts = dev_lcd_puts; /* 'puts' function */
rc = stdio_register (&lcddev);
diff --git a/common/serial.c b/common/serial.c index f85a52e..a4171be 100644 --- a/common/serial.c +++ b/common/serial.c @@ -173,9 +173,9 @@ void serial_reinit_all (void) if ((dev->flags & DEV_FLAGS_SERIAL) != DEV_FLAGS_SERIAL) continue; if (dev->stop) - dev->stop (); + dev->stop (dev); if (dev->start) - dev->start (); + dev->start (dev); } }
@@ -185,13 +185,13 @@ int serial_init (void) struct stdio_dev *dev = default_serial_console ();
if (dev->start) - return dev->start (); + return dev->start (dev);
return 0; }
if (serial_current->start) - return serial_current->start (); + return serial_current->start (serial_current);
return 0; } @@ -201,11 +201,11 @@ void serial_setbrg (void) if (!(gd->flags & GD_FLG_RELOC) || !serial_current) { struct stdio_dev *dev = default_serial_console ();
- dev->setbrg (); + dev->setbrg (dev); return; }
- serial_current->setbrg (); + serial_current->setbrg (serial_current); }
int serial_getc (void) @@ -213,10 +213,10 @@ int serial_getc (void) if (!(gd->flags & GD_FLG_RELOC) || !serial_current) { struct stdio_dev *dev = default_serial_console ();
- return dev->getc (); + return dev->getc (dev); }
- return serial_current->getc (); + return serial_current->getc (serial_current); }
int serial_tstc (void) @@ -224,10 +224,10 @@ int serial_tstc (void) if (!(gd->flags & GD_FLG_RELOC) || !serial_current) { struct stdio_dev *dev = default_serial_console ();
- return dev->tstc (); + return dev->tstc (dev); }
- return serial_current->tstc (); + return serial_current->tstc (serial_current); }
void serial_putc (const char c) @@ -235,11 +235,11 @@ void serial_putc (const char c) if (!(gd->flags & GD_FLG_RELOC) || !serial_current) { struct stdio_dev *dev = default_serial_console ();
- dev->putc (c); + dev->putc (dev, c); return; }
- serial_current->putc (c); + serial_current->putc (serial_current, c); }
void serial_puts (const char *s) @@ -247,9 +247,9 @@ void serial_puts (const char *s) if (!(gd->flags & GD_FLG_RELOC) || !serial_current) { struct stdio_dev *dev = default_serial_console ();
- dev->puts (s); + dev->puts (dev, s); return; }
- serial_current->puts (s); + serial_current->puts (serial_current, s); } diff --git a/common/stdio.c b/common/stdio.c index 7de7d00..8590e5b 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -46,17 +46,17 @@ char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
#ifdef CONFIG_SYS_DEVICE_NULLDEV -void nulldev_putc(const char c) +void nulldev_putc(struct stdio_dev *dev, const char c) { /* nulldev is empty! */ }
-void nulldev_puts(const char *s) +void nulldev_puts(struct stdio_dev *dev, const char *s) { /* nulldev is empty! */ }
-int nulldev_input(void) +int nulldev_input(struct stdio_dev *dev) { /* nulldev is empty! */ return 0; @@ -68,6 +68,43 @@ int nulldev_input(void) ************************************************************************** */
+static void stdio_serial_putc(struct stdio_dev *dev, const char c) +{ +#ifdef CONFIG_SERIAL_SOFTWARE_FIFO + serial_buffered_putc(c); +#else + serial_putc(c); +#endif + +} + +static void stdio_serial_puts(struct stdio_dev *dev, const char *s) +{ +#ifdef CONFIG_SERIAL_SOFTWARE_FIFO + serial_buffered_puts(s); +#else + serial_puts(s); +#endif +} + +static int stdio_serial_getc(struct stdio_dev *dev) +{ +#ifdef CONFIG_SERIAL_SOFTWARE_FIFO + return serial_buffered_getc(); +#else + return serial_getc(); +#endif +} + +static int stdio_serial_tstc(struct stdio_dev *dev) +{ +#ifdef CONFIG_SERIAL_SOFTWARE_FIFO + return serial_buffered_tstc(); +#else + return serial_tstc(); +#endif +} + static void drv_system_init (void) { struct stdio_dev dev; @@ -76,17 +113,10 @@ static void drv_system_init (void)
strcpy (dev.name, "serial"); dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; -#ifdef CONFIG_SERIAL_SOFTWARE_FIFO - dev.putc = serial_buffered_putc; - dev.puts = serial_buffered_puts; - dev.getc = serial_buffered_getc; - dev.tstc = serial_buffered_tstc; -#else - dev.putc = serial_putc; - dev.puts = serial_puts; - dev.getc = serial_getc; - dev.tstc = serial_tstc; -#endif + dev.putc = stdio_serial_putc; + dev.puts = stdio_serial_puts; + dev.getc = stdio_serial_getc; + dev.tstc = stdio_serial_tstc;
stdio_register (&dev);
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index b458d77..638605e 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -118,7 +118,7 @@ static void usb_kbd_put_queue(char data) }
/* test if a character is in the queue */ -static int usb_kbd_testc(void) +static int usb_kbd_testc(struct stdio_dev *dev) { #ifdef CONFIG_SYS_USB_EVENT_POLL usb_event_poll(); @@ -129,7 +129,7 @@ static int usb_kbd_testc(void) return(1); } /* gets the character from the queue */ -static int usb_kbd_getc(void) +static int usb_kbd_getc(struct stdio_dev *dev) { char c; while(usb_in_pointer==usb_out_pointer) { diff --git a/cpu/blackfin/jtag-console.c b/cpu/blackfin/jtag-console.c index 1cd619f..1c51b3e 100644 --- a/cpu/blackfin/jtag-console.c +++ b/cpu/blackfin/jtag-console.c @@ -45,11 +45,11 @@ static void jtag_send(const char *c, uint32_t len) for (i = 0; i < len; i += 4) jtag_write_emudat((c[i] << 0) | (c[i+1] << 8) | (c[i+2] << 16) | (c[i+3] << 24)); } -static void jtag_putc(const char c) +static void jtag_putc(struct stdio_dev *dev, const char c) { jtag_send(&c, 1); } -static void jtag_puts(const char *s) +static void jtag_puts(struct stdio_dev *dev, const char *s) { jtag_send(s, strlen(s)); } @@ -63,7 +63,7 @@ static int jtag_tstc_dbg(void) }
/* Higher layers want to know when any data is available */ -static int jtag_tstc(void) +static int jtag_tstc(struct stdio_dev *dev) { return jtag_tstc_dbg() || leftovers_len; } @@ -72,7 +72,7 @@ static int jtag_tstc(void) * [32bit length][actual data] */ static uint32_t leftovers; -static int jtag_getc(void) +static int jtag_getc(struct stdio_dev *dev) { int ret; uint32_t emudat; diff --git a/cpu/mpc5xxx/serial.c b/cpu/mpc5xxx/serial.c index ce543a6..8112412 100644 --- a/cpu/mpc5xxx/serial.c +++ b/cpu/mpc5xxx/serial.c @@ -296,58 +296,58 @@ int serial_getcts(void) }
#if defined(CONFIG_SERIAL_MULTI) -int serial0_init(void) +int serial0_init(struct stdio_dev *dev) { return (serial_init_dev(PSC_BASE)); }
-int serial1_init(void) +int serial1_init(struct stdio_dev *dev) { return (serial_init_dev(PSC_BASE2)); } -void serial0_setbrg (void) +void serial0_setbrg (struct stdio_dev *dev) { serial_setbrg_dev(PSC_BASE); } -void serial1_setbrg (void) +void serial1_setbrg (struct stdio_dev *dev) { serial_setbrg_dev(PSC_BASE2); }
-void serial0_putc(const char c) +void serial0_putc(struct stdio_dev *dev, const char c) { serial_putc_dev(PSC_BASE,c); }
-void serial1_putc(const char c) +void serial1_putc(struct stdio_dev *dev, const char c) { serial_putc_dev(PSC_BASE2, c); } -void serial0_puts(const char *s) +void serial0_puts(struct stdio_dev *dev, const char *s) { serial_puts_dev(PSC_BASE, s); }
-void serial1_puts(const char *s) +void serial1_puts(struct stdio_dev *dev, const char *s) { serial_puts_dev(PSC_BASE2, s); }
-int serial0_getc(void) +int serial0_getc(struct stdio_dev *dev) { return(serial_getc_dev(PSC_BASE)); }
-int serial1_getc(void) +int serial1_getc(struct stdio_dev *dev) { return(serial_getc_dev(PSC_BASE2)); } -int serial0_tstc(void) +int serial0_tstc(struct stdio_dev *dev) { return (serial_tstc_dev(PSC_BASE)); }
-int serial1_tstc(void) +int serial1_tstc(struct stdio_dev *dev) { return (serial_tstc_dev(PSC_BASE2)); } diff --git a/cpu/mpc8xx/serial.c b/cpu/mpc8xx/serial.c index 7727013..533f6e7 100644 --- a/cpu/mpc8xx/serial.c +++ b/cpu/mpc8xx/serial.c @@ -109,7 +109,7 @@ static void serial_setdivisor(volatile cpm8xx_t *cp) * as serial console interface. */
-static void smc_setbrg (void) +static void smc_setbrg (struct stdio_dev *dev) { volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; volatile cpm8xx_t *cp = &(im->im_cpm); @@ -125,7 +125,7 @@ static void smc_setbrg (void) serial_setdivisor(cp); }
-static int smc_init (void) +static int smc_init (struct stdio_dev *dev) { volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; volatile smc_t *sp; @@ -266,7 +266,7 @@ static int smc_init (void) cp->cp_simode = ((cp->cp_simode & ~0xf000) | 0x7000); #else /* Set up the baud rate generator */ - smc_setbrg (); + smc_setbrg (dev); #endif
/* Make the first buffer the only buffer. */ @@ -294,7 +294,7 @@ static int smc_init (void) }
static void -smc_putc(const char c) +smc_putc(struct stdio_dev *dev, const char c) { volatile smc_uart_t *up; volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; @@ -307,7 +307,7 @@ smc_putc(const char c) #endif
if (c == '\n') - smc_putc ('\r'); + smc_putc (dev, '\r');
up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC]; #ifdef CONFIG_SYS_SMC_UCODE_PATCH @@ -329,15 +329,15 @@ smc_putc(const char c) }
static void -smc_puts (const char *s) +smc_puts (struct stdio_dev *dev, const char *s) { while (*s) { - smc_putc (*s++); + smc_putc (dev, *s++); } }
static int -smc_getc(void) +smc_getc(struct stdio_dev *dev) { volatile smc_uart_t *up; volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; @@ -370,7 +370,7 @@ smc_getc(void) }
static int -smc_tstc(void) +smc_tstc(struct stdio_dev *dev) { volatile smc_uart_t *up; volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; @@ -405,7 +405,7 @@ struct stdio_dev serial_smc_device = defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)
static void -scc_setbrg (void) +scc_setbrg (struct stdio_dev *dev) { volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; volatile cpm8xx_t *cp = &(im->im_cpm); @@ -421,7 +421,7 @@ scc_setbrg (void) serial_setdivisor(cp); }
-static int scc_init (void) +static int scc_init (struct stdio_dev *dev) { volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; volatile scc_t *sp; @@ -502,7 +502,7 @@ static int scc_init (void) tbdf->cbd_sc = 0;
/* Set up the baud rate generator. */ - scc_setbrg (); + scc_setbrg (dev);
/* Set up the uart parameters in the parameter ram. */ up->scc_genscc.scc_rbase = dpaddr; @@ -573,7 +573,7 @@ static int scc_init (void) }
static void -scc_putc(const char c) +scc_putc(struct stdio_dev *dev, const char c) { volatile cbd_t *tbdf; volatile char *buf; @@ -609,7 +609,7 @@ scc_putc(const char c) }
static void -scc_puts (const char *s) +scc_puts (struct stdio_dev *dev, const char *s) { while (*s) { scc_putc (*s++); @@ -617,7 +617,7 @@ scc_puts (const char *s) }
static int -scc_getc(void) +scc_getc(struct stdio_dev *dev) { volatile cbd_t *rbdf; volatile unsigned char *buf; @@ -643,7 +643,7 @@ scc_getc(void) }
static int -scc_tstc(void) +scc_tstc(struct stdio_dev *dev) { volatile cbd_t *rbdf; volatile scc_uart_t *up; diff --git a/cpu/mpc8xx/video.c b/cpu/mpc8xx/video.c index c79c499..61212a6 100644 --- a/cpu/mpc8xx/video.c +++ b/cpu/mpc8xx/video.c @@ -996,7 +996,7 @@ static inline void console_newline (void) } }
-void video_putc (const char c) +void video_putc (struct stdio_dev *dev, const char c) { if (!video_enable) { serial_putc (c); @@ -1033,7 +1033,7 @@ void video_putc (const char c) } }
-void video_puts (const char *s) +void video_puts (struct stdio_dev *dev, const char *s) { int count = strlen (s);
@@ -1042,7 +1042,7 @@ void video_puts (const char *s) serial_putc (*s++); else while (count--) - video_putc (*s++); + video_putc (dev, *s++); }
/************************************************************************/ diff --git a/cpu/ppc4xx/4xx_uart.c b/cpu/ppc4xx/4xx_uart.c index 9c21cce..a7e056b 100644 --- a/cpu/ppc4xx/4xx_uart.c +++ b/cpu/ppc4xx/4xx_uart.c @@ -757,62 +757,62 @@ void kgdb_interruptible (int yes)
#if defined(CONFIG_SERIAL_MULTI) -int serial0_init(void) +int serial0_init(struct stdio_dev *dev) { return (serial_init_dev(UART0_BASE)); }
-int serial1_init(void) +int serial1_init(struct stdio_dev *dev) { return (serial_init_dev(UART1_BASE)); }
-void serial0_setbrg (void) +void serial0_setbrg (struct stdio_dev *dev) { serial_setbrg_dev(UART0_BASE); }
-void serial1_setbrg (void) +void serial1_setbrg (struct stdio_dev *dev) { serial_setbrg_dev(UART1_BASE); }
-void serial0_putc(const char c) +void serial0_putc(struct stdio_dev *dev, const char c) { serial_putc_dev(UART0_BASE,c); }
-void serial1_putc(const char c) +void serial1_putc(struct stdio_dev *dev, const char c) { serial_putc_dev(UART1_BASE, c); }
-void serial0_puts(const char *s) +void serial0_puts(struct stdio_dev *dev, const char *s) { serial_puts_dev(UART0_BASE, s); }
-void serial1_puts(const char *s) +void serial1_puts(struct stdio_dev *dev, const char *s) { serial_puts_dev(UART1_BASE, s); }
-int serial0_getc(void) +int serial0_getc(struct stdio_dev *dev) { return(serial_getc_dev(UART0_BASE)); }
-int serial1_getc(void) +int serial1_getc(struct stdio_dev *dev) { return(serial_getc_dev(UART1_BASE)); }
-int serial0_tstc(void) +int serial0_tstc(struct stdio_dev *dev) { return (serial_tstc_dev(UART0_BASE)); }
-int serial1_tstc(void) +int serial1_tstc(struct stdio_dev *dev) { return (serial_tstc_dev(UART1_BASE)); } diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c index 58094c9..2520021 100644 --- a/drivers/input/i8042.c +++ b/drivers/input/i8042.c @@ -359,7 +359,7 @@ int i8042_kbd_init (void) * i8042_tstc - test if keyboard input is available * option: cursor blinking if called in a loop */ -int i8042_tstc (void) +int i8042_tstc (struct stdio_dev *dev) { unsigned char scan_code = 0;
@@ -395,7 +395,7 @@ int i8042_tstc (void) * i8042_getc - wait till keyboard input is available * option: turn on/off cursor while waiting */ -int i8042_getc (void) +int i8042_getc (struct stdio_dev *dev) { int ret_chr; unsigned char scan_code; diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index f5329a5..428d86d 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -139,7 +139,7 @@ static void nc_send_packet (const char *buf, int len) eth_halt (); }
-int nc_start (void) +int nc_start (struct stdio_dev *dev) { int netmask, our_ip;
@@ -169,7 +169,7 @@ int nc_start (void) return 0; }
-void nc_putc (char c) +void nc_putc (struct stdio_dev *dev, char c) { if (output_recursion) return; @@ -180,7 +180,7 @@ void nc_putc (char c) output_recursion = 0; }
-void nc_puts (const char *s) +void nc_puts (struct stdio_dev *dev, const char *s) { int len;
@@ -196,7 +196,7 @@ void nc_puts (const char *s) output_recursion = 0; }
-int nc_getc (void) +int nc_getc (struct stdio_dev *dev) { uchar c;
@@ -217,7 +217,7 @@ int nc_getc (void) return c; }
-int nc_tstc (void) +int nc_tstc (struct stdio_dev *dev) { struct eth_device *eth;
diff --git a/drivers/serial/arm_dcc.c b/drivers/serial/arm_dcc.c index 7b5ecb5..9c88d03 100644 --- a/drivers/serial/arm_dcc.c +++ b/drivers/serial/arm_dcc.c @@ -90,20 +90,21 @@ #define TIMEOUT_COUNT 0x4000000
#ifndef CONFIG_ARM_DCC_MULTI -#define arm_dcc_init serial_init -void serial_setbrg(void) {} -#define arm_dcc_getc serial_getc -#define arm_dcc_putc serial_putc -#define arm_dcc_puts serial_puts -#define arm_dcc_tstc serial_tstc -#endif - -int arm_dcc_init(void) +int serial_init(void) { return 0; }
-int arm_dcc_getc(void) +void serial_setbrg(void) +{ +} +#endif + +#ifndef CONFIG_ARM_DCC_MULTI +int arm_dcc_getc(struct stdio_dev *dev) +#else +int serial_getc(void) +#endif { int ch; register unsigned int reg; @@ -116,7 +117,11 @@ int arm_dcc_getc(void) return ch; }
-void arm_dcc_putc(char ch) +#ifndef CONFIG_ARM_DCC_MULTI +int arm_dcc_putc(struct stdio_dev *dev, char ch) +#else +void serial_putc(char ch) +#endif { register unsigned int reg; unsigned int timeout_count = TIMEOUT_COUNT; @@ -132,13 +137,21 @@ void arm_dcc_putc(char ch) write_dcc(ch); }
-void arm_dcc_puts(const char *s) +#ifndef CONFIG_ARM_DCC_MULTI +int arm_dcc_puts(struct stdio_dev *dev, const char *s) +#else +void serial_puts(const char *s) +#endif { while (*s) arm_dcc_putc(*s++); }
-int arm_dcc_tstc(void) +#ifndef CONFIG_ARM_DCC_MULTI +int arm_dcc_tstc(struct stdio_dev *dev) +#else +int serial_tstc(void) +#endif { register unsigned int reg;
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index d81a5b5..363c24d 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -94,20 +94,20 @@ static NS16550_t serial_ports[4] = {
/* Multi serial device functions */ #define DECLARE_ESERIAL_FUNCTIONS(port) \ - int eserial##port##_init (void) {\ + int eserial##port##_init (struct stdio_dev *dev) {\ int clock_divisor; \ clock_divisor = calc_divisor(serial_ports[port-1]); \ NS16550_init(serial_ports[port-1], clock_divisor); \ return(0);}\ - void eserial##port##_setbrg (void) {\ + void eserial##port##_setbrg (struct stdio_dev *dev) {\ serial_setbrg_dev(port);}\ - int eserial##port##_getc (void) {\ + int eserial##port##_getc (struct stdio_dev *dev) {\ return serial_getc_dev(port);}\ - int eserial##port##_tstc (void) {\ + int eserial##port##_tstc (struct stdio_dev *dev) {\ return serial_tstc_dev(port);}\ - void eserial##port##_putc (const char c) {\ + void eserial##port##_putc (struct stdio_dev *dev, const char c) {\ serial_putc_dev(port, c);}\ - void eserial##port##_puts (const char *s) {\ + void eserial##port##_puts (struct stdio_dev *dev, const char *s) {\ serial_puts_dev(port, s);}
/* Serial device descriptor */ diff --git a/drivers/serial/serial_pxa.c b/drivers/serial/serial_pxa.c index da3b292..c43f7a6 100644 --- a/drivers/serial/serial_pxa.c +++ b/drivers/serial/serial_pxa.c @@ -231,32 +231,32 @@ pxa_puts_dev (unsigned int uart_index,const char *s) }
#if defined (CONFIG_FFUART) -static int ffuart_init(void) +static int ffuart_init(struct stdio_dev *dev) { return pxa_init_dev(FFUART_INDEX); }
-static void ffuart_setbrg(void) +static void ffuart_setbrg(struct stdio_dev *dev) { return pxa_setbrg_dev(FFUART_INDEX); }
-static void ffuart_putc(const char c) +static void ffuart_putc(struct stdio_dev *dev, const char c) { return pxa_putc_dev(FFUART_INDEX,c); }
-static void ffuart_puts(const char *s) +static void ffuart_puts(struct stdio_dev *dev, const char *s) { return pxa_puts_dev(FFUART_INDEX,s); }
-static int ffuart_getc(void) +static int ffuart_getc(struct stdio_dev *dev) { return pxa_getc_dev(FFUART_INDEX); }
-static int ffuart_tstc(void) +static int ffuart_tstc(struct stdio_dev *dev) { return pxa_tstc_dev(FFUART_INDEX); } @@ -275,32 +275,32 @@ struct stdio_dev serial_ffuart_device = #endif
#if defined (CONFIG_BTUART) -static int btuart_init(void) +static int btuart_init(struct stdio_dev *dev) { return pxa_init_dev(BTUART_INDEX); }
-static void btuart_setbrg(void) +static void btuart_setbrg(struct stdio_dev *dev) { return pxa_setbrg_dev(BTUART_INDEX); }
-static void btuart_putc(const char c) +static void btuart_putc(struct stdio_dev *dev, const char c) { return pxa_putc_dev(BTUART_INDEX,c); }
-static void btuart_puts(const char *s) +static void btuart_puts(struct stdio_dev *dev, const char *s) { return pxa_puts_dev(BTUART_INDEX,s); }
-static int btuart_getc(void) +static int btuart_getc(struct stdio_dev *dev) { return pxa_getc_dev(BTUART_INDEX); }
-static int btuart_tstc(void) +static int btuart_tstc(struct stdio_dev *dev) { return pxa_tstc_dev(BTUART_INDEX); } @@ -319,32 +319,32 @@ struct stdio_dev serial_btuart_device = #endif
#if defined (CONFIG_STUART) -static int stuart_init(void) +static int stuart_init(struct stdio_dev *dev) { return pxa_init_dev(STUART_INDEX); }
-static void stuart_setbrg(void) +static void stuart_setbrg(struct stdio_dev *dev) { return pxa_setbrg_dev(STUART_INDEX); }
-static void stuart_putc(const char c) +static void stuart_putc(struct stdio_dev *dev, const char c) { return pxa_putc_dev(STUART_INDEX,c); }
-static void stuart_puts(const char *s) +static void stuart_puts(struct stdio_dev *dev, const char *s) { return pxa_puts_dev(STUART_INDEX,s); }
-static int stuart_getc(void) +static int stuart_getc(struct stdio_dev *dev) { return pxa_getc_dev(STUART_INDEX); }
-static int stuart_tstc(void) +static int stuart_tstc(struct stdio_dev *dev) { return pxa_tstc_dev(STUART_INDEX); } diff --git a/drivers/serial/serial_s3c24x0.c b/drivers/serial/serial_s3c24x0.c index dc27e00..61e30d7 100644 --- a/drivers/serial/serial_s3c24x0.c +++ b/drivers/serial/serial_s3c24x0.c @@ -51,17 +51,17 @@ DECLARE_GLOBAL_DATA_PTR;
/* Multi serial device functions */ #define DECLARE_S3C_SERIAL_FUNCTIONS(port) \ - int s3serial##port##_init (void) {\ + int s3serial##port##_init (struct stdio_dev *dev) {\ return serial_init_dev(port);}\ - void s3serial##port##_setbrg (void) {\ + void s3serial##port##_setbrg (struct stdio_dev *dev) {\ serial_setbrg_dev(port);}\ - int s3serial##port##_getc (void) {\ + int s3serial##port##_getc (struct stdio_dev *dev) {\ return serial_getc_dev(port);}\ - int s3serial##port##_tstc (void) {\ + int s3serial##port##_tstc (struct stdio_dev *dev) {\ return serial_tstc_dev(port);}\ - void s3serial##port##_putc (const char c) {\ + void s3serial##port##_putc (struct stdio_dev *dev, const char c) {\ serial_putc_dev(port, c);}\ - void s3serial##port##_puts (const char *s) {\ + void s3serial##port##_puts (struct stdio_dev *dev, const char *s) {\ serial_puts_dev(port, s);}
#define INIT_S3C_SERIAL_STRUCTURE(port,name,bus) {\ diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c index cffd5a2..0b4cc17 100644 --- a/drivers/serial/usbtty.c +++ b/drivers/serial/usbtty.c @@ -388,7 +388,7 @@ static void str2wide (char *str, u16 * wide) * Test whether a character is in the RX buffer */
-int usbtty_tstc (void) +int usbtty_tstc (struct stdio_dev *dev) { struct usb_endpoint_instance *endpoint = &endpoint_instance[rx_endpoint]; @@ -408,7 +408,7 @@ int usbtty_tstc (void) * written into its argument c. */
-int usbtty_getc (void) +int usbtty_getc (struct stdio_dev *dev) { char c; struct usb_endpoint_instance *endpoint = @@ -428,7 +428,7 @@ int usbtty_getc (void) /* * Output a single byte to the usb client port. */ -void usbtty_putc (const char c) +void usbtty_putc (struct stdio_dev *dev, const char c) { if (!usbtty_configured ()) return; @@ -483,7 +483,7 @@ static void __usbtty_puts (const char *str, int len) } }
-void usbtty_puts (const char *str) +void usbtty_puts (struct stdio_dev *dev, const char *str) { int n; int len; diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index fbc4df9..b4d90fd 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -693,7 +693,7 @@ static void console_cr (void)
/*****************************************************************************/
-void video_putc (const char c) +void video_putc (struct stdio_dev *dev, const char c) { static int nl = 1;
@@ -737,12 +737,12 @@ CURSOR_SET}
/*****************************************************************************/
-void video_puts (const char *s) +void video_puts (struct stdio_dev *dev, const char *s) { int count = strlen (s);
while (count--) - video_putc (*s++); + video_putc (dev, *s++); }
/*****************************************************************************/ diff --git a/include/i8042.h b/include/i8042.h index 1395289..ed16d76 100644 --- a/include/i8042.h +++ b/include/i8042.h @@ -70,7 +70,7 @@ /* exports */
int i8042_kbd_init(void); -int i8042_tstc(void); -int i8042_getc(void); +int i8042_tstc(struct stdio_dev *dev); +int i8042_getc(struct stdio_dev *dev);
#endif /* _I8042_H_ */ diff --git a/include/stdio_dev.h b/include/stdio_dev.h index 5bb2cad..ba653ce 100644 --- a/include/stdio_dev.h +++ b/include/stdio_dev.h @@ -48,21 +48,21 @@ struct stdio_dev {
/* GENERAL functions */
- int (*start) (void); /* To start the device */ - int (*stop) (void); /* To stop the device */ + int (*start) (struct stdio_dev *dev); /* To start the device */ + int (*stop) (struct stdio_dev *dev); /* To stop the device */
/* OUTPUT functions */
- void (*putc) (const char c); /* To put a char */ - void (*puts) (const char *s); /* To put a string (accelerator) */ + void (*putc) (struct stdio_dev *dev, const char c); /* To put a char */ + void (*puts) (struct stdio_dev *dev, const char *s); /* To put a string */
/* INPUT functions */
- int (*tstc) (void); /* To test if a char is ready... */ - int (*getc) (void); /* To get that char */ + int (*tstc) (struct stdio_dev *dev); /* To test if a char is ready.. */ + int (*getc) (struct stdio_dev *dev); /* To get that char */
/* Other functions */ - void (*setbrg) (void); /* Set baudrate */ + void (*setbrg) (struct stdio_dev *dev); /* Set baudrate */
void *priv; /* Private extensions */ struct list_head list; diff --git a/lib_i386/video.c b/lib_i386/video.c index c58ed10..2c91bd2 100644 --- a/lib_i386/video.c +++ b/lib_i386/video.c @@ -123,7 +123,7 @@ static void __video_putc(const char c, int *x, int *y) } }
-static void video_putc(const char c) +static void video_putc(struct stdio_dev *dev, const char c) { int x,y,pos;
@@ -142,7 +142,7 @@ static void video_putc(const char c) outb_p(0xff & (pos >> 1), vidport+1); }
-static void video_puts(const char *s) +static void video_puts(struct stdio_dev *dev, const char *s) { int x,y,pos; char c;