28 #include "../common/types.h" 99 #define AsebaMaskSet(v, m) ((v) |= (m)) 100 #define AsebaMaskClear(v, m) ((v) &= (~(m))) 102 #define AsebaMaskIsSet(v, m) (((v) & (m)) != 0) 104 #define AsebaMaskIsClear(v, m) (((v) & (m)) == 0) 148 #ifdef __BIG_ENDIAN__ 153 #define AsebaSendMessageWords(vm,type,data,size) AsebaSendMessage(vm,type,data,(size)*2) 175 #ifdef DISABLE_WEAK_CALLBACKS 177 #else // DISABLE_WEAK_CALLBACKS 179 #endif // DISABLE_WEAK_CALLBACKS 182 #ifdef DISABLE_WEAK_CALLBACKS 184 #else // DISABLE_WEAK_CALLBACKS 186 #endif // DISABLE_WEAK_CALLBACKS 190 #ifdef DISABLE_WEAK_CALLBACKS 191 static void AsebaVMErrorCB(
AsebaVMState *vm,
const char* message) {}
192 #else // DISABLE_WEAK_CALLBACKS 194 #endif // DISABLE_WEAK_CALLBACKS 204 ASEBA_ASSERT_UNKNOWN = 0,
205 ASEBA_ASSERT_UNKNOWN_UNARY_OPERATOR,
206 ASEBA_ASSERT_UNKNOWN_BINARY_OPERATOR,
207 ASEBA_ASSERT_UNKNOWN_BYTECODE,
208 ASEBA_ASSERT_STACK_OVERFLOW,
209 ASEBA_ASSERT_STACK_UNDERFLOW,
210 ASEBA_ASSERT_OUT_OF_VARIABLES_BOUNDS,
211 ASEBA_ASSERT_OUT_OF_BYTECODE_BOUNDS,
212 ASEBA_ASSERT_STEP_OUT_OF_RUN,
213 ASEBA_ASSERT_BREAKPOINT_OUT_OF_BYTECODE_BOUNDS,
214 ASEBA_ASSERT_EMIT_BUFFER_TOO_LONG,
sint16 * variables
variables of size variableCount
Definition: vm.h:80
uint16 * bytecode
bytecode space of size bytecodeSize
Definition: vm.h:76
This structure contains the state of the Aseba VM.
Definition: vm.h:69
void AsebaVMDebugMessage(AsebaVMState *vm, uint16 id, uint16 *data, uint16 dataLength)
Execute a debug action from a debug message.
Definition: vm.c:734
void AsebaAssert(AsebaVMState *vm, AsebaAssertReason reason)
If ASEBA_ASSERT is defined, this function is called when an error arise.
uint16 AsebaVMGetEventAddress(AsebaVMState *vm, uint16 event)
Return the starting address of an event, or 0 if the event is not handled.
Definition: vm.c:55
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...
Definition: vm.c:534
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.
uint16 bytecodeSize
total amount of bytecode space
Definition: vm.h:75
AsebaAssertReason
Possible causes of AsebaAssert.
Definition: vm.h:202
void AsebaSendVariables(AsebaVMState *vm, uint16 start, uint16 length)
Called by AsebaVMDebugMessage when some variables must be sent efficiently.
void AsebaVMInit(AsebaVMState *vm)
Setup the execution status of the VM.
Definition: vm.c:44
uint16 AsebaVMSetupEvent(AsebaVMState *vm, uint16 event)
Setup VM to execute an event.
Definition: vm.c:68
unsigned char uint8
8 bits unsigned integer
Definition: types.h:38
uint16 variablesSize
total amount of variables space
Definition: vm.h:79
maximum number of simultaneous breakpoints the target supports
Definition: vm.h:56
void AsebaNativeFunction(AsebaVMState *vm, uint16 id)
Called by AsebaStep to perform a native function call.
unsigned short uint16
16 bits unsigned integer
Definition: types.h:36
signed short sint16
16 bits signed integer
Definition: types.h:35
void AsebaSendDescription(AsebaVMState *vm)
Called by AsebaVMDebugMessage when VM must send its description on the network.
uint16 AsebaVMRun(AsebaVMState *vm, uint16 stepsLimit)
Run the VM depending on the current execution mode.
Definition: vm.c:651
sint16 * stack
execution stack of size stackSize
Definition: vm.h:84
void AsebaWriteBytecode(AsebaVMState *vm)
Called by AsebaVMDebugMessage when VM must write its bytecode to flash, write an empty function to le...
void __attribute__((weak)) AsebaVMRunCB(AsebaVMState *vm)
Called by AsebaVMDebugMessage when VM is going to be run.
void AsebaPutVmToSleep(AsebaVMState *vm)
Called by AsebaVMDebugMessage when VM must put to node in deep sleep.
uint16 AsebaVMShouldDropPacket(AsebaVMState *vm, uint16 source, const uint8 *data)
Return non-zero if VM will ignore the packet, 0 otherwise.
Definition: vm.c:883
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.
uint16 stackSize
depth of execution stack
Definition: vm.h:83