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
fe0775d2
There was an error fetching the commit references. Please try again later.
Unverified
Commit
fe0775d2
authored
7 years ago
by
Lioncash
Browse files
Options
Downloads
Patches
Plain Diff
memory: Silence formatting sepecifier warnings
parent
e6bf7287
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/memory.cpp
+30
-21
30 additions, 21 deletions
src/core/memory.cpp
with
30 additions
and
21 deletions
src/core/memory.cpp
+
30
−
21
View file @
fe0775d2
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include
<algorithm>
#include
<algorithm>
#include
<array>
#include
<array>
#include
<cinttypes>
#include
<cstring>
#include
<cstring>
#include
<boost/optional.hpp>
#include
<boost/optional.hpp>
#include
"common/assert.h"
#include
"common/assert.h"
...
@@ -38,12 +39,12 @@ PageTable* GetCurrentPageTable() {
...
@@ -38,12 +39,12 @@ PageTable* GetCurrentPageTable() {
}
}
static
void
MapPages
(
PageTable
&
page_table
,
VAddr
base
,
u64
size
,
u8
*
memory
,
PageType
type
)
{
static
void
MapPages
(
PageTable
&
page_table
,
VAddr
base
,
u64
size
,
u8
*
memory
,
PageType
type
)
{
LOG_DEBUG
(
HW_Memory
,
"Mapping %p onto %0
8X-%08X"
,
memory
,
base
*
PAGE_SIZE
,
LOG_DEBUG
(
HW_Memory
,
"Mapping %p onto %0
16"
PRIX64
"-%016"
PRIX64
,
memory
,
base
*
PAGE_SIZE
,
(
base
+
size
)
*
PAGE_SIZE
);
(
base
+
size
)
*
PAGE_SIZE
);
VAddr
end
=
base
+
size
;
VAddr
end
=
base
+
size
;
while
(
base
!=
end
)
{
while
(
base
!=
end
)
{
ASSERT_MSG
(
base
<
PAGE_TABLE_NUM_ENTRIES
,
"out of range mapping at %0
8X"
,
base
);
ASSERT_MSG
(
base
<
PAGE_TABLE_NUM_ENTRIES
,
"out of range mapping at %0
16"
PRIX64
,
base
);
page_table
.
attributes
[
base
]
=
type
;
page_table
.
attributes
[
base
]
=
type
;
page_table
.
pointers
[
base
]
=
memory
;
page_table
.
pointers
[
base
]
=
memory
;
...
@@ -55,14 +56,14 @@ static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, Pa
...
@@ -55,14 +56,14 @@ static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, Pa
}
}
void
MapMemoryRegion
(
PageTable
&
page_table
,
VAddr
base
,
u64
size
,
u8
*
target
)
{
void
MapMemoryRegion
(
PageTable
&
page_table
,
VAddr
base
,
u64
size
,
u8
*
target
)
{
ASSERT_MSG
((
size
&
PAGE_MASK
)
==
0
,
"non-page aligned size: %0
8X"
,
size
);
ASSERT_MSG
((
size
&
PAGE_MASK
)
==
0
,
"non-page aligned size: %0
16"
PRIX64
,
size
);
ASSERT_MSG
((
base
&
PAGE_MASK
)
==
0
,
"non-page aligned base: %0
8X"
,
base
);
ASSERT_MSG
((
base
&
PAGE_MASK
)
==
0
,
"non-page aligned base: %0
16"
PRIX64
,
base
);
MapPages
(
page_table
,
base
/
PAGE_SIZE
,
size
/
PAGE_SIZE
,
target
,
PageType
::
Memory
);
MapPages
(
page_table
,
base
/
PAGE_SIZE
,
size
/
PAGE_SIZE
,
target
,
PageType
::
Memory
);
}
}
void
MapIoRegion
(
PageTable
&
page_table
,
VAddr
base
,
u64
size
,
MemoryHookPointer
mmio_handler
)
{
void
MapIoRegion
(
PageTable
&
page_table
,
VAddr
base
,
u64
size
,
MemoryHookPointer
mmio_handler
)
{
ASSERT_MSG
((
size
&
PAGE_MASK
)
==
0
,
"non-page aligned size: %0
8X"
,
size
);
ASSERT_MSG
((
size
&
PAGE_MASK
)
==
0
,
"non-page aligned size: %0
16"
PRIX64
,
size
);
ASSERT_MSG
((
base
&
PAGE_MASK
)
==
0
,
"non-page aligned base: %0
8X"
,
base
);
ASSERT_MSG
((
base
&
PAGE_MASK
)
==
0
,
"non-page aligned base: %0
16"
PRIX64
,
base
);
MapPages
(
page_table
,
base
/
PAGE_SIZE
,
size
/
PAGE_SIZE
,
nullptr
,
PageType
::
Special
);
MapPages
(
page_table
,
base
/
PAGE_SIZE
,
size
/
PAGE_SIZE
,
nullptr
,
PageType
::
Special
);
auto
interval
=
boost
::
icl
::
discrete_interval
<
VAddr
>::
closed
(
base
,
base
+
size
-
1
);
auto
interval
=
boost
::
icl
::
discrete_interval
<
VAddr
>::
closed
(
base
,
base
+
size
-
1
);
...
@@ -71,8 +72,8 @@ void MapIoRegion(PageTable& page_table, VAddr base, u64 size, MemoryHookPointer
...
@@ -71,8 +72,8 @@ void MapIoRegion(PageTable& page_table, VAddr base, u64 size, MemoryHookPointer
}
}
void
UnmapRegion
(
PageTable
&
page_table
,
VAddr
base
,
u64
size
)
{
void
UnmapRegion
(
PageTable
&
page_table
,
VAddr
base
,
u64
size
)
{
ASSERT_MSG
((
size
&
PAGE_MASK
)
==
0
,
"non-page aligned size: %0
8X"
,
size
);
ASSERT_MSG
((
size
&
PAGE_MASK
)
==
0
,
"non-page aligned size: %0
16"
PRIX64
,
size
);
ASSERT_MSG
((
base
&
PAGE_MASK
)
==
0
,
"non-page aligned base: %0
8X"
,
base
);
ASSERT_MSG
((
base
&
PAGE_MASK
)
==
0
,
"non-page aligned base: %0
16"
PRIX64
,
base
);
MapPages
(
page_table
,
base
/
PAGE_SIZE
,
size
/
PAGE_SIZE
,
nullptr
,
PageType
::
Unmapped
);
MapPages
(
page_table
,
base
/
PAGE_SIZE
,
size
/
PAGE_SIZE
,
nullptr
,
PageType
::
Unmapped
);
auto
interval
=
boost
::
icl
::
discrete_interval
<
VAddr
>::
closed
(
base
,
base
+
size
-
1
);
auto
interval
=
boost
::
icl
::
discrete_interval
<
VAddr
>::
closed
(
base
,
base
+
size
-
1
);
...
@@ -120,7 +121,7 @@ T Read(const VAddr vaddr) {
...
@@ -120,7 +121,7 @@ T Read(const VAddr vaddr) {
const
PageType
type
=
current_page_table
->
attributes
[
vaddr
>>
PAGE_BITS
];
const
PageType
type
=
current_page_table
->
attributes
[
vaddr
>>
PAGE_BITS
];
switch
(
type
)
{
switch
(
type
)
{
case
PageType
::
Unmapped
:
case
PageType
::
Unmapped
:
LOG_ERROR
(
HW_Memory
,
"unmapped Read%
l
u @ 0x%016
llX"
,
sizeof
(
T
)
*
8
,
vaddr
);
LOG_ERROR
(
HW_Memory
,
"unmapped Read%
z
u @ 0x%016
"
PRIX64
,
sizeof
(
T
)
*
8
,
vaddr
);
return
0
;
return
0
;
case
PageType
::
Special
:
{
case
PageType
::
Special
:
{
if
(
auto
result
=
ReadSpecial
<
T
>
(
vaddr
))
if
(
auto
result
=
ReadSpecial
<
T
>
(
vaddr
))
...
@@ -129,7 +130,7 @@ T Read(const VAddr vaddr) {
...
@@ -129,7 +130,7 @@ T Read(const VAddr vaddr) {
}
}
case
PageType
::
Memory
:
{
case
PageType
::
Memory
:
{
const
u8
*
page_pointer
=
current_page_table
->
pointers
[
vaddr
>>
PAGE_BITS
];
const
u8
*
page_pointer
=
current_page_table
->
pointers
[
vaddr
>>
PAGE_BITS
];
ASSERT_MSG
(
page_pointer
,
"Mapped memory page without a pointer @ %0
8X"
,
vaddr
);
ASSERT_MSG
(
page_pointer
,
"Mapped memory page without a pointer @ %0
16"
PRIX64
,
vaddr
);
T
value
;
T
value
;
std
::
memcpy
(
&
value
,
&
page_pointer
[
vaddr
&
PAGE_MASK
],
sizeof
(
T
));
std
::
memcpy
(
&
value
,
&
page_pointer
[
vaddr
&
PAGE_MASK
],
sizeof
(
T
));
...
@@ -148,8 +149,8 @@ void Write(const VAddr vaddr, const T data) {
...
@@ -148,8 +149,8 @@ void Write(const VAddr vaddr, const T data) {
const
PageType
type
=
current_page_table
->
attributes
[
vaddr
>>
PAGE_BITS
];
const
PageType
type
=
current_page_table
->
attributes
[
vaddr
>>
PAGE_BITS
];
switch
(
type
)
{
switch
(
type
)
{
case
PageType
::
Unmapped
:
case
PageType
::
Unmapped
:
LOG_ERROR
(
HW_Memory
,
"unmapped Write%
l
u 0x%08X @ 0x%0
8X"
,
sizeof
(
data
)
*
8
,
(
u32
)
data
,
LOG_ERROR
(
HW_Memory
,
"unmapped Write%
z
u 0x%08X @ 0x%0
16"
PRIX64
,
sizeof
(
data
)
*
8
,
vaddr
);
static_cast
<
u32
>
(
data
),
vaddr
);
return
;
return
;
case
PageType
::
Special
:
{
case
PageType
::
Special
:
{
if
(
WriteSpecial
<
T
>
(
vaddr
,
data
))
if
(
WriteSpecial
<
T
>
(
vaddr
,
data
))
...
@@ -158,7 +159,7 @@ void Write(const VAddr vaddr, const T data) {
...
@@ -158,7 +159,7 @@ void Write(const VAddr vaddr, const T data) {
}
}
case
PageType
::
Memory
:
{
case
PageType
::
Memory
:
{
u8
*
page_pointer
=
current_page_table
->
pointers
[
vaddr
>>
PAGE_BITS
];
u8
*
page_pointer
=
current_page_table
->
pointers
[
vaddr
>>
PAGE_BITS
];
ASSERT_MSG
(
page_pointer
,
"Mapped memory page without a pointer @ %0
8X"
,
vaddr
);
ASSERT_MSG
(
page_pointer
,
"Mapped memory page without a pointer @ %0
16"
PRIX64
,
vaddr
);
std
::
memcpy
(
&
page_pointer
[
vaddr
&
PAGE_MASK
],
&
data
,
sizeof
(
T
));
std
::
memcpy
(
&
page_pointer
[
vaddr
&
PAGE_MASK
],
&
data
,
sizeof
(
T
));
return
;
return
;
}
}
...
@@ -203,7 +204,7 @@ u8* GetPointer(const VAddr vaddr) {
...
@@ -203,7 +204,7 @@ u8* GetPointer(const VAddr vaddr) {
return
page_pointer
+
(
vaddr
&
PAGE_MASK
);
return
page_pointer
+
(
vaddr
&
PAGE_MASK
);
}
}
LOG_ERROR
(
HW_Memory
,
"unknown GetPointer @ 0x%0
8x"
,
vaddr
);
LOG_ERROR
(
HW_Memory
,
"unknown GetPointer @ 0x%0
16"
PRIx64
,
vaddr
);
return
nullptr
;
return
nullptr
;
}
}
...
@@ -241,12 +242,13 @@ u8* GetPhysicalPointer(PAddr address) {
...
@@ -241,12 +242,13 @@ u8* GetPhysicalPointer(PAddr address) {
});
});
if
(
area
==
std
::
end
(
memory_areas
))
{
if
(
area
==
std
::
end
(
memory_areas
))
{
LOG_ERROR
(
HW_Memory
,
"unknown GetPhysicalPointer @ 0x%0
8X"
,
address
);
LOG_ERROR
(
HW_Memory
,
"unknown GetPhysicalPointer @ 0x%0
16"
PRIX64
,
address
);
return
nullptr
;
return
nullptr
;
}
}
if
(
area
->
paddr_base
==
IO_AREA_PADDR
)
{
if
(
area
->
paddr_base
==
IO_AREA_PADDR
)
{
LOG_ERROR
(
HW_Memory
,
"MMIO mappings are not supported yet. phys_addr=0x%08X"
,
address
);
LOG_ERROR
(
HW_Memory
,
"MMIO mappings are not supported yet. phys_addr=0x%016"
PRIX64
,
address
);
return
nullptr
;
return
nullptr
;
}
}
...
@@ -321,7 +323,9 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_
...
@@ -321,7 +323,9 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_
switch
(
page_table
.
attributes
[
page_index
])
{
switch
(
page_table
.
attributes
[
page_index
])
{
case
PageType
::
Unmapped
:
case
PageType
::
Unmapped
:
LOG_ERROR
(
HW_Memory
,
"unmapped ReadBlock @ 0x%08X (start address = 0xllx, size = %zu)"
,
LOG_ERROR
(
HW_Memory
,
"unmapped ReadBlock @ 0x%016"
PRIX64
" (start address = 0x%"
PRIx64
", size = %zu)"
,
current_vaddr
,
src_addr
,
size
);
current_vaddr
,
src_addr
,
size
);
std
::
memset
(
dest_buffer
,
0
,
copy_amount
);
std
::
memset
(
dest_buffer
,
0
,
copy_amount
);
break
;
break
;
...
@@ -393,7 +397,8 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi
...
@@ -393,7 +397,8 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi
switch
(
page_table
.
attributes
[
page_index
])
{
switch
(
page_table
.
attributes
[
page_index
])
{
case
PageType
::
Unmapped
:
case
PageType
::
Unmapped
:
LOG_ERROR
(
HW_Memory
,
LOG_ERROR
(
HW_Memory
,
"unmapped WriteBlock @ 0x%08X (start address = 0x%08X, size = %zu)"
,
"unmapped WriteBlock @ 0x%016"
PRIX64
" (start address = 0x%016"
PRIX64
", size = %zu)"
,
current_vaddr
,
dest_addr
,
size
);
current_vaddr
,
dest_addr
,
size
);
break
;
break
;
case
PageType
::
Special
:
case
PageType
::
Special
:
...
@@ -437,7 +442,9 @@ void ZeroBlock(const VAddr dest_addr, const size_t size) {
...
@@ -437,7 +442,9 @@ void ZeroBlock(const VAddr dest_addr, const size_t size) {
switch
(
current_page_table
->
attributes
[
page_index
])
{
switch
(
current_page_table
->
attributes
[
page_index
])
{
case
PageType
::
Unmapped
:
case
PageType
::
Unmapped
:
LOG_ERROR
(
HW_Memory
,
"unmapped ZeroBlock @ 0x%08X (start address = 0x%08X, size = %zu)"
,
LOG_ERROR
(
HW_Memory
,
"unmapped ZeroBlock @ 0x%016"
PRIX64
" (start address = 0x%016"
PRIX64
", size = %zu)"
,
current_vaddr
,
dest_addr
,
size
);
current_vaddr
,
dest_addr
,
size
);
break
;
break
;
case
PageType
::
Special
:
case
PageType
::
Special
:
...
@@ -474,7 +481,9 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) {
...
@@ -474,7 +481,9 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) {
switch
(
current_page_table
->
attributes
[
page_index
])
{
switch
(
current_page_table
->
attributes
[
page_index
])
{
case
PageType
::
Unmapped
:
case
PageType
::
Unmapped
:
LOG_ERROR
(
HW_Memory
,
"unmapped CopyBlock @ 0x%08X (start address = 0x%08X, size = %zu)"
,
LOG_ERROR
(
HW_Memory
,
"unmapped CopyBlock @ 0x%016"
PRIX64
" (start address = 0x%016"
PRIX64
", size = %zu)"
,
current_vaddr
,
src_addr
,
size
);
current_vaddr
,
src_addr
,
size
);
ZeroBlock
(
dest_addr
,
copy_amount
);
ZeroBlock
(
dest_addr
,
copy_amount
);
break
;
break
;
...
@@ -599,7 +608,7 @@ boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) {
...
@@ -599,7 +608,7 @@ boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) {
PAddr
VirtualToPhysicalAddress
(
const
VAddr
addr
)
{
PAddr
VirtualToPhysicalAddress
(
const
VAddr
addr
)
{
auto
paddr
=
TryVirtualToPhysicalAddress
(
addr
);
auto
paddr
=
TryVirtualToPhysicalAddress
(
addr
);
if
(
!
paddr
)
{
if
(
!
paddr
)
{
LOG_ERROR
(
HW_Memory
,
"Unknown virtual address @ 0x%0
8X"
,
addr
);
LOG_ERROR
(
HW_Memory
,
"Unknown virtual address @ 0x%0
16"
PRIX64
,
addr
);
// To help with debugging, set bit on address so that it's obviously invalid.
// To help with debugging, set bit on address so that it's obviously invalid.
return
addr
|
0x80000000
;
return
addr
|
0x80000000
;
}
}
...
...
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