aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Memory/IWritableBlock.cs
blob: 78ae2479dea82faa5d94a01f35a46e453a360b56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.Buffers;

namespace Ryujinx.Memory
{
    public interface IWritableBlock
    {
        /// <summary>
        /// Writes data to CPU mapped memory, with write tracking.
        /// </summary>
        /// <param name="va">Virtual address to write the data into</param>
        /// <param name="data">Data to be written</param>
        /// <exception cref="InvalidMemoryRegionException">Throw for unhandled invalid or unmapped memory accesses</exception>
        void Write(ulong va, ReadOnlySequence<byte> data)
        {
            foreach (ReadOnlyMemory<byte> segment in data)
            {
                Write(va, segment.Span);
                va += (ulong)segment.Length;
            }
        }

        void Write(ulong va, ReadOnlySpan<byte> data);

        void WriteUntracked(ulong va, ReadOnlySpan<byte> data) => Write(va, data);
    }
}