Simple Virtual Machine
A simple but flexible virtual machine
SVM processor execution

This module contains API functions to handle SVM processor execution. More...

Functions

SVM_FUNCTION SVM_Code svm_processor_get_currentcode (const void *svm, const SVM_Kernel kernel)
 This function extracts the SVM code actually executed by the processor. More...
 
SVM_FUNCTION SVM_Value_Symbol svm_processor_get_nextinstruction (const void *svm, const SVM_Kernel kernel)
 This function retrieves the address of the next instruction a processor will execute. More...
 
SVM_FUNCTION SVM_Value_Symbol svm_processor_get_currentinstruction (const void *svm, const SVM_Kernel kernel)
 This function retrieves the address of the current instruction a processor is executing. More...
 
SVM_FUNCTION void svm_processor_jump_local (const void *svm, const SVM_Kernel kernel, const SVM_Address address)
 This function does a local jump on a processor. More...
 
SVM_FUNCTION void svm_processor_jump_global (const void *svm, const SVM_Kernel kernel, const SVM_Value_Symbol symbol)
 This function does a global jump on a processor. More...
 
SVM_FUNCTION void svm_processor_call_local (const void *svm, const SVM_Kernel kernel, const SVM_Address function, const SVM_Value_Pointer parameters)
 This function does a local SVM code function call on a processor. More...
 
SVM_FUNCTION void svm_processor_call_global (const void *svm, const SVM_Kernel kernel, const SVM_Value_Symbol function, const SVM_Value_Pointer parameters)
 This function does a global SVM code function call on a processor. More...
 
SVM_FUNCTION void svm_processor_call_identical (const void *svm, const SVM_Kernel kernel, const SVM_Boolean transfer)
 This function does an identical SVM code function call on a processor. More...
 
SVM_FUNCTION void svm_processor_return (const void *svm, const SVM_Kernel kernel)
 This function does a SVM code function return on a processor. More...
 
SVM_FUNCTION void svm_processor_current_shutdown (const void *svm)
 This function shuts down the processor of the current kernel. More...
 
SVM_FUNCTION void svm_processor_current_sleep (const void *svm, const SVM_Value_Integer seconds, const SVM_Value_Integer milliseconds, const SVM_Boolean soft)
 This function stops the execution of the processor of the current kernel for a given time as integer values. More...
 
SVM_FUNCTION void svm_processor_current_sleep__raw (const void *svm, const unsigned long int seconds, const unsigned long int milliseconds, const SVM_Boolean soft)
 This function stops the execution of the processor of the current kernel for a given time as raw integers. More...
 

Detailed Description

This module contains API functions to handle SVM processor execution.

Function Documentation

◆ svm_processor_call_global()

SVM_FUNCTION void svm_processor_call_global ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Value_Symbol  function,
const SVM_Value_Pointer  parameters 
)

This function does a global SVM code function call on a processor.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted processor is.
[in]functionThe address of the function to jump to.
[in]parametersThe memory pointer locating the function parameters.

The current state of the processor is saved on the return stack, then the next instruction is set to the function address eventually outside the current SVM code executed by the processor, and the current memory pointer is set to the parameters location.

Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_processor_call_identical()

SVM_FUNCTION void svm_processor_call_identical ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Boolean  transfer 
)

This function does an identical SVM code function call on a processor.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted processor is.
[in]transferIndicates whether the local memory shall be transferred to the call.

The current state of the processor is saved on the return stack. The memory already allocated in the current function can not be managed by the two calls: The memory can be managed by the current function call or transferred to the new function call. If the return stack is not modified, it is advised to set the transfer boolean to TRUE.

Note
This API function can be used to store the current state of the processor, but has to be used with caution.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_processor_call_local()

SVM_FUNCTION void svm_processor_call_local ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Address  function,
const SVM_Value_Pointer  parameters 
)

This function does a local SVM code function call on a processor.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted processor is.
[in]functionThe address of the function to jump to.
[in]parametersThe memory pointer locating the function parameters.

The current state of the processor is saved on the return stack, then the next instruction is set to the function address inside the current SVM code executed by the processor, and the current memory pointer is set to the parameters location.

Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_processor_current_shutdown()

