OpenCores
URL https://opencores.org/ocsvn/pcie_ds_dma/pcie_ds_dma/trunk

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [soft/] [linux/] [driver/] [pexdrv/] [pexioctl.h] - Blame information for rev 28

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsmv
#ifndef _PEXIOCTL_H_
2
#define _PEXIOCTL_H_
3
 
4
#define PEX_DEVICE_NAME "pexdevice"
5
 
6
#include <linux/types.h>
7
 
8
#define MAX_STRING_LEN  255
9
#define PEX_DEVICE_TYPE             'x'
10
#define PEX_MAKE_IOCTL(t,c) _IO((t), (c))
11
 
12
//-----------------------------------------------------------------------------
13
// ioctl requests command code
14
typedef enum _PEX_NUM_FUNC {
15
 
16
    PEX_BOARD_INFO = 1,
17
    PEX_MEM_ALLOC = 2,
18
    PEX_MEM_FREE = 3,
19
    PEX_STUB_ALLOC = 4,
20
    PEX_STUB_FREE = 5,
21
 
22
    PEX_MEMIO_SET = 10,
23
    PEX_MEMIO_FREE = 11,
24
    PEX_MEMIO_START = 12,
25
    PEX_MEMIO_STOP = 13,
26
    PEX_MEMIO_STATE = 14,
27
    PEX_WAIT_BUFFER = 15,
28
    PEX_WAIT_BLOCK = 16,
29
    PEX_SET_SRC = 17,
30
    PEX_SET_DIR = 18,
31
    PEX_SET_DRQ = 19,
32
    PEX_RESET_FIFO = 20,
33
    PEX_DONE = 21,
34
    PEX_ADJUST = 22
35
 
36
 
37
} PEX_NUM_FUNC;
38
 
39
//-----------------------------------------------------------------------------
40
// ioctl requests code
41
#define IOCTL_PEX_BOARD_INFO \
42
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_BOARD_INFO)
43
 
44
#define IOCTL_PEX_MEM_ALLOC \
45
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_MEM_ALLOC)
46
 
47
#define IOCTL_PEX_MEM_FREE \
48
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_MEM_FREE)
49
 
50
#define IOCTL_PEX_STUB_ALLOC \
51
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_STUB_ALLOC)
52
 
53
#define IOCTL_PEX_STUB_FREE \
54
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_STUB_FREE)
55
 
56
#define IOCTL_AMB_SET_MEMIO \
57
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_MEMIO_SET)
58
 
59
#define IOCTL_AMB_FREE_MEMIO \
60
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_MEMIO_FREE)
61
 
62
#define IOCTL_AMB_START_MEMIO \
63
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_MEMIO_START)
64
 
65
#define IOCTL_AMB_STOP_MEMIO \
66
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_MEMIO_STOP)
67
 
68
#define IOCTL_AMB_STATE_MEMIO \
69
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_MEMIO_STATE)
70
 
71
#define IOCTL_AMB_WAIT_DMA_BUFFER \
72
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_WAIT_BUFFER)
73
 
74
#define IOCTL_AMB_WAIT_DMA_BLOCK \
75
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_WAIT_BLOCK)
76
 
77
#define IOCTL_AMB_SET_SRC_MEM \
78
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_SET_SRC)
79
 
80
#define IOCTL_AMB_SET_DIR_MEM \
81
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_SET_DIR)
82
 
83
#define IOCTL_AMB_SET_DRQ_MEM \
84
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_SET_DRQ)
85
 
86
#define IOCTL_AMB_RESET_FIFO \
87
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_RESET_FIFO)
88
 
89
#define IOCTL_AMB_DONE \
90
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_DONE)
91
 
92
#define IOCTL_AMB_ADJUST \
93
            PEX_MAKE_IOCTL(PEX_DEVICE_TYPE, PEX_ADJUST)
94
 
95
//-----------------------------------------------------------------------------
96
// memory block structure
97
struct memory_block {
98
        size_t  phys;
99
        void*   virt;
100
        size_t  size;
101
};
102
 
103
//-----------------------------------------------------------------------------
104
// memory block structure
105
struct memory_descriptor {
106
        size_t dma_channel;
107
        size_t total_blocks;
108
        struct memory_block *blocks;
109
};
110
 
111
//-----------------------------------------------------------------------------
112
// stub memory structure
113
struct stub_descriptor {
114
        size_t dma_channel;
115
        struct memory_block stub;
116
};
117
 
118
//-----------------------------------------------------------------------------
119
// Extended FIFO Id
120
#define PE_EXT_FIFO_ID  0x0018
121
 
122
//-----------------------------------------------------------------------------
123
// type of memory
124
enum {
125
    USER_MEMORY_TYPE    = 0,
126
    SYSTEM_MEMORY_TYPE  = 1
127
};
128
 
129
//-----------------------------------------------------------------------------
130
//  state of DMA channel
131
enum {
132
    STATE_RUN = 1,
133
    STATE_STOP = 2,
134
    STATE_DESTROY = 3,
135
    STATE_BREAK = 4
136
};
137
 
138
//-----------------------------------------------------------------------------
139
//  direction of DMA transfer
140
enum {
141
    TRANSFER_DIR_TO_DEVICE = 0x0,       // From Host to Device
142
    TRANSFER_DIR_FROM_DEVICE = 0x1      // From Device to Host
143
};
144
 
145
//-----------------------------------------------------------------------------
146
enum {
147
        BRDstrm_DIR_IN = 0x1,                           // To HOST
148
        BRDstrm_DIR_OUT = 0x2,                          // From HOST
149
        BRDstrm_DIR_INOUT = 0x3                         // Both Directions
150
};
151
 
152
//-----------------------------------------------------------------------------
153
// returns the number of pages spanned by the size.
154
#define PAGES_SPANNED(Size) (((Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)
155
 
156
//-----------------------------------------------------------------------------
157
// Shared Memory between kernel and user mode description
158
typedef struct _SHARED_MEMORY_DESCRIPTION {
159
    void*                       SystemAddress;  // INOUT - system memory address
160
    size_t                      LogicalAddress; // OUT - logical memory address
161
    size_t                      dummy;          // OUT - logical memory address
162
} SHARED_MEMORY_DESCRIPTION, *PSHARED_MEMORY_DESCRIPTION;
163
 
164
//-----------------------------------------------------------------------------
165
// Stub Structure
166
typedef struct _AMB_STUB {
167
    u32 lastBlock;              // Number of Block which was filled last Time
168
    u32 totalCounter;           // Total Counter of all filled Block
169
    u32 offset;                 // First Unfilled Byte
170
    u32 state;                  // CBUF local state
171
} AMB_STUB, *PAMB_STUB;
172
 
173
//-----------------------------------------------------------------------------
174
// Descriptor Structure (PE_EXT_FIFO)
175
// PCI Address (byte 0) = 0 always
176
// DMA Length (byte 0)  = 0 always
177
typedef struct _DMA_CHAINING_DESCR_EXT {
178
 
179
    u8  AddrByte1;                              // PCI Address (byte 1)
180
    u8  AddrByte2;                              // PCI Address (byte 2)
181
    u8  AddrByte3;                              // PCI Address (byte 3)
182
    u8  AddrByte4;                              // PCI Address (byte 4)
183
 
184
    struct {
185
        u8 JumpNextDescr : 1;   // Jump to Next Descriptor
186
        u8 JumpNextBlock : 1;   // Jump to Next Block
187
        u8 JumpDescr0    : 1;   // Jump to Descriptor 0
188
        u8 Res0          : 1;   // reserved
189
        u8 EndOfTrans    : 1;   // End of Transfer
190
        u8 Res           : 3;   // reserved
191
    } Cmd;                                                      // Descriptor Command
192
 
193
    u8  SizeByte1;                              // DMA Length (byte 1), bit 0: 0 - TRANSFER_DIR_TO_DEVICE, 1 - TRANSFER_DIR_FROM_DEVICE
194
    u8  SizeByte2;                              // DMA Length (byte 2)
195
    u8  SizeByte3;                              // DMA Length (byte 3)
196
 
197
} DMA_CHAINING_DESCR_EXT, *PDMA_CHAINING_DESCR_EXT;
198
 
199
//-----------------------------------------------------------------------------
200
// Next descriptor block
201
typedef struct _DMA_NEXT_BLOCK {
202
 
203
    u32 NextBlkAddr;
204
    u16 Signature;                              // 0x4953
205
    u16 Crc;                                    // control code
206
 
207
} DMA_NEXT_BLOCK, *PDMA_NEXT_BLOCK;
208
 
209
#define DSCR_BLOCK_SIZE 64
210
 
211
//-----------------------------------------------------------------------------
212
 
213
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.