XINU
Functions | Variables
ttyinit.c File Reference

TTYラインのバッファおよびモードを初期化します More...

#include <xinu.h>
Include dependency graph for ttyinit.c:

Go to the source code of this file.

Functions

devcall ttyinit (struct dentry *devptr)
 

Variables

struct ttycblk ttytab [Ntty]
 

Detailed Description

TTYラインのバッファおよびモードを初期化します

Definition in file ttyinit.c.

Function Documentation

◆ ttyinit()

devcall ttyinit ( struct dentry devptr)

Definition at line 17 of file ttyinit.c.

References dentry::dvcsr, dentry::dvintr, dentry::dvirq, dentry::dvminor, FALSE, uart_csreg::lcr, uart_csreg::mdr1, OK, semcreate(), set_evec(), TRUE, ttykickout(), ttytab, TY_BACKSP, TY_BACKSP2, TY_EOFCH, TY_FULLCH, TY_IMCOOKED, TY_KILLCH, TY_OBUFLEN, TY_STOPCH, TY_STRTCH, ttycblk::tyebuff, ttycblk::tyecrlf, ttycblk::tyehead, ttycblk::tyeof, ttycblk::tyeofch, ttycblk::tyetail, ttycblk::tyevis, ttycblk::tyibuff, ttycblk::tyicrlf, ttycblk::tyicursor, ttycblk::tyieback, ttycblk::tyiecho, ttycblk::tyierase, ttycblk::tyierasec, ttycblk::tyierasec2, ttycblk::tyifullc, ttycblk::tyihead, ttycblk::tyikill, ttycblk::tyikillc, ttycblk::tyimode, ttycblk::tyisem, ttycblk::tyitail, ttycblk::tyobuff, ttycblk::tyocrlf, ttycblk::tyoflow, ttycblk::tyohead, ttycblk::tyoheld, ttycblk::tyosem, ttycblk::tyostart, ttycblk::tyostop, ttycblk::tyotail, UART_DLL, UART_DLM, UART_FCR_EFIFO, UART_FCR_RRESET, UART_FCR_TRESET, UART_FCR_TRIG2, UART_LCR_8N1, UART_LCR_DLAB, and UART_MDR1_16X.

20 {
21  struct ttycblk *typtr; /* Pointer to ttytab entry */
22  struct uart_csreg *uptr; /* Address of UART's CSRs */
23 
24  typtr = &ttytab[devptr->dvminor];
25 
26  /* Initialize values in the tty control block */
27 
28  typtr->tyihead = typtr->tyitail = /* Set up input queue */
29  &typtr->tyibuff[0]; /* as empty */
30  typtr->tyisem = semcreate(0); /* Input semaphore */
31  typtr->tyohead = typtr->tyotail = /* Set up output queue */
32  &typtr->tyobuff[0]; /* as empty */
33  typtr->tyosem = semcreate(TY_OBUFLEN); /* Output semaphore */
34  typtr->tyehead = typtr->tyetail = /* Set up echo queue */
35  &typtr->tyebuff[0]; /* as empty */
36  typtr->tyimode = TY_IMCOOKED; /* Start in cooked mode */
37  typtr->tyiecho = TRUE; /* Echo console input */
38  typtr->tyieback = TRUE; /* Honor erasing bksp */
39  typtr->tyevis = TRUE; /* Visual control chars */
40  typtr->tyecrlf = TRUE; /* Echo CRLF for NEWLINE*/
41  typtr->tyicrlf = TRUE; /* Map CR to NEWLINE */
42  typtr->tyierase = TRUE; /* Do erasing backspace */
43  typtr->tyierasec = TY_BACKSP; /* Primary erase char */
44  typtr->tyierasec2 = TY_BACKSP2; /* Alternate erase char */
45  typtr->tyeof = TRUE; /* Honor eof on input */
46  typtr->tyeofch = TY_EOFCH; /* End-of-file character*/
47  typtr->tyikill = TRUE; /* Allow line kill */
48  typtr->tyikillc = TY_KILLCH; /* Set line kill to ^U */
49  typtr->tyicursor = 0; /* Start of input line */
50  typtr->tyoflow = TRUE; /* Handle flow control */
51  typtr->tyoheld = FALSE; /* Output not held */
52  typtr->tyostop = TY_STOPCH; /* Stop char is ^S */
53  typtr->tyostart = TY_STRTCH; /* Start char is ^Q */
54  typtr->tyocrlf = TRUE; /* Send CRLF for NEWLINE*/
55  typtr->tyifullc = TY_FULLCH; /* Send ^G when buffer */
56  /* is full */
57 
58  /* Initialize the UART */
59 
60  uptr = (struct uart_csreg *)devptr->dvcsr;
61 
62  /* Set baud rate */
63  uptr->lcr = UART_LCR_DLAB;
64  uptr->dlm = UART_DLM;
65  uptr->dll = UART_DLL;
66 
67  uptr->lcr = UART_LCR_8N1; /* 8 bit char, No Parity, 1 Stop*/
68  uptr->fcr = 0x00; /* Disable FIFO for now */
69 
70  /* Register the interrupt dispatcher for the tty device */
71 
72  set_evec(devptr->dvirq, (uint32)devptr->dvintr);
73 
74  /* Enable interrupts on the device: reset the transmit and */
75  /* receive FIFOS, and set the interrupt trigger level */
76 
77  uptr->fcr = UART_FCR_EFIFO | UART_FCR_RRESET |
79 
80  /* UART must be in 16x mode (TI AM335X specific) */
81 
82  uptr->mdr1 = UART_MDR1_16X;
83 
84  /* Start the device */
85 
86  ttykickout(uptr);
87  return OK;
88 }
#define TY_BACKSP
Definition: tty.h:63
bool8 tyocrlf
Definition: tty.h:56
sid32 semcreate(int32)
未使用セマフォを割り当て、そのセマフォへのインデックス(セマフォID)を返す。
Definition: semcreate.c:22
#define TY_STOPCH
Definition: tty.h:70
bool8 tyiecho
Definition: tty.h:39
char tyeofch
Definition: tty.h:48
int32 dvminor
Definition: conf.h:8
char tyierasec
Definition: tty.h:45
char tyifullc
Definition: tty.h:57
char tyibuff[TY_IBUFLEN]
Definition: tty.h:29
#define UART_FCR_TRESET
Definition: uart.h:84
char tyierasec2
Definition: tty.h:46
bool8 tyicrlf
Definition: tty.h:43
bool8 tyieback
Definition: tty.h:40
#define UART_DLM
Definition: uart.h:55
bool8 tyoheld
Definition: tty.h:53
#define OK
処理が成功した場合
Definition: kernel.h:77
#define UART_MDR1_16X
Definition: uart.h:109
volatile uint32 mdr1
Definition: uart.h:25
#define TY_STRTCH
Definition: tty.h:71
bool8 tyikill
Definition: tty.h:49
#define UART_LCR_8N1
Definition: uart.h:61
bool8 tyecrlf
Definition: tty.h:42
bool8 tyoflow
Definition: tty.h:52
Definition: tty.h:26
int32 set_evec(uint32, uint32)
Definition: evec.c:37
#define TY_FULLCH
Definition: tty.h:74
char * tyehead
Definition: tty.h:35
#define TY_EOFCH
Definition: tty.h:66
char tyobuff[TY_OBUFLEN]
Definition: tty.h:33
#define FALSE
Boolean False(0)
Definition: kernel.h:63
#define TY_KILLCH
Definition: tty.h:72
#define TRUE
Boolean True(1)
Definition: kernel.h:65
char tyostop
Definition: tty.h:54
#define TY_BACKSP2
Definition: tty.h:64
char * tyetail
Definition: tty.h:36
char * tyohead
Definition: tty.h:31
bool8 tyevis
Definition: tty.h:41
char * tyihead
Definition: tty.h:27
#define TY_OBUFLEN
Definition: tty.h:16
char * tyotail
Definition: tty.h:32
char tyikillc
Definition: tty.h:50
char tyimode
Definition: tty.h:38
volatile uint32 lcr
Definition: uart.h:20
byte dvirq
Definition: conf.h:21
#define UART_FCR_RRESET
Definition: uart.h:83
#define TY_IMCOOKED
Definition: tty.h:22
#define UART_FCR_EFIFO
Definition: uart.h:82
bool8 tyierase
Definition: tty.h:44
struct ttycblk ttytab[Ntty]
Definition: ttyinit.c:11
bool8 tyeof
Definition: tty.h:47
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15
void ttykickout(struct uart_csreg *)
Definition: ttykickout.c:10
#define UART_FCR_TRIG2
Definition: uart.h:87
#define UART_LCR_DLAB
Definition: uart.h:60
char tyebuff[TY_EBUFLEN]
Definition: tty.h:37
void * dvcsr
Definition: conf.h:19
int32 tyicursor
Definition: tty.h:51
char tyostart
Definition: tty.h:55
sid32 tyisem
Definition: tty.h:30
void(* dvintr)(void)
Definition: conf.h:20
#define UART_DLL
Definition: uart.h:53
sid32 tyosem
Definition: tty.h:34
char * tyitail
Definition: tty.h:28
Here is the call graph for this function:

Variable Documentation

◆ ttytab

struct ttycblk ttytab[Ntty]

Definition at line 11 of file ttyinit.c.

Referenced by ttycontrol(), ttygetc(), ttyhandler(), ttyinit(), ttyputc(), and ttyread().