CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/MemMapHelpers.h
Views: 1401
// Copyright (C) 2003 Dolphin Project / 2012 PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official SVN repository and contact information can be found at15// http://code.google.com/p/dolphin-emu/1617#pragma once1819#include <cstring>2021#include "Common/CommonTypes.h"22#include "Common/StringUtils.h"23#include "Core/Debugger/MemBlockInfo.h"24#include "Core/MemMap.h"25#include "Core/MIPS/MIPS.h"2627// To avoid pulling in the entire HLE.h.28extern MIPSState *currentMIPS;2930namespace Memory31{3233inline void Memcpy(const u32 to_address, const void *from_data, const u32 len, const char *tag, size_t tagLen) {34u8 *to = GetPointerWriteRange(to_address, len);35if (to) {36memcpy(to, from_data, len);37if (!tag) {38tag = "Memcpy";39tagLen = sizeof("Memcpy") - 1;40}41NotifyMemInfo(MemBlockFlags::WRITE, to_address, len, tag, tagLen);42}43// if not, GetPointer will log.44}4546inline void Memcpy(void *to_data, const u32 from_address, const u32 len, const char *tag, size_t tagLen) {47const u8 *from = GetPointerRange(from_address, len);48if (from) {49memcpy(to_data, from, len);50if (!tag) {51tag = "Memcpy";52tagLen = sizeof("Memcpy") - 1;53}54NotifyMemInfo(MemBlockFlags::READ, from_address, len, tag, tagLen);55}56// if not, GetPointer will log.57}5859inline void Memcpy(const u32 to_address, const u32 from_address, const u32 len, const char *tag, size_t tagLen) {60u8 *to = GetPointerWriteRange(to_address, len);61// If not, GetPointer will log.62if (!to)63return;64const u8 *from = GetPointerRange(from_address, len);65if (!from)66return;6768memcpy(to, from, len);6970if (MemBlockInfoDetailed(len)) {71if (!tag) {72NotifyMemInfoCopy(to_address, from_address, len, "Memcpy/");73} else {74NotifyMemInfo(MemBlockFlags::READ, from_address, len, tag, tagLen);75NotifyMemInfo(MemBlockFlags::WRITE, to_address, len, tag, tagLen);76}77}78}7980template<size_t tagLen>81inline void Memcpy(const u32 to_address, const void *from_data, const u32 len, const char(&tag)[tagLen]) {82Memcpy(to_address, from_data, len, tag, tagLen);83}8485template<size_t tagLen>86inline void Memcpy(void *to_data, const u32 from_address, const u32 len, const char(&tag)[tagLen]) {87Memcpy(to_data, from_address, len, tag, tagLen);88}8990template<size_t tagLen>91inline void Memcpy(const u32 to_address, const u32 from_address, const u32 len, const char(&tag)[tagLen]) {92Memcpy(to_address, from_address, len, tag, tagLen);93}9495inline void Memcpy(const u32 to_address, const void *from_data, const u32 len) {96Memcpy(to_address, from_data, len, nullptr, 0);97}9899inline void Memcpy(void *to_data, const u32 from_address, const u32 len) {100Memcpy(to_data, from_address, len, nullptr, 0);101}102103inline void Memcpy(const u32 to_address, const u32 from_address, const u32 len) {104Memcpy(to_address, from_address, len, nullptr, 0);105}106107void Memset(const u32 _Address, const u8 _Data, const u32 _iLength, const char *tag = "Memset");108109}110111112