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

Go to the source code of this file.

Functions

interrupt ethhandler (uint32 xnum)
 

Function Documentation

◆ ethhandler()

interrupt ethhandler ( uint32  xnum)

Definition at line 9 of file ethhandler.c.

References eth_a_csreg::cpdma, ethcblk::csr, DEFER_START, DEFER_STOP, eth_a_cpdma::eoi_vector, ETH_AM335X_RDS_OWN, ETH_AM335X_RXINT, ETH_AM335X_TDS_OWN, ETH_AM335X_TXINT, ethertab, ethcblk::isem, ethcblk::osem, resched_cntl(), eth_a_stateram::rx_cp, eth_a_stateram::rx_hdp, ethcblk::rxRing, ethcblk::rxRingSize, ethcblk::rxTail, semcount(), signal(), eth_a_rx_desc::stat, eth_a_tx_desc::stat, eth_a_csreg::stateram, eth_a_stateram::tx_cp, eth_a_stateram::tx_hdp, ethcblk::txHead, ethcblk::txRing, and ethcblk::txRingSize.

12 {
13  struct eth_a_csreg *csrptr; /* Ethernet CSR pointer */
14  struct eth_a_tx_desc *tdescptr; /* Tx desc pointer */
15  struct eth_a_rx_desc *rdescptr; /* Rx desc pointer */
16  struct ethcblk *ethptr = &ethertab[0]; /* Ethernet ctl blk ptr */
17 
18  csrptr = (struct eth_a_csreg *)ethptr->csr;
19 
20  if(xnum == ETH_AM335X_TXINT) { /* Transmit interrupt */
21 
22  /* Get pointer to first desc in queue */
23 
24  tdescptr = (struct eth_a_tx_desc *)ethptr->txRing +
25  ethptr->txHead;
26 
27  /* Defer scheduling until all descs are processed */
28 
30 
31  while(semcount(ethptr->osem) < (int32)ethptr->txRingSize) {
32 
33  /* If desc owned by DMA, check if we need to */
34  /* Restart the transmission */
35 
36  if(tdescptr->stat & ETH_AM335X_TDS_OWN) {
37  if(csrptr->stateram->tx_hdp[0] == 0) {
38  csrptr->stateram->tx_hdp[0] =
39  (uint32)tdescptr;
40  }
41  break;
42  }
43 
44  /* Acknowledge the interrupt */
45 
46  csrptr->stateram->tx_cp[0] = (uint32)tdescptr;
47 
48  /* Increment the head index of the queue */
49  /* And go to the next descriptor in queue */
50 
51  ethptr->txHead++;
52  tdescptr++;
53  if(ethptr->txHead >= ethptr->txRingSize) {
54  ethptr->txHead = 0;
55  tdescptr = (struct eth_a_tx_desc *)
56  ethptr->txRing;
57  }
58 
59  /* Signal the output semaphore */
60 
61  signal(ethptr->osem);
62  }
63 
64  /* Acknowledge the transmit interrupt */
65 
66  csrptr->cpdma->eoi_vector = 0x2;
67 
68  /* Resume rescheduling */
69 
71  }
72  else if(xnum == ETH_AM335X_RXINT) { /* Receive interrupt */
73 
74  /* Get the pointer to last desc in the queue */
75 
76  rdescptr = (struct eth_a_rx_desc *)ethptr->rxRing +
77  ethptr->rxTail;
78 
79  /* Defer scheduling until all descriptors are processed */
80 
82 
83  while(semcount(ethptr->isem) < (int32)ethptr->rxRingSize) {
84 
85  /* Check if we need to restart the DMA */
86 
87  if(rdescptr->stat & ETH_AM335X_RDS_OWN) {
88  if(csrptr->stateram->rx_hdp[0] == 0) {
89  csrptr->stateram->rx_hdp[0] =
90  (uint32)rdescptr;
91  }
92  break;
93  }
94 
95  /* Acknowledge the interrupt */
96 
97  csrptr->stateram->rx_cp[0] = (uint32)rdescptr;
98 
99  /* Increment the tail index of the queue */
100  /* And go to the next descriptor in the queue */
101 
102  ethptr->rxTail++;
103  rdescptr++;
104  if(ethptr->rxTail >= ethptr->rxRingSize) {
105  ethptr->rxTail = 0;
106  rdescptr = (struct eth_a_rx_desc *)
107  ethptr->rxRing;
108  }
109 
110  /* Signal the input semaphore */
111 
112  signal(ethptr->isem);
113  }
114 
115  /* Acknowledge the receive interrupt */
116 
117  csrptr->cpdma->eoi_vector = 0x1;
118 
119  /* Resume rescheduling */
120 
122  }
123 }
syscall semcount(sid32)
セマフォのカウント値を返す。
Definition: semcount.c:18
uint32 eoi_vector
CPDMA割り込み終了ベクタ
Definition: am335x_eth.h:94
void * rxRing
Definition: ether.h:82
uint16 stat
DMA状態
Definition: am335x_eth.h:363
uint32 txHead
Definition: ether.h:91
uint32 rx_hdp[8]
RX(受信) チャネル0〜7 先頭ディスクリプタへのポインタ
Definition: am335x_eth.h:128
#define ETH_AM335X_RDS_OWN
DMAが所持するディスクリプタ
Definition: am335x_eth.h:340
Ethernet subsystemレジスタ構造体
Definition: am335x_eth.h:297
DMA TX(送信)ディスクリプタ
Definition: am335x_eth.h:350
Definition: ether.h:68
volatile struct eth_a_cpdma * cpdma
CPSW_CPDMAレジスタ
Definition: am335x_eth.h:302
DMA RX(受信)ディスクリプタ
Definition: am335x_eth.h:319
status resched_cntl(int32)
再スケジューリングを延期させるか、もしくは許可させるかを制御する。
Definition: resched.c:81
struct ethcblk ethertab[]
Definition: ethinit.c:7
uint32 tx_hdp[8]
TX(送信) チャネル0〜7 先頭ディスクリプタへのポインタ
Definition: am335x_eth.h:126
uint16 stat
DMA状態
Definition: am335x_eth.h:332
volatile struct eth_a_stateram * stateram
CPSW_STATERANレジスタ
Definition: am335x_eth.h:304
#define DEFER_STOP
遅延リスケジューリングの停止
Definition: resched.h:10
uint32 rx_cp[8]
RX(受信) チャネル0〜7 完了ポインタレジスタ
Definition: am335x_eth.h:132
#define DEFER_START
遅延リスケジューリングの開始
Definition: resched.h:8
#define ETH_AM335X_TDS_OWN
DMAが所持するディスクリプタ
Definition: am335x_eth.h:371
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
void * txRing
Definition: ether.h:89
#define ETH_AM335X_RXINT
RX(受信)の割り込みベクタ
Definition: am335x_eth.h:396
syscall signal(sid32)
セマフォにシグナルを送り、待機プロセスがある場合は解除する。
Definition: signal.c:18
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15
void * csr
Definition: ether.h:76
uint32 rxRingSize
Definition: ether.h:86
uint32 txRingSize
Definition: ether.h:93
sid32 isem
Definition: ether.h:102
#define ETH_AM335X_TXINT
TX(送信)の割り込みベクタ
Definition: am335x_eth.h:398
uint32 tx_cp[8]
TX(送信) チャネル0〜7 完了ポインタレジスタ
Definition: am335x_eth.h:130
uint32 rxTail
Definition: ether.h:85
sid32 osem
Definition: ether.h:103
Here is the call graph for this function: