bpmpfw: cleanup makefile and split hpp/cpp

This commit is contained in:
souldbminersmwc committed 2026-08-27 18:57:15 -04:00
1 parent e5240d835f
commit 3352dffc39
15 files changed
+464 -266

No files matched your search

+6 -67
View File
@@ -77,76 +77,15 @@ namespace bpmpMmu {
{ IramBase, IramEnd, MmuEnRead | MmuEnWrite | MmuEnExec | MmuEnCached },
};
inline u32 AlignUp(u32 x, u32 a) {
return (x + a - 1) & ~(a - 1);
}
inline u32 AlignDown(u32 x, u32 a) {
return x & ~(a - 1);
}
u32 AlignUp(u32 x, u32 a);
u32 AlignDown(u32 x, u32 a);
inline void Maintenance(u32 op, bool force) {
if (!force && !(MMIO32(CacheBase + CacheConfig) & CfgEnableCache)) {
return;
}
void Maintenance(u32 op, bool force);
MMIO32(CacheBase + IntClear) = IntMaintDone;
void SetEntry(u32 idx, const MmuEntry &entry);
// Blocking operation.
MMIO32(CacheBase + MaintReq) = MaintReqWayBitmapAll | op;
void Enable();
while (!(MMIO32(CacheBase + IntRawEvent) & IntMaintDone))
;
MMIO32(CacheBase + IntClear) = MMIO32(CacheBase + IntRawEvent);
}
inline void SetEntry(u32 idx, const MmuEntry &entry) {
MMIO32(ShadowEntryBase + sizeof(u32) * 4 * idx + 0x0) = AlignUp(entry.startAddr, CacheLineSize);
MMIO32(ShadowEntryBase + sizeof(u32) * 4 * idx + 0x4) = AlignDown(entry.endAddr, CacheLineSize);
MMIO32(ShadowEntryBase + sizeof(u32) * 4 * idx + 0x8) = entry.attr;
MMIO32(CacheBase + MmuShadowCopyMask) |= (1u << idx);
}
inline void Enable() {
if (MMIO32(CacheBase + CacheConfig) & CfgEnableCache) {
return;
}
// Init BPMP MMU.
MMIO32(CacheBase + MmuCmd) = MmuCmdInit;
MMIO32(CacheBase + MmuFallbackEntry) = MmuEnRead | MmuEnWrite | MmuEnExec; // RWX for non-defined regions.
MMIO32(CacheBase + MmuCfg) = MmuCfgSeqEn | MmuCfgTlbEn | MmuCfgAbortStoreLast;
// Init BPMP MMU entries.
MMIO32(CacheBase + MmuShadowCopyMask) = 0;
for (u32 idx = 0; idx < sizeof(Entries) / sizeof(Entries[0]); idx++) {
SetEntry(idx, Entries[idx]);
}
MMIO32(CacheBase + MmuCmd) = MmuCmdCopyShadow;
// Invalidate cache.
Maintenance(MaintInvalidWay, true);
// Enable cache.
MMIO32(CacheBase + CacheConfig) = CfgEnableCache | CfgForceWriteThrough |
(TagModeParallel << CfgMmuTagModeShift) | CfgTagChkAbrtOnErr;
// HW bug. Invalidate cache again.
Maintenance(MaintInvalidWay, false);
}
inline void Disable() {
if (!(MMIO32(CacheBase + CacheConfig) & CfgEnableCache)) {
return;
}
// Clean and invalidate cache.
Maintenance(MaintCleanInvalidWay, false);
// Disable cache.
MMIO32(CacheBase + CacheConfig) = 0;
}
void Disable();
} // namespace bpmpMmu