XINU
ttycontrol.c
Go to the documentation of this file.
1 /* ttycontrol.c - ttycontrol */
2 
3 #include <xinu.h>
4 
5 /*------------------------------------------------------------------------
6  * ttycontrol - Control a tty device by setting modes
7  *------------------------------------------------------------------------
8  */
10  struct dentry *devptr, /* Entry in device switch table */
11  int32 func, /* Function to perform */
12  int32 arg1, /* Argument 1 for request */
13  int32 arg2 /* Argument 2 for request */
14  )
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
devcall ttycontrol(struct dentry *devptr, int32 func, int32 arg1, int32 arg2)
Definition: ttycontrol.c:9
#define TC_MODEK
Definition: tty.h:81
Definition: conf.h:6
Definition: tty.h:26
#define FALSE
Boolean False(0)
Definition: kernel.h:63
#define TRUE
Boolean True(1)
Definition: kernel.h:65
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
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