2018-01-13 22:22:39 +01:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2018-01-09 16:41:13 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
#include "common/common_funcs.h"
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/swap.h"
|
|
|
|
#include "core/hle/service/nvdrv/devices/nvdevice.h"
|
|
|
|
|
|
|
|
namespace Service {
|
2018-01-15 23:39:00 +01:00
|
|
|
namespace Nvidia {
|
2018-01-09 16:41:13 +01:00
|
|
|
namespace Devices {
|
|
|
|
|
|
|
|
class nvmap final : public nvdevice {
|
|
|
|
public:
|
|
|
|
nvmap() = default;
|
|
|
|
~nvmap() override = default;
|
|
|
|
|
|
|
|
/// Returns the allocated address of an nvmap object given its handle.
|
|
|
|
VAddr GetObjectAddress(u32 handle) const;
|
|
|
|
|
Extra nvdrv support (#162)
* FinishInitalize needed for 3.0.1+ games
* nvdrv:s and nvdrv:t both use NVDRV
* Most settings return 0 on hardware, disabled NV_MEMORY_PROFILER for now.
NVN_THROUGH_OPENGL & NVRM_GPU_PREVENT_USE are a few interesting settings to look at. Carefully choosing settings can help with drawing graphics later on
* Initial /dev/nvhost-gpu support
* ZCullBind
* Stubbed SetErrorNotifier
* Fixed SetErrorNotifier log, Added SetChannelPriority
* Allocate GPFIFO Ex2, Allocate Obj Ctx, Submit GPFIFO
* oops
* Fixed up naming/structs/enums. Used vector instead of array for "gpfifo_entry"
* Added missing fixes
* /dev/nvhost-ctrl-gpu
* unneeded struct
* Forgot u32 in enum class
* Automatic descriptor swapping for ioctls, fixed nvgpu_gpu_get_tpc_masks_args being incorrect size
* nvdrv#QueryEvent
* Renamed logs for nvdrv
* Refactor ioctl so nv_result isn't needed
* /dev/nvhost-as-gpu
* Fixed Log service naming, CtxObjects now u32, renamed all structs, added static_asserts to structs, used INSERT_PADDING_WORDS instead of u32s
* nvdevices now uses "Ioctl" union,
* IoctlGpfifoEntry now uses bit field
* final changes
2018-02-06 03:19:31 +01:00
|
|
|
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
2018-01-09 16:41:13 +01:00
|
|
|
|
2018-02-08 03:53:31 +01:00
|
|
|
/// Represents an nvmap object.
|
2018-01-09 16:41:13 +01:00
|
|
|
struct Object {
|
|
|
|
enum class Status { Created, Allocated };
|
|
|
|
u32 id;
|
|
|
|
u32 size;
|
|
|
|
u32 flags;
|
|
|
|
u32 align;
|
|
|
|
u8 kind;
|
|
|
|
VAddr addr;
|
|
|
|
Status status;
|
|
|
|
};
|
|
|
|
|
2018-02-08 03:53:31 +01:00
|
|
|
std::shared_ptr<Object> GetObject(u32 handle) const {
|
|
|
|
auto itr = handles.find(handle);
|
|
|
|
if (itr != handles.end()) {
|
|
|
|
return itr->second;
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-01-09 16:41:13 +01:00
|
|
|
/// Id to use for the next handle that is created.
|
|
|
|
u32 next_handle = 1;
|
|
|
|
|
2018-02-08 03:53:31 +01:00
|
|
|
/// Id to use for the next object that is created.
|
2018-01-09 16:41:13 +01:00
|
|
|
u32 next_id = 1;
|
|
|
|
|
|
|
|
/// Mapping of currently allocated handles to the objects they represent.
|
|
|
|
std::unordered_map<u32, std::shared_ptr<Object>> handles;
|
|
|
|
|
2018-01-21 22:56:58 +01:00
|
|
|
enum class IoctlCommand : u32 {
|
|
|
|
Create = 0xC0080101,
|
|
|
|
FromId = 0xC0080103,
|
|
|
|
Alloc = 0xC0200104,
|
|
|
|
Param = 0xC00C0109,
|
|
|
|
GetId = 0xC008010E
|
2018-01-09 16:41:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct IocCreateParams {
|
|
|
|
// Input
|
|
|
|
u32_le size;
|
|
|
|
// Output
|
|
|
|
u32_le handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IocAllocParams {
|
|
|
|
// Input
|
|
|
|
u32_le handle;
|
|
|
|
u32_le heap_mask;
|
|
|
|
u32_le flags;
|
|
|
|
u32_le align;
|
|
|
|
u8 kind;
|
|
|
|
INSERT_PADDING_BYTES(7);
|
|
|
|
u64_le addr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IocGetIdParams {
|
|
|
|
// Output
|
|
|
|
u32_le id;
|
|
|
|
// Input
|
|
|
|
u32_le handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IocFromIdParams {
|
|
|
|
// Input
|
|
|
|
u32_le id;
|
|
|
|
// Output
|
|
|
|
u32_le handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IocParamParams {
|
|
|
|
// Input
|
|
|
|
u32_le handle;
|
|
|
|
u32_le type;
|
|
|
|
// Output
|
|
|
|
u32_le value;
|
|
|
|
};
|
|
|
|
|
|
|
|
u32 IocCreate(const std::vector<u8>& input, std::vector<u8>& output);
|
|
|
|
u32 IocAlloc(const std::vector<u8>& input, std::vector<u8>& output);
|
|
|
|
u32 IocGetId(const std::vector<u8>& input, std::vector<u8>& output);
|
|
|
|
u32 IocFromId(const std::vector<u8>& input, std::vector<u8>& output);
|
|
|
|
u32 IocParam(const std::vector<u8>& input, std::vector<u8>& output);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Devices
|
2018-01-15 23:39:00 +01:00
|
|
|
} // namespace Nvidia
|
2018-01-09 16:41:13 +01:00
|
|
|
} // namespace Service
|