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

Re: gnumach2 & the serial port



> for a low-level interface.  My thinking is to come up with a reasonable
> oskit interface for serial ports with modem control (layered on top of the
> trivial streamdev, but different from ttydev).  

I finally managed to get the sio driver from freebsd working with the
gnumach kernel.  Was quite tricky to find the problems and the code is
more or less a hack.  To fix the last we defently need a such a
interface.  Here is my (first) attempt to such an interface.  Of
course some more glue code is needed for this interface.

daniel


/*
 * Copyright (c) 1997-1998,2002 University of Utah and the Flux Group.
 * All rights reserved.
 * @OSKIT-FLUX-GPLUS@
 */
/*
 * Definition of the oskit_serialdev interface representing
 * stream devices.
 */
#ifndef _OSKIT_DEV_SERIALDEV_H_
#define _OSKIT_DEV_SERIALDEV_H_

#include <oskit/dev/stream.h>


/*
 * Standard serail device node interface, derived from oskit_streamdev_t,
 * IID 4aa7dfa6-7c74-11cf-b500-08000953adc2.
 */
struct oskit_serialdev
{
	struct oskit_serialdev_ops *ops;
};
typedef struct oskit_serialdev oskit_serialdev_t;

struct oskit_serialdev_ops
{
	/* COM-specified IUnknown interface operations */
	OSKIT_COMDECL_IUNKNOWN(oskit_serialdev_t)

	/* Base fdev device interface operations */
	OSKIT_COMDECL	(*getinfo)(oskit_serialdev_t *fdev,
				   oskit_devinfo_t *out_info);
	OSKIT_COMDECL	(*getdriver)(oskit_serialdev_t *fdev,
				     oskit_driver_t **out_driver);

	/* Stream device interface operations */
	OSKIT_COMDECL	(*open)(oskit_serialdev_t *dev, oskit_u32_t flags,
				struct oskit_stream **out_stream);

	/* Serial device interface operations */
	OSKIT_COMDECL   (*set_speed)(oskit_serialdev_t *dev, oskit_u32_t speed);
	OSKIT_COMDECL   (*get_speed)(oskit_serialdev_t *dev, oskit_u32_t *speed);
	OSKIT_COMDECL   (*enable_rts)(oskit_serialdev_t *dev);
	OSKIT_COMDECL   (*disable_rts)(oskit_serialdev_t *dev);
	OSKIT_COMDECL   (*read_rts)(oskit_serialdev_t *dev, oskit_u32_t *rts);
	OSKIT_COMDECL   (*read_cts)(oskit_serialdev_t *dev);
	OSKIT_COMDECL   (*read_dsr)(oskit_serialdev_t *dev, oskit_u32_t *dsr);
	OSKIT_COMDECL   (*enable_dtr)(oskit_serialdev_t *dev);
	OSKIT_COMDECL   (*disable_dtr)(oskit_serialdev_t *dev);
	OSKIT_COMDECL   (*read_dtr)(oskit_serialdev_t *dev);
};

/* GUID for fdev block device interface */
extern const struct oskit_guid oskit_serialdev_iid;
#define OSKIT_SERIALDEV_IID OSKIT_GUID(0x4aa700d, 0x7c74, 0x11cf, \
		0xb5, 0x00, 0x08, 0x00, 0x09, 0x53, 0xad, 0xc2)

#define oskit_serialdev_query(dev, iid, out_ihandle) \
	((dev)->ops->query((oskit_serialdev_t *)(dev), (iid), (out_ihandle)))
#define oskit_serialdev_addref(dev) \
	((dev)->ops->addref((oskit_serialdev_t *)(dev)))
#define oskit_serialdev_release(dev) \
	((dev)->ops->release((oskit_serialdev_t *)(dev)))
#define oskit_serialdev_getinfo(fdev, out_info) \
	((fdev)->ops->getinfo((oskit_serialdev_t *)(fdev), (out_info)))
#define oskit_serialdev_getdriver(fdev, out_driver) \
	((fdev)->ops->getdriver((oskit_serialdev_t *)(fdev), (out_driver)))
#define oskit_serialdev_open(dev, flags, out_stream) \
	((dev)->ops->open((oskit_serialdev_t *)(dev), (flags), (out_stream)))
#define oskit_serialdev_get_speed(dev, speed) \
	((dev)->ops->get_speed((oskit_serialdev_t *)(dev), (speed)))
#define oskit_serialdev_set_speed(dev, speed) \
	((dev)->ops->set_speed((oskit_serialdev_t *)(dev), (speed)))
#define oskit_serialdev_enable_rts(dev) \
	((dev)->ops->enable_rts((oskit_serialdev_t *)(dev)))
#define oskit_serialdev_disable_rts(dev) \
	((dev)->ops->disable_rts((oskit_serialdev_t *)(dev)))
#define oskit_serialdev_read_rts(dev, rts) \
	((dev)->ops->read_rts((oskit_serialdev_t *)(dev), (rts)))
#define oskit_serialdev_read_cts(dev, cts) \
	((dev)->ops->read_cts((oskit_serialdev_t *)(dev), (cts)))
#define oskit_serialdev_read_dsr(dev, dsr) \
	((dev)->ops->read_dsr((oskit_serialdev_t *)(dev), (dsr)))
#define oskit_serialdev_enable_dtr(dev) \
	((dev)->ops->enable_dtr((oskit_serialdev_t *)(dev)))
#define oskit_serialdev_disable_dtr(dev) \
	((dev)->ops->disable_dtr((oskit_serialdev_t *)(dev)))
#define oskit_serialdev_read_dtr(dev, dtr) \
	((dev)->ops->read_dtr((oskit_serialdev_t *)(dev), (dtr)))

#endif /* _OSKIT_DEV_SERIALDEV_H_ */

Follow-Ups: