2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2018-2021 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
|
2020-04-02 11:28:38 +02:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include <memory>
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2019-10-21 14:54:08 +02:00
|
|
|
class GmmClientContext;
|
2019-12-19 16:24:26 +01:00
|
|
|
class OSInterface;
|
2018-01-12 09:08:49 +01:00
|
|
|
struct HardwareInfo;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-06-21 11:36:47 +02:00
|
|
|
class GmmHelper {
|
2017-12-21 00:45:38 +01:00
|
|
|
public:
|
2018-06-21 11:36:47 +02:00
|
|
|
GmmHelper() = delete;
|
2019-12-19 16:24:26 +01:00
|
|
|
GmmHelper(OSInterface *osInterface, const HardwareInfo *hwInfo);
|
2018-07-13 07:42:18 +02:00
|
|
|
MOCKABLE_VIRTUAL ~GmmHelper();
|
2018-07-23 12:23:48 +02:00
|
|
|
|
2018-07-27 13:59:39 +02:00
|
|
|
const HardwareInfo *getHardwareInfo();
|
2020-02-04 12:13:57 +01:00
|
|
|
uint32_t getMOCS(uint32_t type) const;
|
2021-12-07 15:32:00 +00:00
|
|
|
void disableL3CacheForDebug() { l3CacheForDebugDisabled = true; };
|
2018-07-23 12:23:48 +02:00
|
|
|
|
2021-09-22 16:52:10 +00:00
|
|
|
static constexpr uint64_t maxPossiblePitch = (1ull << 31);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-09-17 12:53:37 +02:00
|
|
|
static uint64_t canonize(uint64_t address) {
|
2019-12-24 13:51:39 +01:00
|
|
|
return static_cast<int64_t>(address << (64 - GmmHelper::addressWidth)) >> (64 - GmmHelper::addressWidth);
|
2019-09-17 12:53:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static uint64_t decanonize(uint64_t address) {
|
2019-12-24 13:51:39 +01:00
|
|
|
return (address & maxNBitValue(GmmHelper::addressWidth));
|
2019-09-17 12:53:37 +02:00
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-12-23 15:32:23 +00:00
|
|
|
bool isValidCanonicalGpuAddress(uint64_t address);
|
|
|
|
|
|
2019-12-04 12:36:16 +01:00
|
|
|
GmmClientContext *getClientContext() const;
|
2018-07-27 13:59:39 +02:00
|
|
|
|
2020-01-14 13:47:40 +01:00
|
|
|
static std::unique_ptr<GmmClientContext> (*createGmmContextWrapperFunc)(OSInterface *, HardwareInfo *);
|
2018-05-17 11:47:35 +02:00
|
|
|
|
2018-07-03 10:00:12 +02:00
|
|
|
protected:
|
2019-12-24 13:51:39 +01:00
|
|
|
static uint32_t addressWidth;
|
2018-07-27 13:59:39 +02:00
|
|
|
const HardwareInfo *hwInfo = nullptr;
|
2018-07-23 12:23:48 +02:00
|
|
|
std::unique_ptr<GmmClientContext> gmmClientContext;
|
2021-12-07 15:32:00 +00:00
|
|
|
bool l3CacheForDebugDisabled = false;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|