github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/termios/var_unix.go (about)

     1  // Copyright 2015-2017 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build !plan9
     6  
     7  package termios
     8  
     9  import (
    10  	"syscall"
    11  
    12  	"golang.org/x/sys/unix"
    13  )
    14  
    15  // Termios is a struct for Termios operations.
    16  type Termios struct {
    17  	*unix.Termios
    18  }
    19  
    20  type bit struct {
    21  	word int
    22  	mask uint32
    23  }
    24  
    25  var (
    26  	boolFields = map[string]*bit{
    27  		// Input processing
    28  		"ignbrk":  {word: I, mask: syscall.IGNBRK},
    29  		"brkint":  {word: I, mask: syscall.BRKINT},
    30  		"ignpar":  {word: I, mask: syscall.IGNPAR},
    31  		"parmrk":  {word: I, mask: syscall.PARMRK},
    32  		"inpck":   {word: I, mask: syscall.INPCK},
    33  		"istrip":  {word: I, mask: syscall.ISTRIP},
    34  		"inlcr":   {word: I, mask: syscall.INLCR},
    35  		"igncr":   {word: I, mask: syscall.IGNCR},
    36  		"icrnl":   {word: I, mask: syscall.ICRNL},
    37  		"iuclc":   {word: I, mask: syscall.IUCLC},
    38  		"ixon":    {word: I, mask: syscall.IXON},
    39  		"ixany":   {word: I, mask: syscall.IXANY},
    40  		"ixoff":   {word: I, mask: syscall.IXOFF},
    41  		"imaxbel": {word: I, mask: syscall.IMAXBEL},
    42  		"iutf8":   {word: I, mask: syscall.IUTF8},
    43  
    44  		//Outputprocessing
    45  		"opost":  {word: O, mask: syscall.OPOST},
    46  		"olcuc":  {word: O, mask: syscall.OLCUC},
    47  		"onlcr":  {word: O, mask: syscall.ONLCR},
    48  		"ocrnl":  {word: O, mask: syscall.OCRNL},
    49  		"onocr":  {word: O, mask: syscall.ONOCR},
    50  		"onlret": {word: O, mask: syscall.ONLRET},
    51  		"ofill":  {word: O, mask: syscall.OFILL},
    52  		"ofdel":  {word: O, mask: syscall.OFDEL},
    53  
    54  		//Localprocessing
    55  		"isig":    {word: L, mask: syscall.ISIG},
    56  		"icanon":  {word: L, mask: syscall.ICANON},
    57  		"xcase":   {word: L, mask: syscall.XCASE},
    58  		"echo":    {word: L, mask: syscall.ECHO},
    59  		"echoe":   {word: L, mask: syscall.ECHOE},
    60  		"echok":   {word: L, mask: syscall.ECHOK},
    61  		"echonl":  {word: L, mask: syscall.ECHONL},
    62  		"noflsh":  {word: L, mask: syscall.NOFLSH},
    63  		"tostop":  {word: L, mask: syscall.TOSTOP},
    64  		"echoctl": {word: L, mask: syscall.ECHOCTL},
    65  		"echoprt": {word: L, mask: syscall.ECHOPRT},
    66  		"echoke":  {word: L, mask: syscall.ECHOKE},
    67  		"flusho":  {word: L, mask: syscall.FLUSHO},
    68  		"pendin":  {word: L, mask: syscall.PENDIN},
    69  		"iexten":  {word: L, mask: syscall.IEXTEN},
    70  
    71  		//Controlprocessing
    72  
    73  		"cstopb": {word: C, mask: syscall.CSTOPB},
    74  		"cread":  {word: C, mask: syscall.CREAD},
    75  		"parenb": {word: C, mask: syscall.PARENB},
    76  		"parodd": {word: C, mask: syscall.PARODD},
    77  		"hupcl":  {word: C, mask: syscall.HUPCL},
    78  		"clocal": {word: C, mask: syscall.CLOCAL},
    79  	}
    80  	cc = map[string]int{
    81  		"min":   5,
    82  		"time":  0,
    83  		"lnext": syscall.VLNEXT,
    84  		//"flush": syscall.VFLUSH,
    85  		"intr":  syscall.VINTR,
    86  		"quit":  syscall.VQUIT,
    87  		"erase": syscall.VERASE,
    88  		"kill":  syscall.VKILL,
    89  		"eof":   syscall.VEOF,
    90  		"eol":   syscall.VEOL,
    91  		"eol2":  syscall.VEOL2,
    92  		//"swtch": syscall.VSWTCH,
    93  		"start": syscall.VSTART,
    94  		"stop":  syscall.VSTOP,
    95  		"susp":  syscall.VSUSP,
    96  		//"rprnt": syscall.VRPRNT,
    97  		"werase": syscall.VWERASE,
    98  	}
    99  )
   100  
   101  // These consts describe the offsets into the termios struct of various elements.
   102  const (
   103  	I = iota // Input control
   104  	O        // Output control
   105  	C        // Control
   106  	L        // Line control
   107  )
   108  
   109  var (
   110  	// baud2unixB convert a baudrate to the corresponding unix const.
   111  	baud2unixB = map[int]uint32{
   112  		50:      unix.B50,
   113  		75:      unix.B75,
   114  		110:     unix.B110,
   115  		134:     unix.B134,
   116  		150:     unix.B150,
   117  		200:     unix.B200,
   118  		300:     unix.B300,
   119  		600:     unix.B600,
   120  		1200:    unix.B1200,
   121  		1800:    unix.B1800,
   122  		2400:    unix.B2400,
   123  		4800:    unix.B4800,
   124  		9600:    unix.B9600,
   125  		19200:   unix.B19200,
   126  		38400:   unix.B38400,
   127  		57600:   unix.B57600,
   128  		115200:  unix.B115200,
   129  		230400:  unix.B230400,
   130  		460800:  unix.B460800,
   131  		500000:  unix.B500000,
   132  		576000:  unix.B576000,
   133  		921600:  unix.B921600,
   134  		1000000: unix.B1000000,
   135  		1152000: unix.B1152000,
   136  		1500000: unix.B1500000,
   137  		2000000: unix.B2000000,
   138  		2500000: unix.B2500000,
   139  		3000000: unix.B3000000,
   140  		3500000: unix.B3500000,
   141  		4000000: unix.B4000000,
   142  	}
   143  )