diff options
Diffstat (limited to 'src/core/memory.h')
| -rw-r--r-- | src/core/memory.h | 85 |
1 files changed, 78 insertions, 7 deletions
diff --git a/src/core/memory.h b/src/core/memory.h index fc0013a96..cc6ab920e 100644 --- a/src/core/memory.h +++ b/src/core/memory.h | |||
| @@ -153,6 +153,46 @@ public: | |||
| 153 | const u8* GetPointer(VAddr vaddr) const; | 153 | const u8* GetPointer(VAddr vaddr) const; |
| 154 | 154 | ||
| 155 | /** | 155 | /** |
| 156 | * Reads an 8-bit unsigned value from the current process' address space | ||
| 157 | * at the given virtual address. | ||
| 158 | * | ||
| 159 | * @param addr The virtual address to read the 8-bit value from. | ||
| 160 | * | ||
| 161 | * @returns the read 8-bit unsigned value. | ||
| 162 | */ | ||
| 163 | u8 Read8(VAddr addr); | ||
| 164 | |||
| 165 | /** | ||
| 166 | * Reads a 16-bit unsigned value from the current process' address space | ||
| 167 | * at the given virtual address. | ||
| 168 | * | ||
| 169 | * @param addr The virtual address to read the 16-bit value from. | ||
| 170 | * | ||
| 171 | * @returns the read 16-bit unsigned value. | ||
| 172 | */ | ||
| 173 | u16 Read16(VAddr addr); | ||
| 174 | |||
| 175 | /** | ||
| 176 | * Reads a 32-bit unsigned value from the current process' address space | ||
| 177 | * at the given virtual address. | ||
| 178 | * | ||
| 179 | * @param addr The virtual address to read the 32-bit value from. | ||
| 180 | * | ||
| 181 | * @returns the read 32-bit unsigned value. | ||
| 182 | */ | ||
| 183 | u32 Read32(VAddr addr); | ||
| 184 | |||
| 185 | /** | ||
| 186 | * Reads a 64-bit unsigned value from the current process' address space | ||
| 187 | * at the given virtual address. | ||
| 188 | * | ||
| 189 | * @param addr The virtual address to read the 64-bit value from. | ||
| 190 | * | ||
| 191 | * @returns the read 64-bit value. | ||
| 192 | */ | ||
| 193 | u64 Read64(VAddr addr); | ||
| 194 | |||
| 195 | /** | ||
| 156 | * Reads a null-terminated string from the given virtual address. | 196 | * Reads a null-terminated string from the given virtual address. |
| 157 | * This function will continually read characters until either: | 197 | * This function will continually read characters until either: |
| 158 | * | 198 | * |
| @@ -170,6 +210,44 @@ public: | |||
| 170 | std::string ReadCString(VAddr vaddr, std::size_t max_length); | 210 | std::string ReadCString(VAddr vaddr, std::size_t max_length); |
| 171 | 211 | ||
| 172 | /** | 212 | /** |
| 213 | * Reads a contiguous block of bytes from a specified process' address space. | ||
| 214 | * | ||
| 215 | * @param process The process to read the data from. | ||
| 216 | * @param src_addr The virtual address to begin reading from. | ||
| 217 | * @param dest_buffer The buffer to place the read bytes into. | ||
| 218 | * @param size The amount of data to read, in bytes. | ||
| 219 | * | ||
| 220 | * @note If a size of 0 is specified, then this function reads nothing and | ||
| 221 | * no attempts to access memory are made at all. | ||
| 222 | * | ||
| 223 | * @pre dest_buffer must be at least size bytes in length, otherwise a | ||
| 224 | * buffer overrun will occur. | ||
| 225 | * | ||
| 226 | * @post The range [dest_buffer, size) contains the read bytes from the | ||
| 227 | * process' address space. | ||
| 228 | */ | ||
| 229 | void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, | ||
| 230 | std::size_t size); | ||
| 231 | |||
| 232 | /** | ||
| 233 | * Reads a contiguous block of bytes from the current process' address space. | ||
| 234 | * | ||
| 235 | * @param src_addr The virtual address to begin reading from. | ||
| 236 | * @param dest_buffer The buffer to place the read bytes into. | ||
| 237 | * @param size The amount of data to read, in bytes. | ||
| 238 | * | ||
| 239 | * @note If a size of 0 is specified, then this function reads nothing and | ||
| 240 | * no attempts to access memory are made at all. | ||
| 241 | * | ||
| 242 | * @pre dest_buffer must be at least size bytes in length, otherwise a | ||
| 243 | * buffer overrun will occur. | ||
| 244 | * | ||
| 245 | * @post The range [dest_buffer, size) contains the read bytes from the | ||
| 246 | * current process' address space. | ||
| 247 | */ | ||
| 248 | void ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size); | ||
| 249 | |||
| 250 | /** | ||
| 173 | * Fills the specified address range within a process' address space with zeroes. | 251 | * Fills the specified address range within a process' address space with zeroes. |
| 174 | * | 252 | * |
| 175 | * @param process The process that will have a portion of its memory zeroed out. | 253 | * @param process The process that will have a portion of its memory zeroed out. |
| @@ -242,18 +320,11 @@ void SetCurrentPageTable(Kernel::Process& process); | |||
| 242 | /// Determines if the given VAddr is a kernel address | 320 | /// Determines if the given VAddr is a kernel address |
| 243 | bool IsKernelVirtualAddress(VAddr vaddr); | 321 | bool IsKernelVirtualAddress(VAddr vaddr); |
| 244 | 322 | ||
| 245 | u8 Read8(VAddr addr); | ||
| 246 | u16 Read16(VAddr addr); | ||
| 247 | u32 Read32(VAddr addr); | ||
| 248 | u64 Read64(VAddr addr); | ||
| 249 | |||
| 250 | void Write8(VAddr addr, u8 data); | 323 | void Write8(VAddr addr, u8 data); |
| 251 | void Write16(VAddr addr, u16 data); | 324 | void Write16(VAddr addr, u16 data); |
| 252 | void Write32(VAddr addr, u32 data); | 325 | void Write32(VAddr addr, u32 data); |
| 253 | void Write64(VAddr addr, u64 data); | 326 | void Write64(VAddr addr, u64 data); |
| 254 | 327 | ||
| 255 | void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, std::size_t size); | ||
| 256 | void ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size); | ||
| 257 | void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, | 328 | void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, |
| 258 | std::size_t size); | 329 | std::size_t size); |
| 259 | void WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size); | 330 | void WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size); |