XINU
Functions
ttyhandler.c File Reference
#include <xinu.h>
Include dependency graph for ttyhandler.c:

Go to the source code of this file.

Functions

void ttyhandler (uint32 xnum)
 

Function Documentation

◆ ttyhandler()

void ttyhandler ( uint32  xnum)

Definition at line 9 of file ttyhandler.c.

References uart_csreg::buffer, CONSOLE, DEFER_START, DEFER_STOP, devtab, dentry::dvcsr, dentry::dvminor, if(), uart_csreg::iir, uart_csreg::lsr, resched_cntl(), ttyhandle_in(), ttyhandle_out(), ttytab, UART_IIR_IDMASK, UART_IIR_IRQ, UART_IIR_MSC, UART_IIR_RDA, UART_IIR_RLSI, UART_IIR_RTO, UART_IIR_THRE, UART_LSR_BI, and UART_LSR_DR.

9  {
10  struct dentry *devptr; /* Address of device control blk*/
11  struct ttycblk *typtr; /* Pointer to ttytab entry */
12  struct uart_csreg *csrptr; /* Address of UART's CSR */
13  uint32 iir = 0; /* Interrupt identification */
14  uint32 lsr = 0; /* Line status */
15 
16 
17  /* Get CSR address of the device (assume console for now) */
18 
19  devptr = (struct dentry *) &devtab[CONSOLE];
20  csrptr = (struct uart_csreg *) devptr->dvcsr;
21 
22  /* Obtain a pointer to the tty control block */
23 
24  typtr = &ttytab[ devptr->dvminor ];
25 
26  /* Decode hardware interrupt request from UART device */
27 
28  /* Check interrupt identification register */
29  iir = csrptr->iir;
30  if (iir & UART_IIR_IRQ) {
31  return;
32  }
33 
34  /* Decode the interrupt cause based upon the value extracted */
35  /* from the UART interrupt identification register. Clear */
36  /* the interrupt source and perform the appropriate handling */
37  /* to coordinate with the upper half of the driver */
38 
39  /* Decode the interrupt cause */
40 
41  iir &= UART_IIR_IDMASK; /* Mask off the interrupt ID */
42  switch (iir) {
43 
44  /* Receiver line status interrupt (error) */
45 
46  case UART_IIR_RLSI:
47  lsr = csrptr->lsr;
48  if(lsr & UART_LSR_BI) { /* Break Interrupt */
49 
50  /* Read the RHR register to acknowledge */
51 
52  lsr = csrptr->buffer;
53  }
54  return;
55 
56  /* Receiver data available or timed out */
57 
58  case UART_IIR_RDA:
59  case UART_IIR_RTO:
60 
62 
63  /* While chars avail. in UART buffer, call ttyhandle_in */
64 
65  while ( (csrptr->lsr & UART_LSR_DR) != 0) {
66  ttyhandle_in(typtr, csrptr);
67  }
68 
70 
71  return;
72 
73  /* Transmitter output FIFO is empty (i.e., ready for more) */
74 
75  case UART_IIR_THRE:
76  ttyhandle_out(typtr, csrptr);
77  return;
78 
79  /* Modem status change (simply ignore) */
80 
81  case UART_IIR_MSC:
82  return;
83  }
84 }
volatile uint32 lsr
Definition: uart.h:22
if(!(yy_init))
Definition: lex.yy.c:679
volatile uint32 buffer
Definition: uart.h:15
int32 dvminor
Definition: conf.h:8
#define CONSOLE
Definition: conf.h:28
#define UART_IIR_RTO
Definition: uart.h:78
#define UART_IIR_MSC
Definition: uart.h:74
#define UART_IIR_RDA
Definition: uart.h:76
status resched_cntl(int32)
再スケジューリングを延期させるか、もしくは許可させるかを制御する。
Definition: resched.c:81
Definition: conf.h:6
Definition: tty.h:26
struct dentry devtab[]
Definition: conf.c:11
#define UART_IIR_RLSI
Definition: uart.h:77
#define UART_LSR_BI
Definition: uart.h:102
#define DEFER_STOP
遅延リスケジューリングの停止
Definition: resched.h:10
#define DEFER_START
遅延リスケジューリングの開始
Definition: resched.h:8
#define UART_IIR_IDMASK
Definition: uart.h:73
struct ttycblk ttytab[]
Definition: ttyinit.c:11
#define UART_IIR_IRQ
Definition: uart.h:72
void ttyhandle_in(struct ttycblk *, struct uart_csreg *)
Definition: ttyhandle_in.c:13
volatile uint32 iir
Definition: uart.h:18
#define UART_IIR_THRE
Definition: uart.h:75
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15
void ttyhandle_out(struct ttycblk *, struct uart_csreg *)
Definition: ttyhandle_out.c:10
void * dvcsr
Definition: conf.h:19
#define UART_LSR_DR
Definition: uart.h:101
Here is the call graph for this function: