RTEMS CPU Kit with SuperCore  4.11.3
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
termiostypes.h File Reference

RTEMS termios device support internal data structures. More...

#include <rtems.h>
#include <rtems/libio.h>
#include <rtems/assoc.h>
#include <rtems/chain.h>
#include <stdint.h>
#include <termios.h>
Include dependency graph for termiostypes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ttywakeup
 
struct  rtems_termios_rawbuf
 
struct  rtems_termios_device_context
 Termios device context. More...
 
struct  rtems_termios_device_handler
 Termios device handler. More...
 
struct  rtems_termios_device_flow
 Termios device flow control handler. More...
 
struct  rtems_termios_device_node
 Termios device node for installed devices. More...
 
struct  rtems_termios_tty
 
struct  rtems_termios_linesw
 

Macros

#define RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER(name)   { RTEMS_INTERRUPT_LOCK_INITIALIZER( name ) }
 Initializer for static initialization of Termios device contexts. More...
 
#define TTYDISC   0 /* termios tty line discipline */
 
#define TABLDISC   3 /* tablet discipline */
 
#define SLIPDISC   4 /* serial IP discipline */
 
#define PPPDISC   5 /* PPP discipline */
 
#define MAXLDISC   8
 

Typedefs

typedef struct rtems_termios_device_context rtems_termios_device_context
 Termios device context. More...
 
typedef struct rtems_termios_device_node rtems_termios_device_node
 Termios device node for installed devices. More...
 
typedef struct rtems_termios_tty rtems_termios_tty
 
typedef uint32_t rtems_termios_baud_t
 

Enumerations

enum  rtems_termios_device_mode { TERMIOS_POLLED, TERMIOS_IRQ_DRIVEN, TERMIOS_TASK_DRIVEN }
 

Functions

RTEMS_INLINE_ROUTINE void rtems_termios_device_context_initialize (rtems_termios_device_context *context, const char *name)
 Initializes a device context. More...
 
rtems_status_code rtems_termios_device_install (const char *device_file, rtems_device_major_number major, rtems_device_minor_number minor, const rtems_termios_device_handler *handler, const rtems_termios_device_flow *flow, rtems_termios_device_context *context)
 Installs a Termios device. More...
 
rtems_status_code rtems_termios_device_remove (const char *device_file, rtems_device_major_number major, rtems_device_minor_number minor)
 Removes a Termios device. More...
 
