diff options
| author | 2019-11-26 17:39:57 -0500 | |
|---|---|---|
| committer | 2019-11-26 21:55:39 -0500 | |
| commit | e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1 (patch) | |
| tree | 14b95ea207543f3884558ebdf8673a511bf64dc3 /src/core/memory.h | |
| parent | core/memory: Migrate over Read{8, 16, 32, 64, Block} to the Memory class (diff) | |
| download | yuzu-e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1.tar.gz yuzu-e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1.tar.xz yuzu-e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1.zip | |
core/memory: Migrate over Write{8, 16, 32, 64, Block} to the Memory class
The Write functions are used slightly less than the Read functions,
which make these a bit nicer to move over.
The only adjustments we really need to make here are to Dynarmic's
exclusive monitor instance. We need to keep a reference to the currently
active memory instance to perform exclusive read/write operations.
Diffstat (limited to 'src/core/memory.h')
| -rw-r--r-- | src/core/memory.h | 97 |
1 files changed, 88 insertions, 9 deletions
diff --git a/src/core/memory.h b/src/core/memory.h index cc6ab920e..7878f3fb1 100644 --- a/src/core/memory.h +++ b/src/core/memory.h | |||
| @@ -193,6 +193,50 @@ public: | |||
| 193 | u64 Read64(VAddr addr); | 193 | u64 Read64(VAddr addr); |
| 194 | 194 | ||
| 195 | /** | 195 | /** |
| 196 | * Writes an 8-bit unsigned integer to the given virtual address in | ||
| 197 | * the current process' address space. | ||
| 198 | * | ||
| 199 | * @param addr The virtual address to write the 8-bit unsigned integer to. | ||
| 200 | * @param data The 8-bit unsigned integer to write to the given virtual address. | ||
| 201 | * | ||
| 202 | * @post The memory at the given virtual address contains the specified data value. | ||
| 203 | */ | ||
| 204 | void Write8(VAddr addr, u8 data); | ||
| 205 | |||
| 206 | /** | ||
| 207 | * Writes a 16-bit unsigned integer to the given virtual address in | ||
| 208 | * the current process' address space. | ||
| 209 | * | ||
| 210 | * @param addr The virtual address to write the 16-bit unsigned integer to. | ||
| 211 | * @param data The 16-bit unsigned integer to write to the given virtual address. | ||
| 212 | * | ||
| 213 | * @post The memory range [addr, sizeof(data)) contains the given data value. | ||
| 214 | */ | ||
| 215 | void Write16(VAddr addr, u16 data); | ||
| 216 | |||
| 217 | /** | ||
| 218 | * Writes a 32-bit unsigned integer to the given virtual address in | ||
| 219 | * the current process' address space. | ||
| 220 | * | ||
| 221 | * @param addr The virtual address to write the 32-bit unsigned integer to. | ||
| 222 | * @param data The 32-bit unsigned integer to write to the given virtual address. | ||
| 223 | * | ||
| 224 | * @post The memory range [addr, sizeof(data)) contains the given data value. | ||
| 225 | */ | ||
| 226 | void Write32(VAddr addr, u32 data); | ||
| 227 | |||
| 228 | /** | ||
| 229 | * Writes a 64-bit unsigned integer to the given virtual address in | ||
| 230 | * the current process' address space. | ||
| 231 | * | ||
| 232 | * @param addr The virtual address to write the 64-bit unsigned integer to. | ||
| 233 | * @param data The 64-bit unsigned integer to write to the given virtual address. | ||
| 234 | * | ||
| 235 | * @post The memory range [addr, sizeof(data)) contains the given data value. | ||
| 236 | */ | ||
| 237 | void Write64(VAddr addr, u64 data); | ||
| 238 | |||
| 239 | /** | ||
| 196 | * Reads a null-terminated string from the given virtual address. | 240 | * Reads a null-terminated string from the given virtual address. |
| 197 | * This function will continually read characters until either: | 241 | * This function will continually read characters until either: |
| 198 | * | 242 | * |
| @@ -248,6 +292,50 @@ public: | |||
| 248 | void ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size); | 292 | void ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size); |
| 249 | 293 | ||
| 250 | /** | 294 | /** |
| 295 | * Writes a range of bytes into a given process' address space at the specified | ||
| 296 | * virtual address. | ||
| 297 | * | ||
| 298 | * @param process The process to write data into the address space of. | ||
| 299 | * @param dest_addr The destination virtual address to begin writing the data at. | ||
| 300 | * @param src_buffer The data to write into the process' address space. | ||
| 301 | * @param size The size of the data to write, in bytes. | ||
| 302 | * | ||
| 303 | * @post The address range [dest_addr, size) in the process' address space | ||
| 304 | * contains the data that was within src_buffer. | ||
| 305 | * | ||
| 306 | * @post If an attempt is made to write into an unmapped region of memory, the writes | ||
| 307 | * will be ignored and an error will be logged. | ||
| 308 | * | ||
| 309 | * @post If a write is performed into a region of memory that is considered cached | ||
| 310 | * rasterizer memory, will cause the currently active rasterizer to be notified | ||
| 311 | * and will mark that region as invalidated to caches that the active | ||
| 312 | * graphics backend may be maintaining over the course of execution. | ||
| 313 | */ | ||
| 314 | void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, | ||
| 315 | std::size_t size); | ||
| 316 | |||
| 317 | /** | ||
| 318 | * Writes a range of bytes into the current process' address space at the specified | ||
| 319 | * virtual address. | ||
| 320 | * | ||
| 321 | * @param dest_addr The destination virtual address to begin writing the data at. | ||
| 322 | * @param src_buffer The data to write into the current process' address space. | ||
| 323 | * @param size The size of the data to write, in bytes. | ||
| 324 | * | ||
| 325 | * @post The address range [dest_addr, size) in the current process' address space | ||
| 326 | * contains the data that was within src_buffer. | ||
| 327 | * | ||
| 328 | * @post If an attempt is made to write into an unmapped region of memory, the writes | ||
| 329 | * will be ignored and an error will be logged. | ||
| 330 | * | ||
| 331 | * @post If a write is performed into a region of memory that is considered cached | ||
| 332 | * rasterizer memory, will cause the currently active rasterizer to be notified | ||
| 333 | * and will mark that region as invalidated to caches that the active | ||
| 334 | * graphics backend may be maintaining over the course of execution. | ||
| 335 | */ | ||
| 336 | void WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size); | ||
| 337 | |||
| 338 | /** | ||
| 251 | * Fills the specified address range within a process' address space with zeroes. | 339 | * Fills the specified address range within a process' address space with zeroes. |
| 252 | * | 340 | * |
| 253 | * @param process The process that will have a portion of its memory zeroed out. | 341 | * @param process The process that will have a portion of its memory zeroed out. |
| @@ -320,13 +408,4 @@ void SetCurrentPageTable(Kernel::Process& process); | |||
| 320 | /// Determines if the given VAddr is a kernel address | 408 | /// Determines if the given VAddr is a kernel address |
| 321 | bool IsKernelVirtualAddress(VAddr vaddr); | 409 | bool IsKernelVirtualAddress(VAddr vaddr); |
| 322 | 410 | ||
| 323 | void Write8(VAddr addr, u8 data); | ||
| 324 | void Write16(VAddr addr, u16 data); | ||
| 325 | void Write32(VAddr addr, u32 data); | ||
| 326 | void Write64(VAddr addr, u64 data); | ||
| 327 | |||
| 328 | void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, | ||
| 329 | std::size_t size); | ||
| 330 | void WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size); | ||
| 331 | |||
| 332 | } // namespace Memory | 411 | } // namespace Memory |