|
| 1 | +/* |
| 2 | + * Copyright (C) 2024 Intel Corporation |
| 3 | + * |
| 4 | + * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. |
| 5 | + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +*/ |
| 7 | + |
| 8 | +#ifndef UMF_FIXED_MEMORY_PROVIDER_H |
| 9 | +#define UMF_FIXED_MEMORY_PROVIDER_H |
| 10 | + |
| 11 | +#include <umf/providers/provider_os_memory.h> |
| 12 | + |
| 13 | +#ifdef __cplusplus |
| 14 | +extern "C" { |
| 15 | +#endif |
| 16 | + |
| 17 | +/// @cond |
| 18 | +#define UMF_FIXED_RESULTS_START_FROM 4000 |
| 19 | +/// @endcond |
| 20 | + |
| 21 | +struct umf_fixed_memory_provider_params_t; |
| 22 | + |
| 23 | +typedef struct umf_fixed_memory_provider_params_t |
| 24 | + *umf_fixed_memory_provider_params_handle_t; |
| 25 | + |
| 26 | +/// @brief Create a struct to store parameters of the Fixed Memory Provider. |
| 27 | +/// @param hParams [out] handle to the newly created parameters struct. |
| 28 | +/// @param ptr [in] pointer to the memory region. |
| 29 | +/// @param size [in] size of the memory region in bytes. |
| 30 | +/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure. |
| 31 | +umf_result_t umfFixedMemoryProviderParamsCreate( |
| 32 | + umf_fixed_memory_provider_params_handle_t *hParams, void *ptr, size_t size); |
| 33 | + |
| 34 | +/// @brief Set the memory region in params struct. Overwrites the previous value. |
| 35 | +/// It provides an ability to use the same instance of params to create multiple |
| 36 | +/// instances of the provider for different memory regions. |
| 37 | +/// @param hParams [in] handle to the parameters of the Fixed Memory Provider. |
| 38 | +/// @param ptr [in] pointer to the memory region. |
| 39 | +/// @param size [in] size of the memory region in bytes. |
| 40 | +/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure. |
| 41 | +umf_result_t umfFixedMemoryProviderParamsSetMemory( |
| 42 | + umf_fixed_memory_provider_params_handle_t hParams, void *ptr, size_t size); |
| 43 | + |
| 44 | +/// @brief Destroy parameters struct. |
| 45 | +/// @param hParams [in] handle to the parameters of the Fixed Memory Provider. |
| 46 | +/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure. |
| 47 | +umf_result_t umfFixedMemoryProviderParamsDestroy( |
| 48 | + umf_fixed_memory_provider_params_handle_t hParams); |
| 49 | + |
| 50 | +/// @brief Retrieve the operations structure for the Fixed Memory Provider. |
| 51 | +/// @return Pointer to the umf_memory_provider_ops_t structure. |
| 52 | +umf_memory_provider_ops_t *umfFixedMemoryProviderOps(void); |
| 53 | + |
| 54 | +/// @brief Fixed Memory Provider operation results |
| 55 | +typedef enum umf_fixed_memory_provider_native_error { |
| 56 | + UMF_FIXED_RESULT_SUCCESS = UMF_FIXED_RESULTS_START_FROM, ///< Success |
| 57 | + UMF_FIXED_RESULT_ERROR_PURGE_FORCE_FAILED, ///< Force purging failed |
| 58 | +} umf_fixed_memory_provider_native_error_t; |
| 59 | + |
| 60 | +#ifdef __cplusplus |
| 61 | +} |
| 62 | +#endif |
| 63 | + |
| 64 | +#endif /* UMF_FIXED_MEMORY_PROVIDER_H */ |
0 commit comments