libparanut
A Hardware Abstraction Layer for ParaNut Architectures.
|
Functions for getting the status of your ParaNut and halting cores. More...
PN_NUMC | pn_numcores (void) |
Get the number of cores in your system. More... | |
PN_CMSK | pn_m2cap (void) |
Check which cores are capable of Mode 2 operation. More... | |
PN_CMSK | pn_m2cap_g (PN_NUMG groupnum) |
Check which cores are capable of Mode 2 operation. More... | |
PN_CMSK | pn_m3cap (void) |
Check which cores are capable of Mode 3 operation. More... | |
PN_CMSK | pn_m3cap_g (PN_NUMG groupnum) |
Check which cores are capable of Mode 3 operation. More... | |
PN_CID | pn_coreid (void) |
Get the ID of the core that this function is executed on. More... | |
PN_CID | pn_coreid_g (PN_NUMG *groupnum) |
Get the ID and group number of the core that this code is running on. More... | |
void | pn_halt (void) |
Halt whatever core the function is executed on. More... | |
int | pn_halt_CoPU (PN_CID coreid) |
Halts a CoPU. More... | |
int | pn_halt_CoPU_m (PN_CMSK coremask) |
Halts one or more CoPUs. More... | |
int | pn_halt_CoPU_gm (PN_CMSK *coremask_array, PN_NUMG array_size) |
Halts the CoPUs specified in the coremask_array. More... | |
unsigned int | pn_clock_freq (void) |
Returns system clock frequency in Hz. More... | |
unsigned int | pn_timebase_us (void) |
Returns machine timer timebase in us. More... | |
long long int | pn_time_ns (void) |
Returns system time in ns. Does not care for overflow. More... | |
int | pn_simulation (void) |
Checks if we run in simulation instead of real hardware. More... | |
Functions for getting the status of your ParaNut and halting cores.
Concerning the _g functions: If your ParaNut implementation has more cores than what is the standard register size on your system (i.e. register size is 32, but you got more than 32 cores including the CePU), you have to chose the group of cores that you want to talk to. For that, most functions in this section have a group version (suffix _g) which has an additional group parameter.
This works the following way: If your register size is 32, than the CePU is in group 0 (0x00000000) and is always represented by the first bit in the coremasks (0x00000001). The first CoPU is also in group 0 and represented by the second bit (0x00000002). After that comes the second CoPU, represented by 0x00000004. And so on until CoPU 30. The 31st CoPU is then represented by group 1 (0x00000001) and the first bit (0x00000001). The 63rd CoPU is represented by group 2 (0x00000002) and the first bit (0x00000001). The 95th CoPU is represented by group 3 (0x00000003) and the first bit (0x00000001). This information may become untrue if a big-endian version of the ParaNut is ever released.
For further information on this topic, you should check the ParaNut Manual itself. Also, the documentation on the ParaNut Modes that is included in here could clear some things up.
unsigned int pn_clock_freq | ( | void | ) |
Returns system clock frequency in Hz.
Returns the value of the paranut pnclockinfo register which should contain the current system clock frequency in Hz. If this value is not what you would expect check your implementation.
PN_CID pn_coreid | ( | void | ) |
Get the ID of the core that this function is executed on.
Get the ID and group number of the core that this code is running on.
[out] | groupnum | is a reference to be filled with the group number of the core. |
[out] | groupnum | is a reference to be filled with the group number of the core. |
void pn_halt | ( | void | ) |
Halt whatever core the function is executed on.
If executed on a core, it will be set to Mode 0 and stop operation. Causes reset of program counter to reset address on a Mode 2 capable CPU.
If executed on CePU, also halts all other CoPUs on system.
See documentation of Modes for more information.
This function returns nothing because it should not be possible for any core to leave this state on its own.
int pn_halt_CoPU | ( | PN_CID | coreid | ) |
Halts a CoPU.
Sets the CoPU with the given ID into a halted state (Mode 0).
See documentation of Modes for more information.
Cannot be executed on CoPU.
Halting an already halted core results in failure (PN_ERR_PARAM) to aid debugging.
[in] | coreid | is the ID of the CoPUs you want to halt. Since ID 0 represents the CePU, this function will throw an error when given 0 to aid debugging. If you want the CePU to halt, use function pn_halt(). |
Sets the CoPU with the given ID into a halted state (Mode 0).
See documentation of Modes for more information.
Cannot be executed on CoPU.
Halting an already halted core results in failure (PN_ERR_PARAM) to aid debugging.
[in] | coreid | is the ID of the CoPUs you want to halt. Since ID 0 represents the CePU, this function will throw an error when given 0 to aid debugging. If you want the CePU to halt, use function pn_halt(). |
Halts the CoPUs specified in the coremask_array.
Sets the CoPUs represented by bitmask and their position in the array (= their group number) into a halted state (Mode 0).
See documentation of Modes for more information.
Cannot be executed on CoPU.
Halting an already halted core results in failure (PN_ERR_PARAM) to aid debugging.
[in] | coremask_array | is a pointer to the start of a coremask array. The position of the mask in the array represents the group number of the cores. When all bits are set to 0, this function will return an error (PN_ERR_PARAM) to aid debugging. Also, setting the first bit to 1 will return an error (PN_ERR_PARAM) since it represents the CePU, which should be halted with pn_halt(). |
[in] | array_size | is the number of entries in the coremask_array. |
Sets the CoPUs represented by bitmask and their position in the array (= their group number) into a halted state (Mode 0).
See documentation of Modes for more information.
Cannot be executed on CoPU.
Halting an already halted core results in failure (PN_ERR_PARAM) to aid debugging.
[in] | coremask_array | is a pointer to the start of a coremask array. The position of the mask in the array represents the group number of the cores. When all bits are set to 0, this function will return an error (PN_ERR_PARAM) to aid debugging. Also, setting the first bit to 1 will return an error (PN_ERR_PARAM) since it represents the CePU, which should be halted with pn_halt(). |
[in] | array_size | is the number of entries in the coremask_array. |
int pn_halt_CoPU_m | ( | PN_CMSK | coremask | ) |
Halts one or more CoPUs.
Sets the CoPUs represented in the bitmask into a halted state (Mode 0).
See documentation of Modes for more information.
Cannot be executed on CoPU.
Halting an already halted core results in failure (PN_ERR_PARAM) to aid debugging.
[in] | coremask | is the bitmask representing the CoPUs you want to halt. When all bits are set to 0, this function will return an error (PN_ERR_PARAM) to aid debugging. Also, setting the first bit to 1 will return an error (PN_ERR_PARAM) since it represents the CePU, which should be halted with pn_halt(). |
PN_CMSK pn_m2cap | ( | void | ) |
Check which cores are capable of Mode 2 operation.
See documentation of Modes for more information.
Cannot be called from CoPU.
Check which cores are capable of Mode 2 operation.
See documentation of Modes for more information.
Cannot be called from CoPU.
[in] | groupnum | is the group of cores you want to know about. |
See documentation of Modes for more information.
Cannot be called from CoPU.
[in] | groupnum | is the group of cores you want to know about. |
PN_CMSK pn_m3cap | ( | void | ) |
Check which cores are capable of Mode 3 operation.
See documentation of Modes for more information.
Cannot be called from CoPU.
Check which cores are capable of Mode 3 operation.
See documentation of Modes for more information.
Cannot be called from CoPU.
[in] | groupnum | is the group of cores you want to know about. |
See documentation of Modes for more information.
Cannot be called from CoPU.
[in] | groupnum | is the group of cores you want to know about. |
PN_NUMC pn_numcores | ( | void | ) |
Get the number of cores in your system.
Cannot be called from CoPU.
int pn_simulation | ( | void | ) |
Checks if we run in simulation instead of real hardware.
long long int pn_time_ns | ( | void | ) |
Returns system time in ns. Does not care for overflow.
Cannot be executed on CoPU.
The first time executing this function takes the longest time since it has to initialize the frequency and an internal conversion factor. So if you want to use it for time measurement, you can call the function once before actual measurement to make the values more comparable.
When testing on my ParaNut, this made a difference of around 2000 ticks.
unsigned int pn_timebase_us | ( | void | ) |
Returns machine timer timebase in us.
Returns the value of the paranut pntimebase register which should contain the current machine timer timebase in us.