SVM_FUNCTION void svm_processor_current_shutdown ( const void *  svm)

This function shuts down the processor of the current kernel.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)

◆ svm_processor_current_sleep()

SVM_FUNCTION void svm_processor_current_sleep ( const void *  svm,
const SVM_Value_Integer  seconds,
const SVM_Value_Integer  milliseconds,
const SVM_Boolean  soft 
)

This function stops the execution of the processor of the current kernel for a given time as integer values.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]secondsThe number of seconds to wait.
[in]millisecondsThe number of extra milliseconds to wait.
[in]softThe process is put in pause while waiting.

This function put the process on hold for a given while.

Warning
Usage of the system sleep functions may result in an undefined behavior. Always use this function instead.
Note
The soft parameter should be set to TRUE, as a FALSE value may freeze the application and should be used only when the scheduling of the process shall not be modified.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when a sleep is performed in protected mode outside a WAITING instruction.
FAILUREinterruption when this API function is called outside a kernel.
FAILUREinterruption when seconds or milliseconds are a negative integer.
See also
svm_process_pause
svm_process_resume
svm_kernel_get_current

◆ svm_processor_current_sleep__raw()

SVM_FUNCTION void svm_processor_current_sleep__raw ( const void *  svm,
const unsigned long int  seconds,
const unsigned long int  milliseconds,
const SVM_Boolean  soft 
)

This function stops the execution of the processor of the current kernel for a given time as raw integers.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]secondsThe number of seconds to wait.
[in]millisecondsThe number of extra milliseconds to wait.
[in]softThe process is put in pause while waiting.

This function put the process on hold for a given while.

Warning
Usage of the system sleep functions may result in an undefined behavior. Always use this function instead.
Note
The soft parameter should be set to TRUE, as a FALSE value may freeze the application and should be used only when the scheduling of the process shall not be modified.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when this API function is called outside a kernel.
FAILUREinterruption when a sleep is performed in protected mode outside a WAITING instruction.
See also
svm_process_pause
svm_process_resume
svm_kernel_get_current

◆ svm_processor_get_currentcode()

SVM_FUNCTION SVM_Code svm_processor_get_currentcode ( const void *  svm,
const SVM_Kernel  kernel 
)

This function extracts the SVM code actually executed by the processor.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel from which the code will be extracted.
Returns
The SVM code executed by the processor.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_processor_get_currentinstruction()

SVM_FUNCTION SVM_Value_Symbol svm_processor_get_currentinstruction ( const void *  svm,
const SVM_Kernel  kernel 
)

This function retrieves the address of the current instruction a processor is executing.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted processor is.
Returns
The symbol pointing on the current instruction.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current
svm_value_symbol_get_location

◆ svm_processor_get_nextinstruction()

SVM_FUNCTION SVM_Value_Symbol svm_processor_get_nextinstruction ( const void *  svm,
const SVM_Kernel  kernel 
)

This function retrieves the address of the next instruction a processor will execute.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted processor is.
Returns
The symbol pointing on the next instruction.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_processor_jump_global()

SVM_FUNCTION void svm_processor_jump_global ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Value_Symbol  symbol 
)

This function does a global jump on a processor.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted processor is.
[in]symbolThe address to jump to.

The next instruction pointer of the processor is set to an address potentially outside the current SVM code.

Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_processor_jump_local()

SVM_FUNCTION void svm_processor_jump_local ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Address  address 
)

This function does a local jump on a processor.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted processor is.
[in]addressThe address to jump to.

The next instruction pointer of the processor is set to an address inside the current SVM code.

Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_processor_return()

SVM_FUNCTION void svm_processor_return ( const void *  svm,
const SVM_Kernel  kernel 
)

This function does a SVM code function return on a processor.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted processor is.

The current state is replaced by the last pushed state on the return stack, the last pushed state is removed from the return stack, and the allocated memory associated to the destroyed state is deleted.

Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
PROCESSORinterruption when the return stack is empty.
See also
svm_process_ownership_lock
svm_kernel_get_current