SPNU151W January 1998 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
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 |
Example7-2 does the following: