[Prev][Next][Index][Thread]

Re: gnumach2 & the serial port



Here is my second attempt.  If this interface is somewhat sane I start
to hack the needed wrapper code.

thanks,
daniel


/*
 * Copyright (c) 1997-1998,2002 University of Utah and the Flux Group.
 * All rights reserved.
 * @OSKIT-FLUX-GPLUS@
 */
/*
 * Definition of a COM interface to support basic serial streams
 */
#ifndef _OSKIT_IO_SERIALSTREAM_H_
#define _OSKIT_IO_SERIALSTREAM_H_

#include <oskit/com.h>
#include <oskit/types.h>
#include <oskit/com/stream.h>

/* XXX The naming scheme looks broken. */
#define OSKIT_IOSPEEDSET      0x001           /* Set the baud rate.  */
#define OSKIT_IOSPEEDGET      0x002           /* Get the baud rate.  */

#define	OSKIT_TIOCMSET	      0x001           /* Set all modem bits.  */
#define	OSKIT_TIOCMBIS	      0x002           /* BIS modem bits.  */
#define	OSKIT_TIOCMBIC	      0x003           /* BIC modem bits.  */
#define	OSKIT_TIOCMGET        0x004	      /* Get all modem bits.  */

#define OSKIT_TIOCM_LE        0x001
#define OSKIT_TIOCM_DTR       0x002
#define OSKIT_TIOCM_RTS       0x004
#define OSKIT_TIOCM_ST        0x008
#define OSKIT_TIOCM_SR        0x010
#define OSKIT_TIOCM_CTS       0x020
#define OSKIT_TIOCM_CAR       0x040
#define OSKIT_TIOCM_RNG       0x080
#define OSKIT_TIOCM_DSR       0x100
#define OSKIT_TIOCM_CD        OSKIT_TIOCM_CAR
#define OSKIT_TIOCM_RI        OSKIT_TIOCM_RNG


/*
 * Basic serial stream object interface,
 * IID 4aa700e-7c74-11cf-b500-08000953adc2.
 * This interface extends the oskit_file interface.
 */
struct oskit_serialstream {
  struct oskit_serialstream_ops *ops;
};
typedef struct oskit_serialstream oskit_serialstream_t;

struct oskit_serialstream_ops {

  /* COM-specified IUnknown interface operations */
  OSKIT_COMDECL_IUNKOWN(oskit_serialstream_t)
       
  /* Operations inherited from IStream interface */
  OSKIT_COMDECL	(*read)(oskit_serialstream_t *s, void *buf, oskit_u32_t len,
			oskit_u32_t *out_actual);
  OSKIT_COMDECL	(*write)( oskit_serialstream_t *s, const void *buf,
			 oskit_u32_t len, oskit_u32_t *out_actual);
  OSKIT_COMDECL	(*seek)(oskit_serialstream_t *s, oskit_s64_t ofs,
			oskit_seek_t whence, oskit_u64_t *out_newpos);
  OSKIT_COMDECL	(*setsize)(oskit_serialstream_t *s, oskit_u64_t new_size);
  OSKIT_COMDECL	(*copyto)(oskit_serialstream_t *s, oskit_serialstream_t *dst,
			  oskit_u64_t size,
			  oskit_u64_t *out_read,
			  oskit_u64_t *out_written);
  OSKIT_COMDECL	(*commit)(oskit_serialstream_t *s,
			  oskit_u32_t commit_flags);
  OSKIT_COMDECL	(*revert)(oskit_serialstream_t *s);
  OSKIT_COMDECL	(*lockregion)(oskit_serialstream_t *s,
			      oskit_u64_t offset, oskit_u64_t size,
			      oskit_u32_t lock_type);
  OSKIT_COMDECL	(*unlockregion)(oskit_serialstream_t *s,
				oskit_u64_t offset, oskit_u64_t size,
				oskit_u32_t lock_type);
  OSKIT_COMDECL	(*stat)(oskit_serialstream_t *s,
			oskit_stream_stat_t *out_stat,
			oskit_u32_t stat_flags);
  OSKIT_COMDECL	(*clone)(oskit_serialstream_t *s,
			 oskit_serialstream_t **out_stream);
  
  /* Serial device interface operations */
  OSKIT_COMDECL (*iospeed)(oskit_serialdev_t *dev, oskit_u32_t request, 
			   oskit_u32_t *speed);
  OSKIT_COMDECL (*ioctl)(oskit_serialdev_t *dev, oskit_u32_t request, 
			 char *arg);
};

/* GUID for oskit_serialstream interface */
extern const struct oskit_guid oskit_serialstream_iid;
#define OSKIT_SERIALSTREAM_IID OSKIT_GUID(0x0aa7d00e, 0x7c74, 0x11cf, \
                          0xb5, 0x00, 0x08, 0x00, 0x09, 0x53, 0xad, 0xc2)

#define oskit_serialstream_query(s, iid, out_ihandle) \
	((s)->ops->query((oskit_serialstream_t *)(s), (iid), (out_ihandle)))
#define oskit_serialstream_addref(s) \
	((s)->ops->addref((oskit_serialstream_t *)(s)))
#define oskit_serialstream_release(s) \
	((s)->ops->release((oskit_serialstream_t *)(s)))
#define oskit_serialstream_read(s, buf, len, out_actual) \
	((s)->ops->read((oskit_serialstream_t *)(s), (buf), (len), (out_actual)))
#define oskit_serialstream_write(s, buf, len, out_actual) \
	((s)->ops->write((oskit_serialstream_t *)(s), (buf), (len), (out_actual)))
#define oskit_serialstream_seek(s, ofs, whence, out_newpos) \
	((s)->ops->seek((oskit_serialstream_t *)(s), (ofs), (whence), (out_newpos)))
#define oskit_serialstream_setsize(s, new_size) \
	((s)->ops->setsize((oskit_serialstream_t *)(s), (new_size)))
#define oskit_serialstream_copyto(s, dst, size, out_read, out_written) \
	((s)->ops->copyto((oskit_serialstream_t *)(s), (dst), (size), (out_read), (out_written)))
#define oskit_serialstream_commit(s, commit_flags) \
	((s)->ops->commit((oskit_serialstream_t *)(s), (commit_flags)))
#define oskit_serialstream_revert(s) \
	((s)->ops->revert((oskit_serialstream_t *)(s)))
#define oskit_serialstream_lockregion(s, offset, size, lock_type) \
	((s)->ops->lockregion((oskit_serialstream_t *)(s), (offset), (size), (lock_type)))
#define oskit_serialstream_unlockregion(s, offset, size, lock_type) \
	((s)->ops->unlockregion((oskit_serialstream_t *)(s), (offset), (size), (lock_type)))
#define oskit_serialstream_stat(s, out_stat, stat_flags) \
	((s)->ops->stat((oskit_serialstream_t *)(s), (out_stat), (stat_flags)))
#define oskit_serialstream_clone(s, out_stream) \
	((s)->ops->clone((oskit_serialstream_t *)(s), (out_stream)))
#define oskit_serialstream_iospeed(s, request, speed) \
        ((s)->ops->ioctl((oskit_serialstream_t *)(s), (request), (speed)))
#define oskit_serialstream_ioctl(s, request, arg) \
        ((s)->ops->ioctl((oskit_serialstream_t *)(s), (request), (arg)))

#endif /* _OSKIT_IO_SERIALSTREAM_H_ */

References: