thermosphere: the fpu cache is only being really modified by gdb anyway

This commit is contained in:
TuxSH 2020-02-03 01:57:11 +00:00
parent edf2bbc30e
commit 788f331de0
3 changed files with 16 additions and 12 deletions

View file

@ -17,7 +17,7 @@
#include "fpu.h"
#include "core_ctx.h"
static FpuRegisterCache TEMPORARY g_fpuRegisterCache[4] = { 0 };
static FpuRegisterCache TEMPORARY g_fpuRegisterCache = { 0 };
// fpu_regs_load_store.s
void fpuLoadRegistersFromCache(const FpuRegisterCache *cache);
@ -25,12 +25,13 @@ void fpuStoreRegistersToCache(FpuRegisterCache *cache);
FpuRegisterCache *fpuGetRegisterCache(void)
{
return &g_fpuRegisterCache[currentCoreCtx->coreId];
g_fpuRegisterCache.coreId = currentCoreCtx->coreId;
return &g_fpuRegisterCache;
}
FpuRegisterCache *fpuReadRegisters(void)
{
FpuRegisterCache *cache = &g_fpuRegisterCache[currentCoreCtx->coreId];
FpuRegisterCache *cache = &g_fpuRegisterCache;
if (!cache->valid) {
fpuStoreRegistersToCache(cache);
cache->valid = true;
@ -40,7 +41,7 @@ FpuRegisterCache *fpuReadRegisters(void)
void fpuCommitRegisters(void)
{
FpuRegisterCache *cache = &g_fpuRegisterCache[currentCoreCtx->coreId];
FpuRegisterCache *cache = &g_fpuRegisterCache;
cache->dirty = true;
// Because the caller rewrote the entire cache in the event it didn't read it before:
@ -49,8 +50,8 @@ void fpuCommitRegisters(void)
void fpuCleanInvalidateRegisterCache(void)
{
FpuRegisterCache *cache = &g_fpuRegisterCache[currentCoreCtx->coreId];
if (cache->dirty) {
FpuRegisterCache *cache = &g_fpuRegisterCache;
if (cache->dirty && cache->coreId == currentCoreCtx->coreId) {
fpuLoadRegistersFromCache(cache);
cache->dirty = false;
}

View file

@ -17,13 +17,14 @@
#pragma once
#include "utils.h"
#include "spinlock.h"
typedef struct FpuRegisterCache {
u128 q[32];
u64 fpsr;
u64 fpcr;
bool valid;
bool dirty;
u128 q[32];
u64 fpsr;
u64 fpcr;
u32 coreId;
bool valid;
bool dirty;
} FpuRegisterCache;
// Only for the current core:

View file

@ -41,6 +41,7 @@
#include "../breakpoints.h"
#include "../software_breakpoints.h"
#include "../watchpoints.h"
#include "../fpu.h"
static TEMPORARY char g_gdbWorkBuffer[GDB_WORK_BUF_LEN];
static TEMPORARY char g_gdbBuffer[GDB_BUF_LEN + 4 + 1];
@ -236,6 +237,7 @@ void GDB_ReleaseContext(GDBContext *ctx)
void GDB_MigrateRxIrq(GDBContext *ctx, u32 coreId)
{
fpuCleanInvalidateRegisterCache();
transportInterfaceSetInterruptAffinity(ctx->transportInterface, BIT(coreId));
}