rtems_status_code rtems_termios_device_open (rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 Opens an installed Termios device. More...
 
rtems_status_code rtems_termios_device_close (void *arg)
 Closes an installed Termios device. More...
 
RTEMS_INLINE_ROUTINE void * rtems_termios_get_device_context (const rtems_termios_tty *tty)
 Returns the device context of an installed Termios device. More...
 
RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_acquire (rtems_termios_device_context *context, rtems_interrupt_lock_context *lock_context)
 Acquires the device lock. More...
 
RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_release (rtems_termios_device_context *context, rtems_interrupt_lock_context *lock_context)
 Releases the device lock. More...
 
void rtems_termios_set_best_baud (struct termios *term, uint32_t baud)
 Sets the best baud value in the Termios control. More...
 
void rtems_termios_rxirq_occured (struct rtems_termios_tty *tty)
 
void rtems_termios_puts (const void *buf, size_t len, struct rtems_termios_tty *tty)
 
tcflag_t rtems_termios_number_to_baud (rtems_termios_baud_t baud)
 Converts the Integral Baud value baud to the Termios Control Flag Representation. More...
 
rtems_termios_baud_t rtems_termios_baud_to_number (tcflag_t c_cflag)
 Convert Baud Part of Termios control flags to an integral Baud Value. More...
 
int rtems_termios_baud_to_index (rtems_termios_baud_t termios_baud)
 Convert Bxxx Constant to Index.
 
int rtems_termios_set_initial_baud (struct rtems_termios_tty *tty, rtems_termios_baud_t baud)
 Sets the initial baud in the Termios context tty. More...
 

Variables

struct rtems_termios_linesw rtems_termios_linesw []
 
int rtems_termios_nlinesw
 
const rtems_assoc_t rtems_termios_baud_table []
 RTEMS Termios Baud Table.
 

Detailed Description

RTEMS termios device support internal data structures.

Macro Definition Documentation

◆ RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER

#define RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER (   name)    { RTEMS_INTERRUPT_LOCK_INITIALIZER( name ) }

Initializer for static initialization of Termios device contexts.

Parameters
nameThe name for the interrupt lock. It must be a string. The name is only used if profiling is enabled.

Typedef Documentation

◆ rtems_termios_device_context

◆ rtems_termios_device_node

Termios device node for installed devices.

See also
rtems_termios_device_install().

Function Documentation

◆ rtems_termios_baud_to_number()

rtems_termios_baud_t rtems_termios_baud_to_number ( tcflag_t  c_cflag)

Convert Baud Part of Termios control flags to an integral Baud Value.

There is no need to mask the c_cflag with CBAUD.

Return values
0Invalid baud value or a baud value of B0.
otherIntegral baud value.

◆ rtems_termios_device_close()

rtems_status_code rtems_termios_device_close ( void *  arg)

Closes an installed Termios device.

Return values
RTEMS_SUCCESSFULSuccessful operation.
See also
rtems_termios_device_install().

References rtems_fatal_error_occurred(), RTEMS_NO_TIMEOUT, rtems_semaphore_obtain(), RTEMS_SUCCESSFUL, and RTEMS_WAIT.

◆ rtems_termios_device_context_initialize()

RTEMS_INLINE_ROUTINE void rtems_termios_device_context_initialize ( rtems_termios_device_context context,
const char *  name 
)

Initializes a device context.

Parameters
[in]contextThe Termios device context.
[in]nameThe name for the interrupt lock. This name must be a string persistent throughout the life time of this lock. The name is only used if profiling is enabled.

References rtems_interrupt_lock_initialize.

◆ rtems_termios_device_install()

rtems_status_code rtems_termios_device_install ( const char *  device_file,
rtems_device_major_number  major,
rtems_device_minor_number  minor,
const rtems_termios_device_handler handler,
const rtems_termios_device_flow flow,
rtems_termios_device_context context 
)

Installs a Termios device.

Parameters
[in]device_fileIf not NULL, then a device file for the specified major and minor number will be created.
[in]majorThe device major number of the corresponding device driver.
[in]minorThe device minor number of the corresponding device driver.
[in]handlerThe device handler. It must be persistent throughout the installed time of the device.
[in]flowThe device flow control handler. The device flow control handler are optional and may be NULL. If present must be persistent throughout the installed time of the device.
[in]contextThe device context. It must be persistent throughout the installed time of the device.
Return values
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_NO_MEMORYNot enough memory to create a device node.
RTEMS_UNSATISFIEDCreation of the device file failed.
RTEMS_RESOURCE_IN_USEThere exists a device node for this major and minor number pair.
RTEMS_INCORRECT_STATETermios is not initialized.
See also
rtems_termios_device_remove(), rtems_termios_device_open(), rtems_termios_device_close() and rtems_termios_get_device_context().

◆ rtems_termios_device_lock_acquire()

RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_acquire ( rtems_termios_device_context context,
rtems_interrupt_lock_context lock_context 
)

Acquires the device lock.

Parameters
[in]contextThe device context.
[in]lock_contextThe local interrupt lock context for an acquire and release pair.

References rtems_interrupt_lock_acquire.

◆ rtems_termios_device_lock_release()

RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_release ( rtems_termios_device_context context,
rtems_interrupt_lock_context lock_context 
)

Releases the device lock.

Parameters
[in]contextThe device context.
[in]lock_contextThe local interrupt lock context for an acquire and release pair.

References rtems_interrupt_lock_release, and rtems_termios_set_best_baud().

◆ rtems_termios_device_open()

rtems_status_code rtems_termios_device_open ( rtems_device_major_number  major,
rtems_device_minor_number  minor,
void *  arg 
)

◆ rtems_termios_device_remove()

rtems_status_code rtems_termios_device_remove ( const char *  device_file,
rtems_device_major_number  major,
rtems_device_minor_number  minor 
)

Removes a Termios device.

Parameters
[in]device_fileIf not NULL, then the device file to remove.
[in]majorThe device major number of the corresponding device driver.
[in]minorThe device minor number of the corresponding device driver.
Return values
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_INVALID_IDThere is no device installed with this major and minor number pair.
RTEMS_RESOURCE_IN_USEThis device is currently in use.
RTEMS_UNSATISFIEDRemoval of the device file failed.
RTEMS_INCORRECT_STATETermios is not initialized.
See also
rtems_termios_device_install().

References rtems_termios_tty::device_node, RTEMS_INCORRECT_STATE, RTEMS_NO_TIMEOUT, rtems_semaphore_obtain(), RTEMS_SUCCESSFUL, and RTEMS_WAIT.

◆ rtems_termios_get_device_context()

RTEMS_INLINE_ROUTINE void* rtems_termios_get_device_context ( const rtems_termios_tty tty)

Returns the device context of an installed Termios device.

Parameters
[in]ttyThe Termios control.

References rtems_termios_tty::device_context.

◆ rtems_termios_number_to_baud()

tcflag_t rtems_termios_number_to_baud ( rtems_termios_baud_t  baud)

Converts the Integral Baud value baud to the Termios Control Flag Representation.

Return values
B0Invalid baud value or a baud value of 0.
otherBaud constant according to baud.

Referenced by rtems_termios_set_initial_baud().

◆ rtems_termios_set_best_baud()

void rtems_termios_set_best_baud ( struct termios term,
uint32_t  baud 
)

Sets the best baud value in the Termios control.

The valid Termios baud values are between 0 and 460800. The Termios baud value is chosen which minimizes the difference to the value specified.

Parameters
[in]termThe Termios attributes.
[in]baudThe current baud setting of the device.

References rtems_termios_baud_table.

Referenced by rtems_termios_device_lock_release().

◆ rtems_termios_set_initial_baud()

int rtems_termios_set_initial_baud ( struct rtems_termios_tty tty,
rtems_termios_baud_t  baud 
)

Sets the initial baud in the Termios context tty.

Return values
0Successful operation.
-1Invalid baud value.

References rtems_termios_number_to_baud().