AleXelA
AleXelA

Reputation: 13

Writing callback function for Xtensa simcall function

I'm writing a code in C++ for Xtensa virtual platform. I want to use the functionality of the simcall_callback, to return data from the internal FW code. My C++ is a little bit rusty.

  1. How do I build the callback function for the following typedef of the callback:
typedef int(∗ simcall_callback)(xtsc_core &core, void ∗callback_arg, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
  1. The function used for setting this callback is:
simcall_callback set_simcall_callback (simcall_callback callback, void ∗callback_arg, void ∗∗ previous_arg = NULL)

How should I invoke the set_simcall_callback correctly, and what should be the second and third arguments?

Documentation about the Xtensa callback functions can be found at the following link (Pg.282, 309)

Upvotes: 1

Views: 113

Answers (1)

Andrey Sv
Andrey Sv

Reputation: 257

If you need declare function you can do it like this:

simcall_callback simcall_callback_func;

Then you need define callback function body:

int simcall_callback_func (xtsc_core &core, void *callback_arg, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
 {
     // Do what you need
     return 0;
 }

then you can invoke set_simcall_callback where first parameter our declared function. All parameters are described on page 310 of instraction.

int main()
 {
     // If you need previouse function then hold returned value
     simcall_callback prev_func = set_simcall_callback (simcall_callback_func, NULL);
     return 0;
 }

Upvotes: 1

Related Questions