XINU
ttyputc.c
Go to the documentation of this file.
1 /* ttyputc.c - ttyputc */
2 
3 #include <xinu.h>
4 
5 /*------------------------------------------------------------------------
6  * ttyputc - Write one character to a tty device (interrupts disabled)
7  *------------------------------------------------------------------------
8  */
10  struct dentry *devptr, /* Entry in device switch table */
11  char ch /* Character to write */
12  )
13 {
14  struct ttycblk *typtr; /* Pointer to tty control block */
15 
16  typtr = &ttytab[devptr->dvminor];
17 
18  /* Handle output CRLF by sending CR first */
19 
20  if ( ch==TY_NEWLINE && typtr->tyocrlf ) {
21  ttyputc(devptr, TY_RETURN);
22  }
23 
24  wait(typtr->tyosem); /* Wait for space in queue */
25  *typtr->tyotail++ = ch;
26 
27  /* Wrap around to beginning of buffer, if needed */
28 
29  if (typtr->tyotail >= &typtr->tyobuff[TY_OBUFLEN]) {
30  typtr->tyotail = typtr->tyobuff;
31  }
32 
33  /* Start output in case device is idle */
34 
35  ttykickout((struct uart_csreg *)devptr->dvcsr);
36 
37  return OK;
38 }
bool8 tyocrlf
Definition: tty.h:56
int32 dvminor
Definition: conf.h:8
全てのシステムヘッダファイルをインクルードする。
#define OK
処理が成功した場合
Definition: kernel.h:77
Definition: conf.h:6
Definition: tty.h:26
char tyobuff[TY_OBUFLEN]
Definition: tty.h:33
#define TY_RETURN
Definition: tty.h:69
devcall ttyputc(struct dentry *devptr, char ch)
Definition: ttyputc.c:9
#define TY_OBUFLEN
Definition: tty.h:16
struct ttycblk ttytab[]
Definition: ttyinit.c:11
char * tyotail
Definition: tty.h:32
syscall wait(sid32)
Definition: wait.c:9
#define TY_NEWLINE
Definition: tty.h:68
int32 devcall
デバイスコール関数 返り値の型
Definition: kernel.h:49
void ttykickout(struct uart_csreg *)
Definition: ttykickout.c:10
void * dvcsr
Definition: conf.h:19
sid32 tyosem
Definition: tty.h:34