Difference between revisions of "TTY Driver"

From Embedded Xinu
Jump to navigation Jump to search
Line 1: Line 1:
[[Image:TtyUartInteraction.png|frame]]The TTY driver is built on top of the UART driver (or other TTY appropriate hardware).  The driver is responsible for sending and receiving character input between a user program level, such as the XINU [[Shell]], and a char-oriented hardware driver.  Line buffering and cooking are the two primary responsibilities for the new TTY driver.
+
[[Image:TtyUartInteraction.png|frame|Diagram of the interaction between hardware, UART driver, TTY driver, and user application.]]The TTY driver is built on top of the UART driver (or other TTY appropriate hardware).  The driver is responsible for sending and receiving character input between a user level application, such as the XINU [[Shell]], and a char-oriented hardware driver.  Line buffering and cooking are the two primary responsibilities for the new TTY driver.
  
 
== Conceptual structure ==
 
== Conceptual structure ==
Line 7: Line 7:
 
=== Initialize ===
 
=== Initialize ===
 
''This section needs updating''
 
''This section needs updating''
 +
 
=== Open ===
 
=== Open ===
''This section needs updating''
+
  struct tty *ttyAlloc(void)
 +
  DEVCALL ttyOpen(struct dentry *pdev, va_list ap)
 +
 
 +
Open associates a TTY with an underlying char-oriented hardware driver.  The underlying device should already be initialized.  A TTY is allocated from the available TTY devices and its circular buffers are initialized.
 +
 
 
=== Close ===
 
=== Close ===
''This section needs updating''
+
  DEVCALL ttyClose(struct dentry *pdev)
 +
 
 +
Close disasociates a TTY from its underlying device.  It also makes the TTY available to be allocated to other processes.
 +
 
 
=== Read ===
 
=== Read ===
 
''This section needs updating''
 
''This section needs updating''
 +
 
=== Write ===
 
=== Write ===
 
''This section needs updating''
 
''This section needs updating''
 +
 
=== Control ===
 
=== Control ===
 +
  DEVCALL ttyControl(struct dentry *pdev, int func, unsigned char arg1, unsigned char arg2)
 +
 +
  /* ttyControl() functions  */
 +
  #define TTY_IOC_SETIFLAG 0x0020  /* set input flags         */
 +
  #define TTY_IOC_CLRIFLAG 0x0021  /* clear input flags         */
 +
  #define TTY_IOC_GETIFLAG 0x0022  /* get input flags              */
 +
  #define TTY_IOC_SETOFLAG 0x0023  /* set output flags            */
 +
  #define TTY_IOC_CLROFLAG 0x0024  /* clear output flags          */
 +
  #define TTY_IOC_GETOFLAG 0x0025  /* get output flags            */
 +
  #define TTY_IOC_EOF            0x0026  /* check if EOF in input        */
 +
  #define TTY_IOC_CBREAK          0x0027  /* check if CBREAK in input    */
 +
 +
  /* TTY input flags */
 +
  #define TTY_IFLAG_RAW 0x0001  /* do raw input                */
 +
  #define TTY_IFLAG_ECHO         0x0002  /* echo input         */
 +
  #define TTY_IFLAG_CBREAK 0x0004  /* have seen Break (Control-C)  */
 +
  #define TTY_IFLAG_EOF 0x0008 /* have seen EOF (Control-D)    */
 +
  /* TTY output flags */
 +
  #define TTY_OFLAG_RAW 0x0001 /* do raw output */
 +
 
''This section needs updating''
 
''This section needs updating''
  

Revision as of 17:08, 20 June 2007

Diagram of the interaction between hardware, UART driver, TTY driver, and user application.

The TTY driver is built on top of the UART driver (or other TTY appropriate hardware). The driver is responsible for sending and receiving character input between a user level application, such as the XINU Shell, and a char-oriented hardware driver. Line buffering and cooking are the two primary responsibilities for the new TTY driver.

Conceptual structure

TtyDriver.png

Functionality

Initialize

This section needs updating

Open

 struct tty *ttyAlloc(void)
 DEVCALL ttyOpen(struct dentry *pdev, va_list ap)

Open associates a TTY with an underlying char-oriented hardware driver. The underlying device should already be initialized. A TTY is allocated from the available TTY devices and its circular buffers are initialized.

Close

 DEVCALL ttyClose(struct dentry *pdev)

Close disasociates a TTY from its underlying device. It also makes the TTY available to be allocated to other processes.

Read

This section needs updating

Write

This section needs updating

Control

 DEVCALL ttyControl(struct dentry *pdev, int func, unsigned char arg1, unsigned char arg2)
 /* ttyControl() functions  */
 #define	TTY_IOC_SETIFLAG	0x0020  /* set input flags	        */
 #define	TTY_IOC_CLRIFLAG	0x0021  /* clear input flags	        */
 #define	TTY_IOC_GETIFLAG	0x0022  /* get input flags              */
 #define	TTY_IOC_SETOFLAG	0x0023  /* set output flags             */
 #define	TTY_IOC_CLROFLAG	0x0024  /* clear output flags           */
 #define	TTY_IOC_GETOFLAG	0x0025  /* get output flags             */
 #define TTY_IOC_EOF             0x0026  /* check if EOF in input        */ 
 #define TTY_IOC_CBREAK          0x0027  /* check if CBREAK in input     */
 /* TTY input flags */
 #define	TTY_IFLAG_RAW		0x0001  /* do raw input                 */
 #define	TTY_IFLAG_ECHO	        0x0002  /* echo input		        */
 #define	TTY_IFLAG_CBREAK	0x0004  /* have seen Break (Control-C)  */
 #define	TTY_IFLAG_EOF		0x0008	/* have seen EOF (Control-D)    */
 /* TTY output flags */
 #define	TTY_OFLAG_RAW		0x0001	/* do raw output		*/

This section needs updating

See also