mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-20 20:49:12 +12:00
Use std::span
for CPU register-state
Following the trend of #33: `std::span` provides some useful utility functions like `size_bytes()` and `as_bytes()` and serves as a better non-owning "chunk of data"-type over just passing around an `std::array&`.
This commit is contained in:
parent
c6f5d19983
commit
fde93381a5
5 changed files with 38 additions and 32 deletions
|
@ -1,8 +1,10 @@
|
|||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include "kernel.hpp"
|
||||
|
||||
#include "arm_defs.hpp"
|
||||
// This header needs to be included because I did stupid forward decl hack so the kernel and CPU can both access each other
|
||||
#include "kernel.hpp"
|
||||
// This header needs to be included because I did stupid forward decl hack so the kernel and CPU can both access each
|
||||
// other
|
||||
#include "cpu.hpp"
|
||||
#include "resource_limits.hpp"
|
||||
|
||||
|
@ -20,17 +22,17 @@ void Kernel::switchThread(int newThreadIndex) {
|
|||
}
|
||||
|
||||
// Backup context
|
||||
std::memcpy(&oldThread.gprs[0], &cpu.regs()[0], 16 * sizeof(u32)); // Backup the 16 GPRs
|
||||
std::memcpy(&oldThread.fprs[0], &cpu.fprs()[0], 32 * sizeof(u32)); // Backup the 32 FPRs
|
||||
oldThread.cpsr = cpu.getCPSR(); // Backup CPSR
|
||||
oldThread.fpscr = cpu.getFPSCR(); // Backup FPSCR
|
||||
std::memcpy(oldThread.gprs.data(), cpu.regs().data(), cpu.regs().size_bytes()); // Backup the 16 GPRs
|
||||
std::memcpy(oldThread.fprs.data(), cpu.fprs().data(), cpu.fprs().size_bytes()); // Backup the 32 FPRs
|
||||
oldThread.cpsr = cpu.getCPSR(); // Backup CPSR
|
||||
oldThread.fpscr = cpu.getFPSCR(); // Backup FPSCR
|
||||
|
||||
// Load new context
|
||||
std::memcpy(&cpu.regs()[0], &newThread.gprs[0], 16 * sizeof(u32)); // Load 16 GPRs
|
||||
std::memcpy(&cpu.fprs()[0], &newThread.fprs[0], 32 * sizeof(u32)); // Load 32 FPRs
|
||||
cpu.setCPSR(newThread.cpsr); // Load CPSR
|
||||
cpu.setFPSCR(newThread.fpscr); // Load FPSCR
|
||||
cpu.setTLSBase(newThread.tlsBase); // Load CP15 thread-local-storage pointer register
|
||||
std::memcpy(cpu.regs().data(), newThread.gprs.data(), cpu.regs().size_bytes()); // Load 16 GPRs
|
||||
std::memcpy(cpu.fprs().data(), newThread.fprs.data(), cpu.fprs().size_bytes()); // Load 32 FPRs
|
||||
cpu.setCPSR(newThread.cpsr); // Load CPSR
|
||||
cpu.setFPSCR(newThread.fpscr); // Load FPSCR
|
||||
cpu.setTLSBase(newThread.tlsBase); // Load CP15 thread-local-storage pointer register
|
||||
|
||||
currentThreadIndex = newThreadIndex;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
#include "services/service_manager.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "ipc.hpp"
|
||||
#include "kernel.hpp"
|
||||
|
||||
ServiceManager::ServiceManager(std::array<u32, 16>& regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel)
|
||||
ServiceManager::ServiceManager(std::span<u32, 16> regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel)
|
||||
: regs(regs), mem(mem), kernel(kernel), ac(mem), am(mem), boss(mem), act(mem), apt(mem, kernel), cam(mem),
|
||||
cecd(mem, kernel), cfg(mem), dlp_srvr(mem), dsp(mem, kernel), hid(mem, kernel), frd(mem), fs(mem, kernel),
|
||||
gsp_gpu(mem, gpu, kernel, currentPID), gsp_lcd(mem), ldr(mem), mic(mem), nfc(mem, kernel), nim(mem), ndm(mem),
|
||||
ptm(mem), y2r(mem, kernel) {}
|
||||
cecd(mem, kernel), cfg(mem), dlp_srvr(mem), dsp(mem, kernel), hid(mem, kernel), frd(mem), fs(mem, kernel),
|
||||
gsp_gpu(mem, gpu, kernel, currentPID), gsp_lcd(mem), ldr(mem), mic(mem), nfc(mem, kernel), nim(mem), ndm(mem),
|
||||
ptm(mem), y2r(mem, kernel) {}
|
||||
|
||||
static constexpr int MAX_NOTIFICATION_COUNT = 16;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue