Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sw bug into power_gate_core_asm power manager HAL #448

Closed
davideschiavone opened this issue Feb 13, 2024 · 1 comment · Fixed by #549
Closed

sw bug into power_gate_core_asm power manager HAL #448

davideschiavone opened this issue Feb 13, 2024 · 1 comment · Fixed by #549
Labels
bug Something isn't working high-priority

Comments

@davideschiavone
Copy link
Member

davideschiavone commented Feb 13, 2024

In function power_gate_core_asm, after the wfi

https://github.com/esl-epfl/x-heep/blob/main/sw/device/lib/drivers/power_manager/power_manager.c#L100

the __power_manager_start is correctly loaded again into the register as the core is returning from reset state after power gating.

However, the compiler does not know that the registers lost their original content, and relies on the gp register to re-load into a0 the __power_manager_start symbol from the linker.

This is wrong as now the gp register does not contain the value that the compiler expects.

One solution could be splitting the functions into 2

00000dce <wakeup>:
     dce:   20040537            lui a0,0x20040
     dd2:   00052823            sw  zero,16(a0) # 20040010 <_sp+0x20032510>
     dd6:   00052023            sw  zero,0(a0)
     dda:   00052223            sw  zero,4(a0)
        [power_manager_power_gate_core_reg_offset] "i" (POWER_MANAGER_POWER_GATE_CORE_REG_OFFSET), \
        [power_manager_wakeup_state_reg_offset] "i" (POWER_MANAGER_WAKEUP_STATE_REG_OFFSET), \
        [power_manager_restore_address_reg_offset] "i" (POWER_MANAGER_RESTORE_ADDRESS_REG_OFFSET) : "a0", "a1" \
    );

    asm volatile (
     dde:   90418513            addi    a0,gp,-1788 # c904 <__power_manager_start>
     de2:   00052083            lw  ra,0(a0)
     de6:   00452103            lw  sp,4(a0)
     dea:   00852183            lw  gp,8(a0)
     dee:   00c52203            lw  tp,12(a0)
     df2:   01052283            lw  t0,16(a0)
     df6:   01452303            lw  t1,20(a0)
     ```
@davideschiavone
Copy link
Member Author

@Ho3eintaji , can you take a look pls? I made a proposal (do not merge it yet pls) at #449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high-priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant