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
1ce6fff0
There was an error fetching the commit references. Please try again later.
Commit
1ce6fff0
authored
7 years ago
by
bunnei
Browse files
Options
Downloads
Patches
Plain Diff
hle_ipc: Add helper functions for reading and writing buffers.
parent
4f8ee5e4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/hle/ipc.h
+4
-0
4 additions, 0 deletions
src/core/hle/ipc.h
src/core/hle/kernel/hle_ipc.cpp
+39
-0
39 additions, 0 deletions
src/core/hle/kernel/hle_ipc.cpp
src/core/hle/kernel/hle_ipc.h
+12
-0
12 additions, 0 deletions
src/core/hle/kernel/hle_ipc.h
with
55 additions
and
0 deletions
src/core/hle/ipc.h
+
4
−
0
View file @
1ce6fff0
...
...
@@ -91,6 +91,10 @@ struct BufferDescriptorX {
address
|=
static_cast
<
VAddr
>
(
address_bits_36_38
)
<<
36
;
return
address
;
}
u64
Size
()
const
{
return
static_cast
<
u64
>
(
size
);
}
};
static_assert
(
sizeof
(
BufferDescriptorX
)
==
8
,
"BufferDescriptorX size is incorrect"
);
...
...
This diff is collapsed.
Click to expand it.
src/core/hle/kernel/hle_ipc.cpp
+
39
−
0
View file @
1ce6fff0
...
...
@@ -12,6 +12,7 @@
#include
"core/hle/kernel/kernel.h"
#include
"core/hle/kernel/process.h"
#include
"core/hle/kernel/server_session.h"
#include
"core/memory.h"
namespace
Kernel
{
...
...
@@ -210,4 +211,42 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, P
return
RESULT_SUCCESS
;
}
std
::
vector
<
u8
>
HLERequestContext
::
ReadBuffer
()
const
{
std
::
vector
<
u8
>
buffer
;
const
bool
is_buffer_a
{
BufferDescriptorA
().
size
()
&&
BufferDescriptorA
()[
0
].
Size
()};
if
(
is_buffer_a
)
{
buffer
.
resize
(
BufferDescriptorA
()[
0
].
Size
());
Memory
::
ReadBlock
(
BufferDescriptorA
()[
0
].
Address
(),
buffer
.
data
(),
buffer
.
size
());
}
else
{
buffer
.
resize
(
BufferDescriptorX
()[
0
].
Size
());
Memory
::
ReadBlock
(
BufferDescriptorX
()[
0
].
Address
(),
buffer
.
data
(),
buffer
.
size
());
}
return
buffer
;
}
size_t
HLERequestContext
::
WriteBuffer
(
const
void
*
buffer
,
const
size_t
size
)
const
{
const
bool
is_buffer_b
{
BufferDescriptorB
().
size
()
&&
BufferDescriptorB
()[
0
].
Size
()};
if
(
is_buffer_b
)
{
const
size_t
size
{
std
::
min
(
BufferDescriptorB
()[
0
].
Size
(),
size
)};
Memory
::
WriteBlock
(
BufferDescriptorB
()[
0
].
Address
(),
buffer
,
size
);
return
size
;
}
else
{
const
size_t
size
{
std
::
min
(
BufferDescriptorC
()[
0
].
Size
(),
size
)};
Memory
::
WriteBlock
(
BufferDescriptorC
()[
0
].
Address
(),
buffer
,
size
);
return
size
;
}
}
size_t
HLERequestContext
::
WriteBuffer
(
const
std
::
vector
<
u8
>&
buffer
)
const
{
return
WriteBuffer
(
buffer
.
data
(),
buffer
.
size
());
}
size_t
HLERequestContext
::
GetWriteBufferSize
()
const
{
const
bool
is_buffer_b
{
BufferDescriptorB
().
size
()
&&
BufferDescriptorB
()[
0
].
Size
()};
return
is_buffer_b
?
BufferDescriptorB
()[
0
].
Size
()
:
BufferDescriptorC
()[
0
].
Size
();
}
}
// namespace Kernel
This diff is collapsed.
Click to expand it.
src/core/hle/kernel/hle_ipc.h
+
12
−
0
View file @
1ce6fff0
...
...
@@ -143,6 +143,18 @@ public:
return
domain_message_header
;
}
/// Helper function to read a buffer using the appropriate buffer descriptor
std
::
vector
<
u8
>
ReadBuffer
()
const
;
/// Helper function to write a buffer using the appropriate buffer descriptor
size_t
WriteBuffer
(
const
void
*
buffer
,
const
size_t
size
)
const
;
/// Helper function to write a buffer using the appropriate buffer descriptor
size_t
WriteBuffer
(
const
std
::
vector
<
u8
>&
buffer
)
const
;
/// Helper function to get the size of the output buffer
size_t
GetWriteBufferSize
()
const
;
template
<
typename
T
>
SharedPtr
<
T
>
GetCopyObject
(
size_t
index
)
{
ASSERT
(
index
<
copy_objects
.
size
());
...
...
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