[ECOS] XScale redboot sys_read()
McAtee, Kip
Kip.McAtee@SpirentCom.COM
Sat Oct 13 17:31:00 GMT 2001
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
}
More information about the Ecos-discuss
mailing list