#ifndef	IOBASE_H
#define	IOBASE_H

#include <../source/TAL/objbase.h>

/*
 *	I/O port object. This object can later be passed to
 *	fileXXXX routines (they just check the handle and then
 *	call member functions).
 *	This object used in numerous routines in VFS and PAL.
 */
typedef struct ioport_base_s
{
	/* Note: destroy() is in ancestor */
	libv_object_t base;
	/*	Character-dev and block-dev IO */
	u32_t	(V_CALL *read)(void *self,void *buf,u32_t len);
	u32_t	(V_CALL *write)(void *self,void *buf,u32_t len);
	/*	Block-dev IO only */
	u32_t	(V_CALL *seek)(void *self,s32_t offset,int whence);
	u32_t	(V_CALL *tell)(void *self);
	u32_t	(V_CALL *size)(void *self);
	/*	ioctl(); error condition must be signaled as != 0 */
	int		(V_CALL	*ioctl)(void *self,int code,void *parameters);
}	ioport_base_t, *ioport_base_p;

/*
**	Descendants' destructors need this for call of libvCloseHandle()
*/
#ifdef	CHECKED_BUILD
#define	IOPORT_MAGIC	0x46494C45			/* {'F','I','L','E'} */
#endif	/* CHECKED_BUILD */

#ifdef	__cplusplus
extern "C" {
#endif	/* __cplusplus */
	/*
     * ioAllocPort() - helper function, used internally by IO manager.
	 * It allocates memory for derived object (for example, file port) 
	 * and sets all methods except 'close()' in file->vtbl
     * to stubs; all stubs just print message 'method not supported'.
	 * Arguments:
	 *   'size_of_real_port' - size of descendant object.
	 */
	file_t	V_CALL	ioAllocPort(u32_t size_of_real_port);
#ifdef	__cplusplus
}
#endif	/* __cplusplus */

#endif	/* IOBASE_H */
