XINU
Functions
ttycontrol.c File Reference
#include <xinu.h>
Include dependency graph for ttycontrol.c:

Go to the source code of this file.

Functions

devcall ttycontrol (struct dentry *devptr, int32 func, int32 arg1, int32 arg2)
 

Function Documentation

◆ ttycontrol()

devcall ttycontrol ( struct dentry devptr,
int32  func,
int32  arg1,
int32  arg2 
)

Definition at line 9 of file ttycontrol.c.

References dentry::dvminor, FALSE, OK, semcount(), signal(), SYSERR, TC_ECHO, TC_ICHARS, TC_MODEC, TC_MODEK, TC_MODER, TC_NEXTC, TC_NOECHO, TRUE, ttytab, TY_IMCBREAK, TY_IMCOOKED, TY_IMRAW, ttycblk::tyiecho, ttycblk::tyimode, ttycblk::tyisem, ttycblk::tyitail, and wait().

15 {
16  struct ttycblk *typtr; /* Pointer to tty control block */
17  char ch; /* Character for lookahead */
18 
19  typtr = &ttytab[devptr->dvminor];
20 
21  /* Process the request */
22 
23  switch ( func ) {
24 
25  case TC_NEXTC:
26  wait(typtr->tyisem);
27  ch = *typtr->tyitail;
28  signal(typtr->tyisem);
29  return (devcall)ch;
30 
31  case TC_MODER:
32  typtr->tyimode = TY_IMRAW;
33  return (devcall)OK;
34 
35  case TC_MODEC:
36  typtr->tyimode = TY_IMCOOKED;
37  return (devcall)OK;
38 
39  case TC_MODEK:
40  typtr->tyimode = TY_IMCBREAK;
41  return (devcall)OK;
42 
43  case TC_ICHARS:
44  return(semcount(typtr->tyisem));
45 
46  case TC_ECHO:
47  typtr->tyiecho = TRUE;
48  return (devcall)OK;
49 
50  case TC_NOECHO:
51  typtr->tyiecho = FALSE;
52  return (devcall)OK;
53 
54  default:
55  return (devcall)SYSERR;
56  }
57 }
syscall semcount(sid32)
セマフォのカウント値を返す。
Definition: semcount.c:18
#define TC_MODEC
Definition: tty.h:80
#define TC_ECHO
Definition: tty.h:83
#define TC_MODER
Definition: tty.h:79
bool8 tyiecho
Definition: tty.h:39
int32 dvminor
Definition: conf.h:8
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
#define TC_ICHARS
Definition: tty.h:82
#define TY_IMCBREAK
Definition: tty.h:23
#define OK
処理が成功した場合
Definition: kernel.h:77
#define TC_NEXTC
Definition: tty.h:78
#define TC_MODEK
Definition: tty.h:81
Definition: tty.h:26
#define FALSE
Boolean False(0)
Definition: kernel.h:63
#define TRUE
Boolean True(1)
Definition: kernel.h:65
struct ttycblk ttytab[]
Definition: ttyinit.c:11
#define TC_NOECHO
Definition: tty.h:84
char tyimode
Definition: tty.h:38
#define TY_IMCOOKED
Definition: tty.h:22
syscall wait(sid32)
Definition: wait.c:9
syscall signal(sid32)
セマフォにシグナルを送り、待機プロセスがある場合は解除する。
Definition: signal.c:18
int32 devcall
デバイスコール関数 返り値の型
Definition: kernel.h:49
sid32 tyisem
Definition: tty.h:30
#define TY_IMRAW
Definition: tty.h:21
char * tyitail
Definition: tty.h:28
Here is the call graph for this function: