Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/host/hardware_sync/include/hardware/sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ extern "C" {

void __sev();

void __wev();

void __wfi();

void __wfe();
Expand Down
35 changes: 28 additions & 7 deletions src/host/hardware_sync/sync_core0_only.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,44 @@ void PICO_WEAK_FUNCTION_IMPL_NAME(spin_unlock)(spin_lock_t *lock, uint32_t saved
spin_unlock_unsafe(lock);
}

PICO_WEAK_FUNCTION_DEF(__sev)
// These are defined on ARM hosts, but don't do what we want for the host
// since this is a simulated build.

#if PICO_C_COMPILER_IS_GNU || !__has_builtin(__sev)
#define __sev_c __sev
#else
#pragma redefine_extname __sev_c __sev
#endif

#if PICO_C_COMPILER_IS_GNU || !__has_builtin(__wfi)
#define __wfi_c __wfi
#else
#pragma redefine_extname __wfi_c __wfi
#endif

#if PICO_C_COMPILER_IS_GNU || !__has_builtin(__wfe)
#define __wfe_c __wfe
#else
#pragma redefine_extname __wfe_c __wfe
#endif

PICO_WEAK_FUNCTION_DEF(__sev_c)

volatile bool event_fired;

void PICO_WEAK_FUNCTION_IMPL_NAME(__sev)() {
void PICO_WEAK_FUNCTION_IMPL_NAME(__sev_c)() {
event_fired = true;
}

PICO_WEAK_FUNCTION_DEF(__wfi)
PICO_WEAK_FUNCTION_DEF(__wfi_c)

void PICO_WEAK_FUNCTION_IMPL_NAME(__wfi)() {
void PICO_WEAK_FUNCTION_IMPL_NAME(__wfi_c)() {
panic("Can't wait on irq for host core0 only implementation");
}

PICO_WEAK_FUNCTION_DEF(__wfe)
PICO_WEAK_FUNCTION_DEF(__wfe_c)

void PICO_WEAK_FUNCTION_IMPL_NAME(__wfe)() {
void PICO_WEAK_FUNCTION_IMPL_NAME(__wfe_c)() {
while (!event_fired) tight_loop_contents();
}

Expand Down Expand Up @@ -146,4 +167,4 @@ int PICO_WEAK_FUNCTION_IMPL_NAME(spin_lock_claim_unused)(bool required) {
PICO_WEAK_FUNCTION_DEF(spin_lock_num)
uint PICO_WEAK_FUNCTION_IMPL_NAME(spin_lock_num)(spin_lock_t *lock) {
return 0;
}
}