summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2016-04-19 21:08:02 +0200
committerSubv <subv2112@gmail.com>2016-05-28 20:52:49 +0200
commit660499ac01b9244301a0642f4a0209ef8309ace4 (patch)
tree372686ef656f18c9afdf80fb9599399b7b4d43e6 /src
parentSOC_U: Remove usage of GetPointer (diff)
downloadyuzu-660499ac01b9244301a0642f4a0209ef8309ace4.tar
yuzu-660499ac01b9244301a0642f4a0209ef8309ace4.tar.gz
yuzu-660499ac01b9244301a0642f4a0209ef8309ace4.tar.bz2
yuzu-660499ac01b9244301a0642f4a0209ef8309ace4.tar.lz
yuzu-660499ac01b9244301a0642f4a0209ef8309ace4.tar.xz
yuzu-660499ac01b9244301a0642f4a0209ef8309ace4.tar.zst
yuzu-660499ac01b9244301a0642f4a0209ef8309ace4.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/frd/frd.cpp10
-rw-r--r--src/core/hle/service/soc_u.cpp14
-rw-r--r--src/core/memory.cpp8
-rw-r--r--src/core/memory.h4
-rw-r--r--src/core/mmio.h4
5 files changed, 19 insertions, 21 deletions
diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp
index 15d604bb6..29d144365 100644
--- a/src/core/hle/service/frd/frd.cpp
+++ b/src/core/hle/service/frd/frd.cpp
@@ -23,7 +23,7 @@ void GetMyPresence(Service::Interface* self) {
ASSERT(shifted_out_size == ((sizeof(MyPresence) << 14) | 2));
- Memory::WriteBlock(my_presence_addr, reinterpret_cast<const u8*>(&my_presence), sizeof(MyPresence));
+ Memory::WriteBlock(my_presence_addr, &my_presence, sizeof(MyPresence));
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
@@ -39,8 +39,7 @@ void GetFriendKeyList(Service::Interface* self) {
FriendKey zero_key = {};
for (u32 i = 0; i < frd_count; ++i) {
- Memory::WriteBlock(frd_key_addr + i * sizeof(FriendKey),
- reinterpret_cast<const u8*>(&zero_key), sizeof(FriendKey));
+ Memory::WriteBlock(frd_key_addr + i * sizeof(FriendKey), &zero_key, sizeof(FriendKey));
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
@@ -58,8 +57,7 @@ void GetFriendProfile(Service::Interface* self) {
Profile zero_profile = {};
for (u32 i = 0; i < count; ++i) {
- Memory::WriteBlock(profiles_addr + i * sizeof(Profile),
- reinterpret_cast<const u8*>(&zero_profile), sizeof(Profile));
+ Memory::WriteBlock(profiles_addr + i * sizeof(Profile), &zero_profile, sizeof(Profile));
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
@@ -88,7 +86,7 @@ void GetMyFriendKey(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- Memory::WriteBlock(cmd_buff[2], reinterpret_cast<const u8*>(&my_friend_key), sizeof(FriendKey));
+ Memory::WriteBlock(cmd_buff[2], &my_friend_key, sizeof(FriendKey));
LOG_WARNING(Service_FRD, "(STUBBED) called");
}
diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp
index a7404085b..9b285567b 100644
--- a/src/core/hle/service/soc_u.cpp
+++ b/src/core/hle/service/soc_u.cpp
@@ -568,7 +568,7 @@ static void SendTo(Service::Interface* self) {
Memory::ReadBlock(input_buff_address, input_buff.data(), input_buff.size());
CTRSockAddr ctr_dest_addr;
- Memory::ReadBlock(dest_addr_addr, reinterpret_cast<u8*>(&ctr_dest_addr), sizeof(ctr_dest_addr));
+ Memory::ReadBlock(dest_addr_addr, &ctr_dest_addr, sizeof(ctr_dest_addr));
int ret = -1;
if (addr_len > 0) {
@@ -623,7 +623,7 @@ static void RecvFrom(Service::Interface* self) {
if (ret >= 0 && buffer_parameters.output_src_address_buffer != 0 && src_addr_len > 0) {
CTRSockAddr ctr_src_addr = CTRSockAddr::FromPlatform(src_addr);
- Memory::WriteBlock(buffer_parameters.output_src_address_buffer, reinterpret_cast<u8*>(&ctr_src_addr), sizeof(ctr_src_addr));
+ Memory::WriteBlock(buffer_parameters.output_src_address_buffer, &ctr_src_addr, sizeof(ctr_src_addr));
}
int result = 0;
@@ -654,7 +654,7 @@ static void Poll(Service::Interface* self) {
}
std::vector<CTRPollFD> ctr_fds(nfds);
- Memory::ReadBlock(input_fds_addr, reinterpret_cast<u8*>(ctr_fds.data()), nfds * sizeof(CTRPollFD));
+ Memory::ReadBlock(input_fds_addr, ctr_fds.data(), nfds * sizeof(CTRPollFD));
// The 3ds_pollfd and the pollfd structures may be different (Windows/Linux have different sizes)
// so we have to copy the data
@@ -666,7 +666,7 @@ static void Poll(Service::Interface* self) {
// Now update the output pollfd structure
std::transform(platform_pollfd.begin(), platform_pollfd.end(), ctr_fds.begin(), CTRPollFD::FromPlatform);
- Memory::WriteBlock(output_fds_addr, reinterpret_cast<u8*>(ctr_fds.data()), nfds * sizeof(CTRPollFD));
+ Memory::WriteBlock(output_fds_addr, ctr_fds.data(), nfds * sizeof(CTRPollFD));
int result = 0;
if (ret == SOCKET_ERROR_VALUE)
@@ -690,7 +690,7 @@ static void GetSockName(Service::Interface* self) {
if (ctr_dest_addr_addr != 0 && Memory::IsValidVirtualAddress(ctr_dest_addr_addr)) {
CTRSockAddr ctr_dest_addr = CTRSockAddr::FromPlatform(dest_addr);
- Memory::WriteBlock(ctr_dest_addr_addr, reinterpret_cast<u8*>(&ctr_dest_addr), sizeof(ctr_dest_addr));
+ Memory::WriteBlock(ctr_dest_addr_addr, &ctr_dest_addr, sizeof(ctr_dest_addr));
} else {
cmd_buffer[1] = -1; // TODO(Subv): Verify error
return;
@@ -731,7 +731,7 @@ static void GetPeerName(Service::Interface* self) {
if (ctr_dest_addr_addr != 0 && Memory::IsValidVirtualAddress(ctr_dest_addr_addr)) {
CTRSockAddr ctr_dest_addr = CTRSockAddr::FromPlatform(dest_addr);
- Memory::WriteBlock(ctr_dest_addr_addr, reinterpret_cast<u8*>(&ctr_dest_addr), sizeof(ctr_dest_addr));
+ Memory::WriteBlock(ctr_dest_addr_addr, &ctr_dest_addr, sizeof(ctr_dest_addr));
} else {
cmd_buffer[1] = -1;
return;
@@ -761,7 +761,7 @@ static void Connect(Service::Interface* self) {
}
CTRSockAddr ctr_input_addr;
- Memory::ReadBlock(ctr_input_addr_addr, reinterpret_cast<u8*>(&ctr_input_addr), sizeof(ctr_input_addr));
+ Memory::ReadBlock(ctr_input_addr_addr, &ctr_input_addr, sizeof(ctr_input_addr));
sockaddr input_addr = CTRSockAddr::ToPlatform(ctr_input_addr);
int ret = ::connect(socket_handle, &input_addr, sizeof(input_addr));
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index bf2493270..2ac3e7de4 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -364,7 +364,7 @@ u64 Read64(const VAddr addr) {
return Read<u64_le>(addr);
}
-void ReadBlock(const VAddr src_addr, u8* dest_buffer, const size_t size) {
+void ReadBlock(const VAddr src_addr, void* dest_buffer, const size_t size) {
size_t remaining_size = size;
size_t page_index = src_addr >> PAGE_BITS;
size_t page_offset = src_addr & PAGE_MASK;
@@ -398,7 +398,7 @@ void ReadBlock(const VAddr src_addr, u8* dest_buffer, const size_t size) {
page_index++;
page_offset = 0;
- dest_buffer += copy_amount;
+ dest_buffer = static_cast<u8*>(dest_buffer) + copy_amount;
remaining_size -= copy_amount;
}
}
@@ -419,7 +419,7 @@ void Write64(const VAddr addr, const u64 data) {
Write<u64_le>(addr, data);
}
-void WriteBlock(const VAddr dest_addr, const u8* src_buffer, const size_t size) {
+void WriteBlock(const VAddr dest_addr, const void* src_buffer, 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;
@@ -452,7 +452,7 @@ void WriteBlock(const VAddr dest_addr, const u8* src_buffer, const size_t size)
page_index++;
page_offset = 0;
- src_buffer += copy_amount;
+ src_buffer = static_cast<const u8*>(src_buffer) + copy_amount;
remaining_size -= copy_amount;
}
}
diff --git a/src/core/memory.h b/src/core/memory.h
index bb5dd0d15..ae5588dee 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -123,8 +123,8 @@ void Write16(VAddr addr, u16 data);
void Write32(VAddr addr, u32 data);
void Write64(VAddr addr, u64 data);
-void ReadBlock(const VAddr src_addr, u8* dest_buffer, size_t size);
-void WriteBlock(const VAddr dest_addr, const u8* src_buffer, size_t size);
+void ReadBlock(const VAddr src_addr, void* dest_buffer, size_t size);
+void WriteBlock(const VAddr dest_addr, const void* src_buffer, size_t size);
void ZeroBlock(const VAddr dest_addr, const size_t size);
void CopyBlock(VAddr dest_addr, VAddr src_addr, size_t size);
diff --git a/src/core/mmio.h b/src/core/mmio.h
index 35b73b061..d76f005d8 100644
--- a/src/core/mmio.h
+++ b/src/core/mmio.h
@@ -25,14 +25,14 @@ public:
virtual u32 Read32(VAddr addr) = 0;
virtual u64 Read64(VAddr addr) = 0;
- virtual bool ReadBlock(VAddr src_addr, u8* dest_buffer, size_t size) = 0;
+ virtual bool ReadBlock(VAddr src_addr, void* dest_buffer, size_t size) = 0;
virtual void Write8(VAddr addr, u8 data) = 0;
virtual void Write16(VAddr addr, u16 data) = 0;
virtual void Write32(VAddr addr, u32 data) = 0;
virtual void Write64(VAddr addr, u64 data) = 0;
- virtual bool WriteBlock(VAddr dest_addr, const u8* src_buffer, size_t size) = 0;
+ virtual bool WriteBlock(VAddr dest_addr, const void* src_buffer, size_t size) = 0;
};
using MMIORegionPointer = std::shared_ptr<MMIORegion>;