2002-11-03 00:01:44 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2000
|
|
|
|
* Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-07-05 16:01:46 +00:00
|
|
|
#include <config.h>
|
2002-11-03 00:01:44 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <malloc.h>
|
2007-07-05 16:01:59 +00:00
|
|
|
#include <param.h>
|
2002-11-03 00:01:44 +00:00
|
|
|
#include <console.h>
|
2007-07-05 16:01:48 +00:00
|
|
|
#include <driver.h>
|
|
|
|
#include <fs.h>
|
2007-07-12 07:31:07 +00:00
|
|
|
#include <init.h>
|
2007-09-21 19:30:59 +00:00
|
|
|
#include <clock.h>
|
|
|
|
#include <kfifo.h>
|
2007-10-01 08:26:45 +00:00
|
|
|
#include <module.h>
|
2010-12-18 10:25:34 +00:00
|
|
|
#include <poller.h>
|
2009-11-02 13:31:18 +00:00
|
|
|
#include <linux/list.h>
|
2011-01-18 12:31:29 +00:00
|
|
|
#include <linux/stringify.h>
|
2012-10-16 10:05:53 +00:00
|
|
|
#include <debug_ll.h>
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2007-10-11 18:36:57 +00:00
|
|
|
LIST_HEAD(console_list);
|
|
|
|
EXPORT_SYMBOL(console_list);
|
2007-07-12 07:31:07 +00:00
|
|
|
|
2012-01-26 09:25:42 +00:00
|
|
|
#define CONSOLE_UNINITIALIZED 0
|
|
|
|
#define CONSOLE_INITIALIZED_BUFFER 1
|
|
|
|
#define CONSOLE_INIT_FULL 2
|
2007-07-12 07:31:07 +00:00
|
|
|
|
2012-02-25 13:24:38 +00:00
|
|
|
#define to_console_dev(d) container_of(d, struct console_device, class_dev)
|
|
|
|
|
2011-09-26 16:55:07 +00:00
|
|
|
static int initialized = 0;
|
2007-07-05 16:01:48 +00:00
|
|
|
|
2012-10-06 20:57:02 +00:00
|
|
|
#define CONSOLE_BUFFER_SIZE 1024
|
|
|
|
|
|
|
|
static char console_input_buffer[CONSOLE_BUFFER_SIZE];
|
|
|
|
static char console_output_buffer[CONSOLE_BUFFER_SIZE];
|
|
|
|
|
|
|
|
static struct kfifo __console_input_fifo;
|
|
|
|
static struct kfifo __console_output_fifo;
|
|
|
|
static struct kfifo *console_input_fifo = &__console_input_fifo;
|
|
|
|
static struct kfifo *console_output_fifo = &__console_output_fifo;
|
|
|
|
|
2007-07-05 16:02:17 +00:00
|
|
|
static int console_std_set(struct device_d *dev, struct param_d *param,
|
|
|
|
const char *val)
|
2007-07-05 16:01:59 +00:00
|
|
|
{
|
2012-02-25 13:24:38 +00:00
|
|
|
struct console_device *cdev = to_console_dev(dev);
|
2010-06-03 08:13:29 +00:00
|
|
|
char active[4];
|
2007-07-05 16:01:59 +00:00
|
|
|
unsigned int flag = 0, i = 0;
|
|
|
|
|
2010-06-03 08:13:29 +00:00
|
|
|
if (!val)
|
|
|
|
dev_param_set_generic(dev, param, NULL);
|
|
|
|
|
2007-07-05 16:01:59 +00:00
|
|
|
if (strchr(val, 'i') && cdev->f_caps & CONSOLE_STDIN) {
|
2010-06-03 08:13:29 +00:00
|
|
|
active[i++] = 'i';
|
2007-07-05 16:01:59 +00:00
|
|
|
flag |= CONSOLE_STDIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strchr(val, 'o') && cdev->f_caps & CONSOLE_STDOUT) {
|
2010-06-03 08:13:29 +00:00
|
|
|
active[i++] = 'o';
|
2007-07-05 16:01:59 +00:00
|
|
|
flag |= CONSOLE_STDOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strchr(val, 'e') && cdev->f_caps & CONSOLE_STDERR) {
|
2010-06-03 08:13:29 +00:00
|
|
|
active[i++] = 'e';
|
2007-07-05 16:01:59 +00:00
|
|
|
flag |= CONSOLE_STDERR;
|
|
|
|
}
|
|
|
|
|
2010-06-03 08:13:29 +00:00
|
|
|
active[i] = 0;
|
2007-07-05 16:01:59 +00:00
|
|
|
cdev->f_active = flag;
|
|
|
|
|
2010-06-03 08:13:29 +00:00
|
|
|
dev_param_set_generic(dev, param, active);
|
|
|
|
|
2012-10-06 20:57:02 +00:00
|
|
|
if (initialized < CONSOLE_INIT_FULL) {
|
|
|
|
char ch;
|
|
|
|
initialized = CONSOLE_INIT_FULL;
|
2012-10-28 09:15:10 +00:00
|
|
|
PUTS_LL("Switch to console [");
|
|
|
|
PUTS_LL(dev_name(dev));
|
|
|
|
PUTS_LL("]\n");
|
2012-10-06 20:57:02 +00:00
|
|
|
barebox_banner();
|
|
|
|
while (kfifo_getc(console_output_fifo, &ch) == 0)
|
|
|
|
console_putc(CONSOLE_STDOUT, ch);
|
|
|
|
}
|
|
|
|
|
2007-07-05 16:01:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-05 16:02:17 +00:00
|
|
|
static int console_baudrate_set(struct device_d *dev, struct param_d *param,
|
|
|
|
const char *val)
|
|
|
|
{
|
2012-02-25 13:24:38 +00:00
|
|
|
struct console_device *cdev = to_console_dev(dev);
|
2007-07-05 16:02:17 +00:00
|
|
|
int baudrate;
|
2010-06-03 08:13:29 +00:00
|
|
|
char baudstr[16];
|
2009-02-06 13:25:04 +00:00
|
|
|
unsigned char c;
|
2007-07-05 16:02:17 +00:00
|
|
|
|
2010-06-03 08:13:29 +00:00
|
|
|
if (!val)
|
|
|
|
dev_param_set_generic(dev, param, NULL);
|
|
|
|
|
2007-07-05 16:02:17 +00:00
|
|
|
baudrate = simple_strtoul(val, NULL, 10);
|
|
|
|
|
|
|
|
if (cdev->f_active) {
|
|
|
|
printf("## Switch baudrate to %d bps and press ENTER ...\n",
|
|
|
|
baudrate);
|
|
|
|
mdelay(50);
|
|
|
|
cdev->setbrg(cdev, baudrate);
|
|
|
|
mdelay(50);
|
2009-02-06 13:25:04 +00:00
|
|
|
do {
|
|
|
|
c = getc();
|
|
|
|
} while (c != '\r' && c != '\n');
|
2007-07-05 16:02:17 +00:00
|
|
|
} else
|
|
|
|
cdev->setbrg(cdev, baudrate);
|
|
|
|
|
2010-06-03 08:13:29 +00:00
|
|
|
sprintf(baudstr, "%d", baudrate);
|
|
|
|
dev_param_set_generic(dev, param, baudstr);
|
2007-07-05 16:02:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-26 09:25:42 +00:00
|
|
|
static void console_init_early(void)
|
2009-05-13 14:23:09 +00:00
|
|
|
{
|
2012-01-26 09:25:42 +00:00
|
|
|
kfifo_init(console_input_fifo, console_input_buffer,
|
|
|
|
CONSOLE_BUFFER_SIZE);
|
|
|
|
kfifo_init(console_output_fifo, console_output_buffer,
|
|
|
|
CONSOLE_BUFFER_SIZE);
|
2009-05-13 14:23:09 +00:00
|
|
|
|
2012-01-26 09:25:42 +00:00
|
|
|
initialized = CONSOLE_INITIALIZED_BUFFER;
|
|
|
|
}
|
2009-05-13 14:23:09 +00:00
|
|
|
|
2007-07-05 16:01:48 +00:00
|
|
|
int console_register(struct console_device *newcdev)
|
2002-11-03 00:01:44 +00:00
|
|
|
{
|
2009-06-11 13:33:49 +00:00
|
|
|
struct device_d *dev = &newcdev->class_dev;
|
2012-10-06 20:57:02 +00:00
|
|
|
int activate = 0;
|
2007-07-05 16:01:48 +00:00
|
|
|
|
2012-01-26 09:25:42 +00:00
|
|
|
if (initialized == CONSOLE_UNINITIALIZED)
|
|
|
|
console_init_early();
|
|
|
|
|
2012-04-15 18:29:34 +00:00
|
|
|
dev->id = DEVICE_ID_DYNAMIC;
|
2009-06-11 13:33:49 +00:00
|
|
|
strcpy(dev->name, "cs");
|
2011-08-15 07:36:37 +00:00
|
|
|
if (newcdev->dev)
|
2012-12-12 13:55:40 +00:00
|
|
|
dev->parent = newcdev->dev;
|
2012-09-19 19:22:17 +00:00
|
|
|
platform_device_register(dev);
|
2009-06-11 13:33:49 +00:00
|
|
|
|
2007-07-05 16:02:18 +00:00
|
|
|
if (newcdev->setbrg) {
|
2010-06-03 08:13:29 +00:00
|
|
|
dev_add_param(dev, "baudrate", console_baudrate_set, NULL, 0);
|
2011-01-18 12:31:29 +00:00
|
|
|
dev_set_param(dev, "baudrate", __stringify(CONFIG_BAUDRATE));
|
2007-07-05 16:02:17 +00:00
|
|
|
}
|
|
|
|
|
2010-06-03 08:13:29 +00:00
|
|
|
dev_add_param(dev, "active", console_std_set, NULL, 0);
|
2007-07-05 16:02:17 +00:00
|
|
|
|
2012-10-06 20:57:02 +00:00
|
|
|
if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_FIRST)) {
|
|
|
|
if (list_empty(&console_list))
|
|
|
|
activate = 1;
|
|
|
|
} else if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_ALL)) {
|
|
|
|
activate = 1;
|
2007-10-19 09:04:33 +00:00
|
|
|
}
|
2007-07-05 16:01:48 +00:00
|
|
|
|
2012-10-06 22:15:17 +00:00
|
|
|
if (newcdev->dev && of_device_is_stdout_path(newcdev->dev))
|
|
|
|
activate = 1;
|
|
|
|
|
2007-10-11 18:36:57 +00:00
|
|
|
list_add_tail(&newcdev->list, &console_list);
|
|
|
|
|
2012-10-06 20:57:02 +00:00
|
|
|
if (activate)
|
|
|
|
dev_set_param(dev, "active", "ioe");
|
2007-10-19 09:04:33 +00:00
|
|
|
|
2007-10-11 18:36:57 +00:00
|
|
|
return 0;
|
2007-07-05 16:01:48 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(console_register);
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2011-11-24 03:01:26 +00:00
|
|
|
int console_unregister(struct console_device *cdev)
|
|
|
|
{
|
|
|
|
struct device_d *dev = &cdev->class_dev;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
list_del(&cdev->list);
|
|
|
|
if (list_empty(&console_list))
|
|
|
|
initialized = CONSOLE_UNINITIALIZED;
|
|
|
|
|
|
|
|
status = unregister_device(dev);
|
|
|
|
if (!status)
|
|
|
|
memset(cdev, 0, sizeof(*cdev));
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(console_unregister);
|
|
|
|
|
2009-09-16 14:21:48 +00:00
|
|
|
static int getc_raw(void)
|
2007-07-05 16:01:48 +00:00
|
|
|
{
|
2007-10-11 18:36:57 +00:00
|
|
|
struct console_device *cdev;
|
|
|
|
int active = 0;
|
|
|
|
|
2007-07-05 16:01:48 +00:00
|
|
|
while (1) {
|
2007-10-11 18:36:57 +00:00
|
|
|
for_each_console(cdev) {
|
|
|
|
if (!(cdev->f_active & CONSOLE_STDIN))
|
|
|
|
continue;
|
|
|
|
active = 1;
|
|
|
|
if (cdev->tstc(cdev))
|
|
|
|
return cdev->getc(cdev);
|
|
|
|
}
|
|
|
|
if (!active)
|
|
|
|
/* no active console found. bail out */
|
|
|
|
return -1;
|
2007-07-05 16:01:48 +00:00
|
|
|
}
|
|
|
|
}
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2011-05-13 13:53:29 +00:00
|
|
|
static int tstc_raw(void)
|
|
|
|
{
|
|
|
|
struct console_device *cdev;
|
|
|
|
|
|
|
|
for_each_console(cdev) {
|
|
|
|
if (!(cdev->f_active & CONSOLE_STDIN))
|
|
|
|
continue;
|
|
|
|
if (cdev->tstc(cdev))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-21 19:30:59 +00:00
|
|
|
int getc(void)
|
|
|
|
{
|
|
|
|
unsigned char ch;
|
|
|
|
uint64_t start;
|
|
|
|
|
2009-05-13 14:11:24 +00:00
|
|
|
/*
|
|
|
|
* For 100us we read the characters from the serial driver
|
|
|
|
* into a kfifo. This helps us not to lose characters
|
|
|
|
* in small hardware fifos.
|
|
|
|
*/
|
2007-09-21 19:30:59 +00:00
|
|
|
start = get_time_ns();
|
|
|
|
while (1) {
|
2011-05-13 13:53:29 +00:00
|
|
|
if (tstc_raw()) {
|
2012-01-26 09:25:42 +00:00
|
|
|
kfifo_putc(console_input_fifo, getc_raw());
|
2007-09-21 19:30:59 +00:00
|
|
|
|
|
|
|
start = get_time_ns();
|
|
|
|
}
|
2009-05-13 14:11:24 +00:00
|
|
|
if (is_timeout(start, 100 * USECOND) &&
|
2012-01-26 09:25:42 +00:00
|
|
|
kfifo_len(console_input_fifo))
|
2007-09-21 19:30:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-01-26 09:25:42 +00:00
|
|
|
kfifo_getc(console_input_fifo, &ch);
|
2007-09-21 19:30:59 +00:00
|
|
|
return ch;
|
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(getc);
|
2007-09-21 19:30:59 +00:00
|
|
|
|
2007-07-05 16:01:48 +00:00
|
|
|
int fgetc(int fd)
|
|
|
|
{
|
|
|
|
char c;
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2007-07-05 16:01:48 +00:00
|
|
|
if (!fd)
|
|
|
|
return getc();
|
|
|
|
return read(fd, &c, 1);
|
2002-11-03 00:01:44 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(fgetc);
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2007-07-05 16:01:50 +00:00
|
|
|
int tstc(void)
|
2002-11-03 00:01:44 +00:00
|
|
|
{
|
2012-01-26 09:25:42 +00:00
|
|
|
return kfifo_len(console_input_fifo) || tstc_raw();
|
2002-11-03 00:01:44 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(tstc);
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2007-07-05 16:01:48 +00:00
|
|
|
void console_putc(unsigned int ch, char c)
|
2002-11-03 00:01:44 +00:00
|
|
|
{
|
2007-10-11 18:36:57 +00:00
|
|
|
struct console_device *cdev;
|
2011-09-26 16:55:07 +00:00
|
|
|
int init = initialized;
|
2007-07-05 16:01:48 +00:00
|
|
|
|
2007-07-12 07:31:07 +00:00
|
|
|
switch (init) {
|
|
|
|
case CONSOLE_UNINITIALIZED:
|
2012-01-26 09:25:42 +00:00
|
|
|
console_init_early();
|
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
case CONSOLE_INITIALIZED_BUFFER:
|
|
|
|
kfifo_putc(console_output_fifo, c);
|
2012-10-16 10:05:53 +00:00
|
|
|
PUTC_LL(c);
|
2007-07-12 07:31:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case CONSOLE_INIT_FULL:
|
2007-10-11 18:36:57 +00:00
|
|
|
for_each_console(cdev) {
|
2007-07-12 07:31:07 +00:00
|
|
|
if (cdev->f_active & ch) {
|
|
|
|
if (c == '\n')
|
|
|
|
cdev->putc(cdev, '\r');
|
2009-08-04 12:22:45 +00:00
|
|
|
cdev->putc(cdev, c);
|
2007-07-12 07:31:07 +00:00
|
|
|
}
|
2007-07-05 16:02:17 +00:00
|
|
|
}
|
2007-07-12 07:31:07 +00:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
/* If we have problems inititalizing our data
|
|
|
|
* get them early
|
|
|
|
*/
|
|
|
|
hang();
|
2007-07-05 16:01:48 +00:00
|
|
|
}
|
2002-11-03 00:01:44 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(console_putc);
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2007-07-05 16:01:48 +00:00
|
|
|
int fputc(int fd, char c)
|
2002-11-03 00:01:44 +00:00
|
|
|
{
|
2007-10-11 18:36:57 +00:00
|
|
|
if(list_empty(&console_list)) {
|
2007-07-12 07:31:07 +00:00
|
|
|
if(!fd)
|
|
|
|
console_putc(0, c);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-05 16:01:48 +00:00
|
|
|
if (fd == 1)
|
2007-09-21 07:09:06 +00:00
|
|
|
putchar(c);
|
2007-07-05 16:01:48 +00:00
|
|
|
else if (fd == 2)
|
|
|
|
eputc(c);
|
|
|
|
else
|
|
|
|
return write(fd, &c, 1);
|
|
|
|
return 0;
|
2002-11-03 00:01:44 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(fputc);
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2011-10-14 06:56:22 +00:00
|
|
|
int console_puts(unsigned int ch, const char *str)
|
2002-11-03 00:01:44 +00:00
|
|
|
{
|
2007-07-12 07:31:07 +00:00
|
|
|
const char *s = str;
|
2011-10-14 06:56:22 +00:00
|
|
|
int n = 0;
|
|
|
|
|
2007-07-12 07:31:07 +00:00
|
|
|
while (*s) {
|
2011-10-14 06:56:22 +00:00
|
|
|
if (*s == '\n') {
|
2007-07-12 07:31:07 +00:00
|
|
|
console_putc(ch, '\r');
|
2011-10-14 06:56:22 +00:00
|
|
|
n++;
|
|
|
|
}
|
2009-08-04 12:22:45 +00:00
|
|
|
console_putc(ch, *s);
|
2011-10-14 06:56:22 +00:00
|
|
|
n++;
|
2007-07-12 07:31:07 +00:00
|
|
|
s++;
|
2007-07-05 16:01:48 +00:00
|
|
|
}
|
2011-10-14 06:56:22 +00:00
|
|
|
return n;
|
2007-07-05 16:01:48 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(console_puts);
|
2007-07-05 16:01:48 +00:00
|
|
|
|
|
|
|
int fputs(int fd, const char *s)
|
|
|
|
{
|
|
|
|
if (fd == 1)
|
2011-10-14 06:56:22 +00:00
|
|
|
return puts(s);
|
2007-07-05 16:01:48 +00:00
|
|
|
else if (fd == 2)
|
2011-10-14 06:56:22 +00:00
|
|
|
return eputs(s);
|
2007-07-05 16:01:48 +00:00
|
|
|
else
|
|
|
|
return write(fd, s, strlen(s));
|
2002-11-03 00:01:44 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(fputs);
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2009-02-21 00:22:48 +00:00
|
|
|
void console_flush(void)
|
|
|
|
{
|
|
|
|
struct console_device *cdev;
|
|
|
|
|
|
|
|
for_each_console(cdev) {
|
|
|
|
if (cdev->flush)
|
|
|
|
cdev->flush(cdev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(console_flush);
|
|
|
|
|
2011-11-11 11:25:53 +00:00
|
|
|
int fprintf(int file, const char *fmt, ...)
|
2007-07-05 16:02:03 +00:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
char printbuffer[CFG_PBSIZE];
|
|
|
|
|
|
|
|
va_start (args, fmt);
|
|
|
|
|
|
|
|
/* For this to work, printbuffer must be larger than
|
|
|
|
* anything we ever want to print.
|
|
|
|
*/
|
2011-12-07 10:44:37 +00:00
|
|
|
vsprintf (printbuffer, fmt, args);
|
2007-07-05 16:02:03 +00:00
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
/* Print the string */
|
2011-11-11 11:25:53 +00:00
|
|
|
return fputs(file, printbuffer);
|
2007-07-05 16:02:03 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(fprintf);
|
2007-07-05 16:02:03 +00:00
|
|
|
|
2007-09-21 07:09:06 +00:00
|
|
|
int printf (const char *fmt, ...)
|
2002-11-03 00:01:44 +00:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
uint i;
|
|
|
|
char printbuffer[CFG_PBSIZE];
|
|
|
|
|
|
|
|
va_start (args, fmt);
|
|
|
|
|
|
|
|
/* For this to work, printbuffer must be larger than
|
|
|
|
* anything we ever want to print.
|
|
|
|
*/
|
|
|
|
i = vsprintf (printbuffer, fmt, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
/* Print the string */
|
|
|
|
puts (printbuffer);
|
2007-09-21 07:09:06 +00:00
|
|
|
|
|
|
|
return i;
|
2002-11-03 00:01:44 +00:00
|
|
|
}
|
2007-10-01 08:26:45 +00:00
|
|
|
EXPORT_SYMBOL(printf);
|
2007-07-05 16:02:03 +00:00
|
|
|
|
2007-09-21 07:09:06 +00:00
|
|
|
int vprintf (const char *fmt, va_list args)
|
2003-06-19 23:40:20 +00:00
|
|
|
{
|
|
|
|
uint i;
|
|
|
|
char printbuffer[CFG_PBSIZE];
|
|
|
|
|
|
|
|
/* For this to work, printbuffer must be larger than
|
|
|
|
* anything we ever want to print.
|
|
|
|
*/
|
|
|
|
i = vsprintf (printbuffer, fmt, args);
|
|
|
|
|
|
|
|
/* Print the string */
|
|
|
|
puts (printbuffer);
|
2007-09-21 07:09:06 +00:00
|
|
|
|
|
|
|
return i;
|
2003-06-19 23:40:20 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(vprintf);
|
2003-06-19 23:40:20 +00:00
|
|
|
|
2008-03-10 23:00:37 +00:00
|
|
|
#ifndef ARCH_HAS_CTRLC
|
2002-11-03 00:01:44 +00:00
|
|
|
/* test if ctrl-c was pressed */
|
|
|
|
int ctrlc (void)
|
|
|
|
{
|
2010-12-18 10:25:34 +00:00
|
|
|
poller_call();
|
|
|
|
|
2007-07-05 16:01:50 +00:00
|
|
|
if (tstc() && getc() == 3)
|
|
|
|
return 1;
|
2002-11-03 00:01:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(ctrlc);
|
2008-03-10 23:00:37 +00:00
|
|
|
#endif /* ARCH_HAS_CTRC */
|