hocclk: add bpmpfw loading

This commit is contained in:
souldbminersmwc committed 2026-08-24 21:21:50 -04:00
1 parent 7fea98a72d
commit bd468f087d
14 files changed
+522 -3

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
#include "regs.hpp"
extern "C" void main() {
UartPuts("[bpmpfw]: Hello from BPMP-FW\n");
for (;;) {
FlowCtlrHaltUsec(200);
}
}
+42
View File
@@ -0,0 +1,42 @@
#pragma once
#include <cstdint>
using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
#define MMIO32(addr) (*reinterpret_cast<volatile u32 *>(addr))
constexpr u32 FlowCtlrBase = 0x60007000;
constexpr u32 FlowCtlrHaltCopEvents = 0x004;
constexpr u32 HaltModeWaitEvent = (2u << 29);
constexpr u32 HaltUsec = (0u << 24);
inline void FlowCtlrHaltUsec(u32 usec) {
MMIO32(FlowCtlrBase + FlowCtlrHaltCopEvents) = HaltModeWaitEvent | HaltUsec | (usec & 0xFFFFFFu);
}
constexpr u32 UartBBase = 0x70006040;
constexpr u32 UartThr = 0x00;
constexpr u32 UartLsr = 0x14;
constexpr u32 UartLsrThre = (1u << 5);
inline void UartPutc(char c) {
while (!(MMIO32(UartBBase + UartLsr) & UartLsrThre))
;
MMIO32(UartBBase + UartThr) = static_cast<u32>(static_cast<u8>(c));
}
inline void UartPuts(const char *s) {
while (*s) {
UartPutc(*s++);
}
}
inline void UartPutHex32(u32 v) {
static const char digits[] = "0123456789ABCDEF";
for (int i = 28; i >= 0; i -= 4) {
UartPutc(digits[(v >> i) & 0xF]);
}
}
+65
View File
@@ -0,0 +1,65 @@
.section .vectors, "ax", %progbits
.align 3
.global reset
reset:
b _start
b _panic
.section .text.start, "ax", %progbits
.align 3
.global _start
.extern main
_start:
/* Mask IRQ + FIQ, enter SVC mode. */
msr cpsr_f, #0xC0
msr cpsr_cf, #0xD3
/* Set the stack pointer. */
ldr sp, =__stack_top
/* Zero .bss. */
ldr r0, =__bss_start__
ldr r1, =__bss_end__
mov r2, #0
1:
cmp r0, r1
bge 2f
str r2, [r0], #4
b 1b
2:
/* Run global constructors. */
ldr r4, =__init_array_start
ldr r5, =__init_array_end
3:
cmp r4, r5
bge 4f
ldr r0, [r4], #4
mov lr, pc
bx r0
b 3b
4:
bl main
.global _panic
_panic:
ldr r0, =0x70006040 /* UART_B_BASE */
adr r3, _panic_msg
7:
ldrb r1, [r3], #1
cmp r1, #0
beq _panic_hang
8:
ldr r2, [r0, #0x14] /* UART_LSR */
tst r2, #0x20 /* UART_LSR_THRE */
beq 8b
str r1, [r0]
b 7b
_panic_msg:
.asciz "[bpmpfw] PANIC\n"
.align 2
_panic_hang:
b _panic_hang