Simple Virtual Machine
A simple but flexible virtual machine
SVM kernel getters

This module contains API functions to get SVM kernels. More...

Functions

SVM_FUNCTION SVM_Kernel svm_kernel_new_code (const void *svm, const SVM_Boolean transmit_interruptions, const SVM_Boolean last_return_is_shutdown, const SVM_Boolean protected_mode, const SVM_AccessControl access_control, const SVM_Code code)
 This function creates a new kernel. More...
 
SVM_FUNCTION SVM_Kernel svm_kernel_new_symbol (const void *svm, const SVM_Boolean transmit_interruptions, const SVM_Boolean last_return_is_shutdown, const SVM_Boolean protected_mode, const SVM_AccessControl access_control, const SVM_Value_Symbol symbol)
 This function creates a new kernel. More...
 
SVM_FUNCTION SVM_Kernel svm_kernel_get_current (const void *svm)
 This function retrieves the current kernel. More...
 
SVM_FUNCTION SVM_Process svm_kernel_get_process (const void *svm, const SVM_Kernel kernel)
 This function returns the process associated to a kernel. More...
 

Detailed Description

This module contains API functions to get SVM kernels.

Function Documentation

◆ svm_kernel_get_current()

SVM_FUNCTION SVM_Kernel svm_kernel_get_current ( const void *  svm)

This function retrieves the current kernel.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
Warning
The resulting variable can be set global and added to a C/C++ structure linked to a type which can be written into the memory of the current kernel. In such case, a circular loop is created, preventing the variable to be destroyed at the proper time unless the variable is set local outside the type destructor or the value is explicitely removed from the kernel memory.
Returns
The current kernel if the API function is invoked inside a kernel, a NULL pointer otherwise.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)

◆ svm_kernel_get_process()

SVM_FUNCTION SVM_Process svm_kernel_get_process ( const void *  svm,
const SVM_Kernel  kernel 
)

This function returns the process associated to a kernel.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel to diagnose.
Returns
The process associated to the kernel if attached to a process, NULL otherwise.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
See also
SVM processes

◆ svm_kernel_new_code()

SVM_FUNCTION SVM_Kernel svm_kernel_new_code ( const void *  svm,
const SVM_Boolean  transmit_interruptions,
const SVM_Boolean  last_return_is_shutdown,
const SVM_Boolean  protected_mode,
const SVM_AccessControl  access_control,
const SVM_Code  code 
)

This function creates a new kernel.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]transmit_interruptionsIf the kernel is interrupted, this flag asks the kernel to forward the interruption to the next kernel.
[in]last_return_is_shutdownThis flag indicates whether an extra return on an empty return stack can be considered as a shutdown.
[in]protected_modeThis flag indicates that the code should be executed in protected mode.
[in]access_controlThe limitations to apply to the code execution. A NULL pointer means no specific restriction.
[in]codeThe code to execute within the kernel.
Note
When this API function is called within a kernel, the protected mode and the access control are always set as restrictions of the current limitations. In particular, if the current kernel executes code in protected mode, the created kernel will automatically be in protected mode, no matter the protected_mode flag could be.
Access control is ignored when the kernel is not created in protected mode.
Warning
When this API function is called outside a kernel, the protected mode and access control parameters are directly applied. This can lead to a security issue unless either the plugin callback containing such call can only be triggered by a system instruction, or the code is coming only from safe sources.
Returns
The created kernel.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when this API function is invoked outside a kernel and outside a system callback.
See also
SVM access control
svm_kernel_get_current

◆ svm_kernel_new_symbol()

SVM_FUNCTION SVM_Kernel svm_kernel_new_symbol ( const void *  svm,
const SVM_Boolean  transmit_interruptions,
const SVM_Boolean  last_return_is_shutdown,
const SVM_Boolean  protected_mode,
const SVM_AccessControl  access_control,
const SVM_Value_Symbol  symbol 
)

This function creates a new kernel.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]transmit_interruptionsIf the kernel is interrupted, this flag asks the kernel to forward the interruption to the next kernel.
[in]last_return_is_shutdownThis flag indicates whether an extra return on an empty return stack can be considered as a shutdown.
[in]protected_modeThis flag indicates that the code should be executed in protected mode.
[in]access_controlThe limitations to apply to the code execution. A NULL pointer means no specific restriction.
[in]symbolThe symbol to jump to within the kernel.
Note
When this API function is called within a kernel, the protected mode and the access control are always set as restrictions of the current limitations. In particular, if the current kernel executes code in protected mode, the created kernel will automatically be in protected mode, no matter the protected_mode flag could be.
Access control is ignored when the kernel is not created in protected mode.
Warning
When this API function is called outside a kernel, the protected mode and access control parameters are directly applied. This can lead to a security issue unless either the plugin callback containing such call can only be triggered by a system instruction, or the code is coming only from safe sources.
Returns
The created kernel.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when this API function is invoked outside a kernel and outside a system callback.
See also
SVM access control
svm_kernel_get_current