summaryrefslogtreecommitdiffstats
path: root/arch/linux/lib/common.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:01:59 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:01:59 +0200
commitfa668fe1849d75c7f62e4fed0ab9f71ddbba61e5 (patch)
tree31ef1c1e62cf8eeab80bb767c6fe1758c408af06 /arch/linux/lib/common.c
parent5735a344786aa5b266c4eeac9ba8ddf7a2650e7b (diff)
downloadbarebox-fa668fe1849d75c7f62e4fed0ab9f71ddbba61e5.tar.gz
barebox-fa668fe1849d75c7f62e4fed0ab9f71ddbba61e5.tar.xz
svn_rev_502
complete multiple console support
Diffstat (limited to 'arch/linux/lib/common.c')
-rw-r--r--arch/linux/lib/common.c47
1 files changed, 36 insertions, 11 deletions
diff --git a/arch/linux/lib/common.c b/arch/linux/lib/common.c
index b44bdad403..2611a1b7cd 100644
--- a/arch/linux/lib/common.c
+++ b/arch/linux/lib/common.c
@@ -25,9 +25,9 @@ static void rawmode(void)
{
tcgetattr(0, &term_orig);
term_vi = term_orig;
- term_vi.c_lflag &= (~ICANON & ~ECHO & ~ISIG); // leave ISIG ON- allow intr's
+ term_vi.c_lflag &= (~ICANON & ~ECHO & ~ISIG);
term_vi.c_iflag &= (~IXON & ~ICRNL);
- term_vi.c_oflag &= (~ONLCR);
+ term_vi.c_oflag |= (ONLCR);
term_vi.c_cc[VMIN] = 1;
term_vi.c_cc[VTIME] = 0;
erase_char = term_vi.c_cc[VERASE];
@@ -51,19 +51,19 @@ void linux_putc (const char c)
fflush(stdout);
}
-int linux_tstc (void)
+int linux_tstc (int fd)
{
fd_set rfds;
struct timeval tv;
int ret;
FD_ZERO(&rfds);
- FD_SET(0, &rfds);
+ FD_SET(fd, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 100;
- ret = select(1, &rfds, NULL, NULL, &tv);
+ ret = select(fd + 1, &rfds, NULL, NULL, &tv);
if (ret)
return 1;
@@ -148,9 +148,9 @@ ssize_t linux_write(int fd, const void *buf, size_t count)
return write(fd, buf, count);
}
-off_t linux_lseek(int fildes, off_t offset)
+off_t linux_lseek(int fd, off_t offset)
{
- return lseek(fildes, offset, SEEK_SET);
+ return lseek(fd, offset, SEEK_SET);
}
void flush_cache (unsigned long dummy1, unsigned long dummy2)
@@ -232,7 +232,11 @@ static void print_usage(const char *prgname)
" -e <file> Map a file to U-Boot. With this option files are mapped as\n"
" /dev/env0 ... /dev/envx and thus are used as default\n"
" environment. An empty file generated with dd will do to get\n"
-" started wth an empty environment\n",
+" started wth an empty environment\n"
+" -O <file> Register file as a console capable of doing stdout. File can\n"
+" be a regular file or a fifo.\n"
+" -I <file> Register file as a console capable of doing stdin. File can\n"
+" be a regular file or a fifo.\n",
prgname
);
}
@@ -240,9 +244,8 @@ static void print_usage(const char *prgname)
int main(int argc, char *argv[])
{
void *ram;
- int opt;
+ int opt, ret, fd;
int malloc_size = 1024 * 1024;
- int ret;
ram = malloc(malloc_size);
if (!ram) {
@@ -251,7 +254,7 @@ int main(int argc, char *argv[])
}
mem_malloc_init(ram, ram + malloc_size);
- while ((opt = getopt(argc, argv, "hi:e:")) != -1) {
+ while ((opt = getopt(argc, argv, "hi:e:I:O:")) != -1) {
switch (opt) {
case 'h':
print_usage(basename(argv[0]));
@@ -273,9 +276,31 @@ int main(int argc, char *argv[])
if (ret)
exit(1);
break;
+ case 'O':
+ fd = open(optarg, O_WRONLY);
+ if (fd < 0) {
+ perror("open");
+ exit(1);
+ }
+
+ u_boot_register_console("cout", -1, fd);
+ break;
+ case 'I':
+ fd = open(optarg, O_RDWR);
+ if (fd < 0) {
+ perror("open");
+ exit(1);
+ }
+
+ u_boot_register_console("cin", fd, -1);
+ break;
+ default:
+ exit(1);
}
}
+ u_boot_register_console("console", 1, 0);
+
rawmode();
start_uboot();