Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
c7763603
There was an error fetching the commit references. Please try again later.
Commit
c7763603
authored
6 years ago
by
David Marcec
Browse files
Options
Downloads
Patches
Plain Diff
Added error codes for nvmap
parent
6d82c4ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/hle/service/nvdrv/devices/nvmap.cpp
+59
-12
59 additions, 12 deletions
src/core/hle/service/nvdrv/devices/nvmap.cpp
with
59 additions
and
12 deletions
src/core/hle/service/nvdrv/devices/nvmap.cpp
+
59
−
12
View file @
c7763603
...
@@ -11,6 +11,13 @@
...
@@ -11,6 +11,13 @@
namespace
Service
::
Nvidia
::
Devices
{
namespace
Service
::
Nvidia
::
Devices
{
namespace
NvErrCodes
{
enum
{
OperationNotPermitted
=
-
1
,
InvalidValue
=
-
22
,
};
}
nvmap
::
nvmap
()
=
default
;
nvmap
::
nvmap
()
=
default
;
nvmap
::~
nvmap
()
=
default
;
nvmap
::~
nvmap
()
=
default
;
...
@@ -44,7 +51,11 @@ u32 nvmap::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& o
...
@@ -44,7 +51,11 @@ u32 nvmap::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& o
u32
nvmap
::
IocCreate
(
const
std
::
vector
<
u8
>&
input
,
std
::
vector
<
u8
>&
output
)
{
u32
nvmap
::
IocCreate
(
const
std
::
vector
<
u8
>&
input
,
std
::
vector
<
u8
>&
output
)
{
IocCreateParams
params
;
IocCreateParams
params
;
std
::
memcpy
(
&
params
,
input
.
data
(),
sizeof
(
params
));
std
::
memcpy
(
&
params
,
input
.
data
(),
sizeof
(
params
));
LOG_DEBUG
(
Service_NVDRV
,
"size=0x{:08X}"
,
params
.
size
);
if
(
!
params
.
size
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
}
// Create a new nvmap object and obtain a handle to it.
// Create a new nvmap object and obtain a handle to it.
auto
object
=
std
::
make_shared
<
Object
>
();
auto
object
=
std
::
make_shared
<
Object
>
();
object
->
id
=
next_id
++
;
object
->
id
=
next_id
++
;
...
@@ -55,8 +66,6 @@ u32 nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) {
...
@@ -55,8 +66,6 @@ u32 nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) {
u32
handle
=
next_handle
++
;
u32
handle
=
next_handle
++
;
handles
[
handle
]
=
std
::
move
(
object
);
handles
[
handle
]
=
std
::
move
(
object
);
LOG_DEBUG
(
Service_NVDRV
,
"size=0x{:08X}"
,
params
.
size
);
params
.
handle
=
handle
;
params
.
handle
=
handle
;
std
::
memcpy
(
output
.
data
(),
&
params
,
sizeof
(
params
));
std
::
memcpy
(
output
.
data
(),
&
params
,
sizeof
(
params
));
...
@@ -66,9 +75,28 @@ u32 nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) {
...
@@ -66,9 +75,28 @@ u32 nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) {
u32
nvmap
::
IocAlloc
(
const
std
::
vector
<
u8
>&
input
,
std
::
vector
<
u8
>&
output
)
{
u32
nvmap
::
IocAlloc
(
const
std
::
vector
<
u8
>&
input
,
std
::
vector
<
u8
>&
output
)
{
IocAllocParams
params
;
IocAllocParams
params
;
std
::
memcpy
(
&
params
,
input
.
data
(),
sizeof
(
params
));
std
::
memcpy
(
&
params
,
input
.
data
(),
sizeof
(
params
));
LOG_DEBUG
(
Service_NVDRV
,
"called, addr={:X}"
,
params
.
addr
);
if
(
!
params
.
handle
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
}
if
((
params
.
align
-
1
)
&
params
.
align
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
}
if
(
params
.
align
<
0x1000
)
{
params
.
align
=
0x1000
;
}
auto
object
=
GetObject
(
params
.
handle
);
auto
object
=
GetObject
(
params
.
handle
);
ASSERT
(
object
);
if
(
!
object
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
}
if
(
object
->
status
==
Object
::
Status
::
Allocated
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
OperationNotPermitted
);
}
object
->
flags
=
params
.
flags
;
object
->
flags
=
params
.
flags
;
object
->
align
=
params
.
align
;
object
->
align
=
params
.
align
;
...
@@ -76,8 +104,6 @@ u32 nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) {
...
@@ -76,8 +104,6 @@ u32 nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) {
object
->
addr
=
params
.
addr
;
object
->
addr
=
params
.
addr
;
object
->
status
=
Object
::
Status
::
Allocated
;
object
->
status
=
Object
::
Status
::
Allocated
;
LOG_DEBUG
(
Service_NVDRV
,
"called, addr={:X}"
,
params
.
addr
);
std
::
memcpy
(
output
.
data
(),
&
params
,
sizeof
(
params
));
std
::
memcpy
(
output
.
data
(),
&
params
,
sizeof
(
params
));
return
0
;
return
0
;
}
}
...
@@ -88,8 +114,14 @@ u32 nvmap::IocGetId(const std::vector<u8>& input, std::vector<u8>& output) {
...
@@ -88,8 +114,14 @@ u32 nvmap::IocGetId(const std::vector<u8>& input, std::vector<u8>& output) {
LOG_WARNING
(
Service_NVDRV
,
"called"
);
LOG_WARNING
(
Service_NVDRV
,
"called"
);
if
(
!
params
.
handle
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
}
auto
object
=
GetObject
(
params
.
handle
);
auto
object
=
GetObject
(
params
.
handle
);
ASSERT
(
object
);
if
(
!
object
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
OperationNotPermitted
);
}
params
.
id
=
object
->
id
;
params
.
id
=
object
->
id
;
...
@@ -105,7 +137,14 @@ u32 nvmap::IocFromId(const std::vector<u8>& input, std::vector<u8>& output) {
...
@@ -105,7 +137,14 @@ u32 nvmap::IocFromId(const std::vector<u8>& input, std::vector<u8>& output) {
auto
itr
=
std
::
find_if
(
handles
.
begin
(),
handles
.
end
(),
auto
itr
=
std
::
find_if
(
handles
.
begin
(),
handles
.
end
(),
[
&
](
const
auto
&
entry
)
{
return
entry
.
second
->
id
==
params
.
id
;
});
[
&
](
const
auto
&
entry
)
{
return
entry
.
second
->
id
==
params
.
id
;
});
ASSERT
(
itr
!=
handles
.
end
());
if
(
itr
==
handles
.
end
())
{
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
}
auto
&
object
=
itr
->
second
;
if
(
object
->
status
!=
Object
::
Status
::
Allocated
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
}
itr
->
second
->
refcount
++
;
itr
->
second
->
refcount
++
;
...
@@ -125,8 +164,13 @@ u32 nvmap::IocParam(const std::vector<u8>& input, std::vector<u8>& output) {
...
@@ -125,8 +164,13 @@ u32 nvmap::IocParam(const std::vector<u8>& input, std::vector<u8>& output) {
LOG_WARNING
(
Service_NVDRV
,
"(STUBBED) called type={}"
,
params
.
param
);
LOG_WARNING
(
Service_NVDRV
,
"(STUBBED) called type={}"
,
params
.
param
);
auto
object
=
GetObject
(
params
.
handle
);
auto
object
=
GetObject
(
params
.
handle
);
ASSERT
(
object
);
if
(
!
object
)
{
ASSERT
(
object
->
status
==
Object
::
Status
::
Allocated
);
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
}
if
(
object
->
status
!=
Object
::
Status
::
Allocated
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
OperationNotPermitted
);
}
switch
(
static_cast
<
ParamTypes
>
(
params
.
param
))
{
switch
(
static_cast
<
ParamTypes
>
(
params
.
param
))
{
case
ParamTypes
::
Size
:
case
ParamTypes
::
Size
:
...
@@ -163,9 +207,12 @@ u32 nvmap::IocFree(const std::vector<u8>& input, std::vector<u8>& output) {
...
@@ -163,9 +207,12 @@ u32 nvmap::IocFree(const std::vector<u8>& input, std::vector<u8>& output) {
LOG_WARNING
(
Service_NVDRV
,
"(STUBBED) called"
);
LOG_WARNING
(
Service_NVDRV
,
"(STUBBED) called"
);
auto
itr
=
handles
.
find
(
params
.
handle
);
auto
itr
=
handles
.
find
(
params
.
handle
);
ASSERT
(
itr
!=
handles
.
end
());
if
(
itr
==
handles
.
end
())
{
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
ASSERT
(
itr
->
second
->
refcount
>
0
);
}
if
(
!
itr
->
second
->
refcount
)
{
return
static_cast
<
u32
>
(
NvErrCodes
::
InvalidValue
);
}
itr
->
second
->
refcount
--
;
itr
->
second
->
refcount
--
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment