/alps/pcitool

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/bar.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-10-22 13:57:59 UTC
  • Revision ID: csa@suren.me-20151022135759-nqs5wowy38tvbw09
Documentation update

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
extern "C" {
6
6
#endif
7
7
 
 
8
/**
 
9
 * Detects in which PCI BAR the specified buffer is residing. The complete specified buffer
 
10
 * of \a size bytes should fit into the BAR. Otherwise, an error will be returned.
 
11
 * @param[in] ctx       - pcilib context
 
12
 * @param[in] addr      - physical address of the begining of the buffer
 
13
 * @param[in] size      - the size of the buffer
 
14
 * @return              - return the BAR (numbered from 0) or PCILIB_BAR_INVALID if buffer does not belong to any BAR.
 
15
 */
8
16
pcilib_bar_t pcilib_detect_bar(pcilib_t *ctx, uintptr_t addr, size_t size);
 
17
 
 
18
/**
 
19
 * Maps the specified bar to the address space of the process. This function may be called multiple times for 
 
20
 * the same bar. It will only map the BAR once. Normally, the required BARs will be automatically mapped when
 
21
 * BAR addresses are resolved with pcilib_resolve_bar_address() and similar.
 
22
 * @param[in,out] ctx   - pcilib context
 
23
 * @param[in] bar       - the PCI BAR number (numbered from 0)
 
24
 * return               - the address where the BAR is mapped. You can't use this address directly, 
 
25
 *                      instead pcilib_resolve_register_address(ctx, bar, 0) have to be used to find 
 
26
 *                      the start of the BAR in virtual address space.
 
27
 */
 
28
void *pcilib_map_bar(pcilib_t *ctx, pcilib_bar_t bar);
 
29
 
 
30
/**
 
31
 * Unmaps the specified bar from the address space of the process. Actually, it will only unmap the BAR if it is 
 
32
 * not used by DMA or Event egines. So, it is fine to include the calls to pcilib_map_bar() / pcilib_unmap_bar() 
 
33
 * when a specific BAR is needed. On other hand, there is a little point in doing so. The BAR may be left mapped
 
34
 * and will be automatically umapped when pcilib_close() is called.
 
35
 * @param[in,out] ctx   - pcilib context
 
36
 * @param[in] bar       - BAR number (numbered from 0)
 
37
 * @param[in,out] data  - The address returned by pcilib_map_bar() call
 
38
 */
 
39
void pcilib_unmap_bar(pcilib_t *ctx, pcilib_bar_t bar, void *data);
 
40
 
 
41
/**
 
42
 * Detects the BAR and mapping offset of the specified PCI buffer. The complete specified buffer
 
43
 * of \a size bytes should fit into the BAR. Otherwise, an error will be returned.
 
44
 * @param[in] ctx       - pcilib context
 
45
 * @param[in,out] bar   - the function will check if the buffer belongs to the specified BAR unless bar is PCILIB_BAR_DETECT.
 
46
 *                      It will be set to the actually detected BAR in the last case.
 
47
 * @param[in,out] addr  - specifies the address to detect. The address may be specified as absolute physical address or offset in the BAR.
 
48
 *                      On success, the addr will contain offset which should be added to the address returned by pcilib_map_bar()
 
49
 *                      to get position of BAR mapping in virtual address space.
 
50
 * @param[in] size      - the size of the buffer
 
51
 * @return              - error code or 0 in case of success
 
52
 */
9
53
int pcilib_detect_address(pcilib_t *ctx, pcilib_bar_t *bar, uintptr_t *addr, size_t size);
10
54
 
 
55
/**
 
56
 * Resolves the virtual address and the size of PCI BAR space used for data exchange.
 
57
 * This is left-over from older version of pcilib and currently unused. We may reconsider
 
58
 * how it is organized and implemented. The data_space parameter may go into the model definition.
 
59
 * @param[in] ctx       - pcilib context
 
60
 * @param[in] addr      - may hint there the data space is located, use 0 to autodetect
 
61
 * @param[out] size     - the size of data space is returned
 
62
 * @return              - virtual address of data space (ready to use) or NULL if detection has failed
 
63
 */
 
64
char *pcilib_resolve_data_space(pcilib_t *ctx, uintptr_t addr, size_t *size);
 
65
 
 
66
 
 
67
/**
 
68
 * The wrapper arround pcilib_resolve_bar_address() provided for backward compatibility. 
 
69
 * If bar is not specified, it first checks the first BAR with registers, before searching
 
70
 * in other available BARs.
 
71
 * @param[in,out] ctx   - pcilib context
 
72
 * @param[in] bar       - specifies the BAR address belong to, use PCILIB_BAR_DETECT for autodetection
 
73
 * @param[in] addr      - specifies the physical address on the PCI bus or offset in the BAR if \a bar is specified
 
74
 * @return              - the virtual address in the process address space or NULL in case of error
 
75
 */
 
76
char *pcilib_resolve_register_address(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr); 
11
77
 
12
78
#ifdef __cplusplus
13
79
}