bzr branch
http://suren.me/webbzr/alps/pcitool
45
by root
North West Logick DMA implementation |
1 |
#ifndef _PCILIB_KMEM_H
|
2 |
#define _PCILIB_KMEM_H
|
|
3 |
||
4 |
#include "pcilib.h" |
|
74
by Suren A. Chilingaryan
Implement DMA access synchronization for NWL implementation |
5 |
#include "tools.h" |
45
by root
North West Logick DMA implementation |
6 |
|
71
by Suren A. Chilingaryan
First iteration of work to preserve DMA state between executions |
7 |
typedef enum { |
73
by Suren A. Chilingaryan
Implement DMA access synchronization in the driver |
8 |
PCILIB_KMEM_FLAG_REUSE = KMEM_FLAG_REUSE, |
9 |
PCILIB_KMEM_FLAG_EXCLUSIVE = KMEM_FLAG_EXCLUSIVE, |
|
10 |
PCILIB_KMEM_FLAG_PERSISTENT = KMEM_FLAG_PERSISTENT, |
|
74
by Suren A. Chilingaryan
Implement DMA access synchronization for NWL implementation |
11 |
PCILIB_KMEM_FLAG_HARDWARE = KMEM_FLAG_HW, |
100
by root
Support exporting data from kernel buffers |
12 |
PCILIB_KMEM_FLAG_FORCE = KMEM_FLAG_FORCE, |
13 |
PCILIB_KMEM_FLAG_TRY = KMEM_FLAG_TRY |
|
71
by Suren A. Chilingaryan
First iteration of work to preserve DMA state between executions |
14 |
} pcilib_kmem_flags_t; |
15 |
||
74
by Suren A. Chilingaryan
Implement DMA access synchronization for NWL implementation |
16 |
|
71
by Suren A. Chilingaryan
First iteration of work to preserve DMA state between executions |
17 |
typedef enum { |
74
by Suren A. Chilingaryan
Implement DMA access synchronization for NWL implementation |
18 |
PCILIB_KMEM_REUSE_ALLOCATED = PCILIB_TRISTATE_NO, |
73
by Suren A. Chilingaryan
Implement DMA access synchronization in the driver |
19 |
PCILIB_KMEM_REUSE_REUSED = PCILIB_TRISTATE_YES, |
20 |
PCILIB_KMEM_REUSE_PARTIAL = PCILIB_TRISTATE_PARTIAL, |
|
21 |
PCILIB_KMEM_REUSE_PERSISTENT = 0x100, |
|
22 |
PCILIB_KMEM_REUSE_HARDWARE = 0x200 |
|
23 |
} pcilib_kmem_reuse_state_t; |
|
24 |
||
45
by root
North West Logick DMA implementation |
25 |
|
26 |
typedef struct { |
|
27 |
int handle_id; |
|
74
by Suren A. Chilingaryan
Implement DMA access synchronization for NWL implementation |
28 |
pcilib_kmem_reuse_state_t reused; |
29 |
||
45
by root
North West Logick DMA implementation |
30 |
uintptr_t pa; |
31 |
// uintptr_t va;
|
|
32 |
void *ua; |
|
33 |
size_t size; |
|
52
by Suren A. Chilingaryan
Support alignments in kmem allocation |
34 |
|
35 |
size_t alignment_offset; |
|
36 |
size_t mmap_offset; |
|
45
by root
North West Logick DMA implementation |
37 |
} pcilib_kmem_addr_t; |
38 |
||
39 |
/**
|
|
40 |
* single allocation - we set only addr, n_blocks = 0
|
|
41 |
* multiple allocation - addr is not set, blocks are set, n_blocks > 0
|
|
42 |
* sgmap allocation - addr contains ua, but pa's are set in blocks, n_blocks > 0
|
|
43 |
*/
|
|
44 |
typedef struct { |
|
45 |
pcilib_kmem_addr_t addr; |
|
73
by Suren A. Chilingaryan
Implement DMA access synchronization in the driver |
46 |
|
47 |
pcilib_kmem_reuse_state_t reused; |
|
45
by root
North West Logick DMA implementation |
48 |
|
49 |
size_t n_blocks; |
|
50 |
pcilib_kmem_addr_t blocks[]; |
|
51 |
} pcilib_kmem_buffer_t; |
|
52 |
||
53 |
typedef void pcilib_kmem_handle_t; |
|
54 |
||
55 |
||
56 |
typedef struct pcilib_kmem_list_s pcilib_kmem_list_t; |
|
57 |
struct pcilib_kmem_list_s { |
|
58 |
pcilib_kmem_list_t *next, *prev; |
|
59 |
||
60 |
pcilib_kmem_buffer_t buf; // variable size, should be last item in struct |
|
61 |
};
|
|
62 |
||
63 |
pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type_t type, size_t nmemb, size_t size, size_t alignment, pcilib_kmem_use_t use, pcilib_kmem_flags_t flags); |
|
71
by Suren A. Chilingaryan
First iteration of work to preserve DMA state between executions |
64 |
void pcilib_free_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_flags_t flags); |
106
by Suren A. Chilingaryan
Sync only required buffers |
65 |
//int pcilib_sync_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_sync_direction_t dir);
|
66 |
int pcilib_kmem_sync_block(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_sync_direction_t dir, size_t block); |
|
45
by root
North West Logick DMA implementation |
67 |
void *pcilib_kmem_get_ua(pcilib_t *ctx, pcilib_kmem_handle_t *k); |
68 |
uintptr_t pcilib_kmem_get_pa(pcilib_t *ctx, pcilib_kmem_handle_t *k); |
|
69 |
void *pcilib_kmem_get_block_ua(pcilib_t *ctx, pcilib_kmem_handle_t *k, size_t block); |
|
70 |
uintptr_t pcilib_kmem_get_block_pa(pcilib_t *ctx, pcilib_kmem_handle_t *k, size_t block); |
|
71 |
size_t pcilib_kmem_get_block_size(pcilib_t *ctx, pcilib_kmem_handle_t *k, size_t block); |
|
73
by Suren A. Chilingaryan
Implement DMA access synchronization in the driver |
72 |
pcilib_kmem_reuse_state_t pcilib_kmem_is_reused(pcilib_t *ctx, pcilib_kmem_handle_t *k); |
45
by root
North West Logick DMA implementation |
73 |
|
81
by Suren A. Chilingaryan
Support forceful clean-up of kernel memory |
74 |
int pcilib_clean_kernel_memory(pcilib_t *ctx, pcilib_kmem_use_t use, pcilib_kmem_flags_t flags); |
75 |
||
45
by root
North West Logick DMA implementation |
76 |
#endif /* _PCILIB_KMEM_H */ |