-
Patrick Robbe authoredPatrick Robbe authored
ecs_driverlib.h 1.76 KiB
#ifndef __PCIE40_ECS_H
#define __PCIE40_ECS_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
//dg`wt.pcie40.c.ecs` In order to interact with the ECS interface of the PCIe40 driver, C libraries are provided (*libpcie40_ecs.so* and *libpcie40_ecs.a*).
// To use these libraries, add ``#include <lhcb/pcie40/ecs.h>`` to your source code and ``-lpcie40_ecs`` to your linker flags.
// This API is very simple, consisting only of a handful of functions to create I/O memory mappings and to access individual I/O registers, see <<PCIe40 driver ECS API>>.
//`p40_ecs_open` Create file descriptor to access an ECS BAR.
int p40_ecs_open(int dev, int bar, uint32_t **regs);//?>
//>`dev` Device identifier corresponding to the given board.
//>`bar` PCI BAR to access, valid values are 0 (for the user registers) and 2 (for the low-level registers).
//<`regs` Address of a valid +uint32_t *+ pointer. It is set by the function upon return.
//`p40_ecs_close` Destroy file descriptor to an open ECS BAR.
void p40_ecs_close(int fd, uint32_t *regs);//?>
//>`fd` File descriptor returned by `p40_ecs_open` .
//>`regs` Pointer populated by `p40_ecs_open` .
//`p40_ecs_bar_size` Query driver for size of a given PCI BAR.
int p40_ecs_bar_size(int fd);//?>
//>`fd` File descriptor returned by `p40_ecs_open` .
//`p40_ecs_w32` Write register at given address.
void p40_ecs_w32(uint32_t volatile *regs, uint32_t addr, uint32_t val);//?>
//>`regs` Pointer populated by `p40_ecs_open` .
//>`addr` Address of register.
//>`val` 32-bit value to write.
//`p40_ecs_r32` Read register at given address.
uint32_t p40_ecs_r32(uint32_t volatile *regs, uint32_t addr);//?>
//>`regs` Pointer populated by `p40_ecs_open` .
//>`addr` Address of register.
#ifdef __cplusplus
} //extern "C"
#endif
#endif//__PCIE40_ECS_H