2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-12-20 23:33:23 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm_lib.h"
|
|
|
|
#include "shared/source/helpers/basic_math.h"
|
2020-04-02 17:28:38 +08:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-10-21 20:54:08 +08:00
|
|
|
class GmmClientContext;
|
|
|
|
class OsLibrary;
|
2019-12-19 23:24:26 +08:00
|
|
|
class OSInterface;
|
2018-01-12 16:08:49 +08:00
|
|
|
struct HardwareInfo;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-06-21 17:36:47 +08:00
|
|
|
class GmmHelper {
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
2018-06-21 17:36:47 +08:00
|
|
|
GmmHelper() = delete;
|
2019-12-19 23:24:26 +08:00
|
|
|
GmmHelper(OSInterface *osInterface, const HardwareInfo *hwInfo);
|
2018-07-13 13:42:18 +08:00
|
|
|
MOCKABLE_VIRTUAL ~GmmHelper();
|
2018-07-23 18:23:48 +08:00
|
|
|
|
2018-07-27 19:59:39 +08:00
|
|
|
const HardwareInfo *getHardwareInfo();
|
2020-02-04 19:13:57 +08:00
|
|
|
uint32_t getMOCS(uint32_t type) const;
|
2018-07-23 18:23:48 +08:00
|
|
|
|
2019-01-18 16:44:52 +08:00
|
|
|
static constexpr uint64_t maxPossiblePitch = 2147483648;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-09-17 18:53:37 +08:00
|
|
|
static uint64_t canonize(uint64_t address) {
|
2019-12-24 20:51:39 +08:00
|
|
|
return static_cast<int64_t>(address << (64 - GmmHelper::addressWidth)) >> (64 - GmmHelper::addressWidth);
|
2019-09-17 18:53:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t decanonize(uint64_t address) {
|
2019-12-24 20:51:39 +08:00
|
|
|
return (address & maxNBitValue(GmmHelper::addressWidth));
|
2019-09-17 18:53:37 +08:00
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-04 19:36:16 +08:00
|
|
|
GmmClientContext *getClientContext() const;
|
2018-07-27 19:59:39 +08:00
|
|
|
|
2020-01-14 20:47:40 +08:00
|
|
|
static std::unique_ptr<GmmClientContext> (*createGmmContextWrapperFunc)(OSInterface *, HardwareInfo *);
|
2018-05-17 17:47:35 +08:00
|
|
|
|
2018-07-03 16:00:12 +08:00
|
|
|
protected:
|
2019-12-24 20:51:39 +08:00
|
|
|
static uint32_t addressWidth;
|
2018-07-27 19:59:39 +08:00
|
|
|
const HardwareInfo *hwInfo = nullptr;
|
2018-07-23 18:23:48 +08:00
|
|
|
std::unique_ptr<GmmClientContext> gmmClientContext;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|