Critical Link MityCam SoC Firmware
1.0
Critical Link MityCam SoC Firmware
|
#include <RegisterFile.h>
Classes | |
struct | tsRegDefinition |
union | tuDataType |
Public Types | |
enum | teEndianness { eeLittleEndian, eeBigEndian } |
Public Member Functions | |
void | initialize (tcSensorBoard *apSensor, tcPayloadSetter *apIface) |
int | get_array (uint32_t address, uint8_t *buff, uint16_t length) const |
Retrieve RAW memory from register space. More... | |
int | get_buffer (uint32_t address, const char *&ptr, uint32_t &length) const |
void | update_buffer (uint32_t address, const uint8_t *buff, uint32_t length) |
GEV_STATUS | set_buffer (uint32_t address, const uint8_t *buff, uint32_t length) |
uint32_t | get_word (uint32_t address) |
void | update_word (uint32_t address, uint32_t data) |
Lean and mean write to shadow. Does not ripple through observers. More... | |
GEV_STATUS | set_word (uint32_t address, uint32_t data) |
uint64_t | get_long (uint32_t address) |
void | update_long (uint32_t address, uint64_t data) |
Lean and mean write to shadow. Does not ripple through observers. More... | |
GEV_STATUS | set_long (uint32_t address, uint64_t data) |
float | get_float (uint32_t address) |
void | update_float (uint32_t address, float data) |
Lean and mean write to shadow. Does not ripple through observers. More... | |
GEV_STATUS | set_float (uint32_t address, float data) |
std::string | get_string (uint32_t address) |
void | update_string (uint32_t address, const char *data, int len=-1) |
Lean and mean write to shadow. Does not ripple through observers. More... | |
GEV_STATUS | set_string (uint32_t address, const char *data) |
void | sync_manifest_table (const std::string &arXmlFile, const uint64_t fpga_version) |
void | sync_user_name (uint64_t anAddress) |
void | check_and_update_payload_size (uint64_t address) |
tsRegDefinition * | reg_def (const char *name) const |
tsRegDefinition * | reg_def (uint64_t address, bool sloppy=false) const |
tsRegDefinition * | next_reg (uint64_t address) const |
uint32_t | reg_addr (const char *name) |
int | reg_size (uint32_t address) |
std::string | reg_name (uint32_t address) |
bool | reg_valid (uint32_t address) |
Is the specified register address valid. More... | |
bool | reg_rd (uint32_t address) |
Is the specified register address readable. More... | |
bool | reg_wr (uint32_t address) |
Is the specified register address writeable. More... | |
bool | reg_a_valid (uint32_t address, int16_t size) |
Is the specified register address space valid. More... | |
bool | reg_a_rd (uint32_t address, int16_t size) |
Is the specified register address space readable. More... | |
bool | reg_a_wr (uint32_t address, int16_t size) |
Is the specified register address space writeable. More... | |
void | show_register (const tsRegDefinition *pregdef) |
void | show_all_registers () |
void | update_payload_size () |
This function is called whenever a register has been changed that will effect the payload size. More... | |
void | latch_timestamp () |
void | reset_timestamp () |
void | sharedInit () |
const struct timespec * | get_resettime () |
int | addRegister (tsRegDefinition *pdef) |
Public Member Functions inherited from tcObservable | |
tcObservable () | |
void | registerObserver (tcObserver *apObs) |
void | unregisterObserver (tcObserver *apObs) |
void | notifyChange (tsUpdate asMessage) |
Public Member Functions inherited from tcRegisterFileObservable | |
tcRegisterFileObservable () | |
virtual | ~tcRegisterFileObservable () |
void | registerReadObserver (int64_t anAddr, tcRegisterFileObserver *apObserver) |
registerReadObserver - Register an observer for pre-read notifications More... | |
void | unregisterReadObserver (tcRegisterFileObserver *apObserver) |
unregisterReadObserver Unregister the observer from pre-read notificatons More... | |
void | unregisterReadObserver (int64_t anAddr, tcRegisterFileObserver *apObserver) |
void | notifyRead (int64_t anAddr, int64_t anOffset, int64_t anLen) const |
notifyRead More... | |
Static Public Member Functions | |
static bool | instanceMade () |
static tcRegisterFile * | getInstance (tsRegDefinition *apRegs=NULL, bool abBigEndian=true) |
template<typename T > | |
static T | swap_endian (T u) |
static std::string | format_memdump (uint8_t *pbuff, uint16_t length) |
This function is for debugging. It formats a multiline string. More... | |
Static Public Attributes | |
static const uint32_t | cnNOADDRESS = 0xFFFFFFFF |
static const uint32_t | cnMAX_IMAGE_WIDTH = 3360 |
These may be dependant on the sensor type, but for now just want a handy place to put them. More... | |
static const uint32_t | cnMAX_IMAGE_HEIGHT = 2496 |
static const uint32_t | cnMAX_PAYLOAD_SIZE = cnMAX_IMAGE_WIDTH * cnMAX_IMAGE_HEIGHT * 2 |
Protected Member Functions | |
tcRegisterFile (tsRegDefinition *apRegs, bool abBigEndian) | |
template<typename ValueType , teRegType RegEnum> | |
ValueType | get_value (uint64_t address) |
template<typename ValueType , teRegType RegEnum> | |
void | update_value (uint64_t address, ValueType data) |
template<typename ValueType , teRegType RegEnum, typename UpdateMsg > | |
GEV_STATUS | set_value (uint32_t address, ValueType data) |
Additional Inherited Members | |
Protected Attributes inherited from tcRegisterFileObservable | |
std::unordered_map< int64_t, std::vector< tcRegisterFileObserver * > > | readObservers |
|
protected |
Constructor. This is called, currently, by GetInstance().
Use the addRegister() scheme and push the transport specific stuff into appropriate interface handlers. Remove calling this in tcControlApp and have getInstance() use the GenICam base register set (common for all). This will also allow sensors to define custom registers on the fly without having to reserve space for them in the main array (which is wasteful for other sensors).
push the abBigEndian stuff into the regsiter definition. Register endianness is not necessary the same for all registers. This is really inefficient for the GigE interface.
apRegs | array of registers to use. These must not be free'd. List must be terminated. |
abBigEndian | true if memory representation of all the registers should be big-endian. |
int tcRegisterFile::addRegister | ( | tsRegDefinition * | pdef | ) |
This function will add one new register definition to an existing map.
pdef | pointer to the new register definition to add. |
void tcRegisterFile::check_and_update_payload_size | ( | uint64_t | address | ) |
This function is called whenever a register has been changed. If the selected register impacts the output image payload size, then we call the update_payload_size method to handl the change.
|
static |
This function is for debugging. It formats a multiline string.
int tcRegisterFile::get_array | ( | uint32_t | address, |
uint8_t * | buff, | ||
uint16_t | length | ||
) | const |
Retrieve RAW memory from register space.
This is the main access point for external GenICam interfaces (e.g., GigE or U3V or CXP) reading register values from the register store. Data is returned as stored in memory - no data marshalling is performed, if it is stored as big endian, that's how it is retrieved, etc.)
address | the address of the register space to start reading |
buff | pointer to where the memory should be copied into |
length | the number of bytes to retrieve |
int tcRegisterFile::get_buffer | ( | uint32_t | address, |
const char *& | ptr, | ||
uint32_t & | length | ||
) | const |
This function retrieves a raw pointer to the requested buffer address.
[in] | address | The address of the register. Can be an offset into the buffer |
[out] | ptr | The pointer of the raw buffer |
[out] | length | the number of valid buffer bytes from the pointer position |
float tcRegisterFile::get_float | ( | uint32_t | address | ) |
This function retrieves the specified floating point register.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
uint64_t SocCamera::tcRegisterFile::get_long | ( | uint32_t | address | ) |
|
inline |
std::string tcRegisterFile::get_string | ( | uint32_t | address | ) |
This function retrieves the specified string register.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
|
inlineprotected |
Can be used for getting simple types; not strings.
address | the address of the desired register |
uint32_t tcRegisterFile::get_word | ( | uint32_t | address | ) |
This function retrieves the specified uint32_t type register.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
|
static |
This function provides a Singleton Accessor for the GenICam Reigster file object. There is some debate as to whether a Singleton should be used vs. a global pointer constructed early in the initialization sequence, but currently this is the implementation. Truthfully, if we ever have a board that supports both GigE and U3V at the same time (which require different endianness implementations as currently designed), we'll need to relook at this implementation anyway. The application doesn't shutdown at all right now, so there is no need for reference counting to clean up nicely.
Normally, code wanting access to this object will call getInstance() with no parameters, but the actual first construction calls need to construct this with the apRegs and Engine parameters.
So the current implementation must call getInstance() in the "correct order" (as part of the GigE or U3V interface construction) otherwise a tcRegisterFile() will be constructed with a NULL initialization structure, and reigster accesses will likely result in a lot of nothing being returned.
This archiecture is a "force fit" leftover from initially only supporting GigE and then attempting to add U3V support at a later time and reusing this management code.
[in] | apRegs | A least of registers that should be created / managed by the class. See tsRegDefinition |
[in] | abBigEndian | When true, this class will store/retrieve integer and float parameters as big endian values. |
void tcRegisterFile::initialize | ( | tcSensorBoard * | apSensor, |
tcPayloadSetter * | apIface | ||
) |
Initialize a few known GenICam registers with default values from sensor. This routine also snags a pointer to a payload setter object to force computing the payloadsize when dependent registers change.
This entire method should really go away. The tcRegisterFile should not have any "knowledge" of how the registers should be configured. Most of these parameters should be set directly by the tcSensorBoard classes. Originally they were not because the CameraLink variants didn't have/use a tcRegisterFile. This is no longer true. There is always a tcRegisterFile present. We leave it mostly due to fears of regression, but it needs to be cleaned up.
Along with above comment, the whole payloadsetter thing should move to a separate Handler and not be integrated into the register file class. Again, fear of regression at this point makes us leave things alone...
apSensor | pointer to active tcSensorBoard class |
apIface | pointer to an object providing the tcPayloadSetting interface. |
|
static |
void tcRegisterFile::latch_timestamp | ( | ) |
This function helps support the timestamp registers. It is called when someone writes the timestamp control register with the latch bit set. It grabs the current time subtracts off the time the last time the timestamp counter was reset and then updates the two timesstamp registers
tcRegisterFile::tsRegDefinition * tcRegisterFile::next_reg | ( | uint64_t | address | ) | const |
This function returns a pointer to the entry in the register definition file that corresponds to the next legally defined register at or above the specified address.
[in] | address | The address to start searching |
bool tcRegisterFile::reg_a_rd | ( | uint32_t | address, |
int16_t | size | ||
) |
Is the specified register address space readable.
This function determines if a register is readable at the specified address and that the register if defined is large enough to hold the specified number of bytes. Or if not large enough if there are contiguous readable registers large enough to make the read viable.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | size | The number of bytes starting at the specified address that must fit within that register. |
bool tcRegisterFile::reg_a_valid | ( | uint32_t | address, |
int16_t | size | ||
) |
Is the specified register address space valid.
This function determines if a register is defined at the specified address and that the register if defined is large enough to hold the specified number of bytes. Or if not large enough if there are contiguous registers large enough to make the access viable. i.e. Read the memory for mac low and high in one operation.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | size | The number of bytes starting at the specified address that must fit within that register. |
bool tcRegisterFile::reg_a_wr | ( | uint32_t | address, |
int16_t | size | ||
) |
Is the specified register address space writeable.
This function determines if a register is writable at the specified address and that the register if defined is large enough to hold the specified number of bytes. Or if not large enough if there are contiguous writable registers large enough to make the read viable.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | size | The number of bytes starting at the specified address that must fit within that register. |
uint32_t tcRegisterFile::reg_addr | ( | const char * | name | ) |
This function returns the register address that corresponds to the specified register name.
[in] | name | The name of the register (i.e. "SCP0"). |
tcRegisterFile::tsRegDefinition * tcRegisterFile::reg_def | ( | const char * | name | ) | const |
This function returns a pointer to the entry in the register definition file that corresponds to the specified register name.
[in] | name | The name of the register (i.e. "SCP0"). |
tcRegisterFile::tsRegDefinition * tcRegisterFile::reg_def | ( | uint64_t | address, |
bool | sloppy = false |
||
) | const |
This function returns a pointer to the entry in the register definition file that corresponds to the specified register address.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | sloppy | If true a sloppy address comparison is done. Sloppy comparison meaning that any address within the register will make a match. For example the SCP0 register is at address 0x0d00. If an address of 0x0d01 is specified and sloppy is true the table entry for SCP0 will be returned, but if 0x0d01 is specified and sloppy is false no match is found and NULL will be returned. |
std::string tcRegisterFile::reg_name | ( | uint32_t | address | ) |
This function returns the name that corresponds to the specified register address.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
bool tcRegisterFile::reg_rd | ( | uint32_t | address | ) |
Is the specified register address readable.
This function determines if a readable register is defined at the specified address.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
int tcRegisterFile::reg_size | ( | uint32_t | address | ) |
This function returns the register size that corresponds to the specified register address.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
bool tcRegisterFile::reg_valid | ( | uint32_t | address | ) |
Is the specified register address valid.
This function determines if a register is defined at the specified address.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
bool tcRegisterFile::reg_wr | ( | uint32_t | address | ) |
Is the specified register address writeable.
This function determines if a writeable register is defined at the specified address.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
void tcRegisterFile::reset_timestamp | ( | ) |
This function helps support the timestamp registers. It is called when someone writes the timestamp control register with the reset bit set. We store a new current timestamp to use in the future as our base time.
GEV_STATUS tcRegisterFile::set_buffer | ( | uint32_t | address, |
const uint8_t * | buff, | ||
uint32_t | length | ||
) |
This function sets the specified buffer register and invokes the command handler chain to process the change.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | buff | The new value for the register. |
[in] | length | The number of bytes to retrieve. |
GEV_STATUS tcRegisterFile::set_float | ( | uint32_t | address, |
float | data | ||
) |
This function sets the specified floating point register and invokes the command handler chain to process the change.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | data | The new floating point value for the register. |
GEV_STATUS SocCamera::tcRegisterFile::set_long | ( | uint32_t | address, |
uint64_t | data | ||
) |
GEV_STATUS tcRegisterFile::set_string | ( | uint32_t | address, |
const char * | data | ||
) |
This function sets the specified string register and invokes the command handler chain to process the change.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | data | The new string value for the register. |
|
inlineprotected |
This routine is called when a register write has been requested. This will force all Observers of register writes to be called in order to support validation of the register setting.
address | the logical register address |
data | the data to write (in HOST endian storage, little endian) |
GEV_STATUS tcRegisterFile::set_word | ( | uint32_t | address, |
uint32_t | data | ||
) |
This function sets the specified uint32_t type register and invokes the command handler chain to process the change.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | data | The new value for the register. |
void SocCamera::tcRegisterFile::sharedInit | ( | ) |
void tcRegisterFile::show_all_registers | ( | ) |
This function is for debugging. It will dump all the registers to the console.
[in] | pregdef | A pointer to an entry in the register definitions table. |
void tcRegisterFile::show_register | ( | const tsRegDefinition * | pregdef | ) |
This function is for debugging. It will dump the specified register to the console.
[in] | pregdef | A pointer to an entry in the register definitions table. |
|
inlinestatic |
void SocCamera::tcRegisterFile::sync_manifest_table | ( | const std::string & | arXmlFile, |
const uint64_t | fpga_version | ||
) |
void SocCamera::tcRegisterFile::sync_user_name | ( | uint64_t | anAddress | ) |
void tcRegisterFile::update_buffer | ( | uint32_t | address, |
const uint8_t * | buff, | ||
uint32_t | length | ||
) |
This function updates a raw pointer backing store with the provided buffer
[in] | address | The address of the register. Can be an offset into the buffer |
[in] | buff | The pointer of the buffer to copy into the backing store |
[in] | length | the number of buffer bytes from the pointer position |
void tcRegisterFile::update_float | ( | uint32_t | address, |
float | data | ||
) |
Lean and mean write to shadow. Does not ripple through observers.
This function writes the specified floating point register.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | data | The new floating point value for the register. |
void SocCamera::tcRegisterFile::update_long | ( | uint32_t | address, |
uint64_t | data | ||
) |
Lean and mean write to shadow. Does not ripple through observers.
void tcRegisterFile::update_payload_size | ( | ) |
This function is called whenever a register has been changed that will effect the payload size.
void tcRegisterFile::update_string | ( | uint32_t | address, |
const char * | data, | ||
int | len = -1 |
||
) |
Lean and mean write to shadow. Does not ripple through observers.
This function writes the specified string register.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | data | The new floating string value for the register. |
|
inlineprotected |
This routine is called when a register write has occurred and validation is OK and all command handlers have had a chance to check / handle the impact of the register change.
address | the logical register address |
data | the data to write (in proper endian storage) |
void tcRegisterFile::update_word | ( | uint32_t | address, |
uint32_t | data | ||
) |
Lean and mean write to shadow. Does not ripple through observers.
This function writes the specified uint32_t type register.
[in] | address | The address of the register (i.e. SCP0_ADDR or 0x0d00). |
[in] | data | The new floating point value for the register. |
|
static |
|
static |
These may be dependant on the sensor type, but for now just want a handy place to put them.
|
static |
|
static |