Simple Virtual Machine A simple but flexible virtual machine

Functions
SVM memory allocation
SVM memories

This module contains API functions to handle SVM memory allocation. More...

## Functions
SVM_FUNCTION SVM_Value_Pointer | svm_memory_allocate (const void *svm, const SVM_Kernel kernel, const SVM_Memory_Zone zone)
| This function allocates a zone in a memory. More...
SVM_FUNCTION SVM_Value_Pointer | svm_memory_allocate_address (const void *svm, const SVM_Kernel kernel, const SVM_Memory_Zone zone, const SVM_Address address)
| This function allocates a zone in a memory at a specified address. More...
SVM_FUNCTION void | svm_memory_free (const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer)
| This function frees a memory zone. More...

## Detailed Description

This module contains API functions to handle SVM memory allocation.

## Function Documentation

## ◆ svm_memory_allocate()

SVM_FUNCTION SVM_Value_Pointer svm_memory_allocate | ( | const void * | svm,
|  | const SVM_Kernel | kernel,
|  | const SVM_Memory_Zone | zone
| ) |  |

This function allocates a zone in a memory.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted memory is.
  [in] | zone | The zone description to allocate.

Warning
  The allocated memory is local and will be freed at the end of the current SVM function. Please refer to the svm_memory_scope_set_global and svm_memory_pointer_list_accessible API functions to create global memory.

Note
  The allocated memory is not initialised. It means each allocated addresses contains a type but no value.

Returns
  The pointer containing the zone 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_memory_scope_set_global
  svm_memory_pointer_list_accessible
  svm_process_ownership_lock
  svm_kernel_get_current

## ◆ svm_memory_allocate_address()

SVM_FUNCTION SVM_Value_Pointer svm_memory_allocate_address | ( | const void * | svm,
|  | const SVM_Kernel | kernel,
|  | const SVM_Memory_Zone | zone,
|  | const SVM_Address | address
| ) |  |

This function allocates a zone in a memory at a specified address.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted memory is.
  [in] | zone | The zone description to allocate.
  [in] | address | The address where to allocate the memory.

Warning
  The allocated memory is local and will be freed at the end of the current SVM function. Please refer to the svm_memory_scope_set_global and svm_memory_pointer_list_accessible API functions to create global memory.

Note
  The allocated memory is not initialised. It means each allocated addresses contains a type but no value.

Returns
  The pointer containing the zone location when the allocation succeeds. A null pointer is returned otherwise.

Example:

SVM_Value_Pointer p = svm_memory_allocate_address(svm,svm_kernel_get_current(svm),zone,address);
if(svm_value_state_is_null(svm,p))
{
svm_processor_current_raise_error_internal__raw(svm,MEMORY,"Unable to reserve memory");
}
svm_memory_allocate_address
SVM_FUNCTION SVM_Value_Pointer svm_memory_allocate_address(const void *svm, const SVM_Kernel kernel, const SVM_Memory_Zone zone, const SVM_Address address)
This function allocates a zone in a memory at a specified address.
SVM_Value_Pointer
SVM_TYPE typedef const void * SVM_Value_Pointer
This type is used to represent a pointer the SVM can store in one of its memories.
Definition: svm.h:570
MEMORY
@ MEMORY
raised on memory access failure
Definition: svm.h:390
svm_processor_current_raise_error_internal__raw
SVM_FUNCTION void svm_processor_current_raise_error_internal__raw(const void *svm, const SVM_Interruption_Internal interruption, const char *message)
This function interrupts the current processor and the current instruction execution from an internal...
svm_kernel_get_current
SVM_FUNCTION SVM_Kernel svm_kernel_get_current(const void *svm)
This function retrieves the current kernel.
svm_value_state_is_null
SVM_FUNCTION SVM_Boolean svm_value_state_is_null(const void *svm, const SVM_Value value)
This function checks whether a value is a null value.

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_memory_scope_set_global
  svm_memory_pointer_list_accessible
  svm_process_ownership_lock
  svm_kernel_get_current
  svm_value_state_is_null

## ◆ svm_memory_free()

SVM_FUNCTION void svm_memory_free | ( | const void * | svm,
|  | const SVM_Kernel | kernel,
|  | const SVM_Value_Pointer | pointer
| ) |  |

This function frees a memory zone.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted memory is.
  [in] | pointer | The pointer locating the memory zone.

The targeted addresses are removed from the memory.

Note
  The scope of the memory is unchanged.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)

See also
  svm_memory_scope_set_local