Simple Virtual Machine A simple but flexible virtual machine

Loading...
Searching...
No Matches
Functions
SVM processor execution
SVM processors

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.
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.
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.
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.
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.
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.
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.
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.
SVM_FUNCTION void | svm_processor_return (const void *svm, const SVM_Kernel kernel)
| This function does a SVM code function return on a processor.
SVM_FUNCTION void | svm_processor_current_shutdown (const void *svm)
| This function shuts down the processor of the current kernel.
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.
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.

## 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted processor is.
  [in] | function | The address of the function to jump to.
  [in] | parameters | The 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

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted processor is.
  [in] | transfer | Indicates 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

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted processor is.
  [in] | function | The address of the function to jump to.
  [in] | parameters | The 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

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.

Exceptions

  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | seconds | The number of seconds to wait.
  [in] | milliseconds | The number of extra milliseconds to wait.
  [in] | soft | The 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

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption when a sleep is performed in protected mode outside a WAITING instruction.
  FAILURE | interruption when this API function is called outside a kernel.
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | seconds | The number of seconds to wait.
  [in] | milliseconds | The number of extra milliseconds to wait.
  [in] | soft | The 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

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption when this API function is called outside a kernel.
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel from which the code will be extracted.

Returns
  The SVM code executed by the processor.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted processor is.

Returns
  The symbol pointing on the current instruction.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted processor is.

Returns
  The symbol pointing on the next instruction.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted processor is.
  [in] | symbol | The address to jump to.

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

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted processor is.
  [in] | address | The address to jump to.

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

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The 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

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption when the kernel is not owned by our process or is not in a process locked by ours.
  PROCESSOR | interruption when the return stack is empty.

See also
  svm_process_ownership_lock
  svm_kernel_get_current