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.
8
16
pcilib_bar_t pcilib_detect_bar(pcilib_t *ctx, uintptr_t addr, size_t size);
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.
28
void *pcilib_map_bar(pcilib_t *ctx, pcilib_bar_t bar);
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
39
void pcilib_unmap_bar(pcilib_t *ctx, pcilib_bar_t bar, void *data);
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
9
53
int pcilib_detect_address(pcilib_t *ctx, pcilib_bar_t *bar, uintptr_t *addr, size_t size);
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
64
char *pcilib_resolve_data_space(pcilib_t *ctx, uintptr_t addr, size_t *size);
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
76
char *pcilib_resolve_register_address(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr);