This commit is contained in:
Dongyan Qian 2026-08-26 22:50:39 +00:00 committed by GitHub
commit a547815fe1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -128,8 +128,9 @@ GetSerialRegisterBase (
UINTN SerialRegisterBase;
//
// The LoongArchVirt serial hook path uses KS1 to hand off the UART base.
// Reuse it here to avoid repeated FDT lookups during early debug output.
// SEC initializes KS1 before the first debug output. The LoongArchVirt
// serial hook path then uses it to hand off the UART base. Reuse the value
// here to avoid repeated FDT lookups during early debug output.
//
SerialRegisterBase = CsrRead (LOONGARCH_CSR_KS1);
if (SerialRegisterBase != 0) {

View file

@ -29,6 +29,17 @@ ASM_PFX(_ModuleEntryPoint):
li.w $a0, 0x1FFF
bl DisableLocalInterrupts
/* Clear per-CPU scratch registers left by the previous boot */
csrwr $zero, LOONGARCH_CSR_KS0
csrwr $zero, LOONGARCH_CSR_KS1
csrwr $zero, LOONGARCH_CSR_KS2
csrwr $zero, LOONGARCH_CSR_KS3
csrwr $zero, LOONGARCH_CSR_KS4
csrwr $zero, LOONGARCH_CSR_KS5
csrwr $zero, LOONGARCH_CSR_KS6
csrwr $zero, LOONGARCH_CSR_KS7
csrwr $zero, LOONGARCH_CSR_KS8
/* Read physical cpu number id */
bl GetApicId
li.d $t0, BOOTCORE_ID //0