SLAU132Y September 2004 – June 2021
Add Device to Device Table
#include <file.h>
int add_device(char *
name,
unsigned
flags
,
int (*
dopen)(const char *path, unsigned
flags, int llv_fd),
int (*
dclose
)( int dev_fd),
int (*
dread)(intdev_fd, char *buf, unsigned
count),
int (*
dwrite
)(int
dev_fd, const char *buf, unsigned
count),
off_t (*
dlseek
)(int dev_fd, off_t
ioffset, int
origin),
int (*
dunlink
)(const char *path),
int (*
drename
)(const char *old_name, const char
*new_name));
lowlev.c (in the lib/src subdirectory of the compiler installation)
The add_device function adds a device record to the device table allowing that device to be used for I/O from C. The first entry in the device table is predefined to be the HOST device on which the debugger is running. The function add_device() finds the first empty position in the device table and initializes the fields of the structure that represent a device.
To open a stream on a newly added device use fopen( ) with a string of the format devicename :filename as the first argument.
_SSA Denotes that the device supports only one open stream at a time
_MSA Denotes that the device supports multiple open streams
More flags can be added by defining them in file.h.
The function returns one of the following values:
0 | if successful |
-1 | on failure |
Section 8.3.5.1 does the following: