XINU
device
tty
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
*/
9
devcall
ttycontrol
(
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
}
semcount
syscall semcount(sid32)
セマフォのカウント値を返す。
Definition:
semcount.c:18
TC_MODEC
#define TC_MODEC
Definition:
tty.h:80
TC_ECHO
#define TC_ECHO
Definition:
tty.h:83
TC_MODER
#define TC_MODER
Definition:
tty.h:79
ttycblk::tyiecho
bool8 tyiecho
Definition:
tty.h:39
dentry::dvminor
int32 dvminor
Definition:
conf.h:8
xinu.h
全てのシステムヘッダファイルをインクルードする。
SYSERR
#define SYSERR
処理が失敗した場合
Definition:
kernel.h:79
TC_ICHARS
#define TC_ICHARS
Definition:
tty.h:82
TY_IMCBREAK
#define TY_IMCBREAK
Definition:
tty.h:23
OK
#define OK
処理が成功した場合
Definition:
kernel.h:77
TC_NEXTC
#define TC_NEXTC
Definition:
tty.h:78
ttycontrol
devcall ttycontrol(struct dentry *devptr, int32 func, int32 arg1, int32 arg2)
Definition:
ttycontrol.c:9
TC_MODEK
#define TC_MODEK
Definition:
tty.h:81
dentry
Definition:
conf.h:6
ttycblk
Definition:
tty.h:26
FALSE
#define FALSE
Boolean False(0)
Definition:
kernel.h:63
TRUE
#define TRUE
Boolean True(1)
Definition:
kernel.h:65
int32
int int32
符号あり32ビット整数(int)
Definition:
kernel.h:11
ttytab
struct ttycblk ttytab[]
Definition:
ttyinit.c:11
TC_NOECHO
#define TC_NOECHO
Definition:
tty.h:84
ttycblk::tyimode
char tyimode
Definition:
tty.h:38
TY_IMCOOKED
#define TY_IMCOOKED
Definition:
tty.h:22
wait
syscall wait(sid32)
Definition:
wait.c:9
signal
syscall signal(sid32)
セマフォにシグナルを送り、待機プロセスがある場合は解除する。
Definition:
signal.c:18
devcall
int32 devcall
デバイスコール関数 返り値の型
Definition:
kernel.h:49
ttycblk::tyisem
sid32 tyisem
Definition:
tty.h:30
TY_IMRAW
#define TY_IMRAW
Definition:
tty.h:21
ttycblk::tyitail
char * tyitail
Definition:
tty.h:28
Generated by
1.8.13