2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-09-19 04:17:55 +08:00
|
|
|
* Copyright (C) 2017-2018 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-19 04:17:55 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "runtime/gen_common/aub_mapper.h"
|
2018-09-26 04:47:03 +08:00
|
|
|
#include "command_stream_receiver_simulated_hw.h"
|
2018-09-26 21:28:11 +08:00
|
|
|
#include "runtime/command_stream/aub_center.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/command_stream/aub_command_stream_receiver.h"
|
|
|
|
#include "runtime/memory_manager/address_mapper.h"
|
|
|
|
#include "runtime/memory_manager/page_table.h"
|
2018-09-26 21:28:11 +08:00
|
|
|
#include "runtime/memory_manager/physical_address_allocator.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
|
|
|
|
|
|
|
namespace OCLRT {
|
2018-06-13 02:33:03 +08:00
|
|
|
|
|
|
|
class AubSubCaptureManager;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
2018-09-26 04:47:03 +08:00
|
|
|
class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFamily> {
|
|
|
|
typedef CommandStreamReceiverSimulatedHw<GfxFamily> BaseClass;
|
2017-12-21 07:45:38 +08:00
|
|
|
typedef typename AUBFamilyMapper<GfxFamily>::AUB AUB;
|
|
|
|
typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg;
|
2018-08-17 19:38:09 +08:00
|
|
|
using ExternalAllocationsContainer = std::vector<AllocationView>;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
public:
|
2018-09-25 18:38:00 +08:00
|
|
|
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
|
|
|
|
|
2018-09-14 16:39:21 +08:00
|
|
|
void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) override;
|
2018-06-13 02:33:03 +08:00
|
|
|
|
2018-08-17 19:38:09 +08:00
|
|
|
void makeResidentExternal(AllocationView &allocationView);
|
|
|
|
void makeNonResidentExternal(uint64_t gpuAddress);
|
|
|
|
|
2018-07-09 17:31:36 +08:00
|
|
|
MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation);
|
2018-08-17 19:38:09 +08:00
|
|
|
MOCKABLE_VIRTUAL bool writeMemory(AllocationView &allocationView);
|
2018-09-24 12:42:07 +08:00
|
|
|
void expectMMIO(uint32_t mmioRegister, uint32_t expectedValue);
|
|
|
|
void expectMemory(void *gfxAddress, const void *srcAddress, size_t length);
|
2018-01-11 05:03:23 +08:00
|
|
|
|
2018-06-13 02:33:03 +08:00
|
|
|
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
// Family specific version
|
2017-11-14 18:15:09 +08:00
|
|
|
void submitLRCA(EngineType engineType, const MiContextDescriptorReg &contextDescriptor);
|
2018-08-24 06:16:32 +08:00
|
|
|
MOCKABLE_VIRTUAL void pollForCompletion(EngineType engineType);
|
2017-12-21 07:45:38 +08:00
|
|
|
void initGlobalMMIO();
|
2017-11-14 18:15:09 +08:00
|
|
|
void initEngineMMIO(EngineType engineType);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
void addContextToken();
|
|
|
|
|
2018-08-08 19:49:09 +08:00
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone, ExecutionEnvironment &executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-08 19:49:09 +08:00
|
|
|
AUBCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone, ExecutionEnvironment &executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
~AUBCommandStreamReceiverHw() override;
|
|
|
|
|
2018-01-19 17:00:51 +08:00
|
|
|
AUBCommandStreamReceiverHw(const AUBCommandStreamReceiverHw &) = delete;
|
|
|
|
AUBCommandStreamReceiverHw &operator=(const AUBCommandStreamReceiverHw &) = delete;
|
|
|
|
|
2018-09-20 06:36:44 +08:00
|
|
|
MOCKABLE_VIRTUAL void openFile(const std::string &fileName);
|
|
|
|
MOCKABLE_VIRTUAL bool reopenFile(const std::string &fileName);
|
2018-07-09 17:31:36 +08:00
|
|
|
MOCKABLE_VIRTUAL void initFile(const std::string &fileName);
|
|
|
|
MOCKABLE_VIRTUAL void closeFile();
|
2018-10-02 16:37:17 +08:00
|
|
|
MOCKABLE_VIRTUAL bool isFileOpen() const;
|
2018-07-09 17:31:36 +08:00
|
|
|
MOCKABLE_VIRTUAL const std::string &getFileName();
|
|
|
|
|
2017-11-14 18:15:09 +08:00
|
|
|
void initializeEngine(EngineType engineType);
|
2018-07-09 17:31:36 +08:00
|
|
|
void freeEngineInfoTable();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-06 16:53:35 +08:00
|
|
|
MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
|
2018-10-01 22:10:54 +08:00
|
|
|
this->memoryManager = new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, true, this->executionEnvironment);
|
2018-04-04 17:34:46 +08:00
|
|
|
this->flatBatchBufferHelper->setMemoryManager(this->memoryManager);
|
2017-12-21 07:45:38 +08:00
|
|
|
return this->memoryManager;
|
|
|
|
}
|
|
|
|
|
2017-11-14 18:15:09 +08:00
|
|
|
static const AubMemDump::LrcaHelper &getCsTraits(EngineType engineType);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
struct EngineInfo {
|
|
|
|
void *pLRCA;
|
|
|
|
uint32_t ggttLRCA;
|
|
|
|
void *pGlobalHWStatusPage;
|
|
|
|
uint32_t ggttHWSP;
|
|
|
|
void *pRingBuffer;
|
|
|
|
uint32_t ggttRingBuffer;
|
|
|
|
size_t sizeRingBuffer;
|
|
|
|
uint32_t tailRingBuffer;
|
2018-07-09 17:31:36 +08:00
|
|
|
} engineInfoTable[EngineType::NUM_ENGINES] = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-20 06:36:44 +08:00
|
|
|
AUBCommandStreamReceiver::AubFileStream *stream;
|
2018-06-13 02:33:03 +08:00
|
|
|
std::unique_ptr<AubSubCaptureManager> subCaptureManager;
|
2018-06-06 23:03:46 +08:00
|
|
|
uint32_t aubDeviceId;
|
2018-01-19 17:00:51 +08:00
|
|
|
bool standalone;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-27 21:08:57 +08:00
|
|
|
std::unique_ptr<std::conditional<is64bit, PML4, PDPE>::type> ppgtt;
|
2018-09-11 20:45:43 +08:00
|
|
|
std::unique_ptr<PDPE> ggtt;
|
2017-12-21 07:45:38 +08:00
|
|
|
// remap CPU VA -> GGTT VA
|
2018-10-02 16:37:17 +08:00
|
|
|
AddressMapper *gttRemap;
|
2018-03-01 05:50:41 +08:00
|
|
|
|
2018-03-14 18:07:51 +08:00
|
|
|
MOCKABLE_VIRTUAL bool addPatchInfoComments();
|
2018-04-04 17:34:46 +08:00
|
|
|
void addGUCStartMessage(uint64_t batchBufferAddress, EngineType engineType);
|
|
|
|
uint32_t getGUCWorkQueueItemHeader(EngineType engineType);
|
2018-05-09 21:25:01 +08:00
|
|
|
uint64_t getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation);
|
|
|
|
void getGTTData(void *memory, AubGTTData &data);
|
2018-09-21 04:54:19 +08:00
|
|
|
uint32_t getMemoryBankForGtt() const;
|
2018-06-06 16:34:51 +08:00
|
|
|
|
|
|
|
CommandStreamReceiverType getType() override {
|
|
|
|
return CommandStreamReceiverType::CSR_AUB;
|
|
|
|
}
|
2018-07-09 17:31:36 +08:00
|
|
|
|
2018-09-21 10:33:21 +08:00
|
|
|
int getAddressSpaceFromPTEBits(uint64_t entryBits) const;
|
|
|
|
|
2018-07-09 17:31:36 +08:00
|
|
|
protected:
|
|
|
|
bool dumpAubNonWritable = false;
|
2018-08-17 19:38:09 +08:00
|
|
|
ExternalAllocationsContainer externalAllocations;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
} // namespace OCLRT
|