--HG-- branch : dtrg-videocore rename : mach/powerpc/as/.distr => mach/vc4/as/.distr rename : mach/powerpc/as/mach0.c => mach/vc4/as/mach0.c rename : mach/powerpc/as/mach1.c => mach/vc4/as/mach1.c rename : mach/powerpc/as/mach2.c => mach/vc4/as/mach2.c rename : mach/powerpc/as/mach3.c => mach/vc4/as/mach3.c rename : mach/powerpc/as/mach4.c => mach/vc4/as/mach4.c rename : mach/powerpc/as/mach5.c => mach/vc4/as/mach5.c rename : mach/i86/build.mk => mach/vc4/build.mk rename : mach/powerpc/libem/powerpc.h => mach/vc4/libem/videocore.h rename : mach/i86/libend/.distr => mach/vc4/libend/.distr rename : mach/i86/libend/edata.s => mach/vc4/libend/edata.s rename : mach/i86/libend/em_end.s => mach/vc4/libend/em_end.s rename : mach/i86/libend/end.s => mach/vc4/libend/end.s rename : mach/i86/libend/etext.s => mach/vc4/libend/etext.s rename : mach/powerpc/ncg/.distr => mach/vc4/ncg/.distr rename : mach/powerpc/ncg/mach.c => mach/vc4/ncg/mach.c rename : mach/powerpc/ncg/mach.h => mach/vc4/ncg/mach.h rename : mach/powerpc/ncg/table => mach/vc4/ncg/table rename : plat/pc86/descr => plat/rpi/descr
		
			
				
	
	
		
			45 lines
		
	
	
	
		
			789 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
	
		
			789 B
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * Raspberry Pi support library for the ACK
 | |
|  * © 2013 David Given
 | |
|  * This file is redistributable under the terms of the 3-clause BSD license.
 | |
|  * See the file 'Copying' in the root of the distribution for the full text.
 | |
|  */
 | |
| 
 | |
| #include <stdlib.h>
 | |
| #include <errno.h>
 | |
| #include <unistd.h>
 | |
| #include "libsys.h"
 | |
| 
 | |
| int read(int fd, void* buffer, size_t count)
 | |
| {
 | |
| 	char i;
 | |
| 	
 | |
| 	/* We're only allowed to read from fd 0, 1 or 2. */
 | |
| 	
 | |
| 	if ((fd < 0) || (fd > 2))
 | |
| 	{
 | |
| 		errno = EBADF;
 | |
| 		return -1;
 | |
| 	}
 | |
| 	
 | |
| 	/* Empty buffer? */
 | |
| 	
 | |
| 	if (count == 0)
 | |
| 		return 0;
 | |
| 	
 | |
| 	/* Read one byte. */
 | |
| 	
 | |
| 	i = _sys_rawread();
 | |
| #if 0
 | |
| 	if ((i == '\r') && !(_sys_ttyflags & RAW)) 
 | |
| 		i = '\n';
 | |
| 	if (_sys_ttyflags & ECHO)
 | |
| 		_sys_write_tty(i);
 | |
| #endif
 | |
| 	if (i == '\r') 
 | |
| 		i = '\n';
 | |
| 	_sys_write_tty(i);
 | |
| 	
 | |
| 	*(char*)buffer = i;
 | |
| 	return 1;
 | |
| }
 |