add bpmp-fw cmd interface

This commit is contained in:
souldbminersmwc committed 2026-08-28 13:43:50 -04:00
1 parent 39c612779b
commit 6b88b43cb9
7 files changed
+94 -17

No files matched your search

+27 -10
View File
@@ -39,11 +39,35 @@ namespace {
} // namespace
[[noreturn]] void HandleShutdown(HocClkBpmpSharedInfo &info) {
/* Deinit MMU otherwise sleep will fatal. */
bpmpMmu::Disable();
info.magic = 0x0;
printf("[hoc-bpmpfw]: Halting...\n");
for (;;)
;
}
void HandleCommand(HocClkBpmpSharedInfo &info) {
switch (info.cmd) {
case HocClkBpmpCmd_None:
break;
case HocClkBpmpCmd_RequestShutdown:
HandleShutdown(info);
break;
case HocClkBpmpCmd_SetUartEnabled:
g_uartLoggingEnabled = (info.cmdArg1 != 0);
info.cmd = HocClkBpmpCmd_None;
break;
default:
info.cmd = HocClkBpmpCmd_None;
break;
}
}
void MainLoop(HocClkBpmpSharedInfo &info) {
for (;;) {
if (info.exitRequested) {
break;
}
HandleCommand(info);
const u32 temp1 = MMIO32(SocthermBase + SocthermSensorTemp1);
const u32 temp2 = MMIO32(SocthermBase + SocthermSensorTemp2);
@@ -60,13 +84,6 @@ void MainLoop(HocClkBpmpSharedInfo &info) {
msleep(250);
}
/* Deinit MMU otherwise sleep will fatal. */
bpmpMmu::Disable();
info.magic = 0x0;
for (;;)
;
}
extern "C" void main() {
+8
View File
@@ -33,13 +33,21 @@
}
}
bool g_uartLoggingEnabled = true;
void UartPutc(char c) {
if (!g_uartLoggingEnabled) {
return;
}
while (!(MMIO32(UartBBase + UartLsr) & UartLsrThre))
;
MMIO32(UartBBase + UartThr) = static_cast<u32>(static_cast<u8>(c));
}
void UartFlush() {
if (!g_uartLoggingEnabled) {
return;
}
while (!(MMIO32(UartBBase + UartLsr) & UartLsrTmty))
;
}
+2
View File
@@ -45,6 +45,8 @@ constexpr u32 UartLsr = 0x14;
constexpr u32 UartLsrThre = (1u << 5);
constexpr u32 UartLsrTmty = (1u << 6);
extern bool g_uartLoggingEnabled;
void UartPutc(char c);
void UartFlush();