ilowlevelio(3)
Section: Interp SDK (3)
Updated: 2009-08-23
NAME
ilowlevelio - encapsulates all target-specific I/O used by interp
SYNOPSIS
#include itypes.h
#include ilowlevelio.h
int get_eof( void );
iword map_memory( iword hardware_address, iword length );
int poll_input( void );
void start_time( iword * scratch1, iword * scratch2 );
iword calc_time( iword * scratch1, iword * scratch2 );
void wait_msec( iword wait_time );
ibyte get_char( void );
ibyte *get_input( ibyte * buf, iword max_index );
void put_string( ibyte * buf );
void put_char( ibyte ch );
void put_line( ibyte * buf );
DESCRIPTION
These functions are the I/O portability layer between interp and the hardware,
or host operating system (if there is one.)
Interp does not directly call any c library functions that read or write
from or to a hardware interface (STDOUT, STDIN, UART, et. al.)
LIST OF FUNCTIONS
- Function
-
Description
- get_eof
-
Returns non-zero if end-of-file (EOF) has been read from the host operating
system standard input (stdin.) For stand-alone (no OS) applications, or
for use with an operating system that does not support input redirection,
this function always returns zero.
- map_memory
-
Returns an address (>0) if the region of count bytes, beginning at
hardware_address can be mapped into system memory. The returned address is
the proxy address for the mapped hardware. A return value of -1 indicates
that the open of the memory driver (/dev/mem) failed. A return value of -2
indicates that the region failed to map. For stand-alone (no OS) applications,
or for use with a non-posix operating system, this function returns zero.
- poll_input
-
Returns true (-1) if input is waiting, or false (0) if not. For use with an
operating system that does not support input polling, this function
always returns zero.
- start_time
-
Initiates measurement of elapsed time. Pointers for two words of static storage
are passed for whatever use the implementation requires. The first argument
should be a pointer to system constant 26, the second to system constant 27.
- calc_time
-
Stop measuring elapsed time and return the elapsed time in microseconds.
The two arguments passed in are the same ones passed to start_time().
- wait_msec
-
Will wait at least
wait_time
milliseconds before returning.
- get_char
-
Returns the next character (byte) available from the input hardware.
If necessary, it waits for data to become available.
- get_input
-
Returns the next line of input (terminated by either a newline or carriage
return) as a zero-terminated string (without the carriage control characters)
in the buffer provided. It will not transfer more than
max_index
characters into the buffer. After which it will append the zero byte
to terminate the string. If necessary, it waits for data to become available.
It returns a pointer to the zero at the end of the string. This facilitates
multiple calls, overwriting the string terminator with the next string.
- put_string
-
Outputs a zero-terminated string of literal characters from the buffer
provided to the output hardware. Processing of escape character sequences is
not supported by this function. If carriage control, numeric string literals,
et. al. are needed please refer to the c library's
sprintf
family of functions. This function does not return until output is finished.
- put_char
-
Outputs one byte to the output hardware. This function does not return until
output is finished.
- put_line
-
Output a string of literal characters from the buffer provided.
Carriage control (newline) is automatically appended to the string.
This function is well suited to output of literal message strings that must
have a carriage return at their end. It does not return until output is
finished.
SEE ALSO
sprintf(3),
feof(3)