pflib v3.9.0-rc3-11-g2537d8f
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
UIO.h
1#ifndef ZCU_UIO_H_INCLUDED
2#define ZCU_UIO_H_INCLUDED
8#include <stdint.h>
9#include <unistd.h>
10
11#include <string>
12
13namespace pflib {
14
15class UIO {
16 public:
19 UIO(const std::string& name, size_t size = 4096);
20
23 ~UIO();
24
26 uint32_t read(size_t i) { return (i < size_) ? (ptr_[i]) : (0xDEADB33F); }
27
29 void write(size_t where, uint32_t what);
30
32 uint32_t readMasked(size_t where, uint32_t mask) {
33 return (read(where) & mask) >> first_bit_set(mask);
34 }
35
37 void writeMasked(size_t where, uint32_t mask, uint32_t val) {
38 rmw(where, mask, (val << first_bit_set(mask)) & mask);
39 }
40
42 void rmw(size_t where, uint32_t bits_to_modify, uint32_t newval);
43
44 private:
46 void iopen(const std::string& dev, size_t size = 4096);
47
48 int first_bit_set(uint32_t mask) {
49 int i;
50 for (i = 0; i < 32; i++)
51 if ((mask & (1 << i)) != 0) return i;
52 return 32;
53 }
54 std::string name_;
55 size_t size_;
56 uint32_t* ptr_;
57 int handle_;
58};
59} // namespace pflib
60#endif
Definition UIO.h:15
UIO(const std::string &name, size_t size=4096)
Open the UIO device given a name, mapping the amount of memory indicated.
Definition UIO.cxx:25
void writeMasked(size_t where, uint32_t mask, uint32_t val)
write with a mask (including shifts)
Definition UIO.h:37
void write(size_t where, uint32_t what)
Write the given value to the UIO device register.
Definition UIO.cxx:129
void iopen(const std::string &dev, size_t size=4096)
Open a given device file directly.
Definition UIO.cxx:99
uint32_t readMasked(size_t where, uint32_t mask)
read with a mask (including shifts)
Definition UIO.h:32
void rmw(size_t where, uint32_t bits_to_modify, uint32_t newval)
Generate an RMW cycle (read, apply INVERSE OF MASK, apply OR)
Definition UIO.cxx:139
uint32_t read(size_t i)
Read the given word from the UIO device register space.
Definition UIO.h:26
~UIO()
Open the UIO device given, mapping the amount of memory indicated.
Definition UIO.cxx:115
This version of the fast control code interfaces with the CMS Fast control library which can be contr...
Definition Backend.cxx:3