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
ca17df57
There was an error fetching the commit references. Please try again later.
Commit
ca17df57
authored
8 years ago
by
MerryMage
Committed by
Subv
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Memory: ZeroBlock
parent
2be17a0c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/memory.cpp
+38
-0
38 additions, 0 deletions
src/core/memory.cpp
src/core/memory.h
+1
-0
1 addition, 0 deletions
src/core/memory.h
with
39 additions
and
0 deletions
src/core/memory.cpp
+
38
−
0
View file @
ca17df57
...
@@ -457,6 +457,44 @@ void WriteBlock(const VAddr dest_addr, const u8* src_buffer, const size_t size)
...
@@ -457,6 +457,44 @@ void WriteBlock(const VAddr dest_addr, const u8* src_buffer, const size_t size)
}
}
}
}
void
ZeroBlock
(
const
VAddr
dest_addr
,
const
size_t
size
)
{
size_t
remaining_size
=
size
;
size_t
page_index
=
dest_addr
>>
PAGE_BITS
;
size_t
page_offset
=
dest_addr
&
PAGE_MASK
;
while
(
remaining_size
>
0
)
{
const
size_t
copy_amount
=
std
::
min
(
PAGE_SIZE
-
page_offset
,
remaining_size
);
const
VAddr
current_vaddr
=
(
page_index
<<
PAGE_BITS
)
+
page_offset
;
switch
(
current_page_table
->
attributes
[
page_index
])
{
case
PageType
::
Unmapped
:
{
LOG_ERROR
(
HW_Memory
,
"unmapped ZeroBlock @ 0x%08X (start address = 0x%08X, size = %zu)"
,
current_vaddr
,
dest_addr
,
size
);
break
;
}
case
PageType
::
Memory
:
{
DEBUG_ASSERT
(
current_page_table
->
pointers
[
page_index
]);
u8
*
dest_ptr
=
current_page_table
->
pointers
[
page_index
]
+
page_offset
;
std
::
memset
(
dest_ptr
,
0
,
copy_amount
);
break
;
}
case
PageType
::
Special
:
{
DEBUG_ASSERT
(
GetMMIOHandler
(
current_vaddr
));
static
const
std
::
array
<
u8
,
PAGE_SIZE
>
zeros
=
{};
GetMMIOHandler
(
current_vaddr
)
->
WriteBlock
(
current_vaddr
,
zeros
.
data
(),
copy_amount
);
break
;
}
default
:
UNREACHABLE
();
}
page_index
++
;
page_offset
=
0
;
remaining_size
-=
copy_amount
;
}
}
template
<
>
template
<
>
u8
ReadMMIO
<
u8
>
(
MMIORegionPointer
mmio_handler
,
VAddr
addr
)
{
u8
ReadMMIO
<
u8
>
(
MMIORegionPointer
mmio_handler
,
VAddr
addr
)
{
return
mmio_handler
->
Read8
(
addr
);
return
mmio_handler
->
Read8
(
addr
);
...
...
This diff is collapsed.
Click to expand it.
src/core/memory.h
+
1
−
0
View file @
ca17df57
...
@@ -126,6 +126,7 @@ void Write32(VAddr addr, u32 data);
...
@@ -126,6 +126,7 @@ void Write32(VAddr addr, u32 data);
void
Write64
(
VAddr
addr
,
u64
data
);
void
Write64
(
VAddr
addr
,
u64
data
);
void
WriteBlock
(
const
VAddr
dest_addr
,
const
u8
*
src_buffer
,
size_t
size
);
void
WriteBlock
(
const
VAddr
dest_addr
,
const
u8
*
src_buffer
,
size_t
size
);
void
ZeroBlock
(
const
VAddr
dest_addr
,
const
size_t
size
);
u8
*
GetPointer
(
VAddr
virtual_address
);
u8
*
GetPointer
(
VAddr
virtual_address
);
...
...
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