1 |
2 |
dsmv |
//****************** File DmaChannel.h *********************************
|
2 |
|
|
// class CDmaChannel definition
|
3 |
|
|
//
|
4 |
|
|
// Copyright (c) 2007, Instrumental Systems,Corp.
|
5 |
|
|
// Written by Dorokhin Andrey
|
6 |
|
|
//
|
7 |
|
|
// History:
|
8 |
|
|
// 28-10-07 - builded
|
9 |
|
|
//
|
10 |
|
|
//*******************************************************************
|
11 |
|
|
|
12 |
|
|
#ifndef _DMA_CHAN_H_
|
13 |
|
|
#define _DMA_CHAN_H_
|
14 |
|
|
|
15 |
|
|
#include "pexioctl.h"
|
16 |
|
|
|
17 |
|
|
#define PE_EXT_FIFO_ID 0x0018
|
18 |
|
|
|
19 |
|
|
typedef void (*TASKLET_ROUTINE)(unsigned long);
|
20 |
|
|
|
21 |
|
|
struct CDmaChannel
|
22 |
|
|
{
|
23 |
|
|
u32 m_NumberOfChannel;
|
24 |
|
|
u16 m_idBlockFifo;
|
25 |
|
|
|
26 |
|
|
void *m_Board; // PCI device object
|
27 |
|
|
struct device *m_dev; // PCI device object
|
28 |
|
|
struct tasklet_struct m_Dpc; // the DPC object
|
29 |
|
|
wait_queue_head_t m_DmaWq;
|
30 |
|
|
spinlock_t m_DmaLock; // spinlock
|
31 |
|
|
|
32 |
|
|
KEVENT m_BlockEndEvent;
|
33 |
|
|
KEVENT m_BufferEndEvent;
|
34 |
|
|
|
35 |
|
|
AMB_STUB m_State;
|
36 |
|
|
|
37 |
|
|
u32 m_AdmNum;
|
38 |
|
|
u32 m_TetrNum;
|
39 |
|
|
u32 m_DmaDirection;
|
40 |
|
|
u32 m_DmaLocalAddress;
|
41 |
|
|
u32 m_DmaCycling;
|
42 |
|
|
|
43 |
|
|
u32 m_CycleNum;
|
44 |
|
|
u32 m_BlocksRemaining;
|
45 |
|
|
u32 m_CurBlockNum;
|
46 |
|
|
|
47 |
|
|
u32 m_UseCount;
|
48 |
|
|
|
49 |
|
|
u32 m_AdjustMode;
|
50 |
|
|
u32 m_DoneBlock;
|
51 |
|
|
u32 m_DoneFlag;
|
52 |
|
|
|
53 |
|
|
u32 m_preBlockCount1;
|
54 |
|
|
u32 m_preBlockCount2;
|
55 |
|
|
u32 m_preBlockCount3;
|
56 |
|
|
|
57 |
|
|
u32 m_MemType;
|
58 |
|
|
AMB_STUB *m_pStub;
|
59 |
|
|
|
60 |
|
|
SHARED_MEMORY_DESCRIPTION m_StubDscr; //Содержит описатель управляющего блока
|
61 |
|
|
|
62 |
|
|
u32 m_BlockCount; //Количество блоков для DMA
|
63 |
|
|
u32 m_BlockSize; //Размер одного блока DMA
|
64 |
|
|
|
65 |
|
|
SHARED_MEMORY_DESCRIPTION m_pBufDscr; //Описатель для адресов блоков DMA каждый элемент содержит
|
66 |
|
|
|
67 |
|
|
DMA_CHAINING_DESCR_EXT *m_pScatterGatherTableExt; //Содержит массив для организации цепочек DMA (v2)
|
68 |
|
|
u32 m_ScatterGatherBlockCnt; //Количество элементов-дескрипторов цепочек DMA
|
69 |
|
|
SHARED_MEMORY_DESCRIPTION m_SGTableDscr; //Описатель массива цепочек DMA
|
70 |
|
|
u32 m_ScatterGatherTableEntryCnt; //Количество блоков для DMA
|
71 |
|
|
|
72 |
|
|
TASKLET_ROUTINE m_DpcForIsr;
|
73 |
|
|
};
|
74 |
|
|
|
75 |
|
|
struct CDmaChannel* CDmaChannelCreate( u32 NumberOfChannel,
|
76 |
|
|
void *m_Board,
|
77 |
|
|
struct device *dev,
|
78 |
|
|
u32 cbMaxTransferLength,
|
79 |
|
|
u16 idBlockFifo,
|
80 |
|
|
int bScatterGather );
|
81 |
|
|
void CDmaChannelDelete(struct CDmaChannel *dma);
|
82 |
|
|
int RequestMemory(struct CDmaChannel *dma, void **ppMemPhysAddr, u32 size, u32 *pCount, void **pStubPhysAddr, u32 bMemType);
|
83 |
|
|
void ReleaseMemory(struct CDmaChannel *dma);
|
84 |
|
|
int RequestSysBuf(struct CDmaChannel *dma, void **pMemPhysAddr);
|
85 |
|
|
void ReleaseSysBuf(struct CDmaChannel *dma);
|
86 |
|
|
int RequestSGList(struct CDmaChannel *dma);
|
87 |
|
|
void ReleaseSGList(struct CDmaChannel *dma);
|
88 |
|
|
int RequestStub(struct CDmaChannel *dma, void **pStubPhysAddr);
|
89 |
|
|
void ReleaseStub(struct CDmaChannel *dma);
|
90 |
|
|
int SetScatterGatherListExt(struct CDmaChannel *dma);
|
91 |
|
|
void FreeUserAddress(struct CDmaChannel *dma);
|
92 |
|
|
u32 NextDmaTransfer(struct CDmaChannel *dma);
|
93 |
|
|
int SetScatterGatherList(struct CDmaChannel *dma);
|
94 |
|
|
int SetDmaDirection(struct CDmaChannel *dma, u32 DmaDirection);
|
95 |
|
|
void SetDmaLocalAddress(struct CDmaChannel *dma, u32 Address);
|
96 |
|
|
void SetLocalBusWidth(struct CDmaChannel *dma, u32 Param);
|
97 |
|
|
void ReferenceBlockEndEvent(struct CDmaChannel *dma, void* hBlockEndEvent);
|
98 |
|
|
void DereferenceBlockEndEvent(struct CDmaChannel *dma);
|
99 |
|
|
void SetAdmTetr(struct CDmaChannel *dma, u32 AdmNum, u32 TetrNum);
|
100 |
|
|
void Adjust(struct CDmaChannel *dma, u32 mode);
|
101 |
|
|
void GetState(struct CDmaChannel *dma, u32 *BlockNum, u32 *BlockNumTotal, u32 *OffsetInBlock, u32 *DmaChanState);
|
102 |
|
|
int CompleteDmaTransfer(struct CDmaChannel *dma);
|
103 |
|
|
int WaitBlockEndEvent(struct CDmaChannel *dma, u32 msTimeout);
|
104 |
|
|
int WaitBufferEndEvent(struct CDmaChannel *dma, u32 msTimeout);
|
105 |
|
|
u32 GetAdmNum(struct CDmaChannel *dma);
|
106 |
|
|
u32 GetTetrNum(struct CDmaChannel *dma);
|
107 |
|
|
void GetSGStartParams(struct CDmaChannel *dma, u64* SGTableAddress, u32* LocalAddress, u32* DmaDirection);
|
108 |
|
|
int StartDmaTransfer(struct CDmaChannel *dma, u32 IsCycling);
|
109 |
|
|
u32 SetDoneBlock(struct CDmaChannel *dma, long numBlk);
|
110 |
|
|
void DmaDpcForIsr( unsigned long Context );
|
111 |
|
|
|
112 |
|
|
#endif //_DMA_CHANNEL_H_
|
113 |
|
|
|
114 |
|
|
//
|
115 |
|
|
// End of File
|
116 |
|
|
//
|