diff --git a/Source/hoc-clk/bpmpfw/out/bpmpfw.bin b/Source/hoc-clk/bpmpfw/out/bpmpfw.bin index bb044fde..3ac590de 100644 Binary files a/Source/hoc-clk/bpmpfw/out/bpmpfw.bin and b/Source/hoc-clk/bpmpfw/out/bpmpfw.bin differ diff --git a/Source/hoc-clk/bpmpfw/source/main.cpp b/Source/hoc-clk/bpmpfw/source/main.cpp index 72a25d0f..af007fe3 100644 --- a/Source/hoc-clk/bpmpfw/source/main.cpp +++ b/Source/hoc-clk/bpmpfw/source/main.cpp @@ -32,6 +32,21 @@ namespace { } // namespace +void MainLoop(HocClkBpmpSharedInfo &info) { + for (;;) { + const u32 temp1 = MMIO32(SocthermBase + SocthermSensorTemp1); + const u32 temp2 = MMIO32(SocthermBase + SocthermSensorTemp2); + + info.tempCpu = TranslateSocthermTemp(static_cast(temp1 >> 16)); + info.tempGpu = TranslateSocthermTemp(static_cast(temp1)); + info.tempMem = TranslateSocthermTemp(static_cast(temp2 >> 16)); + info.tempPllx = TranslateSocthermTemp(static_cast(temp2)); + // printf("tmr=%u\n", MMIO32(TmrBase + TimerUsCntr1Us)); + msleep(500); + //printf("[hoc-bpmpfw]: Done logging\n"); + } +} + extern "C" void main() { InitializeLibc(); @@ -42,15 +57,15 @@ extern "C" void main() { info.status = 0; info.magic = HOCCLK_BPMP_MAGIC; // written last - for (;;) { - const u32 temp1 = MMIO32(SocthermBase + SocthermSensorTemp1); - const u32 temp2 = MMIO32(SocthermBase + SocthermSensorTemp2); + /* If the main loop exits then it is a panic or invalid state */ + MainLoop(info); - info.tempCpu = TranslateSocthermTemp(static_cast(temp1 >> 16)); - info.tempGpu = TranslateSocthermTemp(static_cast(temp1)); - info.tempMem = TranslateSocthermTemp(static_cast(temp2 >> 16)); - info.tempPllx = TranslateSocthermTemp(static_cast(temp2)); + printf("[hoc-bpmpfw]: PANIC\n"); + /* Clear the magic so sysmodule knows of a panic */ + info.magic = 0x0; - usleep(250000); // 250ms - } + /* Give a panic code */ + info.status = ~0; + for(;;) + ; } diff --git a/Source/hoc-clk/bpmpfw/source/regs.hpp b/Source/hoc-clk/bpmpfw/source/regs.hpp index 24adffa2..b287c27b 100644 --- a/Source/hoc-clk/bpmpfw/source/regs.hpp +++ b/Source/hoc-clk/bpmpfw/source/regs.hpp @@ -29,21 +29,28 @@ constexpr u32 FlowCtlrBase = 0x60007000; constexpr u32 FlowCtlrHaltCopEvents = 0x004; constexpr u32 HaltModeWaitEvent = (2u << 29); -constexpr u32 HaltUsec = (0u << 24); +constexpr u32 HaltMsec = (1u << 24); +constexpr u32 HaltUsec = (1u << 25); +constexpr u32 HaltMaxCnt = 0xFF; -[[maybe_unused]] inline void FlowCtlrHaltUsec(u32 usec) { - MMIO32(FlowCtlrBase + FlowCtlrHaltCopEvents) = HaltModeWaitEvent | HaltUsec | (usec & 0xFFFFFFu); +[[maybe_unused]] inline void usleep(u32 us) { + while (us) { + const u32 delay = (us > HaltMaxCnt) ? HaltMaxCnt : us; + us -= delay; + MMIO32(FlowCtlrBase + FlowCtlrHaltCopEvents) = HaltModeWaitEvent | HaltUsec | delay; + } +} +[[maybe_unused]] inline void msleep(u32 ms) { + while (ms) { + const u32 delay = (ms > HaltMaxCnt) ? HaltMaxCnt : ms; + ms -= delay; + MMIO32(FlowCtlrBase + FlowCtlrHaltCopEvents) = HaltModeWaitEvent | HaltMsec | delay; + } } constexpr u32 TmrBase = 0x60005000; constexpr u32 TimerUsCntr1Us = 0x10; -[[maybe_unused]] inline void usleep(u32 us) { - const u32 start = MMIO32(TmrBase + TimerUsCntr1Us); - while ((MMIO32(TmrBase + TimerUsCntr1Us) - start) <= us) - ; -} - constexpr u32 UartBBase = 0x70006040; constexpr u32 UartThr = 0x00; constexpr u32 UartLsr = 0x14;