2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2025-01-04 22:26:02 +03:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-02-27 11:39:32 +01:00
|
|
|
#include <cinttypes>
|
2022-12-01 19:42:57 +00:00
|
|
|
#include <cstddef>
|
2020-07-07 08:41:26 +02:00
|
|
|
#include <limits>
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-04-02 17:01:51 +00:00
|
|
|
struct OsHandle {
|
2022-07-07 21:11:29 +10:00
|
|
|
virtual ~OsHandle() = default;
|
|
|
|
|
|
2021-04-02 17:01:51 +00:00
|
|
|
protected:
|
|
|
|
|
OsHandle() = default;
|
|
|
|
|
};
|
2019-12-17 08:11:16 +01:00
|
|
|
struct ResidencyData;
|
2018-08-27 15:48:29 +02:00
|
|
|
|
2018-10-22 14:20:05 +02:00
|
|
|
constexpr int maxFragmentsCount = 3;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-07-12 10:53:18 +02:00
|
|
|
enum class FragmentPosition {
|
2023-12-12 11:37:31 +00:00
|
|
|
none = 0,
|
|
|
|
|
leading,
|
|
|
|
|
middle,
|
|
|
|
|
trailing
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
2020-10-23 13:01:46 +02:00
|
|
|
enum class RequirementsStatus {
|
2023-12-12 11:37:31 +00:00
|
|
|
success = 0,
|
|
|
|
|
fatal
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PartialAllocation {
|
2023-12-12 11:37:31 +00:00
|
|
|
FragmentPosition fragmentPosition = FragmentPosition::none;
|
2017-12-21 00:45:38 +01:00
|
|
|
const void *allocationPtr = nullptr;
|
|
|
|
|
size_t allocationSize = 0u;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AllocationRequirements {
|
2019-08-07 08:31:20 +02:00
|
|
|
PartialAllocation allocationFragments[maxFragmentsCount];
|
2017-12-21 00:45:38 +01:00
|
|
|
uint64_t totalRequiredSize = 0u;
|
|
|
|
|
uint32_t requiredFragmentsCount = 0u;
|
2020-07-07 08:41:26 +02:00
|
|
|
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct FragmentStorage {
|
2018-03-27 14:01:04 +02:00
|
|
|
const void *fragmentCpuPointer = nullptr;
|
2017-12-21 00:45:38 +01:00
|
|
|
size_t fragmentSize = 0;
|
2025-01-15 07:45:01 +01:00
|
|
|
int refCount = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
OsHandle *osInternalStorage = nullptr;
|
|
|
|
|
ResidencyData *residency = nullptr;
|
2018-05-08 10:00:23 +02:00
|
|
|
bool driverAllocation = false;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AllocationStorageData {
|
2019-07-29 16:11:51 +02:00
|
|
|
OsHandle *osHandleStorage = nullptr;
|
2017-12-21 00:45:38 +01:00
|
|
|
size_t fragmentSize = 0;
|
|
|
|
|
const void *cpuPtr = nullptr;
|
|
|
|
|
bool freeTheFragment = false;
|
|
|
|
|
ResidencyData *residency = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct OsHandleStorage {
|
2018-10-22 14:20:05 +02:00
|
|
|
AllocationStorageData fragmentStorageData[maxFragmentsCount];
|
2017-12-21 00:45:38 +01:00
|
|
|
uint32_t fragmentCount = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|