Commit bb8727d9 authored by Federico Vaga's avatar Federico Vaga

rt: a RT application can be compatible with many FPGA ID

The original assumption that each RT application is compatible with only
one FPGA bitstream is wrong. A RT application can run, as is, on different
FPGA designs. For instance, an "hello world" application can run on any FPGA
design. To be more concrete, the white-rabbit PTP core can run on different
FPGA applications.
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 0f1697bd
......@@ -410,19 +410,34 @@ void rt_get_time(uint32_t *seconds, uint32_t *cycles)
/**
* Initialize the rt library for an optimal usage
* The function initializes the library and it does some compatibility check.
* Initialization
*- purge all the output host-message-queue
* compatibility checks:
* - check bitstream FPGA ID if compatibile with the application. The value in
* app->version.fpga_id will be updated with the FPGA ID from the bitstream
*/
void rt_init(struct rt_application *app)
int rt_init(struct rt_application *app)
{
int i;
uint32_t *fpga_id = &app->version.fpga_id; /* in order to overwrite the const */
_app = app;
pp_printf("Running application '%s'\n", _app->name);
if (_app->version.fpga_id) {
pp_printf(" compatible only with FPGA '0x%"PRIx32"'\n",
_app->version.fpga_id);
/* TODO get app id from FPGA and compare */
/* *fpga_id = 0x1234; /\* TODO read it from the FPGA ID register *\/ */
for (i = 0; i < app->fpga_id_compat_n; i++) {
if (app->fpga_id_compat[i] == *fpga_id)
break;
}
if (app->fpga_id_compat_n && app->fpga_id_compat_n == i) {
pp_printf(" FPGA '0x%"PRIx32"' not compatible with RT app: 0x%"PRIx32" 0x%"PRIx32" (git %"PRIx32")\n",
_app->version.fpga_id,
_app->version.rt_id,
_app->version.rt_version,
_app->version.git_version);
return -1;
}
pp_printf(" application id \t'0x%"PRIx32"'\n", _app->version.rt_id);
pp_printf(" application version\t'%"PRId32".%"PRId32"'\n",
......@@ -449,4 +464,6 @@ void rt_init(struct rt_application *app)
_app->structures[i].struct_ptr,
_app->structures[i].len);
#endif
return 0;
}
......@@ -100,7 +100,11 @@ struct rt_mq {
*/
struct rt_application {
const char name[16];
const struct trtl_rt_version version;
const uint32_t *fpga_id_compat; /**< list of compatible FPGA
application ID */
const unsigned int fpga_id_compat_n; /**< number of entry in
the fpga_id_compat list */
const struct trtl_rt_version version; /**< version running */
struct rt_mq *mq; /**< list of used MQ */
uint8_t n_mq; /**< number of available MQ */
......@@ -114,7 +118,7 @@ struct rt_application {
unsigned int n_actions;
};
extern void rt_init(struct rt_application *app);
extern int rt_init(struct rt_application *app);
extern int rt_mq_register(struct rt_mq *mq, unsigned int n);
extern int rt_mq_action_register(uint32_t id, action_t action);
extern int rt_mq_action_dispatch(unsigned int mq_in);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment