XINU
device
tty
ttygetc.c
Go to the documentation of this file.
1
/* ttygetc.c - ttygetc */
2
3
#include <
xinu.h
>
4
5
/*------------------------------------------------------------------------
6
* ttygetc - Read one character from a tty device (interrupts disabled)
7
*------------------------------------------------------------------------
8
*/
9
devcall
ttygetc
(
10
struct
dentry
*devptr
/* Entry in device switch table */
11
)
12
{
13
char
ch;
/* Character to return */
14
struct
ttycblk
*typtr;
/* Pointer to ttytab entry */
15
16
typtr = &
ttytab
[devptr->
dvminor
];
17
18
/* Wait for a character in the buffer and extract one character */
19
20
wait
(typtr->
tyisem
);
21
ch = *typtr->
tyihead
++;
22
23
/* Wrap around to beginning of buffer, if needed */
24
25
if
(typtr->
tyihead
>= &typtr->
tyibuff
[
TY_IBUFLEN
]) {
26
typtr->
tyihead
= typtr->
tyibuff
;
27
}
28
29
/* In cooked mode, check for the EOF character */
30
31
if
( (typtr->
tyimode
==
TY_IMCOOKED
) && (typtr->
tyeof
) &&
32
(ch == typtr->
tyeofch
) ) {
33
return
(
devcall
)
EOF
;
34
}
35
36
return
(
devcall
)ch;
37
}
ttycblk::tyeofch
char tyeofch
Definition:
tty.h:48
dentry::dvminor
int32 dvminor
Definition:
conf.h:8
xinu.h
全てのシステムヘッダファイルをインクルードする。
ttycblk::tyibuff
char tyibuff[TY_IBUFLEN]
Definition:
tty.h:29
ttygetc
devcall ttygetc(struct dentry *devptr)
Definition:
ttygetc.c:9
EOF
#define EOF
ファイルの終端(End of File)に達した場合(読み込み処理に用いる)
Definition:
kernel.h:81
dentry
Definition:
conf.h:6
ttycblk
Definition:
tty.h:26
ttycblk::tyihead
char * tyihead
Definition:
tty.h:27
ttytab
struct ttycblk ttytab[]
Definition:
ttyinit.c:11
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
TY_IBUFLEN
#define TY_IBUFLEN
Definition:
tty.h:13
ttycblk::tyeof
bool8 tyeof
Definition:
tty.h:47
devcall
int32 devcall
デバイスコール関数 返り値の型
Definition:
kernel.h:49
ttycblk::tyisem
sid32 tyisem
Definition:
tty.h:30
Generated by
1.8.13