📄 serialio.h
字号:
* error, and then the call to DOWN_READ returns byte 5 alone. A * subsequent call to DOWN_READ returns bytes 6-9. The upper layer * continues to call DOWN_READ until 0 is returned, or until it runs out * of buffer space to receive the chars. */#define DOWN_READ(p, buf, len) \ ((p)->sio_calldown->down_read(p, buf, len))/* Turn on/off event notification for the specified events. Notification * status is unchanged for those events not specified. */#define DOWN_NOTIFICATION(p, mask, on) \ ((p)->sio_calldown->down_notification(p, mask, on))/* Notification types. 1 per upcall. The upper layer can specify * exactly which upcalls it wishes to receive. UP_DETACH is mandatory * when applicable and cannot be enabled/disabled. */#define N_DATA_READY 0x01#define N_OUTPUT_LOWAT 0x02#define N_BREAK 0x04#define N_PARITY_ERROR 0x08#define N_FRAMING_ERROR 0x10#define N_OVERRUN_ERROR 0x20#define N_DDCD 0x40#define N_DCTS 0x80#define N_ALL_INPUT (N_DATA_READY | N_BREAK | \ N_PARITY_ERROR | N_FRAMING_ERROR | \ N_OVERRUN_ERROR | N_DDCD | N_DCTS)#define N_ALL_OUTPUT N_OUTPUT_LOWAT#define N_ALL_ERRORS (N_PARITY_ERROR | N_FRAMING_ERROR | N_OVERRUN_ERROR)#define N_ALL (N_DATA_READY | N_OUTPUT_LOWAT | N_BREAK | \ N_PARITY_ERROR | N_FRAMING_ERROR | \ N_OVERRUN_ERROR | N_DDCD | N_DCTS)/* Instruct the lower layer that the upper layer would like to be * notified every t ticks when data is being received. If data is * streaming in, the lower layer should buffer enough data that * notification is not required more often than requested, and set a * timeout so that notification does not occur less often than * requested. If the lower layer does not support such operations, it * should return 1, indicating that the upper layer should emulate these * functions in software. */#define DOWN_RX_TIMEOUT(p, t) \ ((p)->sio_calldown->down_rx_timeout(p, t))/* Set the output value of DTR */#define DOWN_SET_DTR(p, dtr) \ ((p)->sio_calldown->down_set_DTR(p, dtr))/* Set the output value of RTS */#define DOWN_SET_RTS(p, rts) \ ((p)->sio_calldown->down_set_RTS(p, rts))/* Query current input value of DCD */#define DOWN_QUERY_DCD(p) \ ((p)->sio_calldown->down_query_DCD(p))/* Query current input value of CTS */#define DOWN_QUERY_CTS(p) \ ((p)->sio_calldown->down_query_CTS(p))/* Set transmission protocol */#define DOWN_SET_PROTOCOL(p, proto) \ ((p)->sio_calldown->down_set_protocol(p, proto))/* Query mapped interface type */#define DOWN_GET_MAPID(p, arg) \ ((p)->sio_calldown->down_mapid(p, arg))/* Perform mapping to user address space */#define DOWN_MAP(p, vt, off) \ ((p)->sio_calldown->down_map(p, vt, off))/* Cleanup after mapped port is closed */#define DOWN_UNMAP(p) \ ((p)->sio_calldown->down_unmap(p))/* Set/Reset ioc3 sscr register */#define DOWN_SET_SSCR(p, arg, flag) \ ((p)->sio_calldown->down_set_sscr(p, arg, flag))/* The callup struct. This is a set of entry points providing * black-box access to the upper level kernel interface by the * hardware handling code. These entry points are used for event * notification */struct serial_callup { void (*up_data_ready) (sioport_t *port); void (*up_output_lowat) (sioport_t *port); void (*up_ncs) (sioport_t *port, int ncs); void (*up_dDCD) (sioport_t *port, int dcd); void (*up_dCTS) (sioport_t *port, int cts); void (*up_detach) (sioport_t *port);};/* * Macros used by the lower layer to access the upper layer for event * notificaiton. These functions are generally called in response to * an interrupt. Since the port lock may be released across UP calls, * we must check the callup vector each time. However since the port * lock is held during DOWN calls (from which these UP calls are made) * there is no danger of the sio_callup vector being cleared between * where it is checked and where it is used in the macro *//* Notify the upper layer that there are input bytes available and * DOWN_READ may now be called */#define UP_DATA_READY(p) \ ((p)->sio_callup ? (p)->sio_callup->up_data_ready(p):(void)0)/* Notify the upper layer that the lower layer has freed up some * output buffer space and DOWN_WRITE may now be called */#define UP_OUTPUT_LOWAT(p) \ ((p)->sio_callup ? (p)->sio_callup->up_output_lowat(p):(void)0)/* Notify the upper layer that the next char returned by DOWN_READ * has the indicated special status. (see NCS_* above) */#define UP_NCS(p, ncs) \ ((p)->sio_callup ? (p)->sio_callup->up_ncs(p, ncs):(void)0)/* Notify the upper layer of the new DCD input value */#define UP_DDCD(p, dcd) \ ((p)->sio_callup ? (p)->sio_callup->up_dDCD(p, dcd):(void)0)/* Notify the upper layer of the new CTS input value */#define UP_DCTS(p, cts) \ ((p)->sio_callup ? (p)->sio_callup->up_dCTS(p, cts):(void)0)/* notify the upper layer that the lower layer hardware has been detached * Since the port lock is NOT held when this macro is executed, we must * guard against the sio_callup vector being cleared between when we check * it and when we make the upcall, so we use a local copy. */#define UP_DETACH(p) \{ \ struct serial_callup *up; \ if ((up = (p)->sio_callup)) \ up->up_detach(p); \}/* Port locking protocol: * Any time a DOWN call is made into one of the lower layer entry points, * the corresponding port is already locked and remains locked throughout * that downcall. When a lower layer routine makes an UP call, the port * is assumed to be locked on entry to the upper layer routine, but the * upper layer routine may release and reacquire the lock if it wishes. * Thus the lower layer routine should not rely on the port lock being * held across upcalls. Further, since the port may be disconnected * any time the port lock is not held, an UP call may cause subsequent * UP calls to become noops since the upcall vector will be zeroed when * the port is closed. Thus, any lower layer routine making UP calls must * be prepared to deal with the possibility that any UP calls it makes * are noops. * * The only time a lower layer routine should manipulate the port lock * is the lower layer interrupt handler, which should acquire the lock * during its critical execution. * * Any function which assumes that the port is or isn't locked should * use the function sio_port_islocked in an ASSERT statement to verify * this assumption */#if DEBUGextern int sio_port_islocked(sioport_t *);#endif#define SIO_LOCK_PORT(port, flags) spin_lock_irqsave(&port->sio_lock, flags)#define SIO_UNLOCK_PORT(port, flags) spin_unlock_irqrestore(&port->sio_lock, flags)/* kernel debugger support */#ifdef _LANGUAGE_Cextern int console_is_tport;#define CNTRL_A '\001'#if DEBUG#ifndef DEBUG_CHAR#define DEBUG_CHAR CNTRL_A#endif#else#define DEBUG_CHAR CNTRL_A#endif#endifextern void ioc4_serial_initport(sioport_t *, int);/* flags to notify sio_initport() which type of nodes are * desired for a particular hardware type */#define NODE_TYPE_D 0x01 /* standard plain streams interface */#define NODE_TYPE_MODEM 0x02 /* modem streams interface */#define NODE_TYPE_FLOW_MODEM 0x04 /* modem/flow control streams */#define NODE_TYPE_CHAR 0x08 /* character interface */#define NODE_TYPE_MIDI 0x10 /* midi interface */#define NODE_TYPE_D_RS422 0x20 /* RS422 without flow control */#define NODE_TYPE_FLOW_RS422 0x40 /* RS422 with flow control */#define NODE_TYPE_USER 0x80 /* user mapped interface */#define NODE_TYPE_TIMESTAMPED 0x100 /* user mapped interface */#define NODE_TYPE_ALL_RS232 (NODE_TYPE_D | NODE_TYPE_MODEM | \ NODE_TYPE_FLOW_MODEM | NODE_TYPE_CHAR | \ NODE_TYPE_MIDI | NODE_TYPE_TIMESTAMPED)#define NODE_TYPE_ALL_RS422 (NODE_TYPE_D_RS422 | NODE_TYPE_FLOW_RS422 | \ NODE_TYPE_TIMESTAMPED)/* Flags for devflags field of miditype structure */#define MIDIDEV_EXTERNAL 0 /* lower half initializes devflags to this for an external device */#define MIDIDEV_INTERNAL 0x2#define MIDIDEV_UNREGISTERED -1 /* Initialization for portidx field of miditype structure */typedef struct miditype_s{ int devflags; /* DEV_EXTERNAL, DEV_INTERNAL */ int portidx; void *midi_upper; sioport_t *port;} miditype_t;typedef struct tsiotype_s{ void *tsio_upper; sioport_t *port; int portidx; int urbidx;} tsiotype_t;#endif /* _ASM_IA64_SN_SERIALIO_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -