Simple Virtual Machine
A simple but flexible virtual machine
SVM memory allocation

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]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted memory is.
[in]zoneThe 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
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_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]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted memory is.
[in]zoneThe zone description to allocate.
[in]addressThe 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_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_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
raised on memory access failure
Definition: svm.h:390
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_FUNCTION SVM_Kernel svm_kernel_get_current(const void *svm)
This function retrieves the current kernel.
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
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_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]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted memory is.
[in]pointerThe pointer locating the memory zone.

The targeted addresses are removed from the memory.

Note
The scope of the memory is unchanged.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
See also
svm_memory_scope_set_local