IOSerialBSDClient.h [plain text]
#ifndef _IOSERIALSERVER_H
#define _IOSERIALSERVER_H
#include <IOKit/IOLib.h>
#include <IOKit/IOReturn.h>
#include <IOKit/IOTypes.h>
#include <IOKit/IOService.h>
#define TTY_DIALIN_INDEX 0
#define TTY_CALLOUT_INDEX 1
#define TTY_NUM_FLAGS 1
#define TTY_NUM_TYPES (1 << TTY_NUM_FLAGS)
class IOSerialStreamSync;
class IOSerialSessionSync;
class IOSerialBSDClient : public IOService
{
OSDeclareDefaultStructors(IOSerialBSDClient);
public:
virtual void free();
virtual bool start(IOService *provider);
virtual bool matchPropertyTable(OSDictionary *table);
virtual bool requestTerminate(IOService *provider, IOOptionBits options);
virtual bool didTerminate(IOService *provider, IOOptionBits options, bool *defer);
virtual IOReturn setProperties(OSObject *properties);
static struct cdevsw devsw;
private:
struct Session {
struct tty ftty;
struct termios fInitTerm;
void *fCDevNode;
IOSerialBSDClient *fThis;
int fErrno;
} fSessions[TTY_NUM_TYPES];
struct timeval fDTRDownTime;
struct timeval fLastUsedTime;
Session *fActiveSession;
IOThread frxThread; IOThread ftxThread;
dev_t fBaseDev;
int fInOpensPending;
thread_call_t fDCDThreadCall;
bool fPreemptAllowed;
bool fConnectTransit;
boolean_t fAcquired:1;
boolean_t fIsClosing:1;
boolean_t fDeferTerminate:1;
boolean_t fHasAuditSleeper:1;
boolean_t fKillThreads:1;
boolean_t fIstxEnabled:1;
boolean_t fIsrxEnabled:1;
boolean_t frxBlocked:1;
boolean_t fDCDTimerDue:1;
IOSerialStreamSync *fProvider;
int open(dev_t dev, int flags, int devtype, struct proc *p);
void close(dev_t dev, int flags, int devtype, struct proc *p);
void startConnectTransit();
void endConnectTransit();
void initSession(Session *sp);
bool waitOutDelay(void *event,
const struct timeval *start,
const struct timeval *duration);
int waitForIdle();
void preemptActive();
bool createDevNodes();
bool setBaseTypeForDev();
IOReturn setOneProperty(const OSSymbol *key, OSObject *value);
void optimiseInput(struct termios *t);
void convertFlowCtrl(Session *sp, struct termios *t);
virtual int mctl(u_int bits, int how);
void getData(Session *sp);
void procEvent(Session *sp);
void txload(Session *sp, u_long *wait_mask);
void rxFunc();
void txFunc();
void launchThreads();
void killThreads();
void cleanupResources();
IOReturn sessionSetState(Session *sp, UInt32 state, UInt32 mask);
UInt32 sessionGetState(Session *sp);
IOReturn sessionWatchState(Session *sp, UInt32 *state, UInt32 mask);
UInt32 sessionNextEvent(Session *sp);
IOReturn sessionExecuteEvent(Session *sp, UInt32 event, UInt32 data);
IOReturn sessionRequestEvent(Session *sp, UInt32 event, UInt32 *data);
IOReturn
sessionEnqueueEvent(Session *sp, UInt32 event, UInt32 data, bool sleep);
IOReturn sessionDequeueEvent
(Session *sp, UInt32 *event, UInt32 *data, bool sleep);
IOReturn sessionEnqueueData
(Session *sp, UInt8 *buffer, UInt32 size, UInt32 *count, bool sleep);
IOReturn sessionDequeueData
(Session *sp, UInt8 *buffer, UInt32 size, UInt32 *count, UInt32 min);
static int iossopen(dev_t dev, int flags, int devtype, struct proc *p);
static int iossclose(dev_t dev, int flags, int devtype, struct proc *p);
static int iossread(dev_t dev, struct uio *uio, int ioflag);
static int iosswrite(dev_t dev, struct uio *uio, int ioflag);
static int iossselect(dev_t dev, int which, void *wql, struct proc *p);
static int iossioctl(dev_t dev, u_long cmd, caddr_t data, int fflag,
struct proc *p);
static int iossstop(struct tty *tp, int rw);
static void iossstart(struct tty *tp); static int iossparam(struct tty *tp, struct termios *t);
static void iossdcddelay(thread_call_param_t vSelf, thread_call_param_t vSp);
};
#endif