2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2024-01-17 03:42:54 +08:00
|
|
|
* Copyright (C) 2018-2024 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
|
2022-08-29 07:20:29 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/built_ins/sip_kernel_type.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-08-29 07:20:29 +08:00
|
|
|
#include <string>
|
2020-12-02 18:22:27 +08:00
|
|
|
#include <vector>
|
2022-08-29 07:20:29 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class Device;
|
2018-03-09 18:52:14 +08:00
|
|
|
class GraphicsAllocation;
|
2021-04-16 20:52:30 +08:00
|
|
|
class MemoryManager;
|
2022-12-15 22:57:31 +08:00
|
|
|
class GfxCoreHelper;
|
2023-03-27 20:03:02 +08:00
|
|
|
class OsContext;
|
2022-08-29 07:20:29 +08:00
|
|
|
|
2021-04-16 20:52:30 +08:00
|
|
|
struct RootDeviceEnvironment;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class SipKernel {
|
|
|
|
public:
|
2023-08-08 23:18:53 +08:00
|
|
|
SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc, std::vector<char> ssah, std::vector<char> binary);
|
2021-03-31 10:31:58 +08:00
|
|
|
SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc, std::vector<char> ssah);
|
2017-12-21 07:45:38 +08:00
|
|
|
SipKernel(const SipKernel &) = delete;
|
|
|
|
SipKernel &operator=(const SipKernel &) = delete;
|
2020-10-13 17:41:48 +08:00
|
|
|
SipKernel(SipKernel &&) = delete;
|
|
|
|
SipKernel &operator=(SipKernel &&) = delete;
|
2019-12-03 22:57:45 +08:00
|
|
|
virtual ~SipKernel();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-08 10:25:27 +08:00
|
|
|
SipKernelType getType() const {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2023-08-08 23:18:53 +08:00
|
|
|
size_t getCtxOffset() const {
|
|
|
|
return contextIdOffsets[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t getPidOffset() const {
|
|
|
|
return contextIdOffsets[1];
|
|
|
|
}
|
|
|
|
|
2019-12-03 22:57:45 +08:00
|
|
|
MOCKABLE_VIRTUAL GraphicsAllocation *getSipAllocation() const;
|
2021-03-31 10:31:58 +08:00
|
|
|
MOCKABLE_VIRTUAL const std::vector<char> &getStateSaveAreaHeader() const;
|
2022-03-17 00:08:37 +08:00
|
|
|
MOCKABLE_VIRTUAL size_t getStateSaveAreaSize(Device *device) const;
|
2023-08-08 23:18:53 +08:00
|
|
|
MOCKABLE_VIRTUAL const std::vector<char> &getBinary() const;
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL void parseBinaryForContextId();
|
2021-04-16 20:52:30 +08:00
|
|
|
|
|
|
|
static bool initSipKernel(SipKernelType type, Device &device);
|
|
|
|
static void freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, MemoryManager *memoryManager);
|
|
|
|
|
2023-07-28 21:22:38 +08:00
|
|
|
static const SipKernel &getSipKernel(Device &device, OsContext *context);
|
2021-08-18 19:05:17 +08:00
|
|
|
static const SipKernel &getBindlessDebugSipKernel(Device &device);
|
2023-03-27 20:03:02 +08:00
|
|
|
static const SipKernel &getBindlessDebugSipKernel(Device &device, OsContext *context);
|
2021-04-16 20:52:30 +08:00
|
|
|
static SipKernelType getSipKernelType(Device &device);
|
2021-08-18 19:05:17 +08:00
|
|
|
static SipKernelType getSipKernelType(Device &device, bool debuggingEnable);
|
2021-04-16 20:52:30 +08:00
|
|
|
static SipClassType classType;
|
2018-03-09 18:52:14 +08:00
|
|
|
|
2023-12-19 19:02:07 +08:00
|
|
|
enum class Command : uint32_t {
|
|
|
|
resume,
|
|
|
|
ready,
|
|
|
|
slmRead,
|
|
|
|
slmWrite
|
2021-10-29 23:06:11 +08:00
|
|
|
};
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2023-03-27 20:03:02 +08:00
|
|
|
static bool initSipKernelImpl(SipKernelType type, Device &device, OsContext *context);
|
2021-04-16 20:52:30 +08:00
|
|
|
static const SipKernel &getSipKernelImpl(Device &device);
|
|
|
|
|
2023-03-27 20:03:02 +08:00
|
|
|
static bool initBuiltinsSipKernel(SipKernelType type, Device &device, OsContext *context);
|
2021-04-16 20:52:30 +08:00
|
|
|
static bool initRawBinaryFromFileKernel(SipKernelType type, Device &device, std::string &fileName);
|
2021-09-22 23:45:29 +08:00
|
|
|
static std::vector<char> readStateSaveAreaHeaderFromFile(const std::string &fileName);
|
|
|
|
static std::string createHeaderFilename(const std::string &filename);
|
|
|
|
|
2021-08-30 07:41:42 +08:00
|
|
|
static bool initHexadecimalArraySipKernel(SipKernelType type, Device &device);
|
2024-01-17 03:42:54 +08:00
|
|
|
static void selectSipClassType(std::string &fileName, Device &device);
|
2021-04-16 20:52:30 +08:00
|
|
|
|
2021-03-31 10:31:58 +08:00
|
|
|
const std::vector<char> stateSaveAreaHeader;
|
2023-08-08 23:18:53 +08:00
|
|
|
const std::vector<char> binary;
|
|
|
|
size_t contextIdOffsets[2] = {0, 0};
|
2021-04-16 20:52:30 +08:00
|
|
|
GraphicsAllocation *sipAllocation = nullptr;
|
2023-12-11 19:02:15 +08:00
|
|
|
SipKernelType type = SipKernelType::count;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2022-08-29 07:20:29 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|