Beispiel #1
0
const char *dm_getaddr( int fd )
{
	const DM_INSTANCE_DATA *pinst;

	// Find device, check write function
	pinst = dm_get_instance_at( DM_GET_DEVID( fd ) );
	if( !pinst || pinst->pdev->p_getaddr_r == NULL ) {
		_REENT->_errno = ENOSYS;
		return NULL;
	}

	return pinst->pdev->p_getaddr_r( _REENT, DM_GET_FD( fd ), pinst->pdata );
}
Beispiel #2
0
// *****************************************************************************
// _close_r
int _close_r( struct _reent *r, int file )
{
	const DM_INSTANCE_DATA *pinst;

	// Find device, check close function
	pinst = dm_get_instance_at( DM_GET_DEVID( file ) );
	if( pinst->pdev->p_close_r == NULL ) {
		r->_errno = ENOSYS;
		return -1;
	}

	// And call the close function
	return pinst->pdev->p_close_r( r, DM_GET_FD( file ), pinst->pdata );
}
Beispiel #3
0
// *****************************************************************************
// _write_r
_ssize_t _write_r( struct _reent *r, int file, const void *ptr, size_t len )
{
	const DM_INSTANCE_DATA *pinst;

	// Find device, check write function
	pinst = dm_get_instance_at( DM_GET_DEVID( file ) );
	if( pinst->pdev->p_write_r == NULL ) {
		r->_errno = ENOSYS;
		return -1;
	}

	// And call the write function
	return pinst->pdev->p_write_r( r, DM_GET_FD( file ), ptr, len, pinst->pdata );
}
Beispiel #4
0
const char* dm_getaddr( int fd )
{
  const DM_DEVICE* pdev;
  
  // Find device, check write function
  pdev = dm_get_device_at( DM_GET_DEVID( fd ) );
  if( !pdev || pdev->p_getaddr_r == NULL )
  {
    _REENT->_errno = ENOSYS;
    return NULL;
  }
  
  return pdev->p_getaddr_r( _REENT, DM_GET_FD( fd ) );
}
Beispiel #5
0
// *****************************************************************************
// _close_r
int _close_r( struct _reent *r, int file )
{
  const DM_DEVICE* pdev;
  
  // Find device, check close function
  pdev = dm_get_device_at( DM_GET_DEVID( file ) );
  if( pdev->p_close_r == NULL )
  {
    r->_errno = ENOSYS;
    return -1; 
  }
  
  // And call the close function
  return pdev->p_close_r( r, DM_GET_FD( file ) );
}
Beispiel #6
0
// *****************************************************************************
// _write_r 
_ssize_t _write_r( struct _reent *r, int file, const void *ptr, size_t len )
{
  const DM_DEVICE* pdev;
  
  // Find device, check write function
  pdev = dm_get_device_at( DM_GET_DEVID( file ) );
  if( pdev->p_write_r == NULL )
  {
    r->_errno = ENOSYS;
    return -1; 
  }
  
  // And call the write function
  return pdev->p_write_r( r, DM_GET_FD( file ), ptr, len );  
}
Beispiel #7
0
// *****************************************************************************
// ioctl (actually our call, not newlib's)
static int _ioctl_r( struct _reent *r, int file, unsigned long request, void *ptr )
{
  const DM_DEVICE* pdev;
  
  // Find device, check ioctl function
  pdev = dm_get_device_at( DM_GET_DEVID( file ) );
  if( pdev->p_ioctl_r == NULL )
  {
    r->_errno = ENOSYS;
    return -1; 
  }
  
  // And call the ioctl function
  return pdev->p_ioctl_r( r, DM_GET_FD( file ), request, ptr );  
}