|
Aseba
1.5.5
|
Glue logic must implement: More...
Classes | |
| struct | AsebaVariableDescription |
| Description of a variable. More... | |
| struct | AsebaVMDescription |
| Description of all variable. More... | |
| struct | AsebaLocalEventDescription |
| Description of a local event. More... | |
| struct | AsebaNativeFunctionArgumentDescription |
| Description of an argument of a native function. More... | |
| struct | AsebaNativeFunctionDescription |
| Description of a native function. More... | |
| struct | AsebaVMState |
| This structure contains the state of the Aseba VM. More... | |
Macros | |
| #define | ASEBA_NATIVES_STD_COUNT 21 |
| Embedded targets must know the size of ASEBA_NATIVES_STD_FUNCTIONS without having to compute them by hand, please update this when adding a new function. | |
| #define | ASEBA_NATIVES_STD_FUNCTIONS |
| snippet to include standard native functions More... | |
| #define | ASEBA_NATIVES_STD_DESCRIPTIONS |
| snippet to include descriptions of standard native functions More... | |
| #define | GET_BIT(v, b) (((v) >> (b)) & 0x1) |
| Return true if bit b of v is 1. | |
| #define | BIT_SET(v, b) ((v) |= (1 << (b))) |
| Set bit b of v to 1. | |
| #define | BIT_CLR(v, b) ((v) &= (~(1 << (b)))) |
| Set bit b of v to 0. | |
| #define | AsebaMaskSet(v, m) ((v) |= (m)) |
| Set the part masked by m of v to 1. | |
| #define | AsebaMaskClear(v, m) ((v) &= (~(m))) |
| Set the part masked by m of v to 0. | |
| #define | AsebaMaskIsSet(v, m) (((v) & (m)) != 0) |
| Returns true if the part masked by m of v is 1. | |
| #define | AsebaMaskIsClear(v, m) (((v) & (m)) == 0) |
| Returns true if the part masked by m of v is 0. | |
| #define | AsebaSendMessageWords(vm, type, data, size) AsebaSendMessage(vm,type,data,(size)*2) |
Typedefs | |
| typedef void(* | AsebaNativeFunctionPointer) (AsebaVMState *vm) |
| Signature of a native function. | |
Enumerations | |
| enum | { ASEBA_MAX_BREAKPOINTS = 16 } |
| enum | AsebaAssertReason { ASEBA_ASSERT_UNKNOWN = 0, ASEBA_ASSERT_UNKNOWN_UNARY_OPERATOR, ASEBA_ASSERT_UNKNOWN_BINARY_OPERATOR, ASEBA_ASSERT_UNKNOWN_BYTECODE, ASEBA_ASSERT_STACK_OVERFLOW, ASEBA_ASSERT_STACK_UNDERFLOW, ASEBA_ASSERT_OUT_OF_VARIABLES_BOUNDS, ASEBA_ASSERT_OUT_OF_BYTECODE_BOUNDS, ASEBA_ASSERT_STEP_OUT_OF_RUN, ASEBA_ASSERT_BREAKPOINT_OUT_OF_BYTECODE_BOUNDS, ASEBA_ASSERT_EMIT_BUFFER_TOO_LONG } |
| Possible causes of AsebaAssert. | |
Functions | |
| sint16 | aseba_atan2 (sint16 y, sint16 x) |
| sint16 | aseba_sin (sint16 angle) |
| sint16 | aseba_cos (sint16 angle) |
| sint16 | aseba_sqrt (sint16 num) |
| void | aseba_comb_sort (sint16 *input, uint16 size) |
| void | AsebaNative_veccopy (AsebaVMState *vm) |
| Function to copy a vector. | |
| void | AsebaNative_vecfill (AsebaVMState *vm) |
| Function to fill all the elements of a vector to a specific value. | |
| void | AsebaNative_vecaddscalar (AsebaVMState *vm) |
| Function to add a scalar to each element of a vector. | |
| void | AsebaNative_vecadd (AsebaVMState *vm) |
| Function to add two vectors. | |
| void | AsebaNative_vecsub (AsebaVMState *vm) |
| Function to substract two vectors. | |
| void | AsebaNative_vecmul (AsebaVMState *vm) |
| Function to multiply two vectors elements by elements. | |
| void | AsebaNative_vecdiv (AsebaVMState *vm) |
| Function to divide two vectors elements by elements. | |
| void | AsebaNative_vecmin (AsebaVMState *vm) |
| Function to take the element by element minimum. | |
| void | AsebaNative_vecmax (AsebaVMState *vm) |
| Function to take the element by element maximum. | |
| void | AsebaNative_vecclamp (AsebaVMState *vm) |
| Function to clamp a vector of values element by element. | |
| void | AsebaNative_vecdot (AsebaVMState *vm) |
| Function to perform a dot product on a vector. | |
| void | AsebaNative_vecstat (AsebaVMState *vm) |
| Function to perform statistics on a vector. | |
| void | AsebaNative_vecargbounds (AsebaVMState *vm) |
| Function to get indices of the bounds of a vector. | |
| void | AsebaNative_vecsort (AsebaVMState *vm) |
| Function to sort a vector. | |
| void | AsebaNative_mathmuldiv (AsebaVMState *vm) |
| Function to perform dest = (a*b)/c in 32 bits. | |
| void | AsebaNative_mathatan2 (AsebaVMState *vm) |
| Function to perform atan2. | |
| void | AsebaNative_mathsin (AsebaVMState *vm) |
| Function to perform sin. | |
| void | AsebaNative_mathcos (AsebaVMState *vm) |
| Function to perform cos. | |
| void | AsebaNative_mathrot2 (AsebaVMState *vm) |
| Function to perform the rotation of a vector. | |
| void | AsebaNative_mathsqrt (AsebaVMState *vm) |
| Function to perform sqrt. | |
| void | AsebaNative_vecnonzerosequence (AsebaVMState *vm) |
| Function to get the middle index of the largest sequence of non-zero elements. | |
| void | AsebaSetRandomSeed (uint16 seed) |
| Functon to set the seed of random generator. | |
| uint16 | AsebaGetRandom (void) |
| Functon to get a random number. | |
| void | AsebaNative_rand (AsebaVMState *vm) |
| Function to get a 16-bit signed random number. | |
| void | AsebaVMSendExecutionStateChanged (AsebaVMState *vm) |
| Send an execution state changed message. | |
| void | AsebaVMInit (AsebaVMState *vm) |
| Setup the execution status of the VM. More... | |
| uint16 | AsebaVMGetEventAddress (AsebaVMState *vm, uint16 event) |
| Return the starting address of an event, or 0 if the event is not handled. More... | |
| uint16 | AsebaVMSetupEvent (AsebaVMState *vm, uint16 event) |
| Setup VM to execute an event. More... | |
| void | AsebaVMStep (AsebaVMState *vm) |
| Execute one bytecode of the current VM thread. More... | |
| void | AsebaVMEmitNodeSpecificError (AsebaVMState *vm, const char *message) |
| Can be called by glue code (including native functions), to stop vm and emit a node specific error. | |
| uint16 | AsebaVMCheckBreakpoint (AsebaVMState *vm) |
| Execute on bytecode of the current VM thread and check for potential breakpoints. More... | |
| void | AsebaDebugBareRun (AsebaVMState *vm, uint16 stepsLimit) |
| Run without support of breakpoints. More... | |
| void | AsebaDebugBreakpointRun (AsebaVMState *vm, uint16 stepsLimit) |
| Run with support of breakpoints. More... | |
| uint16 | AsebaVMRun (AsebaVMState *vm, uint16 stepsLimit) |
| Run the VM depending on the current execution mode. More... | |
| uint8 | AsebaVMSetBreakpoint (AsebaVMState *vm, uint16 pc) |
| Set a breakpoint at a specific location. More... | |
| uint16 | AsebaVMClearBreakpoint (AsebaVMState *vm, uint16 pc) |
| Clear the breakpoint at a specific location. More... | |
| void | AsebaVMClearBreakpoints (AsebaVMState *vm) |
| Clear all breakpoints. More... | |
| void | AsebaVMDebugMessage (AsebaVMState *vm, uint16 id, uint16 *data, uint16 dataLength) |
| Execute a debug action from a debug message. More... | |
| uint16 | AsebaVMShouldDropPacket (AsebaVMState *vm, uint16 source, const uint8 *data) |
| Return non-zero if VM will ignore the packet, 0 otherwise. | |
| void | AsebaSendMessage (AsebaVMState *vm, uint16 id, const void *data, uint16 size) |
| Called by AsebaStep if there is a message (not an user event) to send. More... | |
| void | AsebaSendVariables (AsebaVMState *vm, uint16 start, uint16 length) |
| Called by AsebaVMDebugMessage when some variables must be sent efficiently. | |
| void | AsebaSendDescription (AsebaVMState *vm) |
| Called by AsebaVMDebugMessage when VM must send its description on the network. More... | |
| void | AsebaNativeFunction (AsebaVMState *vm, uint16 id) |
| Called by AsebaStep to perform a native function call. More... | |
| void | AsebaWriteBytecode (AsebaVMState *vm) |
| Called by AsebaVMDebugMessage when VM must write its bytecode to flash, write an empty function to leave feature unsupported. | |
| void | AsebaResetIntoBootloader (AsebaVMState *vm) |
| Called by AsebaVMDebugMessage when VM must restart the node and enter to the bootloader, write an empty function to leave feature unsupported. | |
| void | AsebaPutVmToSleep (AsebaVMState *vm) |
| Called by AsebaVMDebugMessage when VM must put to node in deep sleep. More... | |
| void | __attribute__ ((weak)) AsebaVMRunCB(AsebaVMState *vm) |
| Called by AsebaVMDebugMessage when VM is going to be run. More... | |
| void | AsebaAssert (AsebaVMState *vm, AsebaAssertReason reason) |
| If ASEBA_ASSERT is defined, this function is called when an error arise. | |
Glue logic must implement:
if (debug command queue is not empty)
execute debug command
else if (executing a thread)
run VM
else if (event queue is not empty)
fetch event
run VM
else
sleep until something happens
| #define ASEBA_NATIVES_STD_DESCRIPTIONS |
snippet to include descriptions of standard native functions
| #define ASEBA_NATIVES_STD_FUNCTIONS |
snippet to include standard native functions
| anonymous enum |
| void __attribute__ | ( | (weak) | ) |
Called by AsebaVMDebugMessage when VM is going to be run.
Called by AsebaVMEmitNodeSpecificError to be notified when VM hit an execution error Is also called for wrong array access or division by 0 with message == NULL.
Called by AsebaVMDebugMessage when VM is being resetted.
| void AsebaDebugBareRun | ( | AsebaVMState * | vm, |
| uint16 | stepsLimit | ||
| ) |
Run without support of breakpoints.
Check ASEBA_VM_EVENT_RUNNING_MASK to exit on interrupts or stepsLimit if > 0.
References ASEBA_VM_EVENT_ACTIVE_MASK, ASEBA_VM_EVENT_RUNNING_MASK, AsebaMaskClear, AsebaMaskIsSet, AsebaMaskSet, and AsebaVMStep().
Referenced by AsebaVMRun().
| void AsebaDebugBreakpointRun | ( | AsebaVMState * | vm, |
| uint16 | stepsLimit | ||
| ) |
Run with support of breakpoints.
Also check ASEBA_VM_EVENT_RUNNING_MASK to exit on interrupts.
References ASEBA_VM_EVENT_ACTIVE_MASK, ASEBA_VM_EVENT_RUNNING_MASK, ASEBA_VM_STEP_BY_STEP_MASK, AsebaMaskClear, AsebaMaskIsSet, AsebaMaskSet, AsebaVMCheckBreakpoint(), AsebaVMSendExecutionStateChanged(), and AsebaVMStep().
Referenced by AsebaVMRun().
| void AsebaNativeFunction | ( | AsebaVMState * | vm, |
| uint16 | id | ||
| ) |
Called by AsebaStep to perform a native function call.
Referenced by AsebaVMStep().
| void AsebaPutVmToSleep | ( | AsebaVMState * | vm | ) |
Called by AsebaVMDebugMessage when VM must put to node in deep sleep.
Write an empty function to leave feature unsupported
Referenced by AsebaVMDebugMessage().
| void AsebaSendDescription | ( | AsebaVMState * | vm | ) |
Called by AsebaVMDebugMessage when VM must send its description on the network.
Referenced by AsebaVMDebugMessage().
| void AsebaSendMessage | ( | AsebaVMState * | vm, |
| uint16 | id, | ||
| const void * | data, | ||
| uint16 | size | ||
| ) |
Called by AsebaStep if there is a message (not an user event) to send.
size is given in number of bytes.
Referenced by AsebaNative_mathmuldiv(), AsebaNative_vecdiv(), and AsebaVMEmitNodeSpecificError().
| uint16 AsebaVMCheckBreakpoint | ( | AsebaVMState * | vm | ) |
Execute on bytecode of the current VM thread and check for potential breakpoints.
Return 1 if breakpoint was seen, 0 otherwise. VM must be ready for run otherwise trashes may occur.
References ASEBA_VM_STEP_BY_STEP_MASK, and AsebaMaskSet.
Referenced by AsebaDebugBreakpointRun().
| uint16 AsebaVMClearBreakpoint | ( | AsebaVMState * | vm, |
| uint16 | pc | ||
| ) |
Clear the breakpoint at a specific location.
Referenced by AsebaVMDebugMessage().
| void AsebaVMClearBreakpoints | ( | AsebaVMState * | vm | ) |
Clear all breakpoints.
Referenced by AsebaVMDebugMessage().
| void AsebaVMDebugMessage | ( | AsebaVMState * | vm, |
| uint16 | id, | ||
| uint16 * | data, | ||
| uint16 | dataLength | ||
| ) |
Execute a debug action from a debug message.
dataLength is given in number of uint16.
References ASEBA_PROTOCOL_VERSION, ASEBA_VM_EVENT_ACTIVE_MASK, ASEBA_VM_STEP_BY_STEP_MASK, AsebaAssert(), AsebaMaskClear, AsebaMaskIsSet, AsebaMaskSet, AsebaPutVmToSleep(), AsebaResetIntoBootloader(), AsebaSendDescription(), AsebaSendVariables(), AsebaVMClearBreakpoint(), AsebaVMClearBreakpoints(), AsebaVMSendExecutionStateChanged(), AsebaVMSetBreakpoint(), AsebaVMSetupEvent(), AsebaVMStep(), AsebaWriteBytecode(), AsebaVMState::bytecode, AsebaVMState::bytecodeSize, AsebaVMState::variables, and AsebaVMState::variablesSize.
| uint16 AsebaVMGetEventAddress | ( | AsebaVMState * | vm, |
| uint16 | event | ||
| ) |
Return the starting address of an event, or 0 if the event is not handled.
References AsebaVMState::bytecode.
Referenced by AsebaVMSetupEvent(), and AsebaVMShouldDropPacket().
| void AsebaVMInit | ( | AsebaVMState * | vm | ) |
Setup the execution status of the VM.
This is not sufficient to have a working VM. nodeId and bytecode, variables, and stack along with their sizes must be set outside this function. The content of the variable array is zeroed by this function.
References AsebaVMState::bytecode, AsebaVMState::variables, and AsebaVMState::variablesSize.
| uint16 AsebaVMRun | ( | AsebaVMState * | vm, |
| uint16 | stepsLimit | ||
| ) |
Run the VM depending on the current execution mode.
Either run or step, depending of the current mode. If stepsLimit > 0, execute at maximim stepsLimit Return 1 if anything was executed, 0 otherwise.
References ASEBA_VM_EVENT_ACTIVE_MASK, ASEBA_VM_STEP_BY_STEP_MASK, AsebaDebugBareRun(), AsebaDebugBreakpointRun(), AsebaMaskIsClear, and AsebaMaskIsSet.
| uint8 AsebaVMSetBreakpoint | ( | AsebaVMState * | vm, |
| uint16 | pc | ||
| ) |
Set a breakpoint at a specific location.
References ASEBA_MAX_BREAKPOINTS, AsebaAssert(), and AsebaVMState::bytecodeSize.
Referenced by AsebaVMDebugMessage().
| uint16 AsebaVMSetupEvent | ( | AsebaVMState * | vm, |
| uint16 | event | ||
| ) |
Setup VM to execute an event.
If event is not handled, VM is not ready for run. Return the starting address of the event, or 0 if the event is not handled.
References ASEBA_UNUSED, ASEBA_VM_EVENT_ACTIVE_MASK, ASEBA_VM_STEP_BY_STEP_MASK, AsebaAssert(), AsebaMaskIsSet, AsebaMaskSet, AsebaVMGetEventAddress(), and AsebaVMSendExecutionStateChanged().
Referenced by AsebaVMDebugMessage().
| void AsebaVMStep | ( | AsebaVMState * | vm | ) |
Execute one bytecode of the current VM thread.
VM must be ready for run otherwise trashes may occur.
References ASEBA_BINARY_OPERATOR_MASK, ASEBA_IF_IS_WHEN_BIT, ASEBA_IF_WAS_TRUE_BIT, ASEBA_MAX_EVENT_ARG_SIZE, ASEBA_UNARY_OPERATOR_MASK, ASEBA_VM_EVENT_ACTIVE_MASK, ASEBA_VM_STEP_BY_STEP_MASK, AsebaAssert(), AsebaMaskClear, AsebaMaskIsClear, AsebaNativeFunction(), BIT_CLR, BIT_SET, AsebaVMState::bytecode, AsebaVMState::bytecodeSize, GET_BIT, AsebaVMState::stack, AsebaVMState::stackSize, AsebaVMState::variables, and AsebaVMState::variablesSize.
Referenced by AsebaDebugBareRun(), AsebaDebugBreakpointRun(), and AsebaVMDebugMessage().
| const AsebaNativeFunctionDescription AsebaNativeDescription_mathatan2 |
Description of AsebaNative_mathatan2.
| const AsebaNativeFunctionDescription AsebaNativeDescription_mathcos |
Description of AsebaNative_mathcos.
| const AsebaNativeFunctionDescription AsebaNativeDescription_mathmuldiv |
Description of AsebaNative_mathmuldiv.
| const AsebaNativeFunctionDescription AsebaNativeDescription_mathrot2 |
Description of AsebaNative_mathrot2.
| const AsebaNativeFunctionDescription AsebaNativeDescription_mathsin |
Description of AsebaNative_mathsin.
| const AsebaNativeFunctionDescription AsebaNativeDescription_mathsqrt |
Description of AsebaNative_mathsqrt.
| const AsebaNativeFunctionDescription AsebaNativeDescription_rand |
Description of AsebaNative_rand.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecadd |
Description of AsebaNative_vecadd.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecaddscalar |
Description of AsebaNative_vecaddscalar.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecargbounds |
Description of AsebaNative_vecargbounds.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecclamp |
Description of AsebaNative_vecclamp.
| const AsebaNativeFunctionDescription AsebaNativeDescription_veccopy |
Description of AsebaNative_veccopy.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecdiv |
Description of AsebaNative_vecsub.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecdot |
Description of AsebaNative_vecdot.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecfill |
Description of AsebaNative_vecfill.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecmax |
Description of AsebaNative_vecsmax.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecmin |
Description of AsebaNative_vecmin.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecmul |
Description of AsebaNative_vecadd.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecnonzerosequence |
Description of AsebaNative_vecnonzerosequence.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecsort |
Description of AsebaNative_vecsort.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecstat |
Description of AsebaNative_vecstat.
| const AsebaNativeFunctionDescription AsebaNativeDescription_vecsub |
Description of AsebaNative_vecsub.
1.8.11