replace asm volatile("pause") with function

This commit is contained in:
2026-10-15 21:20:31 +02:00
parent d7b20baf97
commit 7748a1dac8
8 changed files with 19 additions and 8 deletions
+2 -1
View File
@@ -4,6 +4,7 @@
#include <zinnia/compiler.h>
#include <zinnia/print.h>
#include <zinnia/spin.h>
#include <arch/cpu.h>
#include <stdint.h>
static struct clock* active_clock = nullptr;
@@ -62,6 +63,6 @@ void clock_spin_ns(uint64_t ns) {
uint64_t target = clock_get_elapsed_ns() + ns;
while (clock_get_elapsed_ns() < target) {
// TODO: Maybe pause?
arch_cpu_pause();
}
}
+2 -1
View File
@@ -6,6 +6,7 @@
#include <zinnia/pmap.h>
#include <zinnia/spin.h>
#include <zinnia/vma.h>
#include <arch/cpu.h>
#include <config.h>
// TODO: For now, we assume that we can do generic PTE lookups on every arch that has a MMU.
@@ -231,7 +232,7 @@ void pmap_shootdown(struct pmap* pt) {
const size_t req = atomic_load(percpu_ref_on(cpu, shootdown_req), ATOMIC_RELAXED);
while ((ptrdiff_t)(req - atomic_load(percpu_ref_on(cpu, shootdown_ack), ATOMIC_ACQUIRE)) > 0) {
pmap_shootdown_handle();
asm volatile("pause");
arch_cpu_pause();
}
}
irq_unlock();
+1 -3
View File
@@ -68,7 +68,7 @@ static struct module* find_locked(const char* name) {
return nullptr;
}
void module_init(struct boot_info*) {
void module_init() {
spin_init(&module_lock);
tailq_init(&module_list);
@@ -77,8 +77,6 @@ void module_init(struct boot_info*) {
assert(mod_status == 0, "Built-in entry point returned %i", mod_status);
}
}
INIT_TASK(module_stage, "core.module", module_init);
INIT_DEPENDS(module_stage, sched_stage, ksyms_stage);
static errno_t resolve_symbol(struct module* mod, uint32_t index, uintptr_t* out) {
if (index >= mod->num_syms)
+2 -1
View File
@@ -1,6 +1,7 @@
#include <zinnia/atomic.h>
#include <zinnia/irq.h>
#include <zinnia/spin.h>
#include <arch/cpu.h>
void spin_init(struct spinlock* spin) {
spin->next = 0;
@@ -12,7 +13,7 @@ void spin_lock(struct spinlock* spin) {
uint32_t my = atomic_fetch_add(&spin->next, 1, ATOMIC_RELAXED);
while (atomic_load(&spin->owner, ATOMIC_ACQUIRE) != my) {
asm volatile("pause");
arch_cpu_pause();
}
}