This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
XScale redboot sys_read()
- To: "'ecos-discuss at sources dot redhat dot com'" <ecos-discuss at sources dot redhat dot com>
- Subject: [ECOS] XScale redboot sys_read()
- From: "McAtee, Kip" <Kip dot McAtee at SpirentCom dot COM>
- Date: Sat, 13 Oct 2001 14:37:00 -1000
Greetings-
I made the following change to syscall.c to support console input
via the Green Hills stdio library, which expects a count
(0 for EOF, and -1 for error).
Regards-
Kip
=================================================================
//
// read -- read bytes from the serial port. Ignore fd, since
// we only have stdin.
static int
sys_read(int fd, char *buf, int nbytes)
{
int i = 0;
#if 1
for (i = 0; i < nbytes; i++)
{
*(buf + i) = __getc();
if ((*(buf + i) == '\n') || (*(buf + i) == '\r'))
{
*(buf + i + 1) = 0;
return (i + 1); // return count one based
}
}
// post increment from loop leaves i++ thus one based here
*(buf + i + 1) = 0;
return (i);
#else
if (nbytes == 0) {
return(gets(buf,1,10));
}
for (i = 0; i < nbytes; i++) {
*(buf + i) = __getc();
if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
(*(buf + i + 1)) = 0;
break;
}
}
return (i);
#endif
}