From 31c12de0fecec5889020191ca6de0b7fbf8c51ba Mon Sep 17 00:00:00 2001 From: Chloe Marcec Date: Sun, 8 Nov 2020 19:11:34 +1100 Subject: core: Make nvservices more standardized --- src/core/hle/service/nvdrv/devices/nvmap.h | 68 ++++++++++++++---------------- 1 file changed, 31 insertions(+), 37 deletions(-) (limited to 'src/core/hle/service/nvdrv/devices/nvmap.h') diff --git a/src/core/hle/service/nvdrv/devices/nvmap.h b/src/core/hle/service/nvdrv/devices/nvmap.h index 04b9ef540..4484bd79f 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.h +++ b/src/core/hle/service/nvdrv/devices/nvmap.h @@ -19,13 +19,15 @@ public: explicit nvmap(Core::System& system); ~nvmap() override; + NvResult Ioctl1(Ioctl command, const std::vector& input, std::vector& output) override; + NvResult Ioctl2(Ioctl command, const std::vector& input, + const std::vector& inline_input, std::vector& output) override; + NvResult Ioctl3(Ioctl command, const std::vector& input, std::vector& output, + std::vector& inline_output) override; + /// Returns the allocated address of an nvmap object given its handle. VAddr GetObjectAddress(u32 handle) const; - u32 ioctl(Ioctl command, const std::vector& input, const std::vector& input2, - std::vector& output, std::vector& output2, IoctlCtrl& ctrl, - IoctlVersion version) override; - /// Represents an nvmap object. struct Object { enum class Status { Created, Allocated }; @@ -58,76 +60,68 @@ private: /// Mapping of currently allocated handles to the objects they represent. std::unordered_map> handles; - enum class IoctlCommand : u32 { - Create = 0xC0080101, - FromId = 0xC0080103, - Alloc = 0xC0200104, - Free = 0xC0180105, - Param = 0xC00C0109, - GetId = 0xC008010E, - }; struct IocCreateParams { // Input - u32_le size; + u32_le size{}; // Output - u32_le handle; + u32_le handle{}; }; static_assert(sizeof(IocCreateParams) == 8, "IocCreateParams has wrong size"); struct IocFromIdParams { // Input - u32_le id; + u32_le id{}; // Output - u32_le handle; + u32_le handle{}; }; static_assert(sizeof(IocFromIdParams) == 8, "IocFromIdParams has wrong size"); struct IocAllocParams { // Input - u32_le handle; - u32_le heap_mask; - u32_le flags; - u32_le align; - u8 kind; + u32_le handle{}; + u32_le heap_mask{}; + u32_le flags{}; + u32_le align{}; + u8 kind{}; INSERT_PADDING_BYTES(7); - u64_le addr; + u64_le addr{}; }; static_assert(sizeof(IocAllocParams) == 32, "IocAllocParams has wrong size"); struct IocFreeParams { - u32_le handle; + u32_le handle{}; INSERT_PADDING_BYTES(4); - u64_le address; - u32_le size; - u32_le flags; + u64_le address{}; + u32_le size{}; + u32_le flags{}; }; static_assert(sizeof(IocFreeParams) == 24, "IocFreeParams has wrong size"); struct IocParamParams { // Input - u32_le handle; - u32_le param; + u32_le handle{}; + u32_le param{}; // Output - u32_le result; + u32_le result{}; }; static_assert(sizeof(IocParamParams) == 12, "IocParamParams has wrong size"); struct IocGetIdParams { // Output - u32_le id; + u32_le id{}; // Input - u32_le handle; + u32_le handle{}; }; static_assert(sizeof(IocGetIdParams) == 8, "IocGetIdParams has wrong size"); u32 CreateObject(u32 size); - u32 IocCreate(const std::vector& input, std::vector& output); - u32 IocAlloc(const std::vector& input, std::vector& output); - u32 IocGetId(const std::vector& input, std::vector& output); - u32 IocFromId(const std::vector& input, std::vector& output); - u32 IocParam(const std::vector& input, std::vector& output); - u32 IocFree(const std::vector& input, std::vector& output); + NvResult IocCreate(const std::vector& input, std::vector& output); + NvResult IocAlloc(const std::vector& input, std::vector& output); + NvResult IocGetId(const std::vector& input, std::vector& output); + NvResult IocFromId(const std::vector& input, std::vector& output); + NvResult IocParam(const std::vector& input, std::vector& output); + NvResult IocFree(const std::vector& input, std::vector& output); }; } // namespace Service::Nvidia::Devices -- cgit v1.2.3