|
| 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_DEVDAX_MEMORY_PROVIDER_H |
| 9 | +#define UMF_DEVDAX_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_DEVDAX_RESULTS_START_FROM 2000 |
| 19 | +/// @endcond |
| 20 | + |
| 21 | +/// @brief Memory provider settings struct |
| 22 | +typedef struct umf_devdax_memory_provider_params_t { |
| 23 | + /// path of the device DAX |
| 24 | + char *path; |
| 25 | + /// size of the device DAX in bytes |
| 26 | + size_t size; |
| 27 | + /// combination of 'umf_mem_protection_flags_t' flags |
| 28 | + unsigned protection; |
| 29 | +} umf_devdax_memory_provider_params_t; |
| 30 | + |
| 31 | +/// @brief Devdax Memory Provider operation results |
| 32 | +typedef enum umf_devdax_memory_provider_native_error { |
| 33 | + UMF_DEVDAX_RESULT_SUCCESS = UMF_DEVDAX_RESULTS_START_FROM, ///< Success |
| 34 | + UMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED, ///< Memory allocation failed |
| 35 | + UMF_DEVDAX_RESULT_ERROR_ADDRESS_NOT_ALIGNED, ///< Allocated address is not aligned |
| 36 | + UMF_DEVDAX_RESULT_ERROR_FREE_FAILED, ///< Memory deallocation failed |
| 37 | + UMF_DEVDAX_RESULT_ERROR_PURGE_FORCE_FAILED, ///< Force purging failed |
| 38 | +} umf_devdax_memory_provider_native_error_t; |
| 39 | + |
| 40 | +umf_memory_provider_ops_t *umfDevDaxMemoryProviderOps(void); |
| 41 | + |
| 42 | +/// @brief Create default params for the devdax memory provider |
| 43 | +static inline umf_devdax_memory_provider_params_t |
| 44 | +umfDevDaxMemoryProviderParamsDefault(char *path, size_t size) { |
| 45 | + umf_devdax_memory_provider_params_t params = { |
| 46 | + path, /* path of the device DAX */ |
| 47 | + size, /* size of the device DAX in bytes */ |
| 48 | + UMF_PROTECTION_READ | UMF_PROTECTION_WRITE, /* protection */ |
| 49 | + }; |
| 50 | + |
| 51 | + return params; |
| 52 | +} |
| 53 | + |
| 54 | +#ifdef __cplusplus |
| 55 | +} |
| 56 | +#endif |
| 57 | + |
| 58 | +#endif /* UMF_DEVDAX_MEMORY_PROVIDER_H */ |
0 commit